forked from github/plane
[WEB-383] fix: rendering state and members from different projects in sub-issues (#3996)
* fix: rendering the state and memebers from different projects in sub issues and exception handling while creating an issue from different project * chore: handled different project issue properties in a new function handler
This commit is contained in:
parent
4ea616f1cd
commit
621624e29f
@ -72,8 +72,8 @@ export const IssueProperty: React.FC<IIssueProperty> = (props) => {
|
|||||||
}
|
}
|
||||||
disabled={!disabled}
|
disabled={!disabled}
|
||||||
multiple
|
multiple
|
||||||
buttonVariant={issue.assignee_ids.length > 0 ? "transparent-without-text" : "border-without-text"}
|
buttonVariant={(issue?.assignee_ids || []).length > 0 ? "transparent-without-text" : "border-without-text"}
|
||||||
buttonClassName={issue.assignee_ids.length > 0 ? "hover:bg-transparent px-0" : ""}
|
buttonClassName={(issue?.assignee_ids || []).length > 0 ? "hover:bg-transparent px-0" : ""}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
import concat from "lodash/concat";
|
import concat from "lodash/concat";
|
||||||
import pull from "lodash/pull";
|
import pull from "lodash/pull";
|
||||||
import set from "lodash/set";
|
import set from "lodash/set";
|
||||||
|
import uniq from "lodash/uniq";
|
||||||
import update from "lodash/update";
|
import update from "lodash/update";
|
||||||
import { action, makeObservable, observable, runInAction } from "mobx";
|
import { action, makeObservable, observable, runInAction } from "mobx";
|
||||||
// services
|
|
||||||
import { IssueService } from "@/services/issue";
|
|
||||||
// types
|
// types
|
||||||
import {
|
import {
|
||||||
TIssue,
|
TIssue,
|
||||||
@ -13,6 +12,9 @@ import {
|
|||||||
TIssueSubIssuesIdMap,
|
TIssueSubIssuesIdMap,
|
||||||
TSubIssuesStateDistribution,
|
TSubIssuesStateDistribution,
|
||||||
} from "@plane/types";
|
} from "@plane/types";
|
||||||
|
// services
|
||||||
|
import { IssueService } from "@/services/issue";
|
||||||
|
// store
|
||||||
import { IIssueDetail } from "./root.store";
|
import { IIssueDetail } from "./root.store";
|
||||||
|
|
||||||
export interface IIssueSubIssuesStoreActions {
|
export interface IIssueSubIssuesStoreActions {
|
||||||
@ -48,6 +50,7 @@ export interface IIssueSubIssuesStore extends IIssueSubIssuesStoreActions {
|
|||||||
subIssuesByIssueId: (issueId: string) => string[] | undefined;
|
subIssuesByIssueId: (issueId: string) => string[] | undefined;
|
||||||
subIssueHelpersByIssueId: (issueId: string) => TSubIssueHelpers;
|
subIssueHelpersByIssueId: (issueId: string) => TSubIssueHelpers;
|
||||||
// actions
|
// actions
|
||||||
|
fetchOtherProjectProperties: (workspaceSlug: string, projectIds: string[]) => Promise<void>;
|
||||||
setSubIssueHelpers: (parentIssueId: string, key: TSubIssueHelpersKeys, value: string) => void;
|
setSubIssueHelpers: (parentIssueId: string, key: TSubIssueHelpersKeys, value: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,6 +77,7 @@ export class IssueSubIssuesStore implements IIssueSubIssuesStore {
|
|||||||
updateSubIssue: action,
|
updateSubIssue: action,
|
||||||
removeSubIssue: action,
|
removeSubIssue: action,
|
||||||
deleteSubIssue: action,
|
deleteSubIssue: action,
|
||||||
|
fetchOtherProjectProperties: action,
|
||||||
});
|
});
|
||||||
// root store
|
// root store
|
||||||
this.rootIssueDetailStore = rootStore;
|
this.rootIssueDetailStore = rootStore;
|
||||||
@ -116,6 +120,12 @@ export class IssueSubIssuesStore implements IIssueSubIssuesStore {
|
|||||||
|
|
||||||
this.rootIssueDetailStore.rootIssueStore.issues.addIssue(subIssues);
|
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(() => {
|
runInAction(() => {
|
||||||
set(this.subIssuesStateDistribution, parentIssueId, subIssuesStateDistribution);
|
set(this.subIssuesStateDistribution, parentIssueId, subIssuesStateDistribution);
|
||||||
set(
|
set(
|
||||||
@ -140,6 +150,12 @@ export class IssueSubIssuesStore implements IIssueSubIssuesStore {
|
|||||||
const subIssuesStateDistribution = response?.state_distribution;
|
const subIssuesStateDistribution = response?.state_distribution;
|
||||||
const subIssues = response.sub_issues as TIssue[];
|
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(() => {
|
runInAction(() => {
|
||||||
Object.keys(subIssuesStateDistribution).forEach((key) => {
|
Object.keys(subIssuesStateDistribution).forEach((key) => {
|
||||||
const stateGroup = key as keyof TSubIssuesStateDistribution;
|
const stateGroup = key as keyof TSubIssuesStateDistribution;
|
||||||
@ -292,4 +308,30 @@ export class IssueSubIssuesStore implements IIssueSubIssuesStore {
|
|||||||
throw error;
|
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;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user