fix workspace draft build (#5795)
This commit is contained in:
parent
332d2d5c68
commit
9c2278a810
8 changed files with 111 additions and 32 deletions
|
|
@ -37,6 +37,7 @@ export const WorkspaceDraftIssueLayoutRoot = observer(() => {
|
|||
<div className="relative flex h-full w-full flex-col overflow-hidden">
|
||||
<div className="relative h-full w-full overflow-auto">
|
||||
<BaseListRoot
|
||||
//@ts-expect-error type mismatch
|
||||
QuickActions={WorkspaceDraftIssueQuickActions}
|
||||
canEditPropertiesBasedOnProject={canEditProperties}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -150,10 +150,10 @@ export const CreateUpdateIssueModalBase: React.FC<IssuesModalProps> = 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
|
||||
|
|
|
|||
|
|
@ -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<Props> = memo((props) => {
|
|||
</Popover>
|
||||
);
|
||||
});
|
||||
|
||||
ColorDropdown.displayName = "ColorDropdown";
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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<TIssue>) => {
|
||||
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<TIssue>) => {
|
||||
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<TIssue>) => {
|
||||
if (!workspaceSlug || !issueId || !data) return;
|
||||
return await issues.moveToIssues(workspaceSlug, issueId, data);
|
||||
},
|
||||
[issues]
|
||||
);
|
||||
// const moveToIssue = useCallback(
|
||||
// async (workspaceSlug: string, issueId: string, data: Partial<TIssue>) => {
|
||||
// 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]
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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<TWorkspaceDraftIssue>
|
||||
payload: Partial<TWorkspaceDraftIssue | TIssue>
|
||||
): Promise<TWorkspaceDraftIssue | undefined> {
|
||||
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<TWorkspaceDraftIssue>
|
||||
payload: Partial<TWorkspaceDraftIssue | TIssue>
|
||||
): Promise<TWorkspaceDraftIssue | undefined> {
|
||||
return this.patch(`/api/workspaces/${workspaceSlug}/draft-issues/${issueId}/`, payload)
|
||||
.then((response) => response?.data)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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<TWorkspaceDraftIssue>) => void;
|
||||
removeIssue: (issueId: string) => void;
|
||||
removeIssue: (issueId: string) => Promise<void>;
|
||||
// actions
|
||||
fetchIssues: (
|
||||
workspaceSlug: string,
|
||||
|
|
@ -42,12 +47,12 @@ export interface IWorkspaceDraftIssues {
|
|||
) => Promise<TWorkspaceDraftPaginationInfo<TWorkspaceDraftIssue> | undefined>;
|
||||
createIssue: (
|
||||
workspaceSlug: string,
|
||||
payload: Partial<TWorkspaceDraftIssue>
|
||||
payload: Partial<TWorkspaceDraftIssue | TIssue>
|
||||
) => Promise<TWorkspaceDraftIssue | undefined>;
|
||||
updateIssue: (
|
||||
workspaceSlug: string,
|
||||
issueId: string,
|
||||
payload: Partial<TWorkspaceDraftIssue>
|
||||
payload: Partial<TWorkspaceDraftIssue | TIssue>
|
||||
) => Promise<TWorkspaceDraftIssue | undefined>;
|
||||
deleteIssue: (workspaceSlug: string, issueId: string) => Promise<void>;
|
||||
moveIssue: (workspaceSlug: string, issueId: string, payload: Partial<TWorkspaceDraftIssue>) => Promise<void>;
|
||||
|
|
@ -61,6 +66,42 @@ export interface IWorkspaceDraftIssues {
|
|||
issueId: string,
|
||||
moduleIds: string[]
|
||||
) => Promise<TWorkspaceDraftIssue | undefined>;
|
||||
|
||||
// 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<void>;
|
||||
addIssueToCycle: (
|
||||
workspaceSlug: string,
|
||||
projectId: string,
|
||||
cycleId: string,
|
||||
issueIds: string[],
|
||||
fetchAddedIssues?: boolean
|
||||
) => Promise<void>;
|
||||
removeIssueFromCycle: (workspaceSlug: string, projectId: string, cycleId: string, issueId: string) => Promise<void>;
|
||||
|
||||
removeIssuesFromModule: (
|
||||
workspaceSlug: string,
|
||||
projectId: string,
|
||||
moduleId: string,
|
||||
issueIds: string[]
|
||||
) => Promise<void>;
|
||||
changeModulesInIssue(
|
||||
workspaceSlug: string,
|
||||
projectId: string,
|
||||
issueId: string,
|
||||
addModuleIds: string[],
|
||||
removeModuleIds: string[]
|
||||
): Promise<void>;
|
||||
archiveIssue: (workspaceSlug: string, projectId: string, issueId: string) => Promise<void>;
|
||||
}
|
||||
|
||||
export class WorkspaceDraftIssues implements IWorkspaceDraftIssues {
|
||||
|
|
@ -71,7 +112,7 @@ export class WorkspaceDraftIssues implements IWorkspaceDraftIssues {
|
|||
loader: TWorkspaceDraftIssueLoader = undefined;
|
||||
issuesMap: Record<string, TWorkspaceDraftIssue> = {};
|
||||
|
||||
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<TWorkspaceDraftIssue>
|
||||
payload: Partial<TWorkspaceDraftIssue | TIssue>
|
||||
): Promise<TWorkspaceDraftIssue | undefined> => {
|
||||
try {
|
||||
this.loader = "create";
|
||||
|
|
@ -206,7 +247,7 @@ export class WorkspaceDraftIssues implements IWorkspaceDraftIssues {
|
|||
}
|
||||
};
|
||||
|
||||
updateIssue = async (workspaceSlug: string, issueId: string, payload: Partial<TWorkspaceDraftIssue>) => {
|
||||
updateIssue = async (workspaceSlug: string, issueId: string, payload: Partial<TWorkspaceDraftIssue | TIssue>) => {
|
||||
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) => {};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue