mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
[WEB-838] fix: cycle dropdown fetch (#4076)
* fix: workspace issue properties fetch * fix: issue modal cycle fetch issue * fix: issue modal cycle fetch issue * chore: project issue properties hook updated
This commit is contained in:
parent
86715f5b20
commit
3a466cfe40
@ -26,6 +26,7 @@ import { renderFormattedPayloadDate, getDate } from "@/helpers/date-time.helper"
|
|||||||
import { getChangedIssuefields } from "@/helpers/issue.helper";
|
import { getChangedIssuefields } from "@/helpers/issue.helper";
|
||||||
import { shouldRenderProject } from "@/helpers/project.helper";
|
import { shouldRenderProject } from "@/helpers/project.helper";
|
||||||
import { useApplication, useEstimate, useIssueDetail, useMention, useProject, useWorkspace } from "@/hooks/store";
|
import { useApplication, useEstimate, useIssueDetail, useMention, useProject, useWorkspace } from "@/hooks/store";
|
||||||
|
import { useProjectIssueProperties } from "@/hooks/use-project-issue-properties";
|
||||||
// services
|
// services
|
||||||
import { AIService } from "@/services/ai.service";
|
import { AIService } from "@/services/ai.service";
|
||||||
import { FileService } from "@/services/file.service";
|
import { FileService } from "@/services/file.service";
|
||||||
@ -121,6 +122,7 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
|
|||||||
// store hooks
|
// store hooks
|
||||||
const {
|
const {
|
||||||
config: { envConfig },
|
config: { envConfig },
|
||||||
|
router: { projectId: routeProjectId },
|
||||||
} = useApplication();
|
} = useApplication();
|
||||||
const { getProjectById } = useProject();
|
const { getProjectById } = useProject();
|
||||||
const { areEstimatesEnabledForProject } = useEstimate();
|
const { areEstimatesEnabledForProject } = useEstimate();
|
||||||
@ -128,6 +130,7 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
|
|||||||
const {
|
const {
|
||||||
issue: { getIssueById },
|
issue: { getIssueById },
|
||||||
} = useIssueDetail();
|
} = useIssueDetail();
|
||||||
|
const { fetchCycles } = useProjectIssueProperties();
|
||||||
// form info
|
// form info
|
||||||
const {
|
const {
|
||||||
formState: { errors, isDirty, isSubmitting, dirtyFields },
|
formState: { errors, isDirty, isSubmitting, dirtyFields },
|
||||||
@ -160,6 +163,7 @@ export const IssueFormRoot: FC<IssueFormProps> = observer((props) => {
|
|||||||
parent_id: formData.parent_id,
|
parent_id: formData.parent_id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (projectId && routeProjectId !== projectId) fetchCycles(workspaceSlug, projectId);
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [projectId]);
|
}, [projectId]);
|
||||||
|
|
||||||
|
89
web/hooks/use-project-issue-properties.ts
Normal file
89
web/hooks/use-project-issue-properties.ts
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
import { useCycle, useEstimate, useLabel, useMember, useModule, useProjectState } from "./store";
|
||||||
|
|
||||||
|
export const useProjectIssueProperties = () => {
|
||||||
|
const { fetchProjectStates } = useProjectState();
|
||||||
|
const {
|
||||||
|
project: { fetchProjectMembers },
|
||||||
|
} = useMember();
|
||||||
|
const { fetchProjectLabels } = useLabel();
|
||||||
|
const { fetchAllCycles: fetchProjectAllCycles } = useCycle();
|
||||||
|
const { fetchModules: fetchProjectAllModules } = useModule();
|
||||||
|
const { fetchProjectEstimates } = useEstimate();
|
||||||
|
|
||||||
|
// fetching project states
|
||||||
|
const fetchStates = async (
|
||||||
|
workspaceSlug: string | string[] | undefined,
|
||||||
|
projectId: string | string[] | undefined
|
||||||
|
) => {
|
||||||
|
if (workspaceSlug && projectId) {
|
||||||
|
await fetchProjectStates(workspaceSlug.toString(), projectId.toString());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// fetching project members
|
||||||
|
const fetchMembers = async (
|
||||||
|
workspaceSlug: string | string[] | undefined,
|
||||||
|
projectId: string | string[] | undefined
|
||||||
|
) => {
|
||||||
|
if (workspaceSlug && projectId) {
|
||||||
|
await fetchProjectMembers(workspaceSlug.toString(), projectId.toString());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// fetching project labels
|
||||||
|
const fetchLabels = async (
|
||||||
|
workspaceSlug: string | string[] | undefined,
|
||||||
|
projectId: string | string[] | undefined
|
||||||
|
) => {
|
||||||
|
if (workspaceSlug && projectId) {
|
||||||
|
await fetchProjectLabels(workspaceSlug.toString(), projectId.toString());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// fetching project cycles
|
||||||
|
const fetchCycles = async (
|
||||||
|
workspaceSlug: string | string[] | undefined,
|
||||||
|
projectId: string | string[] | undefined
|
||||||
|
) => {
|
||||||
|
if (workspaceSlug && projectId) {
|
||||||
|
await fetchProjectAllCycles(workspaceSlug.toString(), projectId.toString());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// fetching project modules
|
||||||
|
const fetchModules = async (
|
||||||
|
workspaceSlug: string | string[] | undefined,
|
||||||
|
projectId: string | string[] | undefined
|
||||||
|
) => {
|
||||||
|
if (workspaceSlug && projectId) {
|
||||||
|
await fetchProjectAllModules(workspaceSlug.toString(), projectId.toString());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// fetching project estimates
|
||||||
|
const fetchEstimates = async (
|
||||||
|
workspaceSlug: string | string[] | undefined,
|
||||||
|
projectId: string | string[] | undefined
|
||||||
|
) => {
|
||||||
|
if (workspaceSlug && projectId) {
|
||||||
|
await fetchProjectEstimates(workspaceSlug.toString(), projectId.toString());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const fetchAll = async (workspaceSlug: string | string[] | undefined, projectId: string | string[] | undefined) => {
|
||||||
|
if (workspaceSlug && projectId) {
|
||||||
|
await fetchStates(workspaceSlug, projectId);
|
||||||
|
await fetchMembers(workspaceSlug, projectId);
|
||||||
|
await fetchLabels(workspaceSlug, projectId);
|
||||||
|
await fetchCycles(workspaceSlug, projectId);
|
||||||
|
await fetchModules(workspaceSlug, projectId);
|
||||||
|
await fetchEstimates(workspaceSlug, projectId);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
fetchAll,
|
||||||
|
fetchStates,
|
||||||
|
fetchMembers,
|
||||||
|
fetchLabels,
|
||||||
|
fetchCycles,
|
||||||
|
fetchModules,
|
||||||
|
fetchEstimates,
|
||||||
|
};
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user