fix workspace draft build (#5795)

This commit is contained in:
rahulramesha 2024-10-10 20:50:43 +05:30 committed by GitHub
parent 332d2d5c68
commit 9c2278a810
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 111 additions and 32 deletions

View file

@ -37,6 +37,7 @@ export const WorkspaceDraftIssueLayoutRoot = observer(() => {
<div className="relative flex h-full w-full flex-col overflow-hidden"> <div className="relative flex h-full w-full flex-col overflow-hidden">
<div className="relative h-full w-full overflow-auto"> <div className="relative h-full w-full overflow-auto">
<BaseListRoot <BaseListRoot
//@ts-expect-error type mismatch
QuickActions={WorkspaceDraftIssueQuickActions} QuickActions={WorkspaceDraftIssueQuickActions}
canEditPropertiesBasedOnProject={canEditProperties} canEditPropertiesBasedOnProject={canEditProperties}
/> />

View file

@ -150,10 +150,10 @@ export const CreateUpdateIssueModalBase: React.FC<IssuesModalProps> = observer((
if (!workspaceSlug || !payload.project_id) return; if (!workspaceSlug || !payload.project_id) return;
try { try {
let response; let response: TIssue | undefined;
// if draft issue, use draft issue store to create issue // if draft issue, use draft issue store to create issue
if (is_draft_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 // 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 // or if the moduleIds in Payload does not match the moduleId in url

View file

@ -1,8 +1,8 @@
"use client"; "use client";
import { memo } from "react"; import { memo } from "react";
import { Popover } from "@headlessui/react";
import { ALargeSmall, Ban } from "lucide-react"; import { ALargeSmall, Ban } from "lucide-react";
import { Popover } from "@headlessui/react";
// plane editor // plane editor
import { COLORS_LIST, TColorEditorCommands } from "@plane/editor"; import { COLORS_LIST, TColorEditorCommands } from "@plane/editor";
// helpers // helpers
@ -125,3 +125,5 @@ export const ColorDropdown: React.FC<Props> = memo((props) => {
</Popover> </Popover>
); );
}); });
ColorDropdown.displayName = "ColorDropdown";

View file

@ -16,7 +16,8 @@ type DNDStoreType =
| EIssuesStoreType.PROJECT_VIEW | EIssuesStoreType.PROJECT_VIEW
| EIssuesStoreType.DRAFT | EIssuesStoreType.DRAFT
| EIssuesStoreType.PROFILE | EIssuesStoreType.PROFILE
| EIssuesStoreType.ARCHIVED; | EIssuesStoreType.ARCHIVED
| EIssuesStoreType.WORKSPACE_DRAFT;
export const useGroupIssuesDragNDrop = ( export const useGroupIssuesDragNDrop = (
storeType: DNDStoreType, storeType: DNDStoreType,

View file

@ -13,6 +13,7 @@ import {
TProfileViews, TProfileViews,
} from "@plane/types"; } from "@plane/types";
import { EIssueFilterType, EIssuesStoreType } from "@/constants/issue"; import { EIssueFilterType, EIssuesStoreType } from "@/constants/issue";
import { EDraftIssuePaginationType } from "@/constants/workspace-drafts";
import { useIssues } from "./store"; import { useIssues } from "./store";
interface IssueActions { interface IssueActions {
@ -63,6 +64,7 @@ export const useIssuesActions = (storeType: EIssuesStoreType): IssueActions => {
case EIssuesStoreType.GLOBAL: case EIssuesStoreType.GLOBAL:
return globalIssueActions; return globalIssueActions;
case EIssuesStoreType.WORKSPACE_DRAFT: case EIssuesStoreType.WORKSPACE_DRAFT:
//@ts-expect-error type mismatch
return workspaceDraftIssueActions; return workspaceDraftIssueActions;
case EIssuesStoreType.PROJECT: case EIssuesStoreType.PROJECT:
default: default:
@ -751,45 +753,45 @@ const useWorkspaceDraftIssueActions = () => {
const fetchIssues = useCallback( const fetchIssues = useCallback(
async (loadType: TLoader, options: IssuePaginationOptions) => { async (loadType: TLoader, options: IssuePaginationOptions) => {
if (!workspaceSlug) return; if (!workspaceSlug) return;
return issues.fetchIssues(workspaceSlug.toString(), loadType, options); return issues.fetchIssues(workspaceSlug.toString(), loadType, EDraftIssuePaginationType.INIT);
}, },
[workspaceSlug, issues] [workspaceSlug, issues]
); );
const fetchNextIssues = useCallback(async () => { const fetchNextIssues = useCallback(async () => {
if (!workspaceSlug) return; if (!workspaceSlug) return;
return issues.fetchNextIssues(workspaceSlug.toString()); return issues.fetchIssues(workspaceSlug.toString(), "pagination", EDraftIssuePaginationType.NEXT);
}, [workspaceSlug, issues]); }, [workspaceSlug, issues]);
const createIssue = useCallback( const createIssue = useCallback(
async (projectId: string | undefined | null, data: Partial<TIssue>) => { async (projectId: string | undefined | null, data: Partial<TIssue>) => {
if (!workspaceSlug || !projectId) return; if (!workspaceSlug || !projectId) return;
return await issues.createWorkspaceDraftIssue(workspaceSlug, data); return await issues.createIssue(workspaceSlug, data);
}, },
[issues, workspaceSlug] [issues, workspaceSlug]
); );
const updateIssue = useCallback( const updateIssue = useCallback(
async (projectId: string | undefined | null, issueId: string, data: Partial<TIssue>) => { async (projectId: string | undefined | null, issueId: string, data: Partial<TIssue>) => {
if (!workspaceSlug || !projectId) return; if (!workspaceSlug || !projectId) return;
return await issues.updateWorkspaceDraftIssue(workspaceSlug, issueId, data); return await issues.updateIssue(workspaceSlug, issueId, data);
}, },
[issues, workspaceSlug] [issues, workspaceSlug]
); );
const removeIssue = useCallback( const removeIssue = useCallback(
async (projectId: string | undefined | null, issueId: string) => { async (projectId: string | undefined | null, issueId: string) => {
if (!workspaceSlug || !projectId) return; if (!workspaceSlug || !projectId) return;
return await issues.deleteWorkspaceDraftIssue(workspaceSlug, issueId); return await issues.removeIssue(issueId);
}, },
[issues, workspaceSlug] [issues, workspaceSlug]
); );
const moveToIssue = useCallback( // const moveToIssue = useCallback(
async (workspaceSlug: string, issueId: string, data: Partial<TIssue>) => { // async (workspaceSlug: string, issueId: string, data: Partial<TIssue>) => {
if (!workspaceSlug || !issueId || !data) return; // if (!workspaceSlug || !issueId || !data) return;
return await issues.moveToIssues(workspaceSlug, issueId, data); // return await issues.moveToIssues(workspaceSlug, issueId, data);
}, // },
[issues] // [issues]
); // );
const updateFilters = useCallback( const updateFilters = useCallback(
async ( async (
@ -812,8 +814,7 @@ const useWorkspaceDraftIssueActions = () => {
updateIssue, updateIssue,
removeIssue, removeIssue,
updateFilters, updateFilters,
moveToIssue,
}), }),
[fetchIssues, fetchNextIssues, createIssue, updateIssue, removeIssue, updateFilters, moveToIssue] [fetchIssues, fetchNextIssues, createIssue, updateIssue, removeIssue, updateFilters]
); );
}; };

View file

@ -1,4 +1,4 @@
import { TWorkspaceDraftIssue, TWorkspaceDraftPaginationInfo } from "@plane/types"; import { TIssue, TWorkspaceDraftIssue, TWorkspaceDraftPaginationInfo } from "@plane/types";
// helpers // helpers
import { API_BASE_URL } from "@/helpers/common.helper"; import { API_BASE_URL } from "@/helpers/common.helper";
// services // services
@ -30,7 +30,7 @@ export class WorkspaceDraftService extends APIService {
async createIssue( async createIssue(
workspaceSlug: string, workspaceSlug: string,
payload: Partial<TWorkspaceDraftIssue> payload: Partial<TWorkspaceDraftIssue | TIssue>
): Promise<TWorkspaceDraftIssue | undefined> { ): Promise<TWorkspaceDraftIssue | undefined> {
return this.post(`/api/workspaces/${workspaceSlug}/draft-issues/`, payload) return this.post(`/api/workspaces/${workspaceSlug}/draft-issues/`, payload)
.then((response) => response?.data) .then((response) => response?.data)
@ -42,7 +42,7 @@ export class WorkspaceDraftService extends APIService {
async updateIssue( async updateIssue(
workspaceSlug: string, workspaceSlug: string,
issueId: string, issueId: string,
payload: Partial<TWorkspaceDraftIssue> payload: Partial<TWorkspaceDraftIssue | TIssue>
): Promise<TWorkspaceDraftIssue | undefined> { ): Promise<TWorkspaceDraftIssue | undefined> {
return this.patch(`/api/workspaces/${workspaceSlug}/draft-issues/${issueId}/`, payload) return this.patch(`/api/workspaces/${workspaceSlug}/draft-issues/${issueId}/`, payload)
.then((response) => response?.data) .then((response) => response?.data)

View file

@ -24,7 +24,12 @@ import {
ProjectViewIssues, ProjectViewIssues,
} from "./project-views"; } from "./project-views";
import { WorkspaceIssuesFilter, IWorkspaceIssues, WorkspaceIssues, IWorkspaceIssuesFilter } from "./workspace"; 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 { export interface IIssueRootStore {
currentUserId: string | undefined; currentUserId: string | undefined;
@ -198,7 +203,7 @@ export class IssueRootStore implements IIssueRootStore {
this.profileIssues = new ProfileIssues(this, this.profileIssuesFilter); this.profileIssues = new ProfileIssues(this, this.profileIssuesFilter);
this.workspaceDraftIssuesFilter = new WorkspaceDraftIssuesFilter(this); this.workspaceDraftIssuesFilter = new WorkspaceDraftIssuesFilter(this);
this.workspaceDraftIssues = new WorkspaceDraftIssues(this, this.workspaceDraftIssuesFilter); this.workspaceDraftIssues = new WorkspaceDraftIssues();
this.projectIssuesFilter = new ProjectIssuesFilter(this); this.projectIssuesFilter = new ProjectIssuesFilter(this);
this.projectIssues = new ProjectIssues(this, this.projectIssuesFilter); this.projectIssues = new ProjectIssues(this, this.projectIssuesFilter);

View file

@ -1,3 +1,4 @@
import clone from "lodash/clone";
import orderBy from "lodash/orderBy"; import orderBy from "lodash/orderBy";
import set from "lodash/set"; import set from "lodash/set";
import unset from "lodash/unset"; import unset from "lodash/unset";
@ -9,6 +10,12 @@ import {
TWorkspaceDraftPaginationInfo, TWorkspaceDraftPaginationInfo,
TWorkspaceDraftIssueLoader, TWorkspaceDraftIssueLoader,
TWorkspaceDraftQueryParams, TWorkspaceDraftQueryParams,
TPaginationData,
TLoader,
TGroupedIssues,
TSubGroupedIssues,
ViewFlags,
TIssue,
} from "@plane/types"; } from "@plane/types";
// constants // constants
import { EDraftIssuePaginationType } from "@/constants/workspace-drafts"; import { EDraftIssuePaginationType } from "@/constants/workspace-drafts";
@ -16,8 +23,6 @@ import { EDraftIssuePaginationType } from "@/constants/workspace-drafts";
import { getCurrentDateTimeInISO, convertToISODateString } from "@/helpers/date-time.helper"; import { getCurrentDateTimeInISO, convertToISODateString } from "@/helpers/date-time.helper";
// services // services
import workspaceDraftService from "@/services/issue/workspace_draft.service"; import workspaceDraftService from "@/services/issue/workspace_draft.service";
import { IIssueDetail } from "../issue-details/root.store";
import { clone } from "lodash";
export type TDraftIssuePaginationType = EDraftIssuePaginationType; export type TDraftIssuePaginationType = EDraftIssuePaginationType;
@ -33,7 +38,7 @@ export interface IWorkspaceDraftIssues {
// helper actions // helper actions
addIssue: (issues: TWorkspaceDraftIssue[]) => void; addIssue: (issues: TWorkspaceDraftIssue[]) => void;
mutateIssue: (issueId: string, data: Partial<TWorkspaceDraftIssue>) => void; mutateIssue: (issueId: string, data: Partial<TWorkspaceDraftIssue>) => void;
removeIssue: (issueId: string) => void; removeIssue: (issueId: string) => Promise<void>;
// actions // actions
fetchIssues: ( fetchIssues: (
workspaceSlug: string, workspaceSlug: string,
@ -42,12 +47,12 @@ export interface IWorkspaceDraftIssues {
) => Promise<TWorkspaceDraftPaginationInfo<TWorkspaceDraftIssue> | undefined>; ) => Promise<TWorkspaceDraftPaginationInfo<TWorkspaceDraftIssue> | undefined>;
createIssue: ( createIssue: (
workspaceSlug: string, workspaceSlug: string,
payload: Partial<TWorkspaceDraftIssue> payload: Partial<TWorkspaceDraftIssue | TIssue>
) => Promise<TWorkspaceDraftIssue | undefined>; ) => Promise<TWorkspaceDraftIssue | undefined>;
updateIssue: ( updateIssue: (
workspaceSlug: string, workspaceSlug: string,
issueId: string, issueId: string,
payload: Partial<TWorkspaceDraftIssue> payload: Partial<TWorkspaceDraftIssue | TIssue>
) => Promise<TWorkspaceDraftIssue | undefined>; ) => Promise<TWorkspaceDraftIssue | undefined>;
deleteIssue: (workspaceSlug: string, issueId: string) => Promise<void>; deleteIssue: (workspaceSlug: string, issueId: string) => Promise<void>;
moveIssue: (workspaceSlug: string, issueId: string, payload: Partial<TWorkspaceDraftIssue>) => Promise<void>; moveIssue: (workspaceSlug: string, issueId: string, payload: Partial<TWorkspaceDraftIssue>) => Promise<void>;
@ -61,6 +66,42 @@ export interface IWorkspaceDraftIssues {
issueId: string, issueId: string,
moduleIds: string[] moduleIds: string[]
) => Promise<TWorkspaceDraftIssue | undefined>; ) => 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 { export class WorkspaceDraftIssues implements IWorkspaceDraftIssues {
@ -71,7 +112,7 @@ export class WorkspaceDraftIssues implements IWorkspaceDraftIssues {
loader: TWorkspaceDraftIssueLoader = undefined; loader: TWorkspaceDraftIssueLoader = undefined;
issuesMap: Record<string, TWorkspaceDraftIssue> = {}; issuesMap: Record<string, TWorkspaceDraftIssue> = {};
constructor(private store: IIssueDetail) { constructor() {
makeObservable(this, { makeObservable(this, {
paginationInfo: observable, paginationInfo: observable,
loader: observable.ref, 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; if (!issueId || !this.issuesMap[issueId]) return;
runInAction(() => unset(this.issuesMap, issueId)); runInAction(() => unset(this.issuesMap, issueId));
}; };
@ -188,7 +229,7 @@ export class WorkspaceDraftIssues implements IWorkspaceDraftIssues {
createIssue = async ( createIssue = async (
workspaceSlug: string, workspaceSlug: string,
payload: Partial<TWorkspaceDraftIssue> payload: Partial<TWorkspaceDraftIssue | TIssue>
): Promise<TWorkspaceDraftIssue | undefined> => { ): Promise<TWorkspaceDraftIssue | undefined> => {
try { try {
this.loader = "create"; 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)); const issueBeforeUpdate = clone(this.getIssueById(issueId));
try { try {
this.loader = "update"; this.loader = "update";
@ -277,4 +318,32 @@ export class WorkspaceDraftIssues implements IWorkspaceDraftIssues {
throw error; 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) => {};
} }