forked from github/plane
refactor: added params to filters, and removed manual mutation (#480)
* refractor: added params to fetch key * feat: create views directly from views list page fix: selected filter not showing up in multi-level dropdown, refactor: arranged imports * refactor: added params to filters, and removed manual mutation
This commit is contained in:
parent
505b14e3a6
commit
53df658b60
@ -1,16 +1,19 @@
|
||||
const paramsToKey = (params: any) => {
|
||||
const { state, priority, assignees } = params;
|
||||
|
||||
let stateKey = state ? state.split(",").join(" ") : "";
|
||||
let priorityKey = priority ? priority.split(",").join(" ") : "";
|
||||
let assigneesKey = assignees ? assignees.split(",").join(" ") : "";
|
||||
let stateKey = state ? state.split(",") : [];
|
||||
let priorityKey = priority ? priority.split(",") : [];
|
||||
let assigneesKey = assignees ? assignees.split(",") : [];
|
||||
const type = params.type ? params.type.toUpperCase() : "NULL";
|
||||
const groupBy = params.group_by ? params.group_by.toUpperCase() : "NULL";
|
||||
const orderBy = params.order_by ? params.order_by.toUpperCase() : "NULL";
|
||||
|
||||
// sorting each keys in ascending order
|
||||
stateKey = stateKey.split(" ").sort().join("");
|
||||
priorityKey = priorityKey.split(" ").sort().join("");
|
||||
assigneesKey = assigneesKey.split(" ").sort().join("");
|
||||
stateKey = stateKey.sort().join("_");
|
||||
priorityKey = priorityKey.sort().join("_");
|
||||
assigneesKey = assigneesKey.sort().join("_");
|
||||
|
||||
return `${stateKey}_${priorityKey}_${assigneesKey}`;
|
||||
return `${stateKey}_${priorityKey}_${assigneesKey}_${type}_${groupBy}_${orderBy}`;
|
||||
};
|
||||
|
||||
export const CURRENT_USER = "CURRENT_USER";
|
||||
|
@ -424,39 +424,6 @@ export const IssueViewContextProvider: React.FC<{ children: React.ReactNode }> =
|
||||
});
|
||||
}, [myViewProps, viewDetails]);
|
||||
|
||||
useEffect(() => {
|
||||
const params: any = {
|
||||
order_by: state.orderBy,
|
||||
group_by: state.groupByProperty,
|
||||
assignees: state.filters?.assignees ? state.filters?.assignees.join(",") : undefined,
|
||||
state: state.filters?.state ? state.filters?.state.join(",") : undefined,
|
||||
priority: state.filters?.priority ? state.filters?.priority.join(",") : undefined,
|
||||
type: state.filters?.type ? state.filters?.type : undefined,
|
||||
labels: state.filters?.labels ? state.filters?.labels.join(",") : undefined,
|
||||
issue__assignees__id: state.filters?.issue__assignees__id
|
||||
? state.filters?.issue__assignees__id.join(",")
|
||||
: undefined,
|
||||
issue__labels__id: state.filters?.issue__labels__id
|
||||
? state.filters?.issue__labels__id.join(",")
|
||||
: undefined,
|
||||
};
|
||||
|
||||
// TODO: think of a better way to do this
|
||||
if (cycleId) {
|
||||
mutate(CYCLE_ISSUES_WITH_PARAMS(cycleId as string, params), {}, false);
|
||||
mutate(CYCLE_ISSUES_WITH_PARAMS(cycleId as string, params));
|
||||
} else if (moduleId) {
|
||||
mutate(MODULE_ISSUES_WITH_PARAMS(moduleId as string, params), {}, false);
|
||||
mutate(MODULE_ISSUES_WITH_PARAMS(moduleId as string, params));
|
||||
} else if (viewId) {
|
||||
mutate(VIEW_ISSUES(viewId as string), {}, false);
|
||||
mutate(VIEW_ISSUES(viewId as string));
|
||||
} else {
|
||||
mutate(PROJECT_ISSUES_LIST_WITH_PARAMS(projectId as string, params), {}, false);
|
||||
mutate(PROJECT_ISSUES_LIST_WITH_PARAMS(projectId as string, params));
|
||||
}
|
||||
}, [state, projectId, cycleId, moduleId, viewId]);
|
||||
|
||||
return (
|
||||
<issueViewContext.Provider
|
||||
value={{
|
||||
|
Loading…
Reference in New Issue
Block a user