* fix: dashboard issue stats * chore: code refactor
This commit is contained in:
parent
c44bf861e0
commit
99a7867a5e
5 changed files with 19 additions and 29 deletions
1
packages/types/src/dashboard.d.ts
vendored
1
packages/types/src/dashboard.d.ts
vendored
|
|
@ -109,6 +109,7 @@ export type TWidgetIssue = TIssue & {
|
||||||
project_id: string;
|
project_id: string;
|
||||||
relation_type: TIssueRelationTypes;
|
relation_type: TIssueRelationTypes;
|
||||||
sequence_id: number;
|
sequence_id: number;
|
||||||
|
type_id: string | null;
|
||||||
}[];
|
}[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,12 +67,14 @@ export const AssignedUpcomingIssueListItem: React.FC<IssueListItemProps> = obser
|
||||||
? blockedByIssues.length > 1
|
? blockedByIssues.length > 1
|
||||||
? `${blockedByIssues.length} blockers`
|
? `${blockedByIssues.length} blockers`
|
||||||
: blockedByIssueProjectDetails && (
|
: blockedByIssueProjectDetails && (
|
||||||
<IssueIdentifier
|
<IssueIdentifier
|
||||||
issueId={blockedByIssues[0]?.id}
|
projectIdentifier={blockedByIssueProjectDetails?.identifier}
|
||||||
projectId={blockedByIssueProjectDetails?.id}
|
projectId={blockedByIssueProjectDetails?.id}
|
||||||
textContainerClassName="text-xs text-custom-text-200 font-medium"
|
issueSequenceId={blockedByIssues[0]?.sequence_id}
|
||||||
/>
|
issueTypeId={blockedByIssues[0]?.type_id}
|
||||||
)
|
textContainerClassName="text-xs text-custom-text-200 font-medium"
|
||||||
|
/>
|
||||||
|
)
|
||||||
: "-"}
|
: "-"}
|
||||||
</div>
|
</div>
|
||||||
</ControlLink>
|
</ControlLink>
|
||||||
|
|
|
||||||
|
|
@ -20,17 +20,10 @@ interface IIssuePeekOverview {
|
||||||
embedRemoveCurrentNotification?: () => void;
|
embedRemoveCurrentNotification?: () => void;
|
||||||
is_archived?: boolean;
|
is_archived?: boolean;
|
||||||
is_draft?: boolean;
|
is_draft?: boolean;
|
||||||
shouldReplaceIssueOnFetch?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
|
export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
|
||||||
const {
|
const { embedIssue = false, embedRemoveCurrentNotification, is_archived = false, is_draft = false } = props;
|
||||||
embedIssue = false,
|
|
||||||
embedRemoveCurrentNotification,
|
|
||||||
is_archived = false,
|
|
||||||
is_draft = false,
|
|
||||||
shouldReplaceIssueOnFetch = true,
|
|
||||||
} = props;
|
|
||||||
// router
|
// router
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const {
|
const {
|
||||||
|
|
@ -67,8 +60,7 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
|
||||||
workspaceSlug,
|
workspaceSlug,
|
||||||
projectId,
|
projectId,
|
||||||
issueId,
|
issueId,
|
||||||
is_archived ? "ARCHIVED" : is_draft ? "DRAFT" : "DEFAULT",
|
is_archived ? "ARCHIVED" : is_draft ? "DRAFT" : "DEFAULT"
|
||||||
shouldReplaceIssueOnFetch
|
|
||||||
);
|
);
|
||||||
setLoader(false);
|
setLoader(false);
|
||||||
setError(false);
|
setError(false);
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,7 @@ export interface IIssueStoreActions {
|
||||||
workspaceSlug: string,
|
workspaceSlug: string,
|
||||||
projectId: string,
|
projectId: string,
|
||||||
issueId: string,
|
issueId: string,
|
||||||
issueType?: "DEFAULT" | "DRAFT" | "ARCHIVED",
|
issueType?: "DEFAULT" | "DRAFT" | "ARCHIVED"
|
||||||
shouldReplace?: boolean
|
|
||||||
) => Promise<TIssue>;
|
) => Promise<TIssue>;
|
||||||
updateIssue: (workspaceSlug: string, projectId: string, issueId: string, data: Partial<TIssue>) => Promise<void>;
|
updateIssue: (workspaceSlug: string, projectId: string, issueId: string, data: Partial<TIssue>) => Promise<void>;
|
||||||
removeIssue: (workspaceSlug: string, projectId: string, issueId: string) => Promise<void>;
|
removeIssue: (workspaceSlug: string, projectId: string, issueId: string) => Promise<void>;
|
||||||
|
|
@ -62,13 +61,7 @@ export class IssueStore implements IIssueStore {
|
||||||
});
|
});
|
||||||
|
|
||||||
// actions
|
// actions
|
||||||
fetchIssue = async (
|
fetchIssue = async (workspaceSlug: string, projectId: string, issueId: string, issueType = "DEFAULT") => {
|
||||||
workspaceSlug: string,
|
|
||||||
projectId: string,
|
|
||||||
issueId: string,
|
|
||||||
issueType = "DEFAULT",
|
|
||||||
shouldReplace = true
|
|
||||||
) => {
|
|
||||||
const query = {
|
const query = {
|
||||||
expand: "issue_reactions,issue_attachment,issue_link,parent",
|
expand: "issue_reactions,issue_attachment,issue_link,parent",
|
||||||
};
|
};
|
||||||
|
|
@ -114,7 +107,7 @@ export class IssueStore implements IIssueStore {
|
||||||
is_subscribed: issue?.is_subscribed,
|
is_subscribed: issue?.is_subscribed,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.rootIssueDetailStore.rootIssueStore.issues.addIssue([issuePayload], shouldReplace);
|
this.rootIssueDetailStore.rootIssueStore.issues.addIssue([issuePayload]);
|
||||||
|
|
||||||
// store handlers from issue detail
|
// store handlers from issue detail
|
||||||
// parent
|
// parent
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import update from "lodash/update";
|
||||||
import isEmpty from "lodash/isEmpty";
|
import isEmpty from "lodash/isEmpty";
|
||||||
import set from "lodash/set";
|
import set from "lodash/set";
|
||||||
import { action, makeObservable, observable, runInAction } from "mobx";
|
import { action, makeObservable, observable, runInAction } from "mobx";
|
||||||
|
|
@ -14,7 +15,7 @@ export type IIssueStore = {
|
||||||
issuesMap: Record<string, TIssue>; // Record defines issue_id as key and TIssue as value
|
issuesMap: Record<string, TIssue>; // Record defines issue_id as key and TIssue as value
|
||||||
// actions
|
// actions
|
||||||
getIssues(workspaceSlug: string, projectId: string, issueIds: string[]): Promise<TIssue[]>;
|
getIssues(workspaceSlug: string, projectId: string, issueIds: string[]): Promise<TIssue[]>;
|
||||||
addIssue(issues: TIssue[], shouldReplace?: boolean): void;
|
addIssue(issues: TIssue[]): void;
|
||||||
updateIssue(issueId: string, issue: Partial<TIssue>): void;
|
updateIssue(issueId: string, issue: Partial<TIssue>): void;
|
||||||
removeIssue(issueId: string): void;
|
removeIssue(issueId: string): void;
|
||||||
// helper methods
|
// helper methods
|
||||||
|
|
@ -47,11 +48,12 @@ export class IssueStore implements IIssueStore {
|
||||||
* @param {TIssue[]} issues
|
* @param {TIssue[]} issues
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
addIssue = (issues: TIssue[], shouldReplace = false) => {
|
addIssue = (issues: TIssue[]) => {
|
||||||
if (issues && issues.length <= 0) return;
|
if (issues && issues.length <= 0) return;
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
issues.forEach((issue) => {
|
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 }));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue