From d4fc7538d9db47289320cd95b97822e4a3f13893 Mon Sep 17 00:00:00 2001 From: rahulramesha Date: Thu, 10 Oct 2024 20:43:50 +0530 Subject: [PATCH] fix workspace draft build --- .../roots/workspace-draft-root.tsx | 1 + .../components/issues/issue-modal/base.tsx | 4 +- .../pages/editor/header/color-dropdown.tsx | 4 +- web/core/hooks/use-group-dragndrop.ts | 3 +- web/core/hooks/use-issues-actions.tsx | 29 ++++--- .../services/issue/workspace_draft.service.ts | 6 +- web/core/store/issue/root.store.ts | 9 +- .../issue/workspace-draft/issue.store.ts | 87 +++++++++++++++++-- 8 files changed, 111 insertions(+), 32 deletions(-) diff --git a/web/core/components/issues/issue-layouts/filters/applied-filters/roots/workspace-draft-root.tsx b/web/core/components/issues/issue-layouts/filters/applied-filters/roots/workspace-draft-root.tsx index b97786839fe..feccca5f61c 100644 --- a/web/core/components/issues/issue-layouts/filters/applied-filters/roots/workspace-draft-root.tsx +++ b/web/core/components/issues/issue-layouts/filters/applied-filters/roots/workspace-draft-root.tsx @@ -37,6 +37,7 @@ export const WorkspaceDraftIssueLayoutRoot = observer(() => {
diff --git a/web/core/components/issues/issue-modal/base.tsx b/web/core/components/issues/issue-modal/base.tsx index d6ccf590921..acaea9ebd5a 100644 --- a/web/core/components/issues/issue-modal/base.tsx +++ b/web/core/components/issues/issue-modal/base.tsx @@ -150,10 +150,10 @@ export const CreateUpdateIssueModalBase: React.FC = observer(( if (!workspaceSlug || !payload.project_id) return; try { - let response; + let response: TIssue | undefined; // if draft issue, use draft issue store to create issue if (is_draft_issue) { - response = await draftIssues.createIssue(workspaceSlug.toString(), payload); + response = (await draftIssues.createIssue(workspaceSlug.toString(), payload)) as TIssue; } // if cycle id in payload does not match the cycleId in url // or if the moduleIds in Payload does not match the moduleId in url diff --git a/web/core/components/pages/editor/header/color-dropdown.tsx b/web/core/components/pages/editor/header/color-dropdown.tsx index 33d7c534fb9..6be2b1f7b39 100644 --- a/web/core/components/pages/editor/header/color-dropdown.tsx +++ b/web/core/components/pages/editor/header/color-dropdown.tsx @@ -1,8 +1,8 @@ "use client"; import { memo } from "react"; -import { Popover } from "@headlessui/react"; import { ALargeSmall, Ban } from "lucide-react"; +import { Popover } from "@headlessui/react"; // plane editor import { COLORS_LIST, TColorEditorCommands } from "@plane/editor"; // helpers @@ -125,3 +125,5 @@ export const ColorDropdown: React.FC = memo((props) => { ); }); + +ColorDropdown.displayName = "ColorDropdown"; diff --git a/web/core/hooks/use-group-dragndrop.ts b/web/core/hooks/use-group-dragndrop.ts index 4cf0b900135..08695d341d2 100644 --- a/web/core/hooks/use-group-dragndrop.ts +++ b/web/core/hooks/use-group-dragndrop.ts @@ -16,7 +16,8 @@ type DNDStoreType = | EIssuesStoreType.PROJECT_VIEW | EIssuesStoreType.DRAFT | EIssuesStoreType.PROFILE - | EIssuesStoreType.ARCHIVED; + | EIssuesStoreType.ARCHIVED + | EIssuesStoreType.WORKSPACE_DRAFT; export const useGroupIssuesDragNDrop = ( storeType: DNDStoreType, diff --git a/web/core/hooks/use-issues-actions.tsx b/web/core/hooks/use-issues-actions.tsx index a4604a06152..8fb2ed228ab 100644 --- a/web/core/hooks/use-issues-actions.tsx +++ b/web/core/hooks/use-issues-actions.tsx @@ -13,6 +13,7 @@ import { TProfileViews, } from "@plane/types"; import { EIssueFilterType, EIssuesStoreType } from "@/constants/issue"; +import { EDraftIssuePaginationType } from "@/constants/workspace-drafts"; import { useIssues } from "./store"; interface IssueActions { @@ -63,6 +64,7 @@ export const useIssuesActions = (storeType: EIssuesStoreType): IssueActions => { case EIssuesStoreType.GLOBAL: return globalIssueActions; case EIssuesStoreType.WORKSPACE_DRAFT: + //@ts-expect-error type mismatch return workspaceDraftIssueActions; case EIssuesStoreType.PROJECT: default: @@ -751,45 +753,45 @@ const useWorkspaceDraftIssueActions = () => { const fetchIssues = useCallback( async (loadType: TLoader, options: IssuePaginationOptions) => { if (!workspaceSlug) return; - return issues.fetchIssues(workspaceSlug.toString(), loadType, options); + return issues.fetchIssues(workspaceSlug.toString(), loadType, EDraftIssuePaginationType.INIT); }, [workspaceSlug, issues] ); const fetchNextIssues = useCallback(async () => { if (!workspaceSlug) return; - return issues.fetchNextIssues(workspaceSlug.toString()); + return issues.fetchIssues(workspaceSlug.toString(), "pagination", EDraftIssuePaginationType.NEXT); }, [workspaceSlug, issues]); const createIssue = useCallback( async (projectId: string | undefined | null, data: Partial) => { if (!workspaceSlug || !projectId) return; - return await issues.createWorkspaceDraftIssue(workspaceSlug, data); + return await issues.createIssue(workspaceSlug, data); }, [issues, workspaceSlug] ); const updateIssue = useCallback( async (projectId: string | undefined | null, issueId: string, data: Partial) => { if (!workspaceSlug || !projectId) return; - return await issues.updateWorkspaceDraftIssue(workspaceSlug, issueId, data); + return await issues.updateIssue(workspaceSlug, issueId, data); }, [issues, workspaceSlug] ); const removeIssue = useCallback( async (projectId: string | undefined | null, issueId: string) => { if (!workspaceSlug || !projectId) return; - return await issues.deleteWorkspaceDraftIssue(workspaceSlug, issueId); + return await issues.removeIssue(issueId); }, [issues, workspaceSlug] ); - const moveToIssue = useCallback( - async (workspaceSlug: string, issueId: string, data: Partial) => { - if (!workspaceSlug || !issueId || !data) return; - return await issues.moveToIssues(workspaceSlug, issueId, data); - }, - [issues] - ); + // const moveToIssue = useCallback( + // async (workspaceSlug: string, issueId: string, data: Partial) => { + // if (!workspaceSlug || !issueId || !data) return; + // return await issues.moveToIssues(workspaceSlug, issueId, data); + // }, + // [issues] + // ); const updateFilters = useCallback( async ( @@ -812,8 +814,7 @@ const useWorkspaceDraftIssueActions = () => { updateIssue, removeIssue, updateFilters, - moveToIssue, }), - [fetchIssues, fetchNextIssues, createIssue, updateIssue, removeIssue, updateFilters, moveToIssue] + [fetchIssues, fetchNextIssues, createIssue, updateIssue, removeIssue, updateFilters] ); }; diff --git a/web/core/services/issue/workspace_draft.service.ts b/web/core/services/issue/workspace_draft.service.ts index b15e39e03ad..3d7844fe6ba 100644 --- a/web/core/services/issue/workspace_draft.service.ts +++ b/web/core/services/issue/workspace_draft.service.ts @@ -1,4 +1,4 @@ -import { TWorkspaceDraftIssue, TWorkspaceDraftPaginationInfo } from "@plane/types"; +import { TIssue, TWorkspaceDraftIssue, TWorkspaceDraftPaginationInfo } from "@plane/types"; // helpers import { API_BASE_URL } from "@/helpers/common.helper"; // services @@ -30,7 +30,7 @@ export class WorkspaceDraftService extends APIService { async createIssue( workspaceSlug: string, - payload: Partial + payload: Partial ): Promise { return this.post(`/api/workspaces/${workspaceSlug}/draft-issues/`, payload) .then((response) => response?.data) @@ -42,7 +42,7 @@ export class WorkspaceDraftService extends APIService { async updateIssue( workspaceSlug: string, issueId: string, - payload: Partial + payload: Partial ): Promise { return this.patch(`/api/workspaces/${workspaceSlug}/draft-issues/${issueId}/`, payload) .then((response) => response?.data) diff --git a/web/core/store/issue/root.store.ts b/web/core/store/issue/root.store.ts index f49cb2cae86..8fc49ade192 100644 --- a/web/core/store/issue/root.store.ts +++ b/web/core/store/issue/root.store.ts @@ -24,7 +24,12 @@ import { ProjectViewIssues, } from "./project-views"; import { WorkspaceIssuesFilter, IWorkspaceIssues, WorkspaceIssues, IWorkspaceIssuesFilter } from "./workspace"; -import { IWorkspaceDraftIssues, IWorkspaceDraftIssuesFilter, WorkspaceDraftIssues, WorkspaceDraftIssuesFilter } from "./workspace-draft"; +import { + IWorkspaceDraftIssues, + IWorkspaceDraftIssuesFilter, + WorkspaceDraftIssues, + WorkspaceDraftIssuesFilter, +} from "./workspace-draft"; export interface IIssueRootStore { currentUserId: string | undefined; @@ -198,7 +203,7 @@ export class IssueRootStore implements IIssueRootStore { this.profileIssues = new ProfileIssues(this, this.profileIssuesFilter); this.workspaceDraftIssuesFilter = new WorkspaceDraftIssuesFilter(this); - this.workspaceDraftIssues = new WorkspaceDraftIssues(this, this.workspaceDraftIssuesFilter); + this.workspaceDraftIssues = new WorkspaceDraftIssues(); this.projectIssuesFilter = new ProjectIssuesFilter(this); this.projectIssues = new ProjectIssues(this, this.projectIssuesFilter); diff --git a/web/core/store/issue/workspace-draft/issue.store.ts b/web/core/store/issue/workspace-draft/issue.store.ts index e72eb24bd17..dbb24bb30ce 100644 --- a/web/core/store/issue/workspace-draft/issue.store.ts +++ b/web/core/store/issue/workspace-draft/issue.store.ts @@ -1,3 +1,4 @@ +import clone from "lodash/clone"; import orderBy from "lodash/orderBy"; import set from "lodash/set"; import unset from "lodash/unset"; @@ -9,6 +10,12 @@ import { TWorkspaceDraftPaginationInfo, TWorkspaceDraftIssueLoader, TWorkspaceDraftQueryParams, + TPaginationData, + TLoader, + TGroupedIssues, + TSubGroupedIssues, + ViewFlags, + TIssue, } from "@plane/types"; // constants import { EDraftIssuePaginationType } from "@/constants/workspace-drafts"; @@ -16,8 +23,6 @@ import { EDraftIssuePaginationType } from "@/constants/workspace-drafts"; import { getCurrentDateTimeInISO, convertToISODateString } from "@/helpers/date-time.helper"; // services import workspaceDraftService from "@/services/issue/workspace_draft.service"; -import { IIssueDetail } from "../issue-details/root.store"; -import { clone } from "lodash"; export type TDraftIssuePaginationType = EDraftIssuePaginationType; @@ -33,7 +38,7 @@ export interface IWorkspaceDraftIssues { // helper actions addIssue: (issues: TWorkspaceDraftIssue[]) => void; mutateIssue: (issueId: string, data: Partial) => void; - removeIssue: (issueId: string) => void; + removeIssue: (issueId: string) => Promise; // actions fetchIssues: ( workspaceSlug: string, @@ -42,12 +47,12 @@ export interface IWorkspaceDraftIssues { ) => Promise | undefined>; createIssue: ( workspaceSlug: string, - payload: Partial + payload: Partial ) => Promise; updateIssue: ( workspaceSlug: string, issueId: string, - payload: Partial + payload: Partial ) => Promise; deleteIssue: (workspaceSlug: string, issueId: string) => Promise; moveIssue: (workspaceSlug: string, issueId: string, payload: Partial) => Promise; @@ -61,6 +66,42 @@ export interface IWorkspaceDraftIssues { issueId: string, moduleIds: string[] ) => Promise; + + // dummies + viewFlags: ViewFlags; + groupedIssueIds: TGroupedIssues | TSubGroupedIssues | undefined; + getIssueIds: (groupId?: string, subGroupId?: string) => string[] | undefined; + getPaginationData(groupId: string | undefined, subGroupId: string | undefined): TPaginationData | undefined; + getIssueLoader(groupId?: string, subGroupId?: string): TLoader; + getGroupIssueCount: ( + groupId: string | undefined, + subGroupId: string | undefined, + isSubGroupCumulative: boolean + ) => number | undefined; + removeCycleFromIssue: (workspaceSlug: string, projectId: string, issueId: string) => Promise; + addIssueToCycle: ( + workspaceSlug: string, + projectId: string, + cycleId: string, + issueIds: string[], + fetchAddedIssues?: boolean + ) => Promise; + removeIssueFromCycle: (workspaceSlug: string, projectId: string, cycleId: string, issueId: string) => Promise; + + removeIssuesFromModule: ( + workspaceSlug: string, + projectId: string, + moduleId: string, + issueIds: string[] + ) => Promise; + changeModulesInIssue( + workspaceSlug: string, + projectId: string, + issueId: string, + addModuleIds: string[], + removeModuleIds: string[] + ): Promise; + archiveIssue: (workspaceSlug: string, projectId: string, issueId: string) => Promise; } export class WorkspaceDraftIssues implements IWorkspaceDraftIssues { @@ -71,7 +112,7 @@ export class WorkspaceDraftIssues implements IWorkspaceDraftIssues { loader: TWorkspaceDraftIssueLoader = undefined; issuesMap: Record = {}; - constructor(private store: IIssueDetail) { + constructor() { makeObservable(this, { paginationInfo: observable, loader: observable.ref, @@ -124,7 +165,7 @@ export class WorkspaceDraftIssues implements IWorkspaceDraftIssues { }); }; - removeIssue = (issueId: string) => { + removeIssue = async (issueId: string) => { if (!issueId || !this.issuesMap[issueId]) return; runInAction(() => unset(this.issuesMap, issueId)); }; @@ -188,7 +229,7 @@ export class WorkspaceDraftIssues implements IWorkspaceDraftIssues { createIssue = async ( workspaceSlug: string, - payload: Partial + payload: Partial ): Promise => { try { this.loader = "create"; @@ -206,7 +247,7 @@ export class WorkspaceDraftIssues implements IWorkspaceDraftIssues { } }; - updateIssue = async (workspaceSlug: string, issueId: string, payload: Partial) => { + updateIssue = async (workspaceSlug: string, issueId: string, payload: Partial) => { const issueBeforeUpdate = clone(this.getIssueById(issueId)); try { this.loader = "update"; @@ -277,4 +318,32 @@ export class WorkspaceDraftIssues implements IWorkspaceDraftIssues { throw error; } }; + + // dummies + viewFlags: ViewFlags = { enableQuickAdd: false, enableIssueCreation: false, enableInlineEditing: false }; + groupedIssueIds: TGroupedIssues | TSubGroupedIssues | undefined = undefined; + getIssueIds = (groupId?: string, subGroupId?: string) => undefined; + getPaginationData = (groupId: string | undefined, subGroupId: string | undefined) => undefined; + getIssueLoader = (groupId?: string, subGroupId?: string) => "loaded" as TLoader; + getGroupIssueCount = (groupId: string | undefined, subGroupId: string | undefined, isSubGroupCumulative: boolean) => + undefined; + removeCycleFromIssue = async (workspaceSlug: string, projectId: string, issueId: string) => {}; + addIssueToCycle = async ( + workspaceSlug: string, + projectId: string, + cycleId: string, + issueIds: string[], + fetchAddedIssues?: boolean + ) => {}; + removeIssueFromCycle = async (workspaceSlug: string, projectId: string, cycleId: string, issueId: string) => {}; + + removeIssuesFromModule = async (workspaceSlug: string, projectId: string, moduleId: string, issueIds: string[]) => {}; + changeModulesInIssue = async ( + workspaceSlug: string, + projectId: string, + issueId: string, + addModuleIds: string[], + removeModuleIds: string[] + ) => {}; + archiveIssue = async (workspaceSlug: string, projectId: string, issueId: string) => {}; }