Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ export const ProjectIssueDetailsHeader = observer(() => {
// router
const router = useAppRouter();
const { workspaceSlug, workItem } = useParams();
// plane hooks
const { t } = useTranslation();
// store hooks
const { t } = useTranslation();
const { getProjectById, loader } = useProject();
const {
issue: { getIssueById, getIssueIdByIdentifier },
Expand Down
18 changes: 13 additions & 5 deletions web/core/components/issues/delete-issue-modal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"use client";

import { useEffect, useState } from "react";
import { observer } from "mobx-react";
import { useParams } from "next/navigation";
// types
import { PROJECT_ERROR_MESSAGES, EUserPermissions, EUserPermissionsLevel } from "@plane/constants";
import { useTranslation } from "@plane/i18n";
Expand All @@ -22,21 +24,19 @@ type Props = {
isEpic?: boolean;
};

export const DeleteIssueModal: React.FC<Props> = (props) => {
export const DeleteIssueModal: React.FC<Props> = observer((props) => {
const { dataId, data, isOpen, handleClose, isSubIssue = false, onSubmit, isEpic = false } = props;
// states
const [isDeleting, setIsDeleting] = useState(false);
// store hooks
const { workspaceSlug } = useParams();
const { issueMap } = useIssues();
const { getProjectById } = useProject();
const { allowPermissions } = useUserPermissions();
const { t } = useTranslation();

const { data: currentUser } = useUser();

// derived values
const canPerformProjectAdminActions = allowPermissions([EUserPermissions.ADMIN], EUserPermissionsLevel.PROJECT);

useEffect(() => {
setIsDeleting(false);
}, [isOpen]);
Expand All @@ -47,6 +47,14 @@ export const DeleteIssueModal: React.FC<Props> = (props) => {
const issue = data ? data : issueMap[dataId!];
const projectDetails = getProjectById(issue?.project_id);
const isIssueCreator = issue?.created_by === currentUser?.id;

const canPerformProjectAdminActions = allowPermissions(
[EUserPermissions.ADMIN],
EUserPermissionsLevel.PROJECT,
workspaceSlug?.toString(),
projectDetails?.id
);

const authorized = isIssueCreator || canPerformProjectAdminActions;

const onClose = () => {
Expand Down Expand Up @@ -114,4 +122,4 @@ export const DeleteIssueModal: React.FC<Props> = (props) => {
}
/>
);
};
});