Skip to content

Commit c5d2019

Browse files
author
Julian Roeland
committed
✨ [#728] - feat: version information
1 parent 4bad04a commit c5d2019

File tree

3 files changed

+77
-3
lines changed

3 files changed

+77
-3
lines changed

frontend/src/App.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function App() {
106106
value={{
107107
breadcrumbItems,
108108
primaryNavigationItems: [
109-
<Logo key="logo" width={32} />,
109+
<Logo key="logo" width={32} withDialog />,
110110
{
111111
children: <Solid.HomeIcon />,
112112
title: "Home",

frontend/src/components/Logo/Logo.tsx

+54-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,59 @@
1+
import { AttributeList, Button, Card, P, useDialog } from "@maykin-ui/admin-ui";
2+
import { useCallback } from "react";
3+
4+
import { useDataFetcher } from "../../hooks/useDataFetcher";
5+
import { getAppInfo } from "../../lib/api/app-info";
6+
17
export type LogoProps = {
2-
width?: number;
8+
width?: number | string;
9+
withDialog?: boolean;
310
};
411

5-
export function Logo({ width = 128 }: LogoProps) {
12+
/**
13+
* Implementation of the LogoImage with optional interactivity
14+
*/
15+
export function Logo({ width = 128, withDialog = false }: LogoProps) {
16+
const dialog = useDialog();
17+
18+
const onClick = useCallback(() => {
19+
dialog("Over", <DialogBody />, undefined, { size: "s" });
20+
}, [dialog]);
21+
22+
return withDialog ? (
23+
<Button variant="transparent" onClick={onClick} pad={false}>
24+
<LogoImage width={width} />
25+
</Button>
26+
) : (
27+
<LogoImage width={width} />
28+
);
29+
}
30+
31+
function DialogBody() {
32+
const { data: appInfo } = useDataFetcher(
33+
(signal) => getAppInfo(signal),
34+
{
35+
errorMessage:
36+
"Er is een fout opgetreden bij het ophalen van de versieinfo!",
37+
},
38+
[],
39+
);
40+
41+
return (
42+
<Card>
43+
<LogoImage width={"100%"} />
44+
<AttributeList
45+
object={{
46+
Versie: <P size="xs">{appInfo?.release}</P>,
47+
"Git SHA": <P size="xs">{appInfo?.gitSha}</P>,
48+
}}
49+
/>
50+
</Card>
51+
);
52+
}
53+
54+
/**
55+
* Purely the image of the logo, without any interactivity.
56+
*/
57+
function LogoImage({ width }: { width: number | string }) {
658
return <img src="/logo.svg" alt="Open Archiefbeheer Logo" width={width} />;
759
}

frontend/src/lib/api/app-info.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { request } from "./request";
2+
3+
export type AppInfo = {
4+
release: string;
5+
gitSha: string;
6+
};
7+
8+
/**
9+
* List all the users that have the permission to archive destruction lists.
10+
*/
11+
export async function getAppInfo(signal?: AbortSignal) {
12+
const response = await request(
13+
"GET",
14+
"/app-info",
15+
undefined,
16+
undefined,
17+
undefined,
18+
signal,
19+
);
20+
const promise: Promise<AppInfo> = response.json();
21+
return promise;
22+
}

0 commit comments

Comments
 (0)