mirror of
https://github.com/outline/outline.git
synced 2026-06-13 03:14:59 +03:00
597b6d801c
* fix: Allow deleting failed and canceled imports The delete policy only permitted imports in the Completed state, so the overflow menu for Errored or Canceled imports rendered with no items. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> * test: Cover Errored and Canceled in imports.delete Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
import { ImportState } from "@shared/types";
|
|
import { User, Team, Import } from "@server/models";
|
|
import { allow, can } from "./cancan";
|
|
import { and, isTeamAdmin, isTeamMutable, or } from "./utils";
|
|
|
|
const TerminalStates = [
|
|
ImportState.Completed,
|
|
ImportState.Errored,
|
|
ImportState.Canceled,
|
|
];
|
|
|
|
allow(User, ["createImport", "listImports"], Team, (actor, team) =>
|
|
and(isTeamAdmin(actor, team), isTeamMutable(actor))
|
|
);
|
|
|
|
allow(User, "read", Import, (actor, importModel) =>
|
|
and(isTeamAdmin(actor, importModel), isTeamMutable(actor))
|
|
);
|
|
|
|
allow(User, "delete", Import, (actor, importModel) =>
|
|
and(
|
|
can(actor, "read", importModel),
|
|
!!importModel && TerminalStates.includes(importModel.state)
|
|
)
|
|
);
|
|
|
|
allow(User, "cancel", Import, (actor, importModel) =>
|
|
and(
|
|
can(actor, "read", importModel),
|
|
importModel?.createdById === actor.id,
|
|
or(
|
|
importModel?.state === ImportState.Created,
|
|
importModel?.state === ImportState.InProgress,
|
|
importModel?.state === ImportState.Processed
|
|
)
|
|
)
|
|
);
|