From 4519e63fece8f55761d48b6c99165dcc991dae90 Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia Date: Mon, 9 Sep 2024 17:40:15 +0530 Subject: [PATCH 1/2] fix: dashboard issue stats --- packages/types/src/dashboard.d.ts | 1 + .../widgets/issue-panels/issue-list-item.tsx | 14 ++++++++------ .../components/page-views/workspace-dashboard.tsx | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/types/src/dashboard.d.ts b/packages/types/src/dashboard.d.ts index 47e37a6c6e2..3b1c825a0ab 100644 --- a/packages/types/src/dashboard.d.ts +++ b/packages/types/src/dashboard.d.ts @@ -109,6 +109,7 @@ export type TWidgetIssue = TIssue & { project_id: string; relation_type: TIssueRelationTypes; sequence_id: number; + type_id: string | null; }[]; }; diff --git a/web/core/components/dashboard/widgets/issue-panels/issue-list-item.tsx b/web/core/components/dashboard/widgets/issue-panels/issue-list-item.tsx index bb897916dec..c3dc06b1ecb 100644 --- a/web/core/components/dashboard/widgets/issue-panels/issue-list-item.tsx +++ b/web/core/components/dashboard/widgets/issue-panels/issue-list-item.tsx @@ -67,12 +67,14 @@ export const AssignedUpcomingIssueListItem: React.FC = obser ? blockedByIssues.length > 1 ? `${blockedByIssues.length} blockers` : blockedByIssueProjectDetails && ( - - ) + + ) : "-"} diff --git a/web/core/components/page-views/workspace-dashboard.tsx b/web/core/components/page-views/workspace-dashboard.tsx index a6affa4ae3f..0e377fd4a6a 100644 --- a/web/core/components/page-views/workspace-dashboard.tsx +++ b/web/core/components/page-views/workspace-dashboard.tsx @@ -65,7 +65,7 @@ export const WorkspaceDashboardView = observer(() => { <> {joinedProjectIds.length > 0 || loader ? ( <> - + = 768, From 3149e5c8ddf18491efe3df7c276f93f7bfdb2c70 Mon Sep 17 00:00:00 2001 From: Anmol Singh Bhatia Date: Mon, 9 Sep 2024 18:08:29 +0530 Subject: [PATCH 2/2] chore: code refactor --- web/core/components/issues/peek-overview/root.tsx | 12 ++---------- .../components/page-views/workspace-dashboard.tsx | 2 +- web/core/store/issue/issue-details/issue.store.ts | 13 +++---------- web/core/store/issue/issue.store.ts | 8 +++++--- 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/web/core/components/issues/peek-overview/root.tsx b/web/core/components/issues/peek-overview/root.tsx index 3685767fd2a..a55b0d5464f 100644 --- a/web/core/components/issues/peek-overview/root.tsx +++ b/web/core/components/issues/peek-overview/root.tsx @@ -20,17 +20,10 @@ interface IIssuePeekOverview { embedRemoveCurrentNotification?: () => void; is_archived?: boolean; is_draft?: boolean; - shouldReplaceIssueOnFetch?: boolean; } export const IssuePeekOverview: FC = observer((props) => { - const { - embedIssue = false, - embedRemoveCurrentNotification, - is_archived = false, - is_draft = false, - shouldReplaceIssueOnFetch = true, - } = props; + const { embedIssue = false, embedRemoveCurrentNotification, is_archived = false, is_draft = false } = props; // router const pathname = usePathname(); const { @@ -67,8 +60,7 @@ export const IssuePeekOverview: FC = observer((props) => { workspaceSlug, projectId, issueId, - is_archived ? "ARCHIVED" : is_draft ? "DRAFT" : "DEFAULT", - shouldReplaceIssueOnFetch + is_archived ? "ARCHIVED" : is_draft ? "DRAFT" : "DEFAULT" ); setLoader(false); setError(false); diff --git a/web/core/components/page-views/workspace-dashboard.tsx b/web/core/components/page-views/workspace-dashboard.tsx index 0e377fd4a6a..a6affa4ae3f 100644 --- a/web/core/components/page-views/workspace-dashboard.tsx +++ b/web/core/components/page-views/workspace-dashboard.tsx @@ -65,7 +65,7 @@ export const WorkspaceDashboardView = observer(() => { <> {joinedProjectIds.length > 0 || loader ? ( <> - + = 768, diff --git a/web/core/store/issue/issue-details/issue.store.ts b/web/core/store/issue/issue-details/issue.store.ts index 186fab50903..871be85e026 100644 --- a/web/core/store/issue/issue-details/issue.store.ts +++ b/web/core/store/issue/issue-details/issue.store.ts @@ -13,8 +13,7 @@ export interface IIssueStoreActions { workspaceSlug: string, projectId: string, issueId: string, - issueType?: "DEFAULT" | "DRAFT" | "ARCHIVED", - shouldReplace?: boolean + issueType?: "DEFAULT" | "DRAFT" | "ARCHIVED" ) => Promise; updateIssue: (workspaceSlug: string, projectId: string, issueId: string, data: Partial) => Promise; removeIssue: (workspaceSlug: string, projectId: string, issueId: string) => Promise; @@ -62,13 +61,7 @@ export class IssueStore implements IIssueStore { }); // actions - fetchIssue = async ( - workspaceSlug: string, - projectId: string, - issueId: string, - issueType = "DEFAULT", - shouldReplace = true - ) => { + fetchIssue = async (workspaceSlug: string, projectId: string, issueId: string, issueType = "DEFAULT") => { const query = { expand: "issue_reactions,issue_attachment,issue_link,parent", }; @@ -114,7 +107,7 @@ export class IssueStore implements IIssueStore { is_subscribed: issue?.is_subscribed, }; - this.rootIssueDetailStore.rootIssueStore.issues.addIssue([issuePayload], shouldReplace); + this.rootIssueDetailStore.rootIssueStore.issues.addIssue([issuePayload]); // store handlers from issue detail // parent diff --git a/web/core/store/issue/issue.store.ts b/web/core/store/issue/issue.store.ts index 6b5154d570e..f94188e6416 100644 --- a/web/core/store/issue/issue.store.ts +++ b/web/core/store/issue/issue.store.ts @@ -1,3 +1,4 @@ +import update from "lodash/update"; import isEmpty from "lodash/isEmpty"; import set from "lodash/set"; import { action, makeObservable, observable, runInAction } from "mobx"; @@ -14,7 +15,7 @@ export type IIssueStore = { issuesMap: Record; // Record defines issue_id as key and TIssue as value // actions getIssues(workspaceSlug: string, projectId: string, issueIds: string[]): Promise; - addIssue(issues: TIssue[], shouldReplace?: boolean): void; + addIssue(issues: TIssue[]): void; updateIssue(issueId: string, issue: Partial): void; removeIssue(issueId: string): void; // helper methods @@ -47,11 +48,12 @@ export class IssueStore implements IIssueStore { * @param {TIssue[]} issues * @returns {void} */ - addIssue = (issues: TIssue[], shouldReplace = false) => { + addIssue = (issues: TIssue[]) => { if (issues && issues.length <= 0) return; runInAction(() => { issues.forEach((issue) => { - if (!this.issuesMap[issue.id] || shouldReplace) set(this.issuesMap, issue.id, issue); + if (!this.issuesMap[issue.id]) set(this.issuesMap, issue.id, issue); + else update(this.issuesMap, issue.id, (prevIssue) => ({ ...prevIssue, ...issue })); }); }); };