From 59186071717cfad0bf77c8d5027e99e594111262 Mon Sep 17 00:00:00 2001 From: rahulramesha <71900764+rahulramesha@users.noreply.github.com> Date: Thu, 4 Jul 2024 16:18:33 +0530 Subject: [PATCH] [WEB-1818] fix: issue changes done in Peek overview to reflect in the issue list boards (#5010) * fix issue changes done in Peek overview to reflect in the issue boards * Adding comments to aliased names --- .../issues/issue-detail/module-select.tsx | 5 +- .../components/issues/issue-detail/root.tsx | 66 ++----- .../components/issues/peek-overview/root.tsx | 166 +++++++----------- web/core/store/issue/archived/issue.store.ts | 5 + web/core/store/issue/cycle/issue.store.ts | 7 +- web/core/store/issue/draft/issue.store.ts | 4 + .../store/issue/helpers/base-issues.store.ts | 32 ++-- .../store/issue/issue-details/issue.store.ts | 34 ++-- .../store/issue/issue-details/root.store.ts | 11 +- web/core/store/issue/module/issue.store.ts | 3 + web/core/store/issue/profile/issue.store.ts | 5 + .../store/issue/project-views/issue.store.ts | 3 + web/core/store/issue/project/issue.store.ts | 3 + web/core/store/issue/workspace/issue.store.ts | 5 + 14 files changed, 148 insertions(+), 201 deletions(-) diff --git a/web/core/components/issues/issue-detail/module-select.tsx b/web/core/components/issues/issue-detail/module-select.tsx index 0214a5773..f9f0a51e2 100644 --- a/web/core/components/issues/issue-detail/module-select.tsx +++ b/web/core/components/issues/issue-detail/module-select.tsx @@ -47,11 +47,8 @@ export const IssueModuleSelect: React.FC = observer((props) modulesToAdd.push(moduleId); } } - if (modulesToRemove.length > 0) - await issueOperations.removeModulesFromIssue?.(workspaceSlug, projectId, issueId, modulesToRemove); - if (modulesToAdd.length > 0) - await issueOperations.addModulesToIssue?.(workspaceSlug, projectId, issueId, modulesToAdd); + await issueOperations.changeModulesInIssue?.(workspaceSlug, projectId, issueId, modulesToAdd, modulesToRemove); setIsUpdating(false); }; diff --git a/web/core/components/issues/issue-detail/root.tsx b/web/core/components/issues/issue-detail/root.tsx index 18255ac49..9de3684c7 100644 --- a/web/core/components/issues/issue-detail/root.tsx +++ b/web/core/components/issues/issue-detail/root.tsx @@ -32,18 +32,18 @@ export type TIssueOperations = { addCycleToIssue?: (workspaceSlug: string, projectId: string, cycleId: string, issueId: string) => Promise; addIssueToCycle?: (workspaceSlug: string, projectId: string, cycleId: string, issueIds: string[]) => Promise; removeIssueFromCycle?: (workspaceSlug: string, projectId: string, cycleId: string, issueId: string) => Promise; - addModulesToIssue?: (workspaceSlug: string, projectId: string, issueId: string, moduleIds: string[]) => Promise; removeIssueFromModule?: ( workspaceSlug: string, projectId: string, moduleId: string, issueId: string ) => Promise; - removeModulesFromIssue?: ( + changeModulesInIssue?: ( workspaceSlug: string, projectId: string, issueId: string, - moduleIds: string[] + addModuleIds: string[], + removeModuleIds: string[] ) => Promise; }; @@ -70,9 +70,8 @@ export const IssueDetailRoot: FC = observer((props) => { addCycleToIssue, addIssueToCycle, removeIssueFromCycle, - addModulesToIssue, + changeModulesInIssue, removeIssueFromModule, - removeModulesFromIssue, } = useIssueDetail(); const { issues: { removeIssue: removeArchivedIssue }, @@ -258,35 +257,6 @@ export const IssueDetailRoot: FC = observer((props) => { }); } }, - addModulesToIssue: async (workspaceSlug: string, projectId: string, issueId: string, moduleIds: string[]) => { - try { - const response = await addModulesToIssue(workspaceSlug, projectId, issueId, moduleIds); - captureIssueEvent({ - eventName: ISSUE_UPDATED, - payload: { ...response, state: "SUCCESS", element: "Issue detail page" }, - updates: { - changed_property: "module_id", - change_details: moduleIds, - }, - path: pathname, - }); - } catch (error) { - setToast({ - type: TOAST_TYPE.ERROR, - title: "Error!", - message: "Issue could not be added to the module. Please try again.", - }); - captureIssueEvent({ - eventName: ISSUE_UPDATED, - payload: { id: issueId, state: "FAILED", element: "Issue detail page" }, - updates: { - changed_property: "module_id", - change_details: moduleIds, - }, - path: pathname, - }); - } - }, removeIssueFromModule: async (workspaceSlug: string, projectId: string, moduleId: string, issueId: string) => { try { const removeFromModulePromise = removeIssueFromModule(workspaceSlug, projectId, moduleId, issueId); @@ -323,25 +293,24 @@ export const IssueDetailRoot: FC = observer((props) => { }); } }, - removeModulesFromIssue: async ( + changeModulesInIssue: async ( workspaceSlug: string, projectId: string, issueId: string, - moduleIds: string[] + addModuleIds: string[], + removeModuleIds: string[] ) => { - const removeModulesFromIssuePromise = removeModulesFromIssue(workspaceSlug, projectId, issueId, moduleIds); - setPromiseToast(removeModulesFromIssuePromise, { - loading: "Removing module from issue...", - success: { - title: "Success!", - message: () => "Module removed from issue successfully", - }, - error: { - title: "Error!", - message: () => "Module remove from issue failed", + const promise = await changeModulesInIssue(workspaceSlug, projectId, issueId, addModuleIds, removeModuleIds); + captureIssueEvent({ + eventName: ISSUE_UPDATED, + payload: { id: issueId, state: "SUCCESS", element: "Issue detail page" }, + updates: { + changed_property: "module_id", + change_details: { addModuleIds, removeModuleIds }, }, + path: pathname, }); - await removeModulesFromIssuePromise; + return promise; }, }), [ @@ -353,9 +322,8 @@ export const IssueDetailRoot: FC = observer((props) => { removeArchivedIssue, addIssueToCycle, removeIssueFromCycle, - addModulesToIssue, + changeModulesInIssue, removeIssueFromModule, - removeModulesFromIssue, captureIssueEvent, pathname, ] diff --git a/web/core/components/issues/peek-overview/root.tsx b/web/core/components/issues/peek-overview/root.tsx index 41ee666c4..721124552 100644 --- a/web/core/components/issues/peek-overview/root.tsx +++ b/web/core/components/issues/peek-overview/root.tsx @@ -13,6 +13,7 @@ import { EIssuesStoreType } from "@/constants/issue"; import { EUserProjectRoles } from "@/constants/project"; // hooks import { useEventTracker, useIssueDetail, useIssues, useUser } from "@/hooks/store"; +import { useIssuesStore } from "@/hooks/use-issue-layout-store"; interface IIssuePeekOverview { embedIssue?: boolean; @@ -55,19 +56,10 @@ export const IssuePeekOverview: FC = observer((props) => { } = useIssues(EIssuesStoreType.ARCHIVED); const { peekIssue, - updateIssue, - removeIssue, - archiveIssue, issue: { fetchIssue }, } = useIssueDetail(); - const { - addCycleToIssue, - addIssueToCycle, - removeIssueFromCycle, - addModulesToIssue, - removeIssueFromModule, - removeModulesFromIssue, - } = useIssueDetail(); + + const { issues } = useIssuesStore(); const { captureIssueEvent } = useEventTracker(); // state const [loader, setLoader] = useState(true); @@ -94,34 +86,36 @@ export const IssuePeekOverview: FC = observer((props) => { } }, update: async (workspaceSlug: string, projectId: string, issueId: string, data: Partial) => { - await updateIssue(workspaceSlug, projectId, issueId, data) - .then(() => { - captureIssueEvent({ - eventName: ISSUE_UPDATED, - payload: { ...data, issueId, state: "SUCCESS", element: "Issue peek-overview" }, - updates: { - changed_property: Object.keys(data).join(","), - change_details: Object.values(data).join(","), - }, - path: pathname, - }); - }) - .catch(() => { - captureIssueEvent({ - eventName: ISSUE_UPDATED, - payload: { state: "FAILED", element: "Issue peek-overview" }, - path: pathname, - }); - setToast({ - title: "Error!", - type: TOAST_TYPE.ERROR, - message: "Issue update failed", - }); - }); + issues?.updateIssue && + (await issues + .updateIssue(workspaceSlug, projectId, issueId, data) + .then(() => { + captureIssueEvent({ + eventName: ISSUE_UPDATED, + payload: { ...data, issueId, state: "SUCCESS", element: "Issue peek-overview" }, + updates: { + changed_property: Object.keys(data).join(","), + change_details: Object.values(data).join(","), + }, + path: pathname, + }); + }) + .catch(() => { + captureIssueEvent({ + eventName: ISSUE_UPDATED, + payload: { state: "FAILED", element: "Issue peek-overview" }, + path: pathname, + }); + setToast({ + title: "Error!", + type: TOAST_TYPE.ERROR, + message: "Issue update failed", + }); + })); }, remove: async (workspaceSlug: string, projectId: string, issueId: string) => { try { - removeIssue(workspaceSlug, projectId, issueId); + issues?.removeIssue(workspaceSlug, projectId, issueId); setToast({ title: "Success!", type: TOAST_TYPE.SUCCESS, @@ -147,7 +141,7 @@ export const IssuePeekOverview: FC = observer((props) => { }, archive: async (workspaceSlug: string, projectId: string, issueId: string) => { try { - await archiveIssue(workspaceSlug, projectId, issueId); + issues?.archiveIssue && (await issues.archiveIssue(workspaceSlug, projectId, issueId)); captureIssueEvent({ eventName: ISSUE_ARCHIVED, payload: { id: issueId, state: "SUCCESS", element: "Issue peek-overview" }, @@ -189,8 +183,7 @@ export const IssuePeekOverview: FC = observer((props) => { }, addCycleToIssue: async (workspaceSlug: string, projectId: string, cycleId: string, issueId: string) => { try { - console.log("Peek adding..."); - await addCycleToIssue(workspaceSlug, projectId, cycleId, issueId); + await issues.addCycleToIssue(workspaceSlug, projectId, cycleId, issueId); captureIssueEvent({ eventName: ISSUE_UPDATED, payload: { issueId, state: "SUCCESS", element: "Issue peek-overview" }, @@ -219,7 +212,7 @@ export const IssuePeekOverview: FC = observer((props) => { }, addIssueToCycle: async (workspaceSlug: string, projectId: string, cycleId: string, issueIds: string[]) => { try { - await addIssueToCycle(workspaceSlug, projectId, cycleId, issueIds); + await issues.addIssueToCycle(workspaceSlug, projectId, cycleId, issueIds); captureIssueEvent({ eventName: ISSUE_UPDATED, payload: { ...issueIds, state: "SUCCESS", element: "Issue peek-overview" }, @@ -248,7 +241,7 @@ export const IssuePeekOverview: FC = observer((props) => { }, removeIssueFromCycle: async (workspaceSlug: string, projectId: string, cycleId: string, issueId: string) => { try { - const removeFromCyclePromise = removeIssueFromCycle(workspaceSlug, projectId, cycleId, issueId); + const removeFromCyclePromise = issues.removeIssueFromCycle(workspaceSlug, projectId, cycleId, issueId); setPromiseToast(removeFromCyclePromise, { loading: "Removing issue from the cycle...", success: { @@ -282,38 +275,34 @@ export const IssuePeekOverview: FC = observer((props) => { }); } }, - addModulesToIssue: async (workspaceSlug: string, projectId: string, issueId: string, moduleIds: string[]) => { - try { - const response = await addModulesToIssue(workspaceSlug, projectId, issueId, moduleIds); - captureIssueEvent({ - eventName: ISSUE_UPDATED, - payload: { ...response, state: "SUCCESS", element: "Issue peek-overview" }, - updates: { - changed_property: "module_id", - change_details: moduleIds, - }, - path: pathname, - }); - } catch (error) { - setToast({ - type: TOAST_TYPE.ERROR, - title: "Error!", - message: "Issue could not be added to the module. Please try again.", - }); - captureIssueEvent({ - eventName: ISSUE_UPDATED, - payload: { id: issueId, state: "FAILED", element: "Issue peek-overview" }, - updates: { - changed_property: "module_id", - change_details: moduleIds, - }, - path: pathname, - }); - } + changeModulesInIssue: async ( + workspaceSlug: string, + projectId: string, + issueId: string, + addModuleIds: string[], + removeModuleIds: string[] + ) => { + const promise = await issues.changeModulesInIssue( + workspaceSlug, + projectId, + issueId, + addModuleIds, + removeModuleIds + ); + captureIssueEvent({ + eventName: ISSUE_UPDATED, + payload: { id: issueId, state: "SUCCESS", element: "Issue detail page" }, + updates: { + changed_property: "module_id", + change_details: { addModuleIds, removeModuleIds }, + }, + path: pathname, + }); + return promise; }, removeIssueFromModule: async (workspaceSlug: string, projectId: string, moduleId: string, issueId: string) => { try { - const removeFromModulePromise = removeIssueFromModule(workspaceSlug, projectId, moduleId, issueId); + const removeFromModulePromise = issues.removeIssuesFromModule(workspaceSlug, projectId, moduleId, [issueId]); setPromiseToast(removeFromModulePromise, { loading: "Removing issue from the module...", success: { @@ -347,43 +336,8 @@ export const IssuePeekOverview: FC = observer((props) => { }); } }, - removeModulesFromIssue: async ( - workspaceSlug: string, - projectId: string, - issueId: string, - moduleIds: string[] - ) => { - const removeModulesFromIssuePromise = removeModulesFromIssue(workspaceSlug, projectId, issueId, moduleIds); - setPromiseToast(removeModulesFromIssuePromise, { - loading: "Removing module from issue...", - success: { - title: "Success!", - message: () => "Module removed from issue successfully", - }, - error: { - title: "Error!", - message: () => "Module remove from issue failed", - }, - }); - await removeModulesFromIssuePromise; - }, }), - [ - is_archived, - is_draft, - fetchIssue, - updateIssue, - removeIssue, - archiveIssue, - restoreIssue, - addIssueToCycle, - removeIssueFromCycle, - addModulesToIssue, - removeIssueFromModule, - removeModulesFromIssue, - captureIssueEvent, - pathname, - ] + [is_archived, is_draft, fetchIssue, issues, restoreIssue, captureIssueEvent, pathname] ); useEffect(() => { diff --git a/web/core/store/issue/archived/issue.store.ts b/web/core/store/issue/archived/issue.store.ts index 1d3b691fb..293ce7a3a 100644 --- a/web/core/store/issue/archived/issue.store.ts +++ b/web/core/store/issue/archived/issue.store.ts @@ -33,6 +33,8 @@ export interface IArchivedIssues extends IBaseIssuesStore { removeBulkIssues: (workspaceSlug: string, projectId: string, issueIds: string[]) => Promise; bulkUpdateProperties: (workspaceSlug: string, projectId: string, data: TBulkOperationsPayload) => Promise; + updateIssue: undefined; + archiveIssue: undefined; archiveBulkIssues: undefined; quickAddIssue: undefined; } @@ -192,6 +194,9 @@ export class ArchivedIssues extends BaseIssuesStore implements IArchivedIssues { } }; + // Setting them as undefined as they can not performed on Archived issues + updateIssue = undefined; + archiveIssue = undefined; archiveBulkIssues = undefined; quickAddIssue = undefined; } diff --git a/web/core/store/issue/cycle/issue.store.ts b/web/core/store/issue/cycle/issue.store.ts index a71337ea6..14460b44e 100644 --- a/web/core/store/issue/cycle/issue.store.ts +++ b/web/core/store/issue/cycle/issue.store.ts @@ -370,7 +370,9 @@ export class CycleIssues extends BaseIssuesStore implements ICycleIssues { set(this.activeCycleIds, [cycleId, "nextCursor"], response.next_cursor); set(this.activeCycleIds, [cycleId, "nextPageResults"], response.next_page_results); set(this.activeCycleIds, [cycleId, "issueCount"], response.total_count); - update(this.activeCycleIds, [cycleId, "issueIds"], (issueIds: string[] = []) => this.issuesSortWithOrderBy(uniq(concat(issueIds, activeIssueIds)), this.orderBy)); + update(this.activeCycleIds, [cycleId, "issueIds"], (issueIds: string[] = []) => + this.issuesSortWithOrderBy(uniq(concat(issueIds, activeIssueIds)), this.orderBy) + ); return response; } catch (error) { @@ -413,5 +415,8 @@ export class CycleIssues extends BaseIssuesStore implements ICycleIssues { } }; + // Using aliased names as they cannot be overridden in other stores archiveBulkIssues = this.bulkArchiveIssues; + updateIssue = this.issueUpdate; + archiveIssue = this.issueArchive; } diff --git a/web/core/store/issue/draft/issue.store.ts b/web/core/store/issue/draft/issue.store.ts index b5a85e786..ca322ac8d 100644 --- a/web/core/store/issue/draft/issue.store.ts +++ b/web/core/store/issue/draft/issue.store.ts @@ -37,6 +37,7 @@ export interface IDraftIssues extends IBaseIssuesStore { archiveBulkIssues: undefined; quickAddIssue: undefined; + archiveIssue: undefined; } export class DraftIssues extends BaseIssuesStore implements IDraftIssues { @@ -164,9 +165,12 @@ export class DraftIssues extends BaseIssuesStore implements IDraftIssues { return await this.fetchIssues(workspaceSlug, projectId, loadType, this.paginationOptions, true); }; + // Using aliased names as they cannot be overridden in other stores createIssue = this.createDraftIssue; updateIssue = this.updateDraftIssue; + // Setting them as undefined as they can not performed on draft issues archiveBulkIssues = undefined; quickAddIssue = undefined; + archiveIssue = undefined; } diff --git a/web/core/store/issue/helpers/base-issues.store.ts b/web/core/store/issue/helpers/base-issues.store.ts index 524cda08d..2c88834d3 100644 --- a/web/core/store/issue/helpers/base-issues.store.ts +++ b/web/core/store/issue/helpers/base-issues.store.ts @@ -63,7 +63,7 @@ export interface IBaseIssuesStore { issuePaginationData: TIssuePaginationData; // map of groupId/subgroup and pagination Data of that particular group/subgroup //actions - removeIssue(workspaceSlug: string, projectId: string, issueId: string): Promise; + removeIssue: (workspaceSlug: string, projectId: string, issueId: string) => Promise; // helper methods getIssueIds: (groupId?: string, subGroupId?: string) => string[] | undefined; issuesSortWithOrderBy(issueIds: string[], key: Partial): string[]; @@ -220,12 +220,12 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore { removeIssueFromList: action.bound, createIssue: action, - updateIssue: action, + issueUpdate: action, createDraftIssue: action, updateDraftIssue: action, issueQuickAdd: action.bound, removeIssue: action.bound, - archiveIssue: action.bound, + issueArchive: action.bound, removeBulkIssues: action.bound, bulkArchiveIssues: action.bound, bulkUpdateProperties: action.bound, @@ -539,7 +539,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore { * @param shouldSync If False then only issue is to be updated in the store not call API to update * @returns */ - async updateIssue( + async issueUpdate( workspaceSlug: string, projectId: string, issueId: string, @@ -656,7 +656,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore { * @param projectId * @param issueId */ - async archiveIssue(workspaceSlug: string, projectId: string, issueId: string) { + async issueArchive(workspaceSlug: string, projectId: string, issueId: string) { try { // Male API call const response = await this.issueArchiveService.archiveIssue(workspaceSlug, projectId, issueId); @@ -759,7 +759,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore { runInAction(() => { issueIds.forEach((issueId) => { - this.updateIssue( + this.issueUpdate( workspaceSlug, projectId, issueId, @@ -855,7 +855,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore { // For Each issue update cycle Id by calling current store's update Issue, without making an API call issueIds.forEach((issueId) => { - this.updateIssue(workspaceSlug, projectId, issueId, { cycle_id: cycleId }, false); + this.issueUpdate(workspaceSlug, projectId, issueId, { cycle_id: cycleId }, false); }); } catch (error) { throw error; @@ -883,7 +883,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore { }); // update Issue cycle Id to null by calling current store's update Issue, without making an API call - this.updateIssue(workspaceSlug, projectId, issueId, { cycle_id: null }, false); + this.issueUpdate(workspaceSlug, projectId, issueId, { cycle_id: null }, false); } catch (error) { throw error; } @@ -897,7 +897,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore { // If cycle Id is the current cycle Id, then, add issue to list of issueIds if (this.cycleId === cycleId) this.addIssueToList(issueId); // For Each issue update cycle Id by calling current store's update Issue, without making an API call - this.updateIssue(workspaceSlug, projectId, issueId, { cycle_id: cycleId }, false); + this.issueUpdate(workspaceSlug, projectId, issueId, { cycle_id: cycleId }, false); }); await this.issueService.addIssueToCycle(workspaceSlug, projectId, cycleId, { @@ -912,7 +912,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore { // If cycle Id is the current cycle Id, then, remove issue to list of issueIds if (this.cycleId === cycleId) this.removeIssueFromList(issueId); // For Each issue update cycle Id to previous value by calling current store's update Issue, without making an API call - this.updateIssue(workspaceSlug, projectId, issueId, { cycle_id: issueCycleId }, false); + this.issueUpdate(workspaceSlug, projectId, issueId, { cycle_id: issueCycleId }, false); }); throw error; @@ -936,7 +936,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore { // If cycle Id is the current cycle Id, then, add issue to list of issueIds if (this.cycleId === issueCycleId) this.removeIssueFromList(issueId); // For Each issue update cycle Id by calling current store's update Issue, without making an API call - this.updateIssue(workspaceSlug, projectId, issueId, { cycle_id: null }, false); + this.issueUpdate(workspaceSlug, projectId, issueId, { cycle_id: null }, false); }); // make API call @@ -950,7 +950,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore { // If cycle Id is the current cycle Id, then, add issue to list of issueIds if (this.cycleId === issueCycleId) this.addIssueToList(issueId); // For Each issue update cycle Id by calling current store's update Issue, without making an API call - this.updateIssue(workspaceSlug, projectId, issueId, { cycle_id: issueCycleId }, false); + this.issueUpdate(workspaceSlug, projectId, issueId, { cycle_id: issueCycleId }, false); }); throw error; @@ -993,7 +993,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore { issueIds.forEach((issueId) => { const issueModuleIds = get(this.rootIssueStore.issues.issuesMap, [issueId, "module_ids"]) ?? []; const updatedIssueModuleIds = uniq(concat(issueModuleIds, [moduleId])); - this.updateIssue(workspaceSlug, projectId, issueId, { module_ids: updatedIssueModuleIds }, false); + this.issueUpdate(workspaceSlug, projectId, issueId, { module_ids: updatedIssueModuleIds }, false); }); } catch (error) { throw error; @@ -1031,7 +1031,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore { issueIds.forEach((issueId) => { const issueModuleIds = get(this.rootIssueStore.issues.issuesMap, [issueId, "module_ids"]) ?? []; const updatedIssueModuleIds = pull(issueModuleIds, moduleId); - this.updateIssue(workspaceSlug, projectId, issueId, { module_ids: updatedIssueModuleIds }, false); + this.issueUpdate(workspaceSlug, projectId, issueId, { module_ids: updatedIssueModuleIds }, false); }); }); @@ -1111,7 +1111,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore { currentModuleIds = uniq(concat([...currentModuleIds], addModuleIds)); // For current Issue, update module Ids by calling current store's update Issue, without making an API call - this.updateIssue(workspaceSlug, projectId, issueId, { module_ids: currentModuleIds }, false); + this.issueUpdate(workspaceSlug, projectId, issueId, { module_ids: currentModuleIds }, false); }); //Perform API call @@ -1132,7 +1132,7 @@ export abstract class BaseIssuesStore implements IBaseIssuesStore { if (removeModuleIds.includes(this.moduleId ?? "")) this.addIssueToList(issueId); // For current Issue, update module Ids by calling current store's update Issue, without making an API call - this.updateIssue(workspaceSlug, projectId, issueId, { module_ids: originalModuleIds }, false); + this.issueUpdate(workspaceSlug, projectId, issueId, { module_ids: originalModuleIds }, false); }); throw error; diff --git a/web/core/store/issue/issue-details/issue.store.ts b/web/core/store/issue/issue-details/issue.store.ts index 485eb21be..c464c2589 100644 --- a/web/core/store/issue/issue-details/issue.store.ts +++ b/web/core/store/issue/issue-details/issue.store.ts @@ -21,12 +21,12 @@ export interface IIssueStoreActions { addCycleToIssue: (workspaceSlug: string, projectId: string, cycleId: string, issueId: string) => Promise; addIssueToCycle: (workspaceSlug: string, projectId: string, cycleId: string, issueIds: string[]) => Promise; removeIssueFromCycle: (workspaceSlug: string, projectId: string, cycleId: string, issueId: string) => Promise; - addModulesToIssue: (workspaceSlug: string, projectId: string, issueId: string, moduleIds: string[]) => Promise; - removeModulesFromIssue: ( + changeModulesInIssue: ( workspaceSlug: string, projectId: string, issueId: string, - moduleIds: string[] + addModuleIds: string[], + removeModuleIds: string[] ) => Promise; removeIssueFromModule: (workspaceSlug: string, projectId: string, moduleId: string, issueId: string) => Promise; } @@ -193,29 +193,21 @@ export class IssueStore implements IIssueStore { return cycle; }; - addModulesToIssue = async (workspaceSlug: string, projectId: string, issueId: string, moduleIds: string[]) => { - const currentModule = await this.rootIssueDetailStore.rootIssueStore.moduleIssues.changeModulesInIssue( + changeModulesInIssue = async ( + workspaceSlug: string, + projectId: string, + issueId: string, + addModuleIds: string[], + removeModuleIds: string[] + ) => { + await this.rootIssueDetailStore.rootIssueStore.moduleIssues.changeModulesInIssue( workspaceSlug, projectId, issueId, - moduleIds, - [] - ); - if (moduleIds && moduleIds.length > 0) - await this.rootIssueDetailStore.activity.fetchActivities(workspaceSlug, projectId, issueId); - return currentModule; - }; - - removeModulesFromIssue = async (workspaceSlug: string, projectId: string, issueId: string, moduleIds: string[]) => { - const currentModule = await this.rootIssueDetailStore.rootIssueStore.moduleIssues.changeModulesInIssue( - workspaceSlug, - projectId, - issueId, - [], - moduleIds + addModuleIds, + removeModuleIds ); await this.rootIssueDetailStore.activity.fetchActivities(workspaceSlug, projectId, issueId); - return currentModule; }; removeIssueFromModule = async (workspaceSlug: string, projectId: string, moduleId: string, issueId: string) => { diff --git a/web/core/store/issue/issue-details/root.store.ts b/web/core/store/issue/issue-details/root.store.ts index f488422f1..835c5ef5e 100644 --- a/web/core/store/issue/issue-details/root.store.ts +++ b/web/core/store/issue/issue-details/root.store.ts @@ -198,10 +198,13 @@ export class IssueDetail implements IIssueDetail { this.issue.addIssueToCycle(workspaceSlug, projectId, cycleId, issueIds); removeIssueFromCycle = async (workspaceSlug: string, projectId: string, cycleId: string, issueId: string) => this.issue.removeIssueFromCycle(workspaceSlug, projectId, cycleId, issueId); - addModulesToIssue = async (workspaceSlug: string, projectId: string, issueId: string, moduleIds: string[]) => - this.issue.addModulesToIssue(workspaceSlug, projectId, issueId, moduleIds); - removeModulesFromIssue = async (workspaceSlug: string, projectId: string, issueId: string, moduleIds: string[]) => - this.issue.removeModulesFromIssue(workspaceSlug, projectId, issueId, moduleIds); + changeModulesInIssue = async ( + workspaceSlug: string, + projectId: string, + issueId: string, + addModuleIds: string[], + removeModuleIds: string[] + ) => this.issue.changeModulesInIssue(workspaceSlug, projectId, issueId, addModuleIds, removeModuleIds); removeIssueFromModule = async (workspaceSlug: string, projectId: string, moduleId: string, issueId: string) => this.issue.removeIssueFromModule(workspaceSlug, projectId, moduleId, issueId); diff --git a/web/core/store/issue/module/issue.store.ts b/web/core/store/issue/module/issue.store.ts index 8b592f8ab..ee78b3d7c 100644 --- a/web/core/store/issue/module/issue.store.ts +++ b/web/core/store/issue/module/issue.store.ts @@ -251,5 +251,8 @@ export class ModuleIssues extends BaseIssuesStore implements IModuleIssues { } }; + // Using aliased names as they cannot be overridden in other stores archiveBulkIssues = this.bulkArchiveIssues; + updateIssue = this.issueUpdate; + archiveIssue = this.issueArchive; } diff --git a/web/core/store/issue/profile/issue.store.ts b/web/core/store/issue/profile/issue.store.ts index a41d33088..9637cb623 100644 --- a/web/core/store/issue/profile/issue.store.ts +++ b/web/core/store/issue/profile/issue.store.ts @@ -208,6 +208,11 @@ export class ProfileIssues extends BaseIssuesStore implements IProfileIssues { return await this.fetchIssues(workspaceSlug, userId, loadType, this.paginationOptions, this.currentView, true); }; + // Using aliased names as they cannot be overridden in other stores archiveBulkIssues = this.bulkArchiveIssues; + updateIssue = this.issueUpdate; + archiveIssue = this.issueArchive; + + // Setting them as undefined as they can not performed on profile issues quickAddIssue = undefined; } diff --git a/web/core/store/issue/project-views/issue.store.ts b/web/core/store/issue/project-views/issue.store.ts index 2088d30c1..07824dcd2 100644 --- a/web/core/store/issue/project-views/issue.store.ts +++ b/web/core/store/issue/project-views/issue.store.ts @@ -173,6 +173,9 @@ export class ProjectViewIssues extends BaseIssuesStore implements IProjectViewIs return await this.fetchIssues(workspaceSlug, projectId, viewId, loadType, this.paginationOptions, true); }; + // Using aliased names as they cannot be overridden in other stores archiveBulkIssues = this.bulkArchiveIssues; quickAddIssue = this.issueQuickAdd; + updateIssue = this.issueUpdate; + archiveIssue = this.issueArchive; } diff --git a/web/core/store/issue/project/issue.store.ts b/web/core/store/issue/project/issue.store.ts index 413081716..e1b013e4a 100644 --- a/web/core/store/issue/project/issue.store.ts +++ b/web/core/store/issue/project/issue.store.ts @@ -165,6 +165,9 @@ export class ProjectIssues extends BaseIssuesStore implements IProjectIssues { return await this.fetchIssues(workspaceSlug, projectId, loadType, this.paginationOptions, true); }; + // Using aliased names as they cannot be overridden in other stores archiveBulkIssues = this.bulkArchiveIssues; quickAddIssue = this.issueQuickAdd; + updateIssue = this.issueUpdate; + archiveIssue = this.issueArchive; } diff --git a/web/core/store/issue/workspace/issue.store.ts b/web/core/store/issue/workspace/issue.store.ts index 6960135f1..daeacb650 100644 --- a/web/core/store/issue/workspace/issue.store.ts +++ b/web/core/store/issue/workspace/issue.store.ts @@ -167,6 +167,11 @@ export class WorkspaceIssues extends BaseIssuesStore implements IWorkspaceIssues return await this.fetchIssues(workspaceSlug, viewId, loadType, this.paginationOptions, true); }; + // Using aliased names as they cannot be overridden in other stores archiveBulkIssues = this.bulkArchiveIssues; + updateIssue = this.issueUpdate; + archiveIssue = this.issueArchive; + + // Setting them as undefined as they can not performed on workspace issues quickAddIssue = undefined; }