Block delete for in-progress access review campaigns
Reject deletion while a campaign is fetching sources so workers are not racing a removed record. All other statuses remain deletable. Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Bryan FRIMIN <bryan@frimin.fr>
This commit is contained in:
@@ -132,6 +132,8 @@ export default function AccessReviewCampaignsTab({ queryRef }: Props) {
|
||||
deleteCampaignMutation,
|
||||
);
|
||||
|
||||
const isDeletableStatus = (status: string) => status !== "IN_PROGRESS";
|
||||
|
||||
const handleDelete = (campaignId: string, campaignName: string) => {
|
||||
confirm(
|
||||
() => {
|
||||
@@ -178,7 +180,9 @@ export default function AccessReviewCampaignsTab({ queryRef }: Props) {
|
||||
);
|
||||
};
|
||||
|
||||
const hasActions = accessReviewCampaigns.edges.some(edge => edge.node.canDelete);
|
||||
const hasActions = accessReviewCampaigns.edges.some(
|
||||
edge => edge.node.canDelete && isDeletableStatus(edge.node.status),
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
@@ -209,7 +213,8 @@ export default function AccessReviewCampaignsTab({ queryRef }: Props) {
|
||||
</Thead>
|
||||
<Tbody>
|
||||
{accessReviewCampaigns.edges.map((edge) => {
|
||||
const canDeleteRow = edge.node.canDelete;
|
||||
const canDeleteRow
|
||||
= edge.node.canDelete && isDeletableStatus(edge.node.status);
|
||||
return (
|
||||
<Tr
|
||||
key={edge.node.id}
|
||||
|
||||
@@ -216,7 +216,7 @@ export default function CampaignDetailPage({ queryRef }: Props) {
|
||||
const isInProgress = campaign.status === "IN_PROGRESS";
|
||||
const isDraft = campaign.status === "DRAFT";
|
||||
const isPendingActions = campaign.status === "PENDING_ACTIONS";
|
||||
const canDelete = campaign.canDelete;
|
||||
const canDelete = campaign.canDelete && !isInProgress;
|
||||
|
||||
const campaignIdRef = useRef(campaign.id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user