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.",
});
onClose();
router.push(`/${workspaceSlug}/projects/${projectId}/archives/cycles?peekCycle=${cycleId}`);
router.push(`/${workspaceSlug}/projects/${projectId}/cycles`);
})
.catch(() =>
setToast({

View File

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

View File

@ -129,7 +129,7 @@ export const CycleDetailsSidebar: React.FC<Props> = observer((props) => {
title: "Restore success",
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(() =>
setToast({

View File

@ -39,7 +39,14 @@ export const ArchiveIssueModal: React.FC<Props> = (props) => {
setIsArchiving(true);
await onSubmit()
.then(() => onClose())
.then(() => {
setToast({
type: TOAST_TYPE.SUCCESS,
title: "Archive success",
message: "Your archives can be found in project archives.",
});
onClose();
})
.catch(() =>
setToast({
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) => {
try {
await archiveIssue(workspaceSlug, projectId, issueId);
setToast({
type: TOAST_TYPE.SUCCESS,
title: "Success!",
message: "Issue archived successfully.",
});
captureIssueEvent({
eventName: ISSUE_ARCHIVED,
payload: { id: issueId, state: "SUCCESS", element: "Issue details page" },
path: router.asPath,
});
} catch (error) {
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: "Issue could not be archived. Please try again.",
});
captureIssueEvent({
eventName: ISSUE_ARCHIVED,
payload: { id: issueId, state: "FAILED", element: "Issue details page" },

View File

@ -1,22 +1,23 @@
import { useState } from "react";
import { observer } from "mobx-react";
import { useRouter } from "next/router";
// icons
import { ArchiveRestoreIcon, ExternalLink, Link, Trash2 } from "lucide-react";
// hooks
import { CustomMenu, TOAST_TYPE, setToast } from "@plane/ui";
import { DeleteIssueModal } from "@/components/issues";
// ui
import { CustomMenu, TOAST_TYPE, setToast } from "@plane/ui";
// components
import { DeleteIssueModal } from "@/components/issues";
// constants
import { EIssuesStoreType } from "@/constants/issue";
import { EUserProjectRoles } from "@/constants/project";
import { copyUrlToClipboard } from "@/helpers/string.helper";
import { useEventTracker, useIssues, useUser } from "@/hooks/store";
// components
// helpers
import { copyUrlToClipboard } from "@/helpers/string.helper";
// hooks
import { useEventTracker, useIssues, useUser } from "@/hooks/store";
// 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;
// states
const [deleteIssueModal, setDeleteIssueModal] = useState(false);
@ -46,6 +47,24 @@ export const ArchivedIssueQuickActions: React.FC<IQuickActionProps> = (props) =>
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 (
<>
@ -65,7 +84,7 @@ export const ArchivedIssueQuickActions: React.FC<IQuickActionProps> = (props) =>
ellipsis
>
{isRestoringAllowed && (
<CustomMenu.MenuItem onClick={handleRestore}>
<CustomMenu.MenuItem onClick={handleIssueRestore}>
<div className="flex items-center gap-2">
<ArchiveRestoreIcon className="h-3 w-3" />
Restore
@ -100,4 +119,4 @@ export const ArchivedIssueQuickActions: React.FC<IQuickActionProps> = (props) =>
</CustomMenu>
</>
);
};
});

View File

@ -135,22 +135,12 @@ export const IssuePeekOverview: FC<IIssuePeekOverview> = observer((props) => {
archive: async (workspaceSlug: string, projectId: string, issueId: string) => {
try {
await archiveIssue(workspaceSlug, projectId, issueId);
setToast({
type: TOAST_TYPE.SUCCESS,
title: "Success!",
message: "Issue archived successfully.",
});
captureIssueEvent({
eventName: ISSUE_ARCHIVED,
payload: { id: issueId, state: "SUCCESS", element: "Issue peek-overview" },
path: router.asPath,
});
} catch (error) {
setToast({
type: TOAST_TYPE.ERROR,
title: "Error!",
message: "Issue could not be archived. Please try again.",
});
captureIssueEvent({
eventName: ISSUE_ARCHIVED,
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);
setToast({
type: TOAST_TYPE.SUCCESS,
title: "Success!",
message: "Issue restored successfully.",
title: "Restore success",
message: "Your issue can be found in project issues.",
});
captureIssueEvent({
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.",
});
onClose();
router.push(`/${workspaceSlug}/projects/${projectId}/archives/modules?peekModule=${moduleId}`);
router.push(`/${workspaceSlug}/projects/${projectId}/modules`);
})
.catch(() =>
setToast({

View File

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

View File

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

View File

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