diff --git a/web/components/core/views/all-views.tsx b/web/components/core/views/all-views.tsx index 5973a43cf..e8478e71a 100644 --- a/web/components/core/views/all-views.tsx +++ b/web/components/core/views/all-views.tsx @@ -6,7 +6,7 @@ import useSWR from "swr"; // mobx store import { useMobxStore } from "lib/mobx/store-provider"; // components -import { CalendarLayout, GanttLayout, KanBanLayout } from "components/issues"; +import { CalendarLayout, GanttLayout, KanBanLayout, SpreadsheetLayout } from "components/issues"; export const AllViews: React.FC = observer(() => { const router = useRouter(); @@ -41,6 +41,8 @@ export const AllViews: React.FC = observer(() => { ) : activeLayout === "gantt_chart" ? ( + ) : activeLayout === "spreadsheet" ? ( + ) : null} ); diff --git a/web/components/core/views/spreadsheet-view/single-issue.tsx b/web/components/core/views/spreadsheet-view/single-issue.tsx index f9c9f1cee..12a9eeecb 100644 --- a/web/components/core/views/spreadsheet-view/single-issue.tsx +++ b/web/components/core/views/spreadsheet-view/single-issue.tsx @@ -1,38 +1,27 @@ import React, { useCallback, useState } from "react"; - import { useRouter } from "next/router"; - import { mutate } from "swr"; +import { Popover2 } from "@blueprintjs/popover2"; +// icons +import { Icon } from "components/ui"; +import { EllipsisHorizontalIcon, LinkIcon, PencilIcon, TrashIcon } from "@heroicons/react/24/outline"; +// services +import issuesService from "services/issue.service"; +import trackEventServices from "services/track_event.service"; +// hooks +import useToast from "hooks/use-toast"; // components import { ViewDueDateSelect, ViewEstimateSelect, ViewStartDateSelect } from "components/issues"; import { LabelSelect, MembersSelect, PrioritySelect } from "components/project"; import { StateSelect } from "components/states"; -import { Popover2 } from "@blueprintjs/popover2"; -// icons -import { Icon } from "components/ui"; -import { EllipsisHorizontalIcon, LinkIcon, PencilIcon, TrashIcon } from "@heroicons/react/24/outline"; -// hooks -import useSpreadsheetIssuesView from "hooks/use-spreadsheet-issues-view"; -import useToast from "hooks/use-toast"; -// services -import issuesService from "services/issue.service"; -import trackEventServices from "services/track_event.service"; -// constant -import { - CYCLE_DETAILS, - CYCLE_ISSUES_WITH_PARAMS, - MODULE_DETAILS, - MODULE_ISSUES_WITH_PARAMS, - PROJECT_ISSUES_LIST_WITH_PARAMS, - SUB_ISSUES, - VIEW_ISSUES, -} from "constants/fetch-keys"; -// types -import { ICurrentUserResponse, IIssue, IState, ISubIssueResponse, Properties, TIssuePriorities, UserAuth } from "types"; -// helper +// helpers import { copyTextToClipboard } from "helpers/string.helper"; import { renderLongDetailDateFormat } from "helpers/date-time.helper"; +// types +import { ICurrentUserResponse, IIssue, IState, Properties, TIssuePriorities, UserAuth } from "types"; +// constant +import { CYCLE_DETAILS, MODULE_DETAILS, SUB_ISSUES } from "constants/fetch-keys"; type Props = { issue: IIssue; @@ -67,9 +56,7 @@ export const SingleSpreadsheetIssue: React.FC = ({ const router = useRouter(); - const { workspaceSlug, projectId, cycleId, moduleId, viewId } = router.query; - - const { params } = useSpreadsheetIssuesView(); + const { workspaceSlug, projectId, cycleId, moduleId } = router.query; const { setToastAlert } = useToast(); @@ -77,59 +64,12 @@ export const SingleSpreadsheetIssue: React.FC = ({ (formData: Partial, issue: IIssue) => { if (!workspaceSlug || !projectId) return; - const fetchKey = cycleId - ? CYCLE_ISSUES_WITH_PARAMS(cycleId.toString(), params) - : moduleId - ? MODULE_ISSUES_WITH_PARAMS(moduleId.toString(), params) - : viewId - ? VIEW_ISSUES(viewId.toString(), params) - : PROJECT_ISSUES_LIST_WITH_PARAMS(projectId.toString(), params); - - if (issue.parent) - mutate( - SUB_ISSUES(issue.parent.toString()), - (prevData) => { - if (!prevData) return prevData; - - return { - ...prevData, - sub_issues: (prevData.sub_issues ?? []).map((i) => { - if (i.id === issue.id) { - return { - ...i, - ...formData, - }; - } - return i; - }), - }; - }, - false - ); - else - mutate( - fetchKey, - (prevData) => - (prevData ?? []).map((p) => { - if (p.id === issue.id) { - return { - ...p, - ...formData, - }; - } - return p; - }), - false - ); - issuesService .patchIssue(workspaceSlug as string, projectId as string, issue.id as string, formData, user) .then(() => { if (issue.parent) { mutate(SUB_ISSUES(issue.parent as string)); } else { - mutate(fetchKey); - if (cycleId) mutate(CYCLE_DETAILS(cycleId as string)); if (moduleId) mutate(MODULE_DETAILS(moduleId as string)); } @@ -138,7 +78,7 @@ export const SingleSpreadsheetIssue: React.FC = ({ console.log(error); }); }, - [workspaceSlug, projectId, cycleId, moduleId, viewId, params, user] + [workspaceSlug, projectId, cycleId, moduleId, user] ); const openPeekOverview = () => { diff --git a/web/components/core/views/spreadsheet-view/spreadsheet-columns.tsx b/web/components/core/views/spreadsheet-view/spreadsheet-columns.tsx index f52f1ab38..484faaa0c 100644 --- a/web/components/core/views/spreadsheet-view/spreadsheet-columns.tsx +++ b/web/components/core/views/spreadsheet-view/spreadsheet-columns.tsx @@ -1,48 +1,46 @@ import React from "react"; // hooks -import useSpreadsheetIssuesView from "hooks/use-spreadsheet-issues-view"; import useLocalStorage from "hooks/use-local-storage"; // component import { CustomMenu, Icon } from "components/ui"; // icon import { CheckIcon, ChevronDownIcon } from "@heroicons/react/24/outline"; // types -import { TIssueOrderByOptions } from "types"; +import { IIssueDisplayFilterOptions, TIssueOrderByOptions } from "types"; type Props = { columnData: any; + displayFilters: IIssueDisplayFilterOptions; gridTemplateColumns: string; + handleDisplayFiltersUpdate: (updatedDisplayFilter: Partial) => void; }; -export const SpreadsheetColumns: React.FC = ({ columnData, gridTemplateColumns }) => { +export const SpreadsheetColumns: React.FC = (props) => { + const { columnData, displayFilters, gridTemplateColumns, handleDisplayFiltersUpdate } = props; + const { storedValue: selectedMenuItem, setValue: setSelectedMenuItem } = useLocalStorage( "spreadsheetViewSorting", "" ); - const { storedValue: activeSortingProperty, setValue: setActiveSortingProperty } = - useLocalStorage("spreadsheetViewActiveSortingProperty", ""); - - const { displayFilters, setDisplayFilters } = useSpreadsheetIssuesView(); + const { storedValue: activeSortingProperty, setValue: setActiveSortingProperty } = useLocalStorage( + "spreadsheetViewActiveSortingProperty", + "" + ); const handleOrderBy = (order: TIssueOrderByOptions, itemKey: string) => { - setDisplayFilters({ order_by: order }); + handleDisplayFiltersUpdate({ order_by: order }); setSelectedMenuItem(`${order}_${itemKey}`); setActiveSortingProperty(order === "-created_at" ? "" : itemKey); }; return ( -
+
{columnData.map((col: any) => { if (col.isActive) { return (
{col.propertyName === "title" ? ( @@ -108,10 +106,7 @@ export const SpreadsheetColumns: React.FC = ({ columnData, gridTemplateCo {col.propertyName === "assignee" || col.propertyName === "labels" ? ( <> - + A @@ -123,10 +118,7 @@ export const SpreadsheetColumns: React.FC = ({ columnData, gridTemplateCo col.propertyName === "updated_on" ? ( <> - + New @@ -136,10 +128,7 @@ export const SpreadsheetColumns: React.FC = ({ columnData, gridTemplateCo ) : ( <> - + First @@ -151,18 +140,14 @@ export const SpreadsheetColumns: React.FC = ({ columnData, gridTemplateCo
{ @@ -180,10 +165,7 @@ export const SpreadsheetColumns: React.FC = ({ columnData, gridTemplateCo {col.propertyName === "assignee" || col.propertyName === "labels" ? ( <> - + = ({ columnData, gridTemplateCo ) : col.propertyName === "due_date" ? ( <> - + = ({ columnData, gridTemplateCo ) : ( <> - + = ({ columnData, gridTemplateCo
@@ -243,9 +217,7 @@ export const SpreadsheetColumns: React.FC = ({ columnData, gridTemplateCo selectedMenuItem.includes(col.propertyName) && ( { diff --git a/web/components/core/views/spreadsheet-view/spreadsheet-issues.tsx b/web/components/core/views/spreadsheet-view/spreadsheet-issues.tsx index 6677e8849..8290984fa 100644 --- a/web/components/core/views/spreadsheet-view/spreadsheet-issues.tsx +++ b/web/components/core/views/spreadsheet-view/spreadsheet-issues.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React from "react"; // components import { SingleSpreadsheetIssue } from "components/core"; diff --git a/web/components/core/views/spreadsheet-view/spreadsheet-view.tsx b/web/components/core/views/spreadsheet-view/spreadsheet-view.tsx index 1076f30d0..dc5431a67 100644 --- a/web/components/core/views/spreadsheet-view/spreadsheet-view.tsx +++ b/web/components/core/views/spreadsheet-view/spreadsheet-view.tsx @@ -9,7 +9,6 @@ import { CustomMenu, Spinner } from "components/ui"; import { IssuePeekOverview } from "components/issues"; // hooks import useIssuesProperties from "hooks/use-issue-properties"; -import useSpreadsheetIssuesView from "hooks/use-spreadsheet-issues-view"; // types import { ICurrentUserResponse, IIssue, Properties, UserAuth } from "types"; // constants @@ -39,8 +38,6 @@ export const SpreadsheetView: React.FC = ({ const type = cycleId ? "cycle" : moduleId ? "module" : "issue"; - const { spreadsheetIssues, mutateIssues } = useSpreadsheetIssuesView(); - const [properties] = useIssuesProperties(workspaceSlug as string, projectId as string); const columnData = SPREADSHEET_COLUMN.map((column) => ({ @@ -59,89 +56,89 @@ export const SpreadsheetView: React.FC = ({ .map((column) => column.colSize) .join(" "); - return ( - <> - mutateIssues()} - projectId={projectId?.toString() ?? ""} - workspaceSlug={workspaceSlug?.toString() ?? ""} - readOnly={disableUserActions} - /> -
-
- -
- {spreadsheetIssues ? ( -
- {spreadsheetIssues.map((issue: IIssue, index) => ( - - ))} -
- {type === "issue" ? ( - - ) : ( - !disableUserActions && ( - - - Add Issue - - } - position="left" - optionsClassName="left-5 !w-36" - noBorder - > - { - const e = new KeyboardEvent("keydown", { key: "c" }); - document.dispatchEvent(e); - }} - > - Create new - - {openIssuesListModal && ( - - Add an existing issue - - )} - - ) - )} -
-
- ) : ( - - )} -
- - ); + return null; + + // return ( + // <> + // mutateIssues()} + // projectId={projectId?.toString() ?? ""} + // workspaceSlug={workspaceSlug?.toString() ?? ""} + // readOnly={disableUserActions} + // /> + //
+ //
+ // + //
+ // {spreadsheetIssues ? ( + //
+ // {spreadsheetIssues.map((issue: IIssue, index) => ( + // + // ))} + //
+ // {type === "issue" ? ( + // + // ) : ( + // !disableUserActions && ( + // + // + // Add Issue + // + // } + // position="left" + // optionsClassName="left-5 !w-36" + // noBorder + // > + // { + // const e = new KeyboardEvent("keydown", { key: "c" }); + // document.dispatchEvent(e); + // }} + // > + // Create new + // + // {openIssuesListModal && ( + // Add an existing issue + // )} + // + // ) + // )} + //
+ //
+ // ) : ( + // + // )} + //
+ // + // ); }; diff --git a/web/components/issues/delete-issue-modal.tsx b/web/components/issues/delete-issue-modal.tsx index 81e2d6263..0b7219a1d 100644 --- a/web/components/issues/delete-issue-modal.tsx +++ b/web/components/issues/delete-issue-modal.tsx @@ -12,7 +12,6 @@ import issueServices from "services/issue.service"; import useIssuesView from "hooks/use-issues-view"; import useCalendarIssuesView from "hooks/use-calendar-issues-view"; import useToast from "hooks/use-toast"; -import useSpreadsheetIssuesView from "hooks/use-spreadsheet-issues-view"; // icons import { ExclamationTriangleIcon } from "@heroicons/react/24/outline"; // ui @@ -54,7 +53,6 @@ export const DeleteIssueModal: React.FC = ({ const { displayFilters, params } = useIssuesView(); const { params: calendarParams } = useCalendarIssuesView(); - const { params: spreadsheetParams } = useSpreadsheetIssuesView(); const { setToastAlert } = useToast(); @@ -86,13 +84,6 @@ export const DeleteIssueModal: React.FC = ({ mutate(calendarFetchKey, (prevData) => (prevData ?? []).filter((p) => p.id !== data.id), false); } else if (displayFilters.layout === "spreadsheet") { - const spreadsheetFetchKey = cycleId - ? CYCLE_ISSUES_WITH_PARAMS(cycleId.toString(), spreadsheetParams) - : moduleId - ? MODULE_ISSUES_WITH_PARAMS(moduleId.toString(), spreadsheetParams) - : viewId - ? VIEW_ISSUES(viewId.toString(), spreadsheetParams) - : PROJECT_ISSUES_LIST_WITH_PARAMS(data.project, spreadsheetParams); if (data.parent) { mutate( SUB_ISSUES(data.parent.toString()), @@ -107,13 +98,6 @@ export const DeleteIssueModal: React.FC = ({ }, false ); - mutate(spreadsheetFetchKey); - } else { - mutate( - spreadsheetFetchKey, - (prevData) => (prevData ?? []).filter((p) => p.id !== data.id), - false - ); } } else { if (cycleId) mutate(CYCLE_ISSUES_WITH_PARAMS(cycleId as string, params)); diff --git a/web/components/issues/draft-issue-modal.tsx b/web/components/issues/draft-issue-modal.tsx index b1dcf0cc0..0a6ce7ec7 100644 --- a/web/components/issues/draft-issue-modal.tsx +++ b/web/components/issues/draft-issue-modal.tsx @@ -13,7 +13,6 @@ import useUser from "hooks/use-user"; import useIssuesView from "hooks/use-issues-view"; import useCalendarIssuesView from "hooks/use-calendar-issues-view"; import useToast from "hooks/use-toast"; -import useSpreadsheetIssuesView from "hooks/use-spreadsheet-issues-view"; import useLocalStorage from "hooks/use-local-storage"; import useProjects from "hooks/use-projects"; import useMyIssues from "hooks/my-issues/use-my-issues"; @@ -81,7 +80,6 @@ export const CreateUpdateDraftIssueModal: React.FC = (props) = const { displayFilters, params } = useIssuesView(); const { params: calendarParams } = useCalendarIssuesView(); const { ...viewGanttParams } = params; - const { params: spreadsheetParams } = useSpreadsheetIssuesView(); const { user } = useUser(); const { projects } = useProjects(); @@ -156,14 +154,6 @@ export const CreateUpdateDraftIssueModal: React.FC = (props) = ? VIEW_ISSUES(viewId.toString(), calendarParams) : PROJECT_ISSUES_LIST_WITH_PARAMS(activeProject?.toString() ?? "", calendarParams); - const spreadsheetFetchKey = cycleId - ? CYCLE_ISSUES_WITH_PARAMS(cycleId.toString(), spreadsheetParams) - : moduleId - ? MODULE_ISSUES_WITH_PARAMS(moduleId.toString(), spreadsheetParams) - : viewId - ? VIEW_ISSUES(viewId.toString(), spreadsheetParams) - : PROJECT_ISSUES_LIST_WITH_PARAMS(activeProject?.toString() ?? "", spreadsheetParams); - const ganttFetchKey = cycleId ? CYCLE_ISSUES_WITH_PARAMS(cycleId.toString()) : moduleId @@ -187,7 +177,6 @@ export const CreateUpdateDraftIssueModal: React.FC = (props) = start_target_date: true, order_by: "sort_order", }); - if (displayFilters.layout === "spreadsheet") mutate(spreadsheetFetchKey); if (groupedIssues) mutateMyIssues(); setToastAlert({ @@ -222,7 +211,6 @@ export const CreateUpdateDraftIssueModal: React.FC = (props) = mutate(PROJECT_ISSUES_DETAILS, (prevData) => ({ ...prevData, ...res }), false); } else { if (displayFilters.layout === "calendar") mutate(calendarFetchKey); - if (displayFilters.layout === "spreadsheet") mutate(spreadsheetFetchKey); if (payload.parent) mutate(SUB_ISSUES(payload.parent.toString())); mutate(PROJECT_ISSUES_LIST_WITH_PARAMS(activeProject ?? "", params)); mutate(PROJECT_DRAFT_ISSUES_LIST_WITH_PARAMS(activeProject ?? "", params)); @@ -308,7 +296,6 @@ export const CreateUpdateDraftIssueModal: React.FC = (props) = start_target_date: true, order_by: "sort_order", }); - if (displayFilters.layout === "spreadsheet") mutate(spreadsheetFetchKey); if (groupedIssues) mutateMyIssues(); setToastAlert({ diff --git a/web/components/issues/issue-layouts/gantt/root.tsx b/web/components/issues/issue-layouts/gantt/root.tsx index fd4df3e69..732134b46 100644 --- a/web/components/issues/issue-layouts/gantt/root.tsx +++ b/web/components/issues/issue-layouts/gantt/root.tsx @@ -25,9 +25,6 @@ export const GanttLayout: React.FC = observer(() => { const isAllowed = projectDetails?.member_role === 20 || projectDetails?.member_role === 15; - console.log("issues", issues); - console.log("appliedFilters", issueFilterStore.appliedFilters); - return ( <> { enableBlockRightResize={isAllowed} enableBlockMove={isAllowed} enableReorder={appliedDisplayFilters.order_by === "sort_order" && isAllowed} - bottomSpacing />
diff --git a/web/components/issues/issue-layouts/index.ts b/web/components/issues/issue-layouts/index.ts index b1490b52e..f000ec7bf 100644 --- a/web/components/issues/issue-layouts/index.ts +++ b/web/components/issues/issue-layouts/index.ts @@ -2,3 +2,4 @@ export * from "./calendar"; export * from "./gantt"; export * from "./header"; export * from "./kanban"; +export * from "./spreadsheet"; diff --git a/web/components/issues/issue-layouts/spreadsheet/index.ts b/web/components/issues/issue-layouts/spreadsheet/index.ts new file mode 100644 index 000000000..1efe34c51 --- /dev/null +++ b/web/components/issues/issue-layouts/spreadsheet/index.ts @@ -0,0 +1 @@ +export * from "./root"; diff --git a/web/components/issues/issue-layouts/spreadsheet/root.tsx b/web/components/issues/issue-layouts/spreadsheet/root.tsx new file mode 100644 index 000000000..4ceb15fc6 --- /dev/null +++ b/web/components/issues/issue-layouts/spreadsheet/root.tsx @@ -0,0 +1,160 @@ +import React, { useCallback, useState } from "react"; +import { useRouter } from "next/router"; +import { observer } from "mobx-react-lite"; + +// mobx store +import { useMobxStore } from "lib/mobx/store-provider"; +// hooks +import useUser from "hooks/use-user"; +import useProjectDetails from "hooks/use-project-details"; +// components +import { SpreadsheetColumns, SpreadsheetIssues } from "components/core"; +import { IssuePeekOverview } from "components/issues"; +// ui +import { CustomMenu, Spinner } from "components/ui"; +// icon +import { PlusIcon } from "@heroicons/react/24/outline"; +// types +import { IIssue, IIssueDisplayFilterOptions, IIssueDisplayProperties } from "types"; +import { IIssueUnGroupedStructure } from "store/issue"; +// constants +import { SPREADSHEET_COLUMN } from "constants/spreadsheet"; + +export const SpreadsheetLayout: React.FC = observer(() => { + const [expandedIssues, setExpandedIssues] = useState([]); + + const router = useRouter(); + const { workspaceSlug, projectId, cycleId, moduleId } = router.query; + + const { user } = useUser(); + const { projectDetails } = useProjectDetails(); + + const { issue: issueStore, issueFilter: issueFilterStore } = useMobxStore(); + + const issues = issueStore.getIssues; + const issueDisplayProperties = issueFilterStore.userDisplayProperties; + + const handleDisplayFiltersUpdate = useCallback( + (updatedDisplayFilter: Partial) => { + if (!workspaceSlug || !projectId) return; + + issueFilterStore.updateUserFilters(workspaceSlug.toString(), projectId.toString(), { + display_filters: { + ...updatedDisplayFilter, + }, + }); + }, + [issueFilterStore, projectId, workspaceSlug] + ); + + const type = cycleId ? "cycle" : moduleId ? "module" : "issue"; + + const columnData = SPREADSHEET_COLUMN.map((column) => ({ + ...column, + isActive: issueDisplayProperties + ? column.propertyName === "labels" + ? issueDisplayProperties[column.propertyName as keyof IIssueDisplayProperties] + : column.propertyName === "title" + ? true + : issueDisplayProperties[column.propertyName as keyof IIssueDisplayProperties] + : false, + })); + + const gridTemplateColumns = columnData + .filter((column) => column.isActive) + .map((column) => column.colSize) + .join(" "); + + const isAllowed = projectDetails?.member_role === 20 || projectDetails?.member_role === 15; + + return ( + <> + +
+
+ +
+ {issues ? ( +
+ {(issues as IIssueUnGroupedStructure).map((issue: IIssue, index) => ( + {}} + disableUserActions={!isAllowed} + user={user} + userAuth={{ + isViewer: projectDetails?.member_role === 5, + isGuest: projectDetails?.member_role === 10, + isMember: projectDetails?.member_role === 15, + isOwner: projectDetails?.member_role === 20, + }} + /> + ))} +
+ {type === "issue" ? ( + + ) : ( + isAllowed && ( + + + Add Issue + + } + position="left" + optionsClassName="left-5 !w-36" + noBorder + > + { + const e = new KeyboardEvent("keydown", { key: "c" }); + document.dispatchEvent(e); + }} + > + Create new + + {true && {}}>Add an existing issue} + + ) + )} +
+
+ ) : ( + + )} +
+ + ); +}); diff --git a/web/components/issues/modal.tsx b/web/components/issues/modal.tsx index 9ea5f1871..28da11878 100644 --- a/web/components/issues/modal.tsx +++ b/web/components/issues/modal.tsx @@ -16,7 +16,6 @@ import useIssuesView from "hooks/use-issues-view"; import useCalendarIssuesView from "hooks/use-calendar-issues-view"; import useToast from "hooks/use-toast"; import useInboxView from "hooks/use-inbox-view"; -import useSpreadsheetIssuesView from "hooks/use-spreadsheet-issues-view"; import useProjects from "hooks/use-projects"; import useMyIssues from "hooks/my-issues/use-my-issues"; import useLocalStorage from "hooks/use-local-storage"; @@ -87,7 +86,6 @@ export const CreateUpdateIssueModal: React.FC = ({ const { params: calendarParams } = useCalendarIssuesView(); const { ...viewGanttParams } = params; const { params: inboxParams } = useInboxView(); - const { params: spreadsheetParams } = useSpreadsheetIssuesView(); const { user } = useUser(); const { projects } = useProjects(); @@ -280,14 +278,6 @@ export const CreateUpdateIssueModal: React.FC = ({ ? VIEW_ISSUES(viewId.toString(), calendarParams) : PROJECT_ISSUES_LIST_WITH_PARAMS(activeProject?.toString() ?? "", calendarParams); - const spreadsheetFetchKey = cycleId - ? CYCLE_ISSUES_WITH_PARAMS(cycleId.toString(), spreadsheetParams) - : moduleId - ? MODULE_ISSUES_WITH_PARAMS(moduleId.toString(), spreadsheetParams) - : viewId - ? VIEW_ISSUES(viewId.toString(), spreadsheetParams) - : PROJECT_ISSUES_LIST_WITH_PARAMS(activeProject?.toString() ?? "", spreadsheetParams); - const ganttFetchKey = cycleId ? CYCLE_ISSUES_WITH_PARAMS(cycleId.toString()) : moduleId @@ -314,7 +304,6 @@ export const CreateUpdateIssueModal: React.FC = ({ start_target_date: true, order_by: "sort_order", }); - if (displayFilters.layout === "spreadsheet") mutate(spreadsheetFetchKey); if (groupedIssues) mutateMyIssues(); setToastAlert({ @@ -387,7 +376,6 @@ export const CreateUpdateIssueModal: React.FC = ({ mutate(PROJECT_ISSUES_DETAILS, (prevData) => ({ ...prevData, ...res }), false); } else { if (displayFilters.layout === "calendar") mutate(calendarFetchKey); - if (displayFilters.layout === "spreadsheet") mutate(spreadsheetFetchKey); if (payload.parent) mutate(SUB_ISSUES(payload.parent.toString())); mutate(PROJECT_ISSUES_LIST_WITH_PARAMS(activeProject ?? "", params)); } diff --git a/web/hooks/gantt-chart/issue-view.tsx b/web/hooks/gantt-chart/issue-view.tsx deleted file mode 100644 index 2f9fd9c18..000000000 --- a/web/hooks/gantt-chart/issue-view.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import useSWR from "swr"; - -// services -import issuesService from "services/issue.service"; -// hooks -import useIssuesView from "hooks/use-issues-view"; -// fetch-keys -import { PROJECT_ISSUES_LIST_WITH_PARAMS } from "constants/fetch-keys"; - -const useGanttChartIssues = (workspaceSlug: string | undefined, projectId: string | undefined) => { - const { displayFilters, filters } = useIssuesView(); - - const params: any = { - order_by: displayFilters.order_by, - type: displayFilters?.type ? displayFilters?.type : undefined, - sub_issue: displayFilters.sub_issue, - assignees: filters?.assignees ? filters?.assignees.join(",") : undefined, - state: filters?.state ? filters?.state.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, - start_target_date: true, // to fetch only issues with a start and target date - }; - - // all issues under the workspace and project - const { data: ganttIssues, mutate: mutateGanttIssues } = useSWR( - workspaceSlug && projectId ? PROJECT_ISSUES_LIST_WITH_PARAMS(projectId, params) : null, - workspaceSlug && projectId - ? () => issuesService.getIssuesWithParams(workspaceSlug.toString(), projectId.toString(), params) - : null - ); - - return { - ganttIssues, - mutateGanttIssues, - }; -}; - -export default useGanttChartIssues; diff --git a/web/hooks/use-spreadsheet-issues-view.tsx b/web/hooks/use-spreadsheet-issues-view.tsx deleted file mode 100644 index 54cc8670a..000000000 --- a/web/hooks/use-spreadsheet-issues-view.tsx +++ /dev/null @@ -1,116 +0,0 @@ -import { useContext } from "react"; - -import { useRouter } from "next/router"; - -import useSWR from "swr"; - -// contexts -import { issueViewContext } from "contexts/issue-view.context"; -// services -import issuesService from "services/issue.service"; -import cyclesService from "services/cycles.service"; -import modulesService from "services/modules.service"; -// types -import { IIssue } from "types"; -// fetch-keys -import { - CYCLE_ISSUES_WITH_PARAMS, - MODULE_ISSUES_WITH_PARAMS, - PROJECT_ISSUES_LIST_WITH_PARAMS, - VIEW_ISSUES, -} from "constants/fetch-keys"; - -const useSpreadsheetIssuesView = () => { - const { - display_filters: displayFilters, - setDisplayFilters, - filters, - setFilters, - resetFilterToDefault, - setNewFilterDefaultView, - } = useContext(issueViewContext); - - const router = useRouter(); - const { workspaceSlug, projectId, cycleId, moduleId, viewId } = router.query; - - const params: any = { - order_by: displayFilters?.order_by, - assignees: filters?.assignees ? filters?.assignees.join(",") : undefined, - state: filters?.state ? filters?.state.join(",") : undefined, - priority: filters?.priority ? filters?.priority.join(",") : undefined, - type: displayFilters?.type ? displayFilters?.type : 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, - sub_issue: "false", - }; - - const { data: projectSpreadsheetIssues, mutate: mutateProjectSpreadsheetIssues } = useSWR( - workspaceSlug && projectId ? PROJECT_ISSUES_LIST_WITH_PARAMS(projectId.toString(), params) : null, - workspaceSlug && projectId - ? () => issuesService.getIssuesWithParams(workspaceSlug.toString(), projectId.toString(), params) - : null - ); - - const { data: cycleSpreadsheetIssues, mutate: mutateCycleSpreadsheetIssues } = useSWR( - workspaceSlug && projectId && cycleId ? CYCLE_ISSUES_WITH_PARAMS(cycleId.toString(), params) : null, - workspaceSlug && projectId && cycleId - ? () => - cyclesService.getCycleIssuesWithParams( - workspaceSlug.toString(), - projectId.toString(), - cycleId.toString(), - params - ) - : null - ); - - const { data: moduleSpreadsheetIssues, mutate: mutateModuleSpreadsheetIssues } = useSWR( - workspaceSlug && projectId && moduleId ? MODULE_ISSUES_WITH_PARAMS(moduleId.toString(), params) : null, - workspaceSlug && projectId && moduleId - ? () => - modulesService.getModuleIssuesWithParams( - workspaceSlug.toString(), - projectId.toString(), - moduleId.toString(), - params - ) - : null - ); - - const { data: viewSpreadsheetIssues, mutate: mutateViewSpreadsheetIssues } = useSWR( - workspaceSlug && projectId && viewId && params ? VIEW_ISSUES(viewId.toString(), params) : null, - workspaceSlug && projectId && viewId && params - ? () => issuesService.getIssuesWithParams(workspaceSlug.toString(), projectId.toString(), params) - : null - ); - - const spreadsheetIssues = cycleId - ? (cycleSpreadsheetIssues as IIssue[]) - : moduleId - ? (moduleSpreadsheetIssues as IIssue[]) - : viewId - ? (viewSpreadsheetIssues as IIssue[]) - : (projectSpreadsheetIssues as IIssue[]); - - return { - displayFilters, - setDisplayFilters, - mutateIssues: cycleId - ? mutateCycleSpreadsheetIssues - : moduleId - ? mutateModuleSpreadsheetIssues - : viewId - ? mutateViewSpreadsheetIssues - : mutateProjectSpreadsheetIssues, - spreadsheetIssues: spreadsheetIssues ?? [], - filters, - setFilters, - params, - resetFilterToDefault, - setNewFilterDefaultView, - } as const; -}; - -export default useSpreadsheetIssuesView;