forked from github/plane
fix: create issue modal not working on workspace level (#1393)
This commit is contained in:
parent
1a48fdd142
commit
c70fe91886
@ -23,7 +23,6 @@ import {
|
|||||||
IssueStateSelect,
|
IssueStateSelect,
|
||||||
} from "components/issues/select";
|
} from "components/issues/select";
|
||||||
import { CreateStateModal } from "components/states";
|
import { CreateStateModal } from "components/states";
|
||||||
import { CreateUpdateCycleModal } from "components/cycles";
|
|
||||||
import { CreateLabelModal } from "components/labels";
|
import { CreateLabelModal } from "components/labels";
|
||||||
// ui
|
// ui
|
||||||
import {
|
import {
|
||||||
@ -73,7 +72,6 @@ const defaultValues: Partial<IIssue> = {
|
|||||||
description_html: "<p></p>",
|
description_html: "<p></p>",
|
||||||
estimate_point: null,
|
estimate_point: null,
|
||||||
state: "",
|
state: "",
|
||||||
cycle: null,
|
|
||||||
priority: null,
|
priority: null,
|
||||||
assignees: [],
|
assignees: [],
|
||||||
assignees_list: [],
|
assignees_list: [],
|
||||||
@ -122,7 +120,6 @@ export const IssueForm: FC<IssueFormProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
// states
|
// states
|
||||||
const [mostSimilarIssue, setMostSimilarIssue] = useState<IIssue | undefined>();
|
const [mostSimilarIssue, setMostSimilarIssue] = useState<IIssue | undefined>();
|
||||||
const [cycleModal, setCycleModal] = useState(false);
|
|
||||||
const [stateModal, setStateModal] = useState(false);
|
const [stateModal, setStateModal] = useState(false);
|
||||||
const [labelModal, setLabelModal] = useState(false);
|
const [labelModal, setLabelModal] = useState(false);
|
||||||
const [parentIssueListModalOpen, setParentIssueListModalOpen] = useState(false);
|
const [parentIssueListModalOpen, setParentIssueListModalOpen] = useState(false);
|
||||||
@ -252,11 +249,6 @@ export const IssueForm: FC<IssueFormProps> = ({
|
|||||||
projectId={projectId}
|
projectId={projectId}
|
||||||
user={user}
|
user={user}
|
||||||
/>
|
/>
|
||||||
<CreateUpdateCycleModal
|
|
||||||
isOpen={cycleModal}
|
|
||||||
handleClose={() => setCycleModal(false)}
|
|
||||||
user={user}
|
|
||||||
/>
|
|
||||||
<CreateLabelModal
|
<CreateLabelModal
|
||||||
isOpen={labelModal}
|
isOpen={labelModal}
|
||||||
handleClose={() => setLabelModal(false)}
|
handleClose={() => setLabelModal(false)}
|
||||||
|
@ -82,12 +82,17 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = ({
|
|||||||
const { params: inboxParams } = useInboxView();
|
const { params: inboxParams } = useInboxView();
|
||||||
const { params: spreadsheetParams } = useSpreadsheetIssuesView();
|
const { params: spreadsheetParams } = useSpreadsheetIssuesView();
|
||||||
|
|
||||||
if (cycleId) prePopulateData = { ...prePopulateData, cycle: cycleId as string };
|
|
||||||
if (moduleId) prePopulateData = { ...prePopulateData, module: moduleId as string };
|
|
||||||
|
|
||||||
const { user } = useUser();
|
const { user } = useUser();
|
||||||
const { setToastAlert } = useToast();
|
const { setToastAlert } = useToast();
|
||||||
|
|
||||||
|
if (cycleId) prePopulateData = { ...prePopulateData, cycle: cycleId as string };
|
||||||
|
if (moduleId) prePopulateData = { ...prePopulateData, module: moduleId as string };
|
||||||
|
if (router.asPath.includes("my-issues"))
|
||||||
|
prePopulateData = {
|
||||||
|
...prePopulateData,
|
||||||
|
assignees: [...(prePopulateData?.assignees ?? []), user?.id ?? ""],
|
||||||
|
};
|
||||||
|
|
||||||
const { data: issues } = useSWR(
|
const { data: issues } = useSWR(
|
||||||
workspaceSlug && activeProject
|
workspaceSlug && activeProject
|
||||||
? PROJECT_ISSUES_LIST(workspaceSlug as string, activeProject ?? "")
|
? PROJECT_ISSUES_LIST(workspaceSlug as string, activeProject ?? "")
|
||||||
@ -121,7 +126,7 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = ({
|
|||||||
}, [handleClose]);
|
}, [handleClose]);
|
||||||
|
|
||||||
const addIssueToCycle = async (issueId: string, cycleId: string) => {
|
const addIssueToCycle = async (issueId: string, cycleId: string) => {
|
||||||
if (!workspaceSlug || !projectId) return;
|
if (!workspaceSlug || !activeProject) return;
|
||||||
|
|
||||||
await issuesService
|
await issuesService
|
||||||
.addIssueToCycle(
|
.addIssueToCycle(
|
||||||
@ -142,7 +147,7 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const addIssueToModule = async (issueId: string, moduleId: string) => {
|
const addIssueToModule = async (issueId: string, moduleId: string) => {
|
||||||
if (!workspaceSlug || !projectId) return;
|
if (!workspaceSlug || !activeProject) return;
|
||||||
|
|
||||||
await modulesService
|
await modulesService
|
||||||
.addIssuesToModule(
|
.addIssuesToModule(
|
||||||
@ -163,7 +168,7 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const addIssueToInbox = async (formData: Partial<IIssue>) => {
|
const addIssueToInbox = async (formData: Partial<IIssue>) => {
|
||||||
if (!workspaceSlug || !projectId || !inboxId) return;
|
if (!workspaceSlug || !activeProject || !inboxId) return;
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
issue: {
|
issue: {
|
||||||
@ -178,7 +183,7 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = ({
|
|||||||
await inboxServices
|
await inboxServices
|
||||||
.createInboxIssue(
|
.createInboxIssue(
|
||||||
workspaceSlug.toString(),
|
workspaceSlug.toString(),
|
||||||
projectId.toString(),
|
activeProject.toString(),
|
||||||
inboxId.toString(),
|
inboxId.toString(),
|
||||||
payload,
|
payload,
|
||||||
user
|
user
|
||||||
@ -191,7 +196,7 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
router.push(
|
router.push(
|
||||||
`/${workspaceSlug}/projects/${projectId}/inbox/${inboxId}?inboxIssueId=${res.issue_inbox[0].id}`
|
`/${workspaceSlug}/projects/${activeProject}/inbox/${inboxId}?inboxIssueId=${res.issue_inbox[0].id}`
|
||||||
);
|
);
|
||||||
|
|
||||||
mutate(INBOX_ISSUES(inboxId.toString(), inboxParams));
|
mutate(INBOX_ISSUES(inboxId.toString(), inboxParams));
|
||||||
@ -211,7 +216,7 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = ({
|
|||||||
? MODULE_ISSUES_WITH_PARAMS(moduleId.toString(), calendarParams)
|
? MODULE_ISSUES_WITH_PARAMS(moduleId.toString(), calendarParams)
|
||||||
: viewId
|
: viewId
|
||||||
? VIEW_ISSUES(viewId.toString(), calendarParams)
|
? VIEW_ISSUES(viewId.toString(), calendarParams)
|
||||||
: PROJECT_ISSUES_LIST_WITH_PARAMS(projectId?.toString() ?? "", calendarParams);
|
: PROJECT_ISSUES_LIST_WITH_PARAMS(activeProject?.toString() ?? "", calendarParams);
|
||||||
|
|
||||||
const spreadsheetFetchKey = cycleId
|
const spreadsheetFetchKey = cycleId
|
||||||
? CYCLE_ISSUES_WITH_PARAMS(cycleId.toString(), spreadsheetParams)
|
? CYCLE_ISSUES_WITH_PARAMS(cycleId.toString(), spreadsheetParams)
|
||||||
@ -219,7 +224,7 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = ({
|
|||||||
? MODULE_ISSUES_WITH_PARAMS(moduleId.toString(), spreadsheetParams)
|
? MODULE_ISSUES_WITH_PARAMS(moduleId.toString(), spreadsheetParams)
|
||||||
: viewId
|
: viewId
|
||||||
? VIEW_ISSUES(viewId.toString(), spreadsheetParams)
|
? VIEW_ISSUES(viewId.toString(), spreadsheetParams)
|
||||||
: PROJECT_ISSUES_LIST_WITH_PARAMS(projectId?.toString() ?? "", spreadsheetParams);
|
: PROJECT_ISSUES_LIST_WITH_PARAMS(activeProject?.toString() ?? "", spreadsheetParams);
|
||||||
|
|
||||||
const ganttFetchKey = cycleId
|
const ganttFetchKey = cycleId
|
||||||
? CYCLE_ISSUES_WITH_PARAMS(cycleId.toString())
|
? CYCLE_ISSUES_WITH_PARAMS(cycleId.toString())
|
||||||
@ -227,10 +232,10 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = ({
|
|||||||
? MODULE_ISSUES_WITH_PARAMS(moduleId.toString())
|
? MODULE_ISSUES_WITH_PARAMS(moduleId.toString())
|
||||||
: viewId
|
: viewId
|
||||||
? VIEW_ISSUES(viewId.toString(), viewGanttParams)
|
? VIEW_ISSUES(viewId.toString(), viewGanttParams)
|
||||||
: PROJECT_ISSUES_LIST_WITH_PARAMS(projectId?.toString() ?? "");
|
: PROJECT_ISSUES_LIST_WITH_PARAMS(activeProject?.toString() ?? "");
|
||||||
|
|
||||||
const createIssue = async (payload: Partial<IIssue>) => {
|
const createIssue = async (payload: Partial<IIssue>) => {
|
||||||
if (!workspaceSlug || !projectId) return;
|
if (!workspaceSlug || !activeProject) return;
|
||||||
|
|
||||||
if (inboxId) await addIssueToInbox(payload);
|
if (inboxId) await addIssueToInbox(payload);
|
||||||
else
|
else
|
||||||
@ -252,7 +257,8 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = ({
|
|||||||
message: "Issue created successfully.",
|
message: "Issue created successfully.",
|
||||||
});
|
});
|
||||||
|
|
||||||
if (payload.assignees_list?.some((assignee) => assignee === user?.id)) mutate(USER_ISSUE);
|
if (payload.assignees_list?.some((assignee) => assignee === user?.id))
|
||||||
|
mutate(USER_ISSUE(workspaceSlug as string));
|
||||||
|
|
||||||
if (payload.parent && payload.parent !== "") mutate(SUB_ISSUES(payload.parent));
|
if (payload.parent && payload.parent !== "") mutate(SUB_ISSUES(payload.parent));
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user