fix: bugs related to issues (#2995)

* hide properties in list and kanban with 0 or nil values

* module and cycle mutation from peek overlay

* fix peek over view title change while switching

* fix create issue fetching

* fix build errors by mutating the values as well
This commit is contained in:
rahulramesha 2023-12-06 01:02:18 +05:30 committed by Aaryan Khandelwal
parent 97d9a40d2d
commit fe0e4433dd
11 changed files with 193 additions and 117 deletions

View File

@ -164,7 +164,7 @@ export const KanBanProperties: React.FC<IKanBanProperties> = observer((props) =>
{/* extra render properties */} {/* extra render properties */}
{/* sub-issues */} {/* sub-issues */}
{displayProperties && displayProperties?.sub_issue_count && ( {displayProperties && displayProperties?.sub_issue_count && !!issue?.sub_issues_count && (
<Tooltip tooltipHeading="Sub-issues" tooltipContent={`${issue.sub_issues_count}`}> <Tooltip tooltipHeading="Sub-issues" tooltipContent={`${issue.sub_issues_count}`}>
<div className="flex-shrink-0 border-[0.5px] border-custom-border-300 overflow-hidden rounded flex justify-center items-center gap-2 px-2.5 py-1 h-5"> <div className="flex-shrink-0 border-[0.5px] border-custom-border-300 overflow-hidden rounded flex justify-center items-center gap-2 px-2.5 py-1 h-5">
<Layers className="h-3 w-3 flex-shrink-0" strokeWidth={2} /> <Layers className="h-3 w-3 flex-shrink-0" strokeWidth={2} />
@ -174,7 +174,7 @@ export const KanBanProperties: React.FC<IKanBanProperties> = observer((props) =>
)} )}
{/* attachments */} {/* attachments */}
{displayProperties && displayProperties?.attachment_count && ( {displayProperties && displayProperties?.attachment_count && !!issue?.attachment_count && (
<Tooltip tooltipHeading="Attachments" tooltipContent={`${issue.attachment_count}`}> <Tooltip tooltipHeading="Attachments" tooltipContent={`${issue.attachment_count}`}>
<div className="flex-shrink-0 border-[0.5px] border-custom-border-300 overflow-hidden rounded flex justify-center items-center gap-2 px-2.5 py-1 h-5"> <div className="flex-shrink-0 border-[0.5px] border-custom-border-300 overflow-hidden rounded flex justify-center items-center gap-2 px-2.5 py-1 h-5">
<Paperclip className="h-3 w-3 flex-shrink-0" strokeWidth={2} /> <Paperclip className="h-3 w-3 flex-shrink-0" strokeWidth={2} />
@ -184,7 +184,7 @@ export const KanBanProperties: React.FC<IKanBanProperties> = observer((props) =>
)} )}
{/* link */} {/* link */}
{displayProperties && displayProperties?.link && ( {displayProperties && displayProperties?.link && !!issue?.link_count && (
<Tooltip tooltipHeading="Links" tooltipContent={`${issue.link_count}`}> <Tooltip tooltipHeading="Links" tooltipContent={`${issue.link_count}`}>
<div className="flex-shrink-0 border-[0.5px] border-custom-border-300 overflow-hidden rounded flex justify-center items-center gap-2 px-2.5 py-1 h-5"> <div className="flex-shrink-0 border-[0.5px] border-custom-border-300 overflow-hidden rounded flex justify-center items-center gap-2 px-2.5 py-1 h-5">
<Link className="h-3 w-3 flex-shrink-0" strokeWidth={2} /> <Link className="h-3 w-3 flex-shrink-0" strokeWidth={2} />

View File

@ -135,7 +135,7 @@ export const ListProperties: FC<IListProperties> = observer((props) => {
{/* extra render properties */} {/* extra render properties */}
{/* sub-issues */} {/* sub-issues */}
{displayProperties && displayProperties?.sub_issue_count && ( {displayProperties && displayProperties?.sub_issue_count && !!issue?.sub_issues_count && (
<Tooltip tooltipHeading="Sub-issues" tooltipContent={`${issue.sub_issues_count}`}> <Tooltip tooltipHeading="Sub-issues" tooltipContent={`${issue.sub_issues_count}`}>
<div className="flex-shrink-0 border-[0.5px] border-custom-border-300 overflow-hidden rounded flex justify-center items-center gap-2 px-2.5 py-1 h-5"> <div className="flex-shrink-0 border-[0.5px] border-custom-border-300 overflow-hidden rounded flex justify-center items-center gap-2 px-2.5 py-1 h-5">
<Layers className="h-3 w-3 flex-shrink-0" strokeWidth={2} /> <Layers className="h-3 w-3 flex-shrink-0" strokeWidth={2} />
@ -145,7 +145,7 @@ export const ListProperties: FC<IListProperties> = observer((props) => {
)} )}
{/* attachments */} {/* attachments */}
{displayProperties && displayProperties?.attachment_count && ( {displayProperties && displayProperties?.attachment_count && !!issue?.attachment_count && (
<Tooltip tooltipHeading="Attachments" tooltipContent={`${issue.attachment_count}`}> <Tooltip tooltipHeading="Attachments" tooltipContent={`${issue.attachment_count}`}>
<div className="flex-shrink-0 border-[0.5px] border-custom-border-300 overflow-hidden rounded flex justify-center items-center gap-2 px-2.5 py-1 h-5"> <div className="flex-shrink-0 border-[0.5px] border-custom-border-300 overflow-hidden rounded flex justify-center items-center gap-2 px-2.5 py-1 h-5">
<Paperclip className="h-3 w-3 flex-shrink-0" strokeWidth={2} /> <Paperclip className="h-3 w-3 flex-shrink-0" strokeWidth={2} />
@ -155,7 +155,7 @@ export const ListProperties: FC<IListProperties> = observer((props) => {
)} )}
{/* link */} {/* link */}
{displayProperties && displayProperties?.link && ( {displayProperties && displayProperties?.link && !!issue?.link_count && (
<Tooltip tooltipHeading="Links" tooltipContent={`${issue.link_count}`}> <Tooltip tooltipHeading="Links" tooltipContent={`${issue.link_count}`}>
<div className="flex-shrink-0 border-[0.5px] border-custom-border-300 overflow-hidden rounded flex justify-center items-center gap-2 px-2.5 py-1 h-5"> <div className="flex-shrink-0 border-[0.5px] border-custom-border-300 overflow-hidden rounded flex justify-center items-center gap-2 px-2.5 py-1 h-5">
<Link className="h-3 w-3 flex-shrink-0" strokeWidth={2} /> <Link className="h-3 w-3 flex-shrink-0" strokeWidth={2} />

View File

@ -60,8 +60,8 @@ export const PeekOverviewIssueDetails: FC<IPeekOverviewIssueDetails> = (props) =
formState: { errors }, formState: { errors },
} = useForm<IIssue>({ } = useForm<IIssue>({
defaultValues: { defaultValues: {
name: "", name: issue.name,
description_html: "", description_html: issue.description_html,
}, },
}); });
@ -78,7 +78,7 @@ export const PeekOverviewIssueDetails: FC<IPeekOverviewIssueDetails> = (props) =
[issue, issueUpdate] [issue, issueUpdate]
); );
const [localTitleValue, setLocalTitleValue] = useState(""); const [localTitleValue, setLocalTitleValue] = useState(issue.name);
const issueTitleCurrentValue = watch("name"); const issueTitleCurrentValue = watch("name");
useEffect(() => { useEffect(() => {
if (localTitleValue === "" && issueTitleCurrentValue !== "") { if (localTitleValue === "" && issueTitleCurrentValue !== "") {
@ -86,6 +86,10 @@ export const PeekOverviewIssueDetails: FC<IPeekOverviewIssueDetails> = (props) =
} }
}, [issueTitleCurrentValue, localTitleValue]); }, [issueTitleCurrentValue, localTitleValue]);
useEffect(() => {
setLocalTitleValue(issue.name);
}, [issue.name]);
const debouncedFormSave = debounce(async () => { const debouncedFormSave = debounce(async () => {
handleSubmit(handleDescriptionFormSubmit)().finally(() => setIsSubmitting("submitted")); handleSubmit(handleDescriptionFormSubmit)().finally(() => setIsSubmitting("submitted"));
}, 1500); }, 1500);

View File

@ -47,12 +47,13 @@ export const PeekOverviewProperties: FC<IPeekOverviewProperties> = observer((pro
const { const {
user: { currentProjectRole }, user: { currentProjectRole },
cycleIssues: { addIssueToCycle }, cycleIssues: cycleIssueStore,
moduleIssues: { addIssueToModule }, moduleIssues: { addIssueToModule },
issueDetail: { fetchPeekIssueDetails },
} = useMobxStore(); } = useMobxStore();
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId } = router.query; const { workspaceSlug, projectId } = router.query as { workspaceSlug: string; projectId: string };
const { setToastAlert } = useToast(); const { setToastAlert } = useToast();
@ -77,17 +78,6 @@ export const PeekOverviewProperties: FC<IPeekOverviewProperties> = observer((pro
const handleParent = (_parent: string) => { const handleParent = (_parent: string) => {
issueUpdate({ ...issue, parent: _parent }); issueUpdate({ ...issue, parent: _parent });
}; };
const handleAddIssueToCycle = async (cycleId: string) => {
if (!workspaceSlug || !issue || !cycleId) return;
addIssueToCycle(workspaceSlug.toString(), cycleId, [issue.id]);
};
const handleAddIssueToModule = async (moduleId: string) => {
if (!workspaceSlug || !issue || !moduleId) return;
addIssueToModule(workspaceSlug.toString(), moduleId, [issue.id]);
};
const handleLabels = (formData: Partial<IIssue>) => { const handleLabels = (formData: Partial<IIssue>) => {
issueUpdate({ ...issue, ...formData }); issueUpdate({ ...issue, ...formData });
}; };
@ -147,6 +137,12 @@ export const PeekOverviewProperties: FC<IPeekOverviewProperties> = observer((pro
}); });
}; };
const handleCycleOrModuleChange = async () => {
if (!workspaceSlug || !projectId) return;
await fetchPeekIssueDetails(workspaceSlug, projectId, issue.id);
};
const handleEditLink = (link: ILinkDetails) => { const handleEditLink = (link: ILinkDetails) => {
setSelectedLinkToUpdate(link); setSelectedLinkToUpdate(link);
setLinkModal(true); setLinkModal(true);
@ -309,8 +305,8 @@ export const PeekOverviewProperties: FC<IPeekOverviewProperties> = observer((pro
<div> <div>
<SidebarCycleSelect <SidebarCycleSelect
issueDetail={issue} issueDetail={issue}
handleCycleChange={handleAddIssueToCycle}
disabled={disableUserActions} disabled={disableUserActions}
handleIssueUpdate={handleCycleOrModuleChange}
/> />
</div> </div>
</div> </div>
@ -323,8 +319,8 @@ export const PeekOverviewProperties: FC<IPeekOverviewProperties> = observer((pro
<div> <div>
<SidebarModuleSelect <SidebarModuleSelect
issueDetail={issue} issueDetail={issue}
handleModuleChange={handleAddIssueToModule}
disabled={disableUserActions} disabled={disableUserActions}
handleIssueUpdate={handleCycleOrModuleChange}
/> />
</div> </div>
</div> </div>

View File

@ -240,7 +240,7 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = observer((prop
if (handleSubmit) { if (handleSubmit) {
await handleSubmit(res); await handleSubmit(res);
} else { } else {
if (viewId) currentIssueStore.fetchIssues(workspaceSlug, dataIdToUpdate, "mutation", viewId); currentIssueStore.fetchIssues(workspaceSlug, dataIdToUpdate, "mutation", viewId);
if (payload.cycle && payload.cycle !== "") await addIssueToCycle(res, payload.cycle); if (payload.cycle && payload.cycle !== "") await addIssueToCycle(res, payload.cycle);
if (payload.module && payload.module !== "") await addIssueToModule(res, payload.module); if (payload.module && payload.module !== "") await addIssueToModule(res, payload.module);

View File

@ -1,4 +1,4 @@
import React from "react"; import React, { useState } from "react";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import useSWR, { mutate } from "swr"; import useSWR, { mutate } from "swr";
// mobx store // mobx store
@ -6,7 +6,7 @@ import { useMobxStore } from "lib/mobx/store-provider";
// services // services
import { CycleService } from "services/cycle.service"; import { CycleService } from "services/cycle.service";
// ui // ui
import { ContrastIcon, CustomSearchSelect, Tooltip } from "@plane/ui"; import { ContrastIcon, CustomSearchSelect, Spinner, Tooltip } from "@plane/ui";
// types // types
import { IIssue } from "types"; import { IIssue } from "types";
// fetch-keys // fetch-keys
@ -14,23 +14,26 @@ import { CYCLE_ISSUES, INCOMPLETE_CYCLES_LIST, ISSUE_DETAILS } from "constants/f
type Props = { type Props = {
issueDetail: IIssue | undefined; issueDetail: IIssue | undefined;
handleCycleChange: (cycleId: string) => void; handleCycleChange?: (cycleId: string) => void;
disabled?: boolean; disabled?: boolean;
handleIssueUpdate?: () => void;
}; };
// services // services
const cycleService = new CycleService(); const cycleService = new CycleService();
export const SidebarCycleSelect: React.FC<Props> = (props) => { export const SidebarCycleSelect: React.FC<Props> = (props) => {
const { issueDetail, handleCycleChange, disabled = false } = props; const { issueDetail, disabled = false, handleIssueUpdate, handleCycleChange } = props;
// router // router
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId } = router.query; const { workspaceSlug, projectId } = router.query;
// mobx store // mobx store
const { const {
cycleIssues: { removeIssueFromCycle }, cycleIssues: { removeIssueFromCycle, addIssueToCycle },
} = useMobxStore(); } = useMobxStore();
const [isUpdating, setIsUpdating] = useState(false);
const { data: incompleteCycles } = useSWR( const { data: incompleteCycles } = useSWR(
workspaceSlug && projectId ? INCOMPLETE_CYCLES_LIST(projectId as string) : null, workspaceSlug && projectId ? INCOMPLETE_CYCLES_LIST(projectId as string) : null,
workspaceSlug && projectId workspaceSlug && projectId
@ -38,17 +41,35 @@ export const SidebarCycleSelect: React.FC<Props> = (props) => {
: null : null
); );
const handleCycleStoreChange = async (cycleId: string) => {
if (!workspaceSlug || !issueDetail || !cycleId) return;
setIsUpdating(true);
await addIssueToCycle(workspaceSlug.toString(), cycleId, [issueDetail.id], false, projectId?.toString())
.then(async () => {
handleIssueUpdate && (await handleIssueUpdate());
})
.finally(() => {
setIsUpdating(false);
});
};
const handleRemoveIssueFromCycle = (bridgeId: string, cycleId: string) => { const handleRemoveIssueFromCycle = (bridgeId: string, cycleId: string) => {
if (!workspaceSlug || !projectId || !issueDetail) return; if (!workspaceSlug || !projectId || !issueDetail) return;
setIsUpdating(true);
removeIssueFromCycle(workspaceSlug.toString(), projectId.toString(), cycleId, issueDetail.id, bridgeId) removeIssueFromCycle(workspaceSlug.toString(), projectId.toString(), cycleId, issueDetail.id, bridgeId)
.then(() => { .then(async () => {
handleIssueUpdate && (await handleIssueUpdate());
mutate(ISSUE_DETAILS(issueDetail.id)); mutate(ISSUE_DETAILS(issueDetail.id));
mutate(CYCLE_ISSUES(cycleId)); mutate(CYCLE_ISSUES(cycleId));
}) })
.catch((e) => { .catch((e) => {
console.log(e); console.log(e);
})
.finally(() => {
setIsUpdating(false);
}); });
}; };
@ -67,13 +88,18 @@ export const SidebarCycleSelect: React.FC<Props> = (props) => {
const issueCycle = issueDetail?.issue_cycle; const issueCycle = issueDetail?.issue_cycle;
const disableSelect = disabled || isUpdating;
return ( return (
<div className="flex items-center gap-1">
<CustomSearchSelect <CustomSearchSelect
value={issueCycle?.cycle_detail.id} value={issueCycle?.cycle_detail.id}
onChange={(value: any) => { onChange={(value: any) => {
value === issueCycle?.cycle_detail.id value === issueCycle?.cycle_detail.id
? handleRemoveIssueFromCycle(issueCycle?.id ?? "", issueCycle?.cycle ?? "") ? handleRemoveIssueFromCycle(issueCycle?.id ?? "", issueCycle?.cycle ?? "")
: handleCycleChange(value); : handleCycleChange
? handleCycleChange(value)
: handleCycleStoreChange(value);
}} }}
options={options} options={options}
customButton={ customButton={
@ -82,7 +108,7 @@ export const SidebarCycleSelect: React.FC<Props> = (props) => {
<button <button
type="button" type="button"
className={`bg-custom-background-80 text-xs rounded px-2.5 py-0.5 w-full flex items-center ${ className={`bg-custom-background-80 text-xs rounded px-2.5 py-0.5 w-full flex items-center ${
disabled ? "cursor-not-allowed" : "" disableSelect ? "cursor-not-allowed" : ""
} max-w-[10rem]`} } max-w-[10rem]`}
> >
<span <span
@ -99,7 +125,9 @@ export const SidebarCycleSelect: React.FC<Props> = (props) => {
} }
width="max-w-[10rem]" width="max-w-[10rem]"
noChevron noChevron
disabled={disabled} disabled={disableSelect}
/> />
{isUpdating && <Spinner className="w-4 h-4" />}
</div>
); );
}; };

View File

@ -1,11 +1,11 @@
import React from "react"; import React, { useState } from "react";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
import { mutate } from "swr"; import { mutate } from "swr";
// mobx store // mobx store
import { useMobxStore } from "lib/mobx/store-provider"; import { useMobxStore } from "lib/mobx/store-provider";
// ui // ui
import { CustomSearchSelect, DiceIcon, Tooltip } from "@plane/ui"; import { CustomSearchSelect, DiceIcon, Spinner, Tooltip } from "@plane/ui";
// types // types
import { IIssue } from "types"; import { IIssue } from "types";
// fetch-keys // fetch-keys
@ -13,32 +13,53 @@ import { ISSUE_DETAILS, MODULE_ISSUES } from "constants/fetch-keys";
type Props = { type Props = {
issueDetail: IIssue | undefined; issueDetail: IIssue | undefined;
handleModuleChange: (moduleId: string) => void; handleModuleChange?: (moduleId: string) => void;
disabled?: boolean; disabled?: boolean;
handleIssueUpdate?: () => void;
}; };
export const SidebarModuleSelect: React.FC<Props> = observer((props) => { export const SidebarModuleSelect: React.FC<Props> = observer((props) => {
const { issueDetail, handleModuleChange, disabled = false } = props; const { issueDetail, disabled = false, handleIssueUpdate, handleModuleChange } = props;
// router // router
const router = useRouter(); const router = useRouter();
const { workspaceSlug, projectId } = router.query; const { workspaceSlug, projectId } = router.query;
// mobx store // mobx store
const { const {
module: { projectModules }, module: { projectModules },
moduleIssues: { removeIssueFromModule }, moduleIssues: { removeIssueFromModule, addIssueToModule },
} = useMobxStore(); } = useMobxStore();
const [isUpdating, setIsUpdating] = useState(false);
const handleModuleStoreChange = async (moduleId: string) => {
if (!workspaceSlug || !issueDetail || !moduleId) return;
setIsUpdating(true);
await addIssueToModule(workspaceSlug.toString(), moduleId, [issueDetail.id], false, projectId?.toString())
.then(async () => {
handleIssueUpdate && (await handleIssueUpdate());
})
.finally(() => {
setIsUpdating(false);
});
};
const handleRemoveIssueFromModule = (bridgeId: string, moduleId: string) => { const handleRemoveIssueFromModule = (bridgeId: string, moduleId: string) => {
if (!workspaceSlug || !projectId || !issueDetail) return; if (!workspaceSlug || !projectId || !issueDetail) return;
setIsUpdating(true);
removeIssueFromModule(workspaceSlug.toString(), projectId.toString(), moduleId, issueDetail.id, bridgeId) removeIssueFromModule(workspaceSlug.toString(), projectId.toString(), moduleId, issueDetail.id, bridgeId)
.then(() => { .then(async () => {
handleIssueUpdate && (await handleIssueUpdate());
mutate(ISSUE_DETAILS(issueDetail.id)); mutate(ISSUE_DETAILS(issueDetail.id));
mutate(MODULE_ISSUES(moduleId)); mutate(MODULE_ISSUES(moduleId));
}) })
.catch((e) => { .catch((e) => {
console.log(e); console.log(e);
})
.finally(() => {
setIsUpdating(false);
}); });
}; };
@ -57,13 +78,18 @@ export const SidebarModuleSelect: React.FC<Props> = observer((props) => {
const issueModule = issueDetail?.issue_module; const issueModule = issueDetail?.issue_module;
const disableSelect = disabled || isUpdating;
return ( return (
<div className="flex items-center gap-1">
<CustomSearchSelect <CustomSearchSelect
value={issueModule?.module_detail.id} value={issueModule?.module_detail.id}
onChange={(value: any) => { onChange={(value: any) => {
value === issueModule?.module_detail.id value === issueModule?.module_detail.id
? handleRemoveIssueFromModule(issueModule?.id ?? "", issueModule?.module ?? "") ? handleRemoveIssueFromModule(issueModule?.id ?? "", issueModule?.module ?? "")
: handleModuleChange(value); : handleModuleChange
? handleModuleChange(value)
: handleModuleStoreChange(value);
}} }}
options={options} options={options}
customButton={ customButton={
@ -75,7 +101,7 @@ export const SidebarModuleSelect: React.FC<Props> = observer((props) => {
<button <button
type="button" type="button"
className={`bg-custom-background-80 text-xs rounded px-2.5 py-0.5 w-full flex items-center ${ className={`bg-custom-background-80 text-xs rounded px-2.5 py-0.5 w-full flex items-center ${
disabled ? "cursor-not-allowed" : "" disableSelect ? "cursor-not-allowed" : ""
} max-w-[10rem]`} } max-w-[10rem]`}
> >
<span <span
@ -94,7 +120,9 @@ export const SidebarModuleSelect: React.FC<Props> = observer((props) => {
} }
width="max-w-[10rem]" width="max-w-[10rem]"
noChevron noChevron
disabled={disabled} disabled={disableSelect}
/> />
{isUpdating && <Spinner className="w-4 h-4" />}
</div>
); );
}); });

View File

@ -34,7 +34,7 @@ export const ProfileIssuesPage = observer((props: IProfileIssuesPage) => {
async () => { async () => {
if (workspaceSlug && userId) { if (workspaceSlug && userId) {
await fetchFilters(workspaceSlug); await fetchFilters(workspaceSlug);
await fetchIssues(workspaceSlug, userId, getIssues ? "mutation" : "init-loader", type); await fetchIssues(workspaceSlug, userId, getIssues ? "mutation" : "init-loader", undefined, type);
} }
} }
); );

View File

@ -28,6 +28,7 @@ export interface IProfileIssuesStore {
workspaceSlug: string, workspaceSlug: string,
userId: string, userId: string,
loadType: TLoader, loadType: TLoader,
id?: string | undefined,
type?: "assigned" | "created" | "subscribed" type?: "assigned" | "created" | "subscribed"
) => Promise<IIssueResponse>; ) => Promise<IIssueResponse>;
createIssue: (workspaceSlug: string, userId: string, data: Partial<IIssue>) => Promise<IIssue | undefined>; createIssue: (workspaceSlug: string, userId: string, data: Partial<IIssue>) => Promise<IIssue | undefined>;
@ -150,6 +151,7 @@ export class ProfileIssuesStore extends IssueBaseStore implements IProfileIssues
workspaceSlug: string, workspaceSlug: string,
userId: string, userId: string,
loadType: TLoader = "init-loader", loadType: TLoader = "init-loader",
id?: string | undefined,
type?: "assigned" | "created" | "subscribed" type?: "assigned" | "created" | "subscribed"
) => { ) => {
try { try {

View File

@ -53,7 +53,8 @@ export interface ICycleIssuesStore {
workspaceSlug: string, workspaceSlug: string,
cycleId: string, cycleId: string,
issueIds: string[], issueIds: string[],
fetchAfterAddition?: boolean fetchAfterAddition?: boolean,
projectId?: string
) => Promise<IIssue>; ) => Promise<IIssue>;
removeIssueFromCycle: ( removeIssueFromCycle: (
workspaceSlug: string, workspaceSlug: string,
@ -314,19 +315,27 @@ export class CycleIssuesStore extends IssueBaseStore implements ICycleIssuesStor
} }
}; };
addIssueToCycle = async (workspaceSlug: string, cycleId: string, issueIds: string[], fetchAfterAddition = true) => { addIssueToCycle = async (
if (!this.currentProjectId) return; workspaceSlug: string,
cycleId: string,
issueIds: string[],
fetchAfterAddition = true,
projectId?: string
) => {
if (!this.currentProjectId && !projectId) return;
const projectIdToUpdate: string = this.currentProjectId || projectId || "";
try { try {
const issueToCycle = await this.issueService.addIssueToCycle(workspaceSlug, this.currentProjectId, cycleId, { const issueToCycle = await this.issueService.addIssueToCycle(workspaceSlug, projectIdToUpdate, cycleId, {
issues: issueIds, issues: issueIds,
}); });
if (fetchAfterAddition) this.fetchIssues(workspaceSlug, this.currentProjectId, "mutation", cycleId); if (fetchAfterAddition) this.fetchIssues(workspaceSlug, projectIdToUpdate, "mutation", cycleId);
return issueToCycle; return issueToCycle;
} catch (error) { } catch (error) {
this.fetchIssues(workspaceSlug, this.currentProjectId, "mutation", cycleId); this.fetchIssues(workspaceSlug, projectIdToUpdate, "mutation", cycleId);
throw error; throw error;
} }
}; };

View File

@ -53,7 +53,8 @@ export interface IModuleIssuesStore {
workspaceSlug: string, workspaceSlug: string,
moduleId: string, moduleId: string,
issueIds: string[], issueIds: string[],
fetchAfterAddition?: boolean fetchAfterAddition?: boolean,
projectId?: string
) => Promise<any>; ) => Promise<any>;
removeIssueFromModule: ( removeIssueFromModule: (
workspaceSlug: string, workspaceSlug: string,
@ -306,19 +307,27 @@ export class ModuleIssuesStore extends IssueBaseStore implements IModuleIssuesSt
} }
}; };
addIssueToModule = async (workspaceSlug: string, moduleId: string, issueIds: string[], fetchAfterAddition = true) => { addIssueToModule = async (
if (!this.currentProjectId) return; workspaceSlug: string,
moduleId: string,
issueIds: string[],
fetchAfterAddition = true,
projectId?: string
) => {
if (!this.currentProjectId && !projectId) return;
const projectIdToUpdate: string = this.currentProjectId || projectId || "";
try { try {
const issueToModule = await this.moduleService.addIssuesToModule(workspaceSlug, this.currentProjectId, moduleId, { const issueToModule = await this.moduleService.addIssuesToModule(workspaceSlug, projectIdToUpdate, moduleId, {
issues: issueIds, issues: issueIds,
}); });
if (fetchAfterAddition) this.fetchIssues(workspaceSlug, this.currentProjectId, "mutation", moduleId); if (fetchAfterAddition) this.fetchIssues(workspaceSlug, projectIdToUpdate, "mutation", moduleId);
return issueToModule; return issueToModule;
} catch (error) { } catch (error) {
this.fetchIssues(workspaceSlug, this.currentProjectId, "mutation", moduleId); this.fetchIssues(workspaceSlug, projectIdToUpdate, "mutation", moduleId);
throw error; throw error;
} }
}; };