Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

[WEB-383] fix: rendering state and members from different projects in sub-issues (#3996)

guru_sainath621624e29fad
diff --git a/web/components/issues/sub-issues/properties.tsx b/web/components/issues/sub-issues/properties.tsx
index 33f346b6dc..6c611468a7 100644
--- a/web/components/issues/sub-issues/properties.tsx
+++ b/web/components/issues/sub-issues/properties.tsx
@@ -72,8 +72,8 @@ export const IssueProperty: React.FC<IIssueProperty> = (props) => {
}
disabled={!disabled}
multiple
- buttonVariant={issue.assignee_ids.length > 0 ? "transparent-without-text" : "border-without-text"}
- buttonClassName={issue.assignee_ids.length > 0 ? "hover:bg-transparent px-0" : ""}
+ buttonVariant={(issue?.assignee_ids || []).length > 0 ? "transparent-without-text" : "border-without-text"}
+ buttonClassName={(issue?.assignee_ids || []).length > 0 ? "hover:bg-transparent px-0" : ""}
/>
</div>
</div>
diff --git a/web/store/issue/issue-details/sub_issues.store.ts b/web/store/issue/issue-details/sub_issues.store.ts
index ca15289284..f4bd20772f 100644
--- a/web/store/issue/issue-details/sub_issues.store.ts
+++ b/web/store/issue/issue-details/sub_issues.store.ts
@@ -1,10 +1,9 @@
import concat from "lodash/concat";
import pull from "lodash/pull";
import set from "lodash/set";
+import uniq from "lodash/uniq";
import update from "lodash/update";
import { action, makeObservable, observable, runInAction } from "mobx";
-// services
-import { IssueService } from "@/services/issue";
// types
import {
TIssue,
@@ -13,6 +12,9 @@ import {
TIssueSubIssuesIdMap,
TSubIssuesStateDistribution,
} from "@plane/types";
+// services
+import { IssueService } from "@/services/issue";
+// store
import { IIssueDetail } from "./root.store";
export interface IIssueSubIssuesStoreActions {
@@ -48,6 +50,7 @@ export interface IIssueSubIssuesStore extends IIssueSubIssuesStoreActions {
subIssuesByIssueId: (issueId: string) => string[] | undefined;
subIssueHelpersByIssueId: (issueId: string) => TSubIssueHelpers;
// actions
+ fetchOtherProjectProperties: (workspaceSlug: string, projectIds: string[]) => Promise<void>;
setSubIssueHelpers: (parentIssueId: string, key: TSubIssueHelpersKeys, value: string) => void;
}
@@ -74,6 +77,7 @@ export class IssueSubIssuesStore implements IIssueSubIssuesStore {
updateSubIssue: action,
removeSubIssue: action,
deleteSubIssue: action,
+ fetchOtherProjectProperties: action,
});
// root store
this.rootIssueDetailStore = rootStore;
@@ -116,6 +120,12 @@ export class IssueSubIssuesStore implements IIssueSubIssuesStore {
this.rootIssueDetailStore.rootIssueStore.issues.addIssue(subIssues);
+ // fetch other issues states and members when sub-issues are from different project
+ if (subIssues && subIssues.length > 0) {
+ const otherProjectIds = uniq(subIssues.map((issue) => issue.project_id).filter((id) => id !== projectId));
+ this.fetchOtherProjectProperties(workspaceSlug, otherProjectIds);
+ }
+
runInAction(() => {
set(this.subIssuesStateDistribution, parentIssueId, subIssuesStateDistribution);
set(
@@ -140,6 +150,12 @@ export class IssueSubIssuesStore implements IIssueSubIssuesStore {
const subIssuesStateDistribution = response?.state_distribution;
const subIssues = response.sub_issues as TIssue[];
+ // fetch other issues states and members when sub-issues are from different project
+ if (subIssues && subIssues.length > 0) {
+ const otherProjectIds = uniq(subIssues.map((issue) => issue.project_id).filter((id) => id !== projectId));
+ this.fetchOtherProjectProperties(workspaceSlug, otherProjectIds);
+ }
+
runInAction(() => {
Object.keys(subIssuesStateDistribution).forEach((key) => {
const stateGroup = key as keyof TSubIssuesStateDistribution;
@@ -292,4 +308,30 @@ export class IssueSubIssuesStore implements IIssueSubIssuesStore {
throw error;
}
};
+
+ fetchOtherProjectProperties = async (workspaceSlug: string, projectIds: string[]) => {
+ try {
+ if (projectIds.length > 0) {
+ for (const projectId of projectIds) {
+ // fetching other project states
+ this.rootIssueDetailStore.rootIssueStore.rootStore.state.fetchProjectStates(workspaceSlug, projectId);
+ // fetching other project members
+ this.rootIssueDetailStore.rootIssueStore.rootStore.memberRoot.project.fetchProjectMembers(
+ workspaceSlug,
+ projectId
+ );
+ // fetching other project labels
+ this.rootIssueDetailStore.rootIssueStore.rootStore.label.fetchProjectLabels(workspaceSlug, projectId);
+ // fetching other project cycles
+ this.rootIssueDetailStore.rootIssueStore.rootStore.cycle.fetchAllCycles(workspaceSlug, projectId);
+ // fetching other project modules
+ this.rootIssueDetailStore.rootIssueStore.rootStore.module.fetchModules(workspaceSlug, projectId);
+ // fetching other project estimates
+ this.rootIssueDetailStore.rootIssueStore.rootStore.estimate.fetchProjectEstimates(workspaceSlug, projectId);
+ }
+ }
+ } catch (error) {
+ throw error;
+ }
+ };
}