From 92e237205153f4a1df6ffd0291f889c64ebf42b8 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 6 Oct 2021 03:03:05 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20`AuthorizationAdminBox`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../authorization/AuthorizationAdminBox.tsx | 61 +++++++++++++++++++ .../authorization/AuthorizationStepPage.tsx | 2 + 2 files changed, 63 insertions(+) create mode 100644 frontend/src/components/authorization/AuthorizationAdminBox.tsx diff --git a/frontend/src/components/authorization/AuthorizationAdminBox.tsx b/frontend/src/components/authorization/AuthorizationAdminBox.tsx new file mode 100644 index 0000000..dc1061c --- /dev/null +++ b/frontend/src/components/authorization/AuthorizationAdminBox.tsx @@ -0,0 +1,61 @@ +import {navigate} from "@reach/router" +import {Box, Form, Heading, Idiomatic as I} from "@steffo/bluelib-react" +import * as React from "react" +import {useAuthorizationContext} from "../../contexts/authorization" +import {useInstanceContext} from "../../contexts/instance" + + +export interface AuthorizationAdminBoxProps { + +} + + +export function AuthorizationAdminBox({}: AuthorizationAdminBoxProps): JSX.Element { + const instance = useInstanceContext() + const authorization = useAuthorizationContext() + + const canAdministrate = + React.useMemo( + () => ( + authorization !== undefined && !authorization.state.running + ), + [authorization], + ) + + const doAdministrate = + React.useCallback( + async () => { + if(!instance) { + return + } + if(!instance.state.url) { + return + } + + await navigate(`${instance.state.url}admin`) + }, + [instance], + ) + + + return ( + + + Site administration + +

+ To configure the Sophon server, an account with superuser access is required. +

+

+ If you are the server administrator, please refer to the Sophon manual for details on how to acquire the credentials for this account. +

+
+ + + Administrate + + +
+
+ ) +} diff --git a/frontend/src/components/authorization/AuthorizationStepPage.tsx b/frontend/src/components/authorization/AuthorizationStepPage.tsx index 4a25eee..815f93e 100644 --- a/frontend/src/components/authorization/AuthorizationStepPage.tsx +++ b/frontend/src/components/authorization/AuthorizationStepPage.tsx @@ -1,6 +1,7 @@ import {Chapter} from "@steffo/bluelib-react" import * as React from "react" import {InstanceDescriptionBox} from "../instance/InstanceDescriptionBox" +import {AuthorizationAdminBox} from "./AuthorizationAdminBox" import {AuthorizationBrowseBox} from "./AuthorizationBrowseBox" import {AuthorizationLoginBox} from "./AuthorizationLoginBox" @@ -12,5 +13,6 @@ export function AuthorizationStepPage(): JSX.Element { + }