feat: issues filter using views (#448)
* fix: made basic UI for views, binded services and logic for views * feat: views list, delete view, and conditionally updating filters or my view props
This commit is contained in:
parent
96ad751e11
commit
ef0e326ca0
15 changed files with 509 additions and 127 deletions
|
|
@ -15,10 +15,12 @@ import {
|
|||
CYCLE_ISSUES_WITH_PARAMS,
|
||||
MODULE_ISSUES_WITH_PARAMS,
|
||||
PROJECT_ISSUES_LIST_WITH_PARAMS,
|
||||
VIEW_ISSUES,
|
||||
} from "constants/fetch-keys";
|
||||
|
||||
// types
|
||||
import type { IIssue } from "types";
|
||||
import viewsService from "services/views.service";
|
||||
|
||||
const useIssuesView = () => {
|
||||
const {
|
||||
|
|
@ -36,18 +38,22 @@ const useIssuesView = () => {
|
|||
} = useContext(issueViewContext);
|
||||
|
||||
const router = useRouter();
|
||||
const { workspaceSlug, projectId, cycleId, moduleId } = router.query;
|
||||
const { workspaceSlug, projectId, cycleId, moduleId, viewId } = router.query;
|
||||
|
||||
const params: any = {
|
||||
order_by: orderBy,
|
||||
group_by: groupByProperty,
|
||||
assignees: filters.assignees ? filters.assignees.join(",") : undefined,
|
||||
type: filters.type ? filters.type : undefined,
|
||||
labels: filters.labels ? filters.labels.join(",") : undefined,
|
||||
issue__assignees__id: filters.issue__assignees__id
|
||||
? filters.issue__assignees__id.join(",")
|
||||
assignees: filters?.assignees ? filters?.assignees.join(",") : undefined,
|
||||
state: filters?.state ? filters?.state.join(",") : undefined,
|
||||
priority: filters?.priority ? filters?.priority.join(",") : undefined,
|
||||
type: filters?.type ? filters?.type : undefined,
|
||||
labels: filters?.labels ? filters?.labels.join(",") : undefined,
|
||||
issue__assignees__id: filters?.issue__assignees__id
|
||||
? filters?.issue__assignees__id.join(",")
|
||||
: undefined,
|
||||
issue__labels__id: filters?.issue__labels__id
|
||||
? filters?.issue__labels__id.join(",")
|
||||
: undefined,
|
||||
issue__labels__id: filters.issue__labels__id ? filters.issue__labels__id.join(",") : undefined,
|
||||
};
|
||||
|
||||
const { data: projectIssues } = useSWR(
|
||||
|
|
@ -60,6 +66,14 @@ const useIssuesView = () => {
|
|||
: null
|
||||
);
|
||||
|
||||
const { data: viewIssues } = useSWR(
|
||||
workspaceSlug && projectId && viewId ? VIEW_ISSUES(viewId as string) : null,
|
||||
workspaceSlug && projectId && viewId
|
||||
? () =>
|
||||
viewsService.getViewIssues(workspaceSlug as string, projectId as string, viewId as string)
|
||||
: null
|
||||
);
|
||||
|
||||
const { data: cycleIssues } = useSWR(
|
||||
workspaceSlug && projectId && cycleId && params
|
||||
? CYCLE_ISSUES_WITH_PARAMS(cycleId as string)
|
||||
|
|
@ -95,11 +109,11 @@ const useIssuesView = () => {
|
|||
[key: string]: IIssue[];
|
||||
}
|
||||
| undefined = useMemo(() => {
|
||||
const issuesToGroup = cycleIssues ?? moduleIssues ?? projectIssues;
|
||||
const issuesToGroup = viewIssues ?? cycleIssues ?? moduleIssues ?? projectIssues;
|
||||
|
||||
if (Array.isArray(issuesToGroup)) return { allIssues: issuesToGroup };
|
||||
else return issuesToGroup;
|
||||
}, [projectIssues, cycleIssues, moduleIssues]);
|
||||
}, [projectIssues, cycleIssues, moduleIssues, viewIssues]);
|
||||
|
||||
return {
|
||||
groupedByIssues,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue