feat: workspace global view, style: spreadsheet view revamp (#2273)
* chore: workspace view types, services and hooks added * style: spreadsheet view revamp and code refactor * feat: workspace view * fix: build fix * chore: sidebar workspace issues redirection updated
This commit is contained in:
parent
a187e7765c
commit
3a6d72e4b6
61 changed files with 4253 additions and 733 deletions
|
|
@ -11,9 +11,9 @@ import { ISubIssueResponse } from "types";
|
|||
// fetch-keys
|
||||
import { SUB_ISSUES } from "constants/fetch-keys";
|
||||
|
||||
const useSubIssue = (issueId: string, isExpanded: boolean) => {
|
||||
const useSubIssue = (projectId: string, issueId: string, isExpanded: boolean) => {
|
||||
const router = useRouter();
|
||||
const { workspaceSlug, projectId } = router.query;
|
||||
const { workspaceSlug } = router.query;
|
||||
|
||||
const shouldFetch = workspaceSlug && projectId && issueId && isExpanded;
|
||||
|
||||
|
|
|
|||
113
web/hooks/use-worskpace-issue-filter.tsx
Normal file
113
web/hooks/use-worskpace-issue-filter.tsx
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
import { useEffect, useCallback } from "react";
|
||||
|
||||
import useSWR, { mutate } from "swr";
|
||||
|
||||
// services
|
||||
import workspaceService from "services/workspace.service";
|
||||
// types
|
||||
import { IIssueFilterOptions, IView } from "types";
|
||||
// fetch-keys
|
||||
import { WORKSPACE_VIEW_DETAILS } from "constants/fetch-keys";
|
||||
|
||||
const initialValues: IIssueFilterOptions = {
|
||||
assignees: null,
|
||||
created_by: null,
|
||||
labels: null,
|
||||
priority: null,
|
||||
state: null,
|
||||
state_group: null,
|
||||
subscriber: null,
|
||||
start_date: null,
|
||||
target_date: null,
|
||||
project: null,
|
||||
};
|
||||
|
||||
const useWorkspaceIssuesFilters = (
|
||||
workspaceSlug: string | undefined,
|
||||
workspaceViewId: string | undefined
|
||||
) => {
|
||||
const { data: workspaceViewDetails } = useSWR(
|
||||
workspaceSlug && workspaceViewId ? WORKSPACE_VIEW_DETAILS(workspaceViewId) : null,
|
||||
workspaceSlug && workspaceViewId
|
||||
? () => workspaceService.getViewDetails(workspaceSlug, workspaceViewId)
|
||||
: null
|
||||
);
|
||||
|
||||
const saveData = useCallback(
|
||||
(data: Partial<IIssueFilterOptions>) => {
|
||||
if (!workspaceSlug || !workspaceViewId || !workspaceViewDetails) return;
|
||||
|
||||
const oldData = { ...workspaceViewDetails };
|
||||
|
||||
mutate<IView>(
|
||||
WORKSPACE_VIEW_DETAILS(workspaceViewId),
|
||||
(prevData) => {
|
||||
if (!prevData) return;
|
||||
return {
|
||||
...prevData,
|
||||
query_data: {
|
||||
...prevData?.query_data,
|
||||
...data,
|
||||
},
|
||||
};
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
workspaceService.updateView(workspaceSlug, workspaceViewId, {
|
||||
query_data: {
|
||||
...oldData.query_data,
|
||||
...data,
|
||||
},
|
||||
});
|
||||
},
|
||||
[workspaceViewDetails, workspaceSlug, workspaceViewId]
|
||||
);
|
||||
|
||||
const filters = workspaceViewDetails?.query_data ?? initialValues;
|
||||
|
||||
const setFilters = useCallback(
|
||||
(updatedFilter: Partial<IIssueFilterOptions>) => {
|
||||
if (!workspaceViewDetails) return;
|
||||
|
||||
saveData({
|
||||
...workspaceViewDetails?.query_data,
|
||||
...updatedFilter,
|
||||
});
|
||||
},
|
||||
[workspaceViewDetails, saveData]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!workspaceViewDetails || !workspaceSlug || !workspaceViewId) return;
|
||||
|
||||
if (!workspaceViewDetails.query_data) {
|
||||
workspaceService.updateView(workspaceSlug, workspaceViewId, {
|
||||
query_data: { ...initialValues },
|
||||
});
|
||||
}
|
||||
}, [workspaceViewDetails, workspaceViewId, workspaceSlug]);
|
||||
|
||||
const params: any = {
|
||||
assignees: filters?.assignees ? filters?.assignees.join(",") : undefined,
|
||||
subscriber: filters?.subscriber ? filters?.subscriber.join(",") : undefined,
|
||||
state: filters?.state ? filters?.state.join(",") : undefined,
|
||||
state_group: filters?.state_group ? filters?.state_group.join(",") : undefined,
|
||||
priority: filters?.priority ? filters?.priority.join(",") : undefined,
|
||||
labels: filters?.labels ? filters?.labels.join(",") : undefined,
|
||||
created_by: filters?.created_by ? filters?.created_by.join(",") : undefined,
|
||||
start_date: filters?.start_date ? filters?.start_date.join(",") : undefined,
|
||||
target_date: filters?.target_date ? filters?.target_date.join(",") : undefined,
|
||||
project: filters?.project ? filters?.project.join(",") : undefined,
|
||||
sub_issue: false,
|
||||
type: undefined,
|
||||
};
|
||||
|
||||
return {
|
||||
params,
|
||||
filters,
|
||||
setFilters,
|
||||
};
|
||||
};
|
||||
|
||||
export default useWorkspaceIssuesFilters;
|
||||
Loading…
Add table
Add a link
Reference in a new issue