mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
fix: issue delete redirection, chore: code refactor (#1521)
This commit is contained in:
parent
60e96bcb72
commit
7361657660
@ -39,13 +39,11 @@ export const AutoArchiveAutomation: React.FC<Props> = ({ projectDetails, handleC
|
|||||||
</div>
|
</div>
|
||||||
<ToggleSwitch
|
<ToggleSwitch
|
||||||
value={projectDetails?.archive_in !== 0}
|
value={projectDetails?.archive_in !== 0}
|
||||||
onChange={() => {
|
onChange={() =>
|
||||||
if (projectDetails?.archive_in === 0) {
|
projectDetails?.archive_in === 0
|
||||||
handleChange({ archive_in: 1 });
|
? handleChange({ archive_in: 1 })
|
||||||
} else {
|
: handleChange({ archive_in: 0 })
|
||||||
handleChange({ archive_in: 0 });
|
}
|
||||||
}
|
|
||||||
}}
|
|
||||||
size="sm"
|
size="sm"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -88,13 +88,11 @@ export const AutoCloseAutomation: React.FC<Props> = ({ projectDetails, handleCha
|
|||||||
</div>
|
</div>
|
||||||
<ToggleSwitch
|
<ToggleSwitch
|
||||||
value={projectDetails?.close_in !== 0}
|
value={projectDetails?.close_in !== 0}
|
||||||
onChange={() => {
|
onChange={() =>
|
||||||
if (projectDetails?.close_in === 0) {
|
projectDetails?.close_in === 0
|
||||||
handleChange({ close_in: 1, default_state: defaultState });
|
? handleChange({ close_in: 1, default_state: defaultState })
|
||||||
} else {
|
: handleChange({ close_in: 0, default_state: null })
|
||||||
handleChange({ close_in: 0, default_state: null });
|
}
|
||||||
}
|
|
||||||
}}
|
|
||||||
size="sm"
|
size="sm"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -121,6 +121,7 @@ export const DeleteIssueModal: React.FC<Props> = ({ isOpen, handleClose, data, u
|
|||||||
type: "success",
|
type: "success",
|
||||||
message: "Issue deleted successfully",
|
message: "Issue deleted successfully",
|
||||||
});
|
});
|
||||||
|
router.back();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
@ -142,7 +143,7 @@ export const DeleteIssueModal: React.FC<Props> = ({ isOpen, handleClose, data, u
|
|||||||
type: "success",
|
type: "success",
|
||||||
message: "Issue deleted successfully",
|
message: "Issue deleted successfully",
|
||||||
});
|
});
|
||||||
router.push(`/${workspaceSlug}/projects/${projectId}/archived-issues/`);
|
router.back();
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
@ -150,6 +151,9 @@ export const DeleteIssueModal: React.FC<Props> = ({ isOpen, handleClose, data, u
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleIssueDelete = () =>
|
||||||
|
isArchivedIssues ? handleArchivedIssueDeletion() : handleDeletion();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Transition.Root show={isOpen} as={React.Fragment}>
|
<Transition.Root show={isOpen} as={React.Fragment}>
|
||||||
<Dialog as="div" className="relative z-20" onClose={onClose}>
|
<Dialog as="div" className="relative z-20" onClose={onClose}>
|
||||||
@ -201,13 +205,7 @@ export const DeleteIssueModal: React.FC<Props> = ({ isOpen, handleClose, data, u
|
|||||||
</span>
|
</span>
|
||||||
<div className="flex justify-end gap-2">
|
<div className="flex justify-end gap-2">
|
||||||
<SecondaryButton onClick={onClose}>Cancel</SecondaryButton>
|
<SecondaryButton onClick={onClose}>Cancel</SecondaryButton>
|
||||||
<DangerButton
|
<DangerButton onClick={handleIssueDelete} loading={isDeleteLoading}>
|
||||||
onClick={() => {
|
|
||||||
if (isArchivedIssues) handleArchivedIssueDeletion();
|
|
||||||
else handleDeletion();
|
|
||||||
}}
|
|
||||||
loading={isDeleteLoading}
|
|
||||||
>
|
|
||||||
{isDeleteLoading ? "Deleting..." : "Delete Issue"}
|
{isDeleteLoading ? "Deleting..." : "Delete Issue"}
|
||||||
</DangerButton>
|
</DangerButton>
|
||||||
</div>
|
</div>
|
||||||
|
@ -21,7 +21,7 @@ import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
|
|||||||
import type { NextPage } from "next";
|
import type { NextPage } from "next";
|
||||||
import { IProject } from "types";
|
import { IProject } from "types";
|
||||||
// constant
|
// constant
|
||||||
import { PROJECT_DETAILS } from "constants/fetch-keys";
|
import { PROJECTS_LIST, PROJECT_DETAILS } from "constants/fetch-keys";
|
||||||
|
|
||||||
const AutomationsSettings: NextPage = () => {
|
const AutomationsSettings: NextPage = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@ -40,10 +40,15 @@ const AutomationsSettings: NextPage = () => {
|
|||||||
(prevData) => ({ ...(prevData as IProject), ...formData }),
|
(prevData) => ({ ...(prevData as IProject), ...formData }),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
await projectService
|
await projectService
|
||||||
.updateProject(workspaceSlug as string, projectId as string, formData, user)
|
.updateProject(workspaceSlug as string, projectId as string, formData, user)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
mutate<IProject[]>(
|
||||||
|
PROJECTS_LIST(workspaceSlug as string),
|
||||||
|
(prevData) =>
|
||||||
|
(prevData ?? []).map((p) => (p.id === projectDetails?.id ? { ...p, ...formData } : p)),
|
||||||
|
false
|
||||||
|
);
|
||||||
mutate(PROJECT_DETAILS(projectId as string));
|
mutate(PROJECT_DETAILS(projectId as string));
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user