From 957e981168d2fa5c5ed17cf659da981373f33759 Mon Sep 17 00:00:00 2001 From: rahulramesha Date: Mon, 29 Jul 2024 18:41:46 +0530 Subject: [PATCH 1/3] use common getIssues from issue service instead of multiple different services for modules and cycles --- web/core/store/issue/cycle/filter.store.ts | 7 ++++++- web/core/store/issue/cycle/issue.store.ts | 4 ++-- web/core/store/issue/module/filter.store.ts | 7 ++++++- web/core/store/issue/module/issue.store.ts | 4 ++-- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/web/core/store/issue/cycle/filter.store.ts b/web/core/store/issue/cycle/filter.store.ts index 490393a43a6..2b35ee74632 100644 --- a/web/core/store/issue/cycle/filter.store.ts +++ b/web/core/store/issue/cycle/filter.store.ts @@ -119,7 +119,12 @@ export class CycleIssuesFilter extends IssueFilterHelperStore implements ICycleI groupId: string | undefined, subGroupId: string | undefined ) => { - const filterParams = this.getAppliedFilters(cycleId); + let filterParams = this.getAppliedFilters(cycleId); + + if (!filterParams) { + filterParams = {}; + } + filterParams["cycle"] = cycleId; const paginationParams = this.getPaginationParams(filterParams, options, cursor, groupId, subGroupId); return paginationParams; diff --git a/web/core/store/issue/cycle/issue.store.ts b/web/core/store/issue/cycle/issue.store.ts index 41dacd8a0f5..250e786ae45 100644 --- a/web/core/store/issue/cycle/issue.store.ts +++ b/web/core/store/issue/cycle/issue.store.ts @@ -164,7 +164,7 @@ export class CycleIssues extends BaseIssuesStore implements ICycleIssues { // get params from pagination options const params = this.issueFilterStore?.getFilterParams(options, cycleId, undefined, undefined, undefined); // call the fetch issues API with the params - const response = await this.cycleService.getCycleIssues(workspaceSlug, projectId, cycleId, params, { + const response = await this.issueService.getIssues(workspaceSlug, projectId, params, { signal: this.controller.signal, }); @@ -212,7 +212,7 @@ export class CycleIssues extends BaseIssuesStore implements ICycleIssues { subGroupId ); // call the fetch issues API with the params for next page in issues - const response = await this.cycleService.getCycleIssues(workspaceSlug, projectId, cycleId, params); + const response = await this.issueService.getIssues(workspaceSlug, projectId, cycleId, params); // after the next page of issues are fetched, call the base method to process the response this.onfetchNexIssues(response, groupId, subGroupId); diff --git a/web/core/store/issue/module/filter.store.ts b/web/core/store/issue/module/filter.store.ts index 1e02ba13adf..d64a4c0f015 100644 --- a/web/core/store/issue/module/filter.store.ts +++ b/web/core/store/issue/module/filter.store.ts @@ -119,7 +119,12 @@ export class ModuleIssuesFilter extends IssueFilterHelperStore implements IModul groupId: string | undefined, subGroupId: string | undefined ) => { - const filterParams = this.getAppliedFilters(moduleId); + let filterParams = this.getAppliedFilters(moduleId); + + if (!filterParams) { + filterParams = {}; + } + filterParams["module"] = moduleId; const paginationParams = this.getPaginationParams(filterParams, options, cursor, groupId, subGroupId); return paginationParams; diff --git a/web/core/store/issue/module/issue.store.ts b/web/core/store/issue/module/issue.store.ts index ee78b3d7c44..a69d5ee77cf 100644 --- a/web/core/store/issue/module/issue.store.ts +++ b/web/core/store/issue/module/issue.store.ts @@ -118,7 +118,7 @@ export class ModuleIssues extends BaseIssuesStore implements IModuleIssues { // get params from pagination options const params = this.issueFilterStore?.getFilterParams(options, moduleId, undefined, undefined, undefined); // call the fetch issues API with the params - const response = await this.moduleService.getModuleIssues(workspaceSlug, projectId, moduleId, params, { + const response = await this.issueService.getIssues(workspaceSlug, projectId, params, { signal: this.controller.signal, }); @@ -166,7 +166,7 @@ export class ModuleIssues extends BaseIssuesStore implements IModuleIssues { subGroupId ); // call the fetch issues API with the params for next page in issues - const response = await this.moduleService.getModuleIssues(workspaceSlug, projectId, moduleId, params); + const response = await this.issueService.getIssues(workspaceSlug, projectId, params); // after the next page of issues are fetched, call the base method to process the response this.onfetchNexIssues(response, groupId, subGroupId); From 4bec993f2a3730a79413cde271aeaa0c6d2ccabf Mon Sep 17 00:00:00 2001 From: rahulramesha Date: Mon, 29 Jul 2024 19:02:10 +0530 Subject: [PATCH 2/3] fix parent issue refresh --- .../issues/issue-detail/parent-select.tsx | 2 +- .../components/issues/issue-detail/root.tsx | 2 +- .../components/issues/peek-overview/root.tsx | 31 +++---------------- .../issue/issue-details/sub_issues.store.ts | 6 ++++ 4 files changed, 12 insertions(+), 29 deletions(-) diff --git a/web/core/components/issues/issue-detail/parent-select.tsx b/web/core/components/issues/issue-detail/parent-select.tsx index 3d5f8c3063d..26694f5a91b 100644 --- a/web/core/components/issues/issue-detail/parent-select.tsx +++ b/web/core/components/issues/issue-detail/parent-select.tsx @@ -48,7 +48,7 @@ export const IssueParentSelect: React.FC = observer((props) const handleParentIssue = async (_issueId: string | null = null) => { try { await issueOperations.update(workspaceSlug, projectId, issueId, { parent_id: _issueId }); - await issueOperations.fetch(workspaceSlug, projectId, issueId); + await issueOperations.fetch(workspaceSlug, projectId, issueId, false); _issueId && (await fetchSubIssues(workspaceSlug, projectId, _issueId)); toggleParentIssueModal(null); } catch (error) { diff --git a/web/core/components/issues/issue-detail/root.tsx b/web/core/components/issues/issue-detail/root.tsx index f2ec2256818..e520da2acbf 100644 --- a/web/core/components/issues/issue-detail/root.tsx +++ b/web/core/components/issues/issue-detail/root.tsx @@ -24,7 +24,7 @@ import { IssueMainContent } from "./main-content"; import { IssueDetailsSidebar } from "./sidebar"; export type TIssueOperations = { - fetch: (workspaceSlug: string, projectId: string, issueId: string) => Promise; + fetch: (workspaceSlug: string, projectId: string, issueId: string, loader?: boolean) => Promise; update: (workspaceSlug: string, projectId: string, issueId: string, data: Partial) => Promise; remove: (workspaceSlug: string, projectId: string, issueId: string) => Promise; archive?: (workspaceSlug: string, projectId: string, issueId: string) => Promise; diff --git a/web/core/components/issues/peek-overview/root.tsx b/web/core/components/issues/peek-overview/root.tsx index 597f3179af1..10241f95d96 100644 --- a/web/core/components/issues/peek-overview/root.tsx +++ b/web/core/components/issues/peek-overview/root.tsx @@ -6,7 +6,7 @@ import { usePathname } from "next/navigation"; import { TIssue } from "@plane/types"; import { TOAST_TYPE, setPromiseToast, setToast } from "@plane/ui"; // components -import { IssueView } from "@/components/issues"; +import { IssueView, TIssueOperations } from "@/components/issues"; // constants import { ISSUE_UPDATED, ISSUE_DELETED, ISSUE_ARCHIVED, ISSUE_RESTORED } from "@/constants/event-tracker"; import { EIssuesStoreType } from "@/constants/issue"; @@ -22,29 +22,6 @@ interface IIssuePeekOverview { is_draft?: boolean; } -export type TIssuePeekOperations = { - fetch: (workspaceSlug: string, projectId: string, issueId: string) => Promise; - update: (workspaceSlug: string, projectId: string, issueId: string, data: Partial) => Promise; - remove: (workspaceSlug: string, projectId: string, issueId: string) => Promise; - archive: (workspaceSlug: string, projectId: string, issueId: string) => Promise; - restore: (workspaceSlug: string, projectId: 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?: ( - workspaceSlug: string, - projectId: string, - issueId: string, - moduleIds: string[] - ) => Promise; -}; - export const IssuePeekOverview: FC = observer((props) => { const { embedIssue = false, embedRemoveCurrentNotification, is_archived = false, is_draft = false } = props; // router @@ -66,11 +43,11 @@ export const IssuePeekOverview: FC = observer((props) => { const [loader, setLoader] = useState(true); const [error, setError] = useState(false); - const issueOperations: TIssuePeekOperations = useMemo( + const issueOperations: TIssueOperations = useMemo( () => ({ - fetch: async (workspaceSlug: string, projectId: string, issueId: string) => { + fetch: async (workspaceSlug: string, projectId: string, issueId: string, loader = true) => { try { - setLoader(true); + setLoader(loader); setError(false); await fetchIssue( workspaceSlug, diff --git a/web/core/store/issue/issue-details/sub_issues.store.ts b/web/core/store/issue/issue-details/sub_issues.store.ts index 0bbdffe499d..da25d9bfb40 100644 --- a/web/core/store/issue/issue-details/sub_issues.store.ts +++ b/web/core/store/issue/issue-details/sub_issues.store.ts @@ -128,6 +128,12 @@ export class IssueSubIssuesStore implements IIssueSubIssuesStore { this.fetchOtherProjectProperties(workspaceSlug, otherProjectIds); } + if (subIssues) { + this.rootIssueDetailStore.rootIssueStore.issues.updateIssue(parentIssueId, { + sub_issues_count: subIssues.length, + }); + } + runInAction(() => { set(this.subIssuesStateDistribution, parentIssueId, subIssuesStateDistribution); set( From ae64023bb2cd913bc2fe90cbe7a695ac66bb305c Mon Sep 17 00:00:00 2001 From: rahulramesha Date: Mon, 29 Jul 2024 19:08:36 +0530 Subject: [PATCH 3/3] Revert "use common getIssues from issue service instead of multiple different services for modules and cycles" This reverts commit 957e981168d2fa5c5ed17cf659da981373f33759. --- web/core/store/issue/cycle/filter.store.ts | 7 +------ web/core/store/issue/cycle/issue.store.ts | 4 ++-- web/core/store/issue/module/filter.store.ts | 7 +------ web/core/store/issue/module/issue.store.ts | 4 ++-- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/web/core/store/issue/cycle/filter.store.ts b/web/core/store/issue/cycle/filter.store.ts index 2b35ee74632..490393a43a6 100644 --- a/web/core/store/issue/cycle/filter.store.ts +++ b/web/core/store/issue/cycle/filter.store.ts @@ -119,12 +119,7 @@ export class CycleIssuesFilter extends IssueFilterHelperStore implements ICycleI groupId: string | undefined, subGroupId: string | undefined ) => { - let filterParams = this.getAppliedFilters(cycleId); - - if (!filterParams) { - filterParams = {}; - } - filterParams["cycle"] = cycleId; + const filterParams = this.getAppliedFilters(cycleId); const paginationParams = this.getPaginationParams(filterParams, options, cursor, groupId, subGroupId); return paginationParams; diff --git a/web/core/store/issue/cycle/issue.store.ts b/web/core/store/issue/cycle/issue.store.ts index 250e786ae45..41dacd8a0f5 100644 --- a/web/core/store/issue/cycle/issue.store.ts +++ b/web/core/store/issue/cycle/issue.store.ts @@ -164,7 +164,7 @@ export class CycleIssues extends BaseIssuesStore implements ICycleIssues { // get params from pagination options const params = this.issueFilterStore?.getFilterParams(options, cycleId, undefined, undefined, undefined); // call the fetch issues API with the params - const response = await this.issueService.getIssues(workspaceSlug, projectId, params, { + const response = await this.cycleService.getCycleIssues(workspaceSlug, projectId, cycleId, params, { signal: this.controller.signal, }); @@ -212,7 +212,7 @@ export class CycleIssues extends BaseIssuesStore implements ICycleIssues { subGroupId ); // call the fetch issues API with the params for next page in issues - const response = await this.issueService.getIssues(workspaceSlug, projectId, cycleId, params); + const response = await this.cycleService.getCycleIssues(workspaceSlug, projectId, cycleId, params); // after the next page of issues are fetched, call the base method to process the response this.onfetchNexIssues(response, groupId, subGroupId); diff --git a/web/core/store/issue/module/filter.store.ts b/web/core/store/issue/module/filter.store.ts index d64a4c0f015..1e02ba13adf 100644 --- a/web/core/store/issue/module/filter.store.ts +++ b/web/core/store/issue/module/filter.store.ts @@ -119,12 +119,7 @@ export class ModuleIssuesFilter extends IssueFilterHelperStore implements IModul groupId: string | undefined, subGroupId: string | undefined ) => { - let filterParams = this.getAppliedFilters(moduleId); - - if (!filterParams) { - filterParams = {}; - } - filterParams["module"] = moduleId; + const filterParams = this.getAppliedFilters(moduleId); const paginationParams = this.getPaginationParams(filterParams, options, cursor, groupId, subGroupId); return paginationParams; diff --git a/web/core/store/issue/module/issue.store.ts b/web/core/store/issue/module/issue.store.ts index a69d5ee77cf..ee78b3d7c44 100644 --- a/web/core/store/issue/module/issue.store.ts +++ b/web/core/store/issue/module/issue.store.ts @@ -118,7 +118,7 @@ export class ModuleIssues extends BaseIssuesStore implements IModuleIssues { // get params from pagination options const params = this.issueFilterStore?.getFilterParams(options, moduleId, undefined, undefined, undefined); // call the fetch issues API with the params - const response = await this.issueService.getIssues(workspaceSlug, projectId, params, { + const response = await this.moduleService.getModuleIssues(workspaceSlug, projectId, moduleId, params, { signal: this.controller.signal, }); @@ -166,7 +166,7 @@ export class ModuleIssues extends BaseIssuesStore implements IModuleIssues { subGroupId ); // call the fetch issues API with the params for next page in issues - const response = await this.issueService.getIssues(workspaceSlug, projectId, params); + const response = await this.moduleService.getModuleIssues(workspaceSlug, projectId, moduleId, params); // after the next page of issues are fetched, call the base method to process the response this.onfetchNexIssues(response, groupId, subGroupId);