Skip to content

Commit

Permalink
Merge pull request #817 from Health-Informatics-UoN/fix/add-permissio…
Browse files Browse the repository at this point in the history
…n-SR-details

Add permission on layout of SR details page
  • Loading branch information
AndrewThien authored Aug 1, 2024
2 parents 4366d91 + 1967b3e commit 61cd998
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
9 changes: 9 additions & 0 deletions app/next-client-app/app/scanreports/[id]/details/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from "@/api/datasets";
import { ScanReportDetailsForm } from "@/components/scanreports/ScanReportDetailsForm";
import { getScanReport, getScanReportPermissions } from "@/api/scanreports";
import { Forbidden } from "@/components/core/Forbidden";

interface ScanReportDetailsProps {
params: {
Expand All @@ -34,6 +35,14 @@ export default async function ScanreportDetails({
const permissionsSR = await getScanReportPermissions(id);
const isAuthor = permissionsSR.permissions.includes("IsAuthor");

if (permissionsDS.permissions.length === 0) {
return (
<div>
<Forbidden />
</div>
);
}

return (
<div>
<ScanReportDetailsForm
Expand Down
17 changes: 10 additions & 7 deletions app/next-client-app/components/core/Forbidden.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { ExclamationTriangleIcon } from "@radix-ui/react-icons";

import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { TriangleAlert } from "lucide-react";

export function Forbidden() {
return (
<Alert variant="destructive">
<ExclamationTriangleIcon className="h-4 w-4" />
<AlertTitle>Error</AlertTitle>
<AlertDescription>
You do not have permission to access this resource.
</AlertDescription>
<div>
<AlertTitle className="flex items-center">
<TriangleAlert className="h-4 w-4 mr-2" />
Error
</AlertTitle>
<AlertDescription>
You do not have permission to access this resource.
</AlertDescription>
</div>
</Alert>
);
}

0 comments on commit 61cd998

Please sign in to comment.