Skip to content

Commit

Permalink
#557 - feat: add link to report after deletion of zaken
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvandescheur committed Jan 2, 2025
1 parent 7bb6987 commit a727120
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# fmt: off
from django.test import tag

from openarchiefbeheer.utils.tests.e2e import browser_page
from openarchiefbeheer.utils.tests.gherkin import GherkinLikeTestCase

from ....constants import ListStatus


@tag("e2e")
class FeatureListDestroyTests(GherkinLikeTestCase):
async def test_scenario_record_manager_destroys_list(self):
async with browser_page() as page:
await self.given.record_manager_exists()
destruction_list = await self.given.list_exists(
name="Destruction list to destroy",
status=ListStatus.ready_to_delete,
uuid="00000000-0000-0000-0000-000000000000",
)

await self.when.record_manager_logs_in(page)
await self.then.path_should_be(page, "/destruction-lists")

await self.when.user_clicks_button(page, "Destruction list to destroy")
await self.then.path_should_be(page, f"/destruction-lists/{destruction_list.uuid}/edit")

await self.when.user_clicks_button(page, "Vernietigen starten")
await self.when.user_fills_form_field(page, "Type naam van de lijst ter bevestiging", "Destruction list to destroy")
await self.when.user_clicks_button(page, "100 zaken vernietigen")

await self.then.path_should_be(page, "/destruction-lists")
# TODO: Seems to rely on open zaak (mock?)
# await self.then.list_should_have_status(page, destruction_list, ListStatus.deleted)
10 changes: 10 additions & 0 deletions frontend/src/lib/auth/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,13 @@ export const canReassignDestructionList: DestructionListPermissionCheck = (
canReviewDestructionList(user, destructionList)) &&
(destructionList.status === "new" ||
destructionList.status === "ready_to_review");

export const canDownloadReport: DestructionListPermissionCheck = (
user,
destructionList,
) => {
if (!user.role.canStartDestruction) {
return false;
}
return destructionList.status === "deleted";
};
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,9 @@ export function useSecondaryNavigation(): ToolbarItem[] {

getPermittedToolbarItem(
BUTTON_ABORT_PROCESS,
(user, destructionList) => destructionList.status !== "new",
(user, destructionList) =>
destructionList.status !== "new" &&
destructionList.status !== "deleted",
),

// Status: "changes_requested", "Opnieuw indienen"
Expand Down
21 changes: 19 additions & 2 deletions frontend/src/pages/landing/Landing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ import { User } from "../../lib/api/auth";
import {
DESTRUCTION_LIST_STATUSES,
DestructionList,
DestructionListStatus,
} from "../../lib/api/destructionLists";
import { ProcessingStatus } from "../../lib/api/processingStatus";
import { API_BASE_URL, API_URL } from "../../lib/api/request";
import {
canCoReviewDestructionList,
canDownloadReport,
canMarkAsReadyToReview,
canMarkListAsFinal,
canReviewDestructionList,
Expand All @@ -47,6 +50,7 @@ export type LandingKanbanEntry = {
disabled: boolean;
plannedDestructionDate: string | null;
processingStatus: ProcessingStatus;
status: DestructionListStatus;
title: string;
timeAgo: string;
assignees: React.ReactNode;
Expand Down Expand Up @@ -163,6 +167,11 @@ export const Landing = () => {
? `/destruction-lists/${list.uuid}`
: undefined;

case "deleted":
return canViewDestructionList(user, list)
? API_BASE_URL + `/destruction-lists/${list.uuid}/download_report`
: undefined;

default:
return undefined;
}
Expand Down Expand Up @@ -191,10 +200,12 @@ export const Landing = () => {

return {
key: list.name,
onClick: () => navigate(href),
onClick: () =>
href.startsWith("http") ? window.open(href) : navigate(href),
disabled: !href,
processingStatus: list.processingStatus,
plannedDestructionDate: list.plannedDestructionDate,
status: list.status,
title: list.name,
timeAgo: timeAgo(list.created),
assignees: otherAssignees.length ? (
Expand Down Expand Up @@ -354,7 +365,13 @@ export const Landing = () => {
entry.processingStatus === "new" &&
!entry.plannedDestructionDate
) {
return (
return canDownloadReport(user, {
status: entry.status,
} as DestructionList) ? (
<Badge level="success">
<Outline.CloudArrowDownIcon /> Download rapport
</Badge>
) : (
<Badge aria-label="opgesteld">
<Outline.DocumentPlusIcon />
{entry.timeAgo as string}
Expand Down

0 comments on commit a727120

Please sign in to comment.