chore: archival of modules, cycles and issues enhancement. (#4100)

This commit is contained in:
Prateek Shourya 2024-04-03 18:19:34 +05:30 committed by GitHub
parent 91d85ffed0
commit 4c97098218
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 48 additions and 47 deletions

View File

@ -41,7 +41,7 @@ export const ArchiveCycleModal: React.FC<Props> = (props) => {
message: "Your archives can be found in project archives.", message: "Your archives can be found in project archives.",
}); });
onClose(); onClose();
router.push(`/${workspaceSlug}/projects/${projectId}/archives/cycles?peekCycle=${cycleId}`); router.push(`/${workspaceSlug}/projects/${projectId}/cycles`);
}) })
.catch(() => .catch(() =>
setToast({ setToast({

View File

@ -78,7 +78,7 @@ export const CycleQuickActions: React.FC<Props> = observer((props) => {
title: "Restore success", title: "Restore success",
message: "Your cycle can be found in project cycles.", message: "Your cycle can be found in project cycles.",
}); });
router.push(`/${workspaceSlug}/projects/${projectId}/cycles/${cycleId}`); router.push(`/${workspaceSlug}/projects/${projectId}/archives/cycles`);
}) })
.catch(() => .catch(() =>
setToast({ setToast({

View File

@ -129,7 +129,7 @@ export const CycleDetailsSidebar: React.FC<Props> = observer((props) => {
title: "Restore success", title: "Restore success",
message: "Your cycle can be found in project cycles.", message: "Your cycle can be found in project cycles.",
}); });
router.push(`/${workspaceSlug.toString()}/projects/${projectId.toString()}/cycles/${cycleId}`); router.push(`/${workspaceSlug.toString()}/projects/${projectId.toString()}/archives/cycles`);
}) })
.catch(() => .catch(() =>
setToast({ setToast({

View File

@ -39,7 +39,14 @@ export const ArchiveIssueModal: React.FC<Props> = (props) => {
setIsArchiving(true); setIsArchiving(true);
await onSubmit() await onSubmit()
.then(() => onClose()) .then(() => {
setToast({
type: TOAST_TYPE.SUCCESS,
title: "Archive success",
message: "Your archives can be found in project archives.",
});
onClose();
})
.catch(() => .catch(() =>
setToast({ setToast({
type: TOAST_TYPE.ERROR, type: TOAST_TYPE.ERROR,

View File

@ -144,22 +144,12 @@ export const IssueDetailRoot: FC<TIssueDetailRoot> = observer((props) => {
archive: async (workspaceSlug: string, projectId: string, issueId: string) => { archive: async (workspaceSlug: string, projectId: string, issueId: string) => {
try { try {
await archiveIssue(workspaceSlug, projectId, issueId); await archiveIssue(workspaceSlug, projectId, issueId);
setToast({
type: TOAST_TYPE.SUCCESS,
title: "Success!",
message: "Issue archived successfully.",
});
captureIssueEvent({ captureIssueEvent({
eventName: ISSUE_ARCHIVED, eventName: ISSUE_ARCHIVED,
payload: { id: issueId, state: "SUCCESS", element: "Issue details page" }, payload: { id: issueId, state: "SUCCESS", element: "Issue details page" },
path: router.asPath, path: router.asPath,
}); });
} catch (error) { } catch (error) {
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: "Issue could not be archived. Please try again.",
});
captureIssueEvent({ captureIssueEvent({
eventName: ISSUE_ARCHIVED, eventName: ISSUE_ARCHIVED,
payload: { id: issueId, state: "FAILED", element: "Issue details page" }, payload: { id: issueId, state: "FAILED", element: "Issue details page" },

View File

@ -1,22 +1,23 @@
import { useState } from "react"; import { useState } from "react";
import { observer } from "mobx-react";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
// icons
import { ArchiveRestoreIcon, ExternalLink, Link, Trash2 } from "lucide-react"; import { ArchiveRestoreIcon, ExternalLink, Link, Trash2 } from "lucide-react";
// hooks
import { CustomMenu, TOAST_TYPE, setToast } from "@plane/ui";
import { DeleteIssueModal } from "@/components/issues";
// ui // ui
import { CustomMenu, TOAST_TYPE, setToast } from "@plane/ui";
// components // components
import { DeleteIssueModal } from "@/components/issues";
// constants
import { EIssuesStoreType } from "@/constants/issue"; import { EIssuesStoreType } from "@/constants/issue";
import { EUserProjectRoles } from "@/constants/project"; import { EUserProjectRoles } from "@/constants/project";
import { copyUrlToClipboard } from "@/helpers/string.helper";
import { useEventTracker, useIssues, useUser } from "@/hooks/store";
// components
// helpers // helpers
import { copyUrlToClipboard } from "@/helpers/string.helper";
// hooks
import { useEventTracker, useIssues, useUser } from "@/hooks/store";
// types // types
import { IQuickActionProps } from "../list/list-view-types"; import { IQuickActionProps } from "../list/list-view-types";
export const ArchivedIssueQuickActions: React.FC<IQuickActionProps> = (props) => { export const ArchivedIssueQuickActions: React.FC<IQuickActionProps> = observer((props) => {
const { issue, handleDelete, handleRestore, customActionButton, portalElement, readOnly = false } = props; const { issue, handleDelete, handleRestore, customActionButton, portalElement, readOnly = false } = props;
// states // states
const [deleteIssueModal, setDeleteIssueModal] = useState(false); const [deleteIssueModal, setDeleteIssueModal] = useState(false);
@ -46,6 +47,24 @@ export const ArchivedIssueQuickActions: React.FC<IQuickActionProps> = (props) =>
message: "Issue link copied to clipboard", message: "Issue link copied to clipboard",
}) })
); );
const handleIssueRestore = async () => {
if (!handleRestore) return;
await handleRestore()
.then(() => {
setToast({
type: TOAST_TYPE.SUCCESS,
title: "Restore success",
message: "Your issue can be found in project issues.",
});
})
.catch(() => {
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: "Issue could not be restored. Please try again.",
});
});
};
return ( return (
<> <>
@ -65,7 +84,7 @@ export const ArchivedIssueQuickActions: React.FC<IQuickActionProps> = (props) =>
ellipsis ellipsis
> >
{isRestoringAllowed && ( {isRestoringAllowed && (
<CustomMenu.MenuItem onClick={handleRestore}> <CustomMenu.MenuItem onClick={handleIssueRestore}>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<ArchiveRestoreIcon className="h-3 w-3" /> <ArchiveRestoreIcon className="h-3 w-3" />
Restore Restore
@ -100,4 +119,4 @@ export const ArchivedIssueQuickActions: React.FC<IQuickActionProps> = (props) =>
</CustomMenu> </CustomMenu>
</> </>
); );
}; });

View File

@ -135,22 +135,12 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
archive: async (workspaceSlug: string, projectId: string, issueId: string) => { archive: async (workspaceSlug: string, projectId: string, issueId: string) => {
try { try {
await archiveIssue(workspaceSlug, projectId, issueId); await archiveIssue(workspaceSlug, projectId, issueId);
setToast({
type: TOAST_TYPE.SUCCESS,
title: "Success!",
message: "Issue archived successfully.",
});
captureIssueEvent({ captureIssueEvent({
eventName: ISSUE_ARCHIVED, eventName: ISSUE_ARCHIVED,
payload: { id: issueId, state: "SUCCESS", element: "Issue peek-overview" }, payload: { id: issueId, state: "SUCCESS", element: "Issue peek-overview" },
path: router.asPath, path: router.asPath,
}); });
} catch (error) { } catch (error) {
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: "Issue could not be archived. Please try again.",
});
captureIssueEvent({ captureIssueEvent({
eventName: ISSUE_ARCHIVED, eventName: ISSUE_ARCHIVED,
payload: { id: issueId, state: "FAILED", element: "Issue peek-overview" }, payload: { id: issueId, state: "FAILED", element: "Issue peek-overview" },
@ -163,8 +153,8 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
await restoreIssue(workspaceSlug, projectId, issueId); await restoreIssue(workspaceSlug, projectId, issueId);
setToast({ setToast({
type: TOAST_TYPE.SUCCESS, type: TOAST_TYPE.SUCCESS,
title: "Success!", title: "Restore success",
message: "Issue restored successfully.", message: "Your issue can be found in project issues.",
}); });
captureIssueEvent({ captureIssueEvent({
eventName: ISSUE_RESTORED, eventName: ISSUE_RESTORED,

View File

@ -41,7 +41,7 @@ export const ArchiveModuleModal: React.FC<Props> = (props) => {
message: "Your archives can be found in project archives.", message: "Your archives can be found in project archives.",
}); });
onClose(); onClose();
router.push(`/${workspaceSlug}/projects/${projectId}/archives/modules?peekModule=${moduleId}`); router.push(`/${workspaceSlug}/projects/${projectId}/modules`);
}) })
.catch(() => .catch(() =>
setToast({ setToast({

View File

@ -79,7 +79,7 @@ export const ModuleQuickActions: React.FC<Props> = observer((props) => {
title: "Restore success", title: "Restore success",
message: "Your module can be found in project modules.", message: "Your module can be found in project modules.",
}); });
router.push(`/${workspaceSlug}/projects/${projectId}/modules/${moduleId}`); router.push(`/${workspaceSlug}/projects/${projectId}/archives/modules`);
}) })
.catch(() => .catch(() =>
setToast({ setToast({

View File

@ -227,7 +227,7 @@ export const ModuleDetailsSidebar: React.FC<Props> = observer((props) => {
title: "Restore success", title: "Restore success",
message: "Your module can be found in project modules.", message: "Your module can be found in project modules.",
}); });
router.push(`/${workspaceSlug}/projects/${projectId}/modules/${moduleId}`); router.push(`/${workspaceSlug}/projects/${projectId}/archives/modules`);
}) })
.catch(() => .catch(() =>
setToast({ setToast({

View File

@ -66,13 +66,8 @@ const ArchivedIssueDetailsPage: NextPageWithLayout = observer(() => {
.then(() => { .then(() => {
setToast({ setToast({
type: TOAST_TYPE.SUCCESS, type: TOAST_TYPE.SUCCESS,
title: "Success", title: "Restore success",
message: message: "Your issue can be found in project issues.",
issue &&
`${getProjectById(issue.project_id)
?.identifier}-${issue?.sequence_id} is restored successfully under the project ${getProjectById(
issue.project_id
)?.name}`,
}); });
router.push(`/${workspaceSlug}/projects/${projectId}/issues/${archivedIssueId}`); router.push(`/${workspaceSlug}/projects/${projectId}/issues/${archivedIssueId}`);
}) })
@ -80,7 +75,7 @@ const ArchivedIssueDetailsPage: NextPageWithLayout = observer(() => {
setToast({ setToast({
type: TOAST_TYPE.ERROR, type: TOAST_TYPE.ERROR,
title: "Error!", title: "Error!",
message: "Something went wrong. Please try again.", message: "Issue could not be restored. Please try again.",
}); });
}) })
.finally(() => setIsRestoring(false)); .finally(() => setIsRestoring(false));