Some checks failed
CodeQL / Analyze (javascript) (push) Failing after 16s
CodeQL / Analyze (python) (push) Failing after 3s
i18n sync check / check:sync (push) Failing after 3s
React Doctor / react-doctor (push) Failing after 16s
Branch Build CE / Build-Push Admin Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Admin Manifest (push) Has been cancelled
Branch Build CE / Build-Push Web Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Web Manifest (push) Has been cancelled
Branch Build CE / Build-Push Space Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Proxy Manifest (push) Has been cancelled
Branch Build CE / Merge Space Manifest (push) Has been cancelled
Branch Build CE / Prepare AIO Assets (push) Has been cancelled
Branch Build CE / Build Setup (push) Has been cancelled
Branch Build CE / Build-Push Live Collaboration Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge Live Collaboration Manifest (push) Has been cancelled
Branch Build CE / Build-Push API Server Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge API Server Manifest (push) Has been cancelled
Branch Build CE / Build-Push Proxy Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Build-Push AIO Docker Image (${{ matrix.arch }}) (push) Has been cancelled
Branch Build CE / Merge AIO Manifest (push) Has been cancelled
Branch Build CE / Upload Build Assets (push) Has been cancelled
Branch Build CE / Build Release (push) Has been cancelled
89 lines
2.7 KiB
TypeScript
89 lines
2.7 KiB
TypeScript
/**
|
|
* Copyright (c) 2023-present Plane Software, Inc. and contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
* See the LICENSE file for details.
|
|
*/
|
|
|
|
import { useState } from "react";
|
|
// i18n
|
|
import { useTranslation } from "@plane/i18n";
|
|
// types
|
|
import { Button } from "@plane/propel/button";
|
|
import { TOAST_TYPE, setToast } from "@plane/propel/toast";
|
|
import type { TDeDupeIssue, TIssue } from "@plane/types";
|
|
import { EModalPosition, EModalWidth, ModalCore } from "@plane/ui";
|
|
// hooks
|
|
import { useIssues } from "@/hooks/store/use-issues";
|
|
import { useProject } from "@/hooks/store/use-project";
|
|
|
|
type Props = {
|
|
data?: TIssue | TDeDupeIssue;
|
|
dataId?: string | null | undefined;
|
|
handleClose: () => void;
|
|
isOpen: boolean;
|
|
onSubmit?: () => Promise<void>;
|
|
};
|
|
|
|
export function ArchiveIssueModal(props: Props) {
|
|
const { dataId, data, isOpen, handleClose, onSubmit } = props;
|
|
const { t } = useTranslation();
|
|
// states
|
|
const [isArchiving, setIsArchiving] = useState(false);
|
|
// store hooks
|
|
const { getProjectById } = useProject();
|
|
const { issueMap } = useIssues();
|
|
|
|
if (!dataId && !data) return null;
|
|
|
|
const issue = data ? data : issueMap[dataId!];
|
|
const projectDetails = getProjectById(issue.project_id);
|
|
|
|
const onClose = () => {
|
|
setIsArchiving(false);
|
|
handleClose();
|
|
};
|
|
|
|
const handleArchiveIssue = async () => {
|
|
if (!onSubmit) return;
|
|
|
|
setIsArchiving(true);
|
|
await onSubmit()
|
|
.then(() => {
|
|
setToast({
|
|
type: TOAST_TYPE.SUCCESS,
|
|
title: t("issue.archive.success.label"),
|
|
message: t("issue.archive.success.message"),
|
|
});
|
|
onClose();
|
|
return;
|
|
})
|
|
.catch(() =>
|
|
setToast({
|
|
type: TOAST_TYPE.ERROR,
|
|
title: t("common.error.label"),
|
|
message: t("issue.archive.failed.message"),
|
|
})
|
|
)
|
|
.finally(() => setIsArchiving(false));
|
|
};
|
|
|
|
return (
|
|
<ModalCore isOpen={isOpen} handleClose={onClose} position={EModalPosition.CENTER} width={EModalWidth.LG}>
|
|
<div className="px-5 py-4">
|
|
<h3 className="text-18 font-medium 2xl:text-20">
|
|
{t("issue.archive.label")} {projectDetails?.identifier} {issue.sequence_id}
|
|
</h3>
|
|
<p className="mt-3 text-13 text-secondary">{t("issue.archive.confirm_message")}</p>
|
|
<div className="mt-3 flex justify-end gap-2">
|
|
<Button variant="secondary" size="lg" onClick={onClose}>
|
|
{t("common.cancel")}
|
|
</Button>
|
|
<Button variant="primary" size="lg" tabIndex={1} onClick={handleArchiveIssue} loading={isArchiving}>
|
|
{isArchiving ? t("common.archiving") : t("common.archive")}
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</ModalCore>
|
|
);
|
|
}
|