From 7d1621767cec57e9e7217f620844655279ab1af5 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 7 Aug 2023 06:51:10 -0300 Subject: [PATCH] ui settings view --- .../src/Application.tsx | 24 +++++-- .../src/ApplicationReadyRoutes.tsx | 14 +++- .../src/InstanceRoutes.tsx | 7 ++ .../src/components/exception/login.tsx | 2 +- .../src/components/menu/NavigationBar.tsx | 2 - .../src/components/menu/SideBar.tsx | 64 ++++++++++++------- .../src/components/menu/index.tsx | 7 +- .../paths/instance/orders/list/ListPage.tsx | 4 +- .../instance/templates/create/CreatePage.tsx | 38 +++++------ .../src/paths/settings/index.tsx | 15 +++++ 10 files changed, 118 insertions(+), 59 deletions(-) create mode 100644 packages/merchant-backoffice-ui/src/paths/settings/index.tsx diff --git a/packages/merchant-backoffice-ui/src/Application.tsx b/packages/merchant-backoffice-ui/src/Application.tsx index 23510c456..f6a81ff8d 100644 --- a/packages/merchant-backoffice-ui/src/Application.tsx +++ b/packages/merchant-backoffice-ui/src/Application.tsx @@ -26,7 +26,7 @@ import { } from "@gnu-taler/web-util/browser"; import { Fragment, h, VNode } from "preact"; import { route } from "preact-router"; -import { useMemo } from "preact/hooks"; +import { useMemo, useState } from "preact/hooks"; import { ApplicationReadyRoutes } from "./ApplicationReadyRoutes.js"; import { Loading } from "./components/exception/loading.js"; import { @@ -42,6 +42,7 @@ import { useBackendConfig } from "./hooks/backend.js"; import { strings } from "./i18n/strings.js"; import LoginPage from "./paths/login/index.js"; import { HttpStatusCode } from "@gnu-taler/taler-util"; +import { Settings } from "./paths/settings/index.js"; export function Application(): VNode { return ( @@ -70,10 +71,19 @@ function ApplicationStatusRoutes(): VNode { : { currency: "unknown", version: "unknown" }; const ctx = useMemo(() => ({ currency, version }), [currency, version]); + const [showSettings, setShowSettings] = useState(false) + + if (showSettings) { + return + setShowSettings(true)} title="UI Settings" /> + + + } + if (!triedToLog) { return ( - + setShowSettings(true)} /> ); @@ -87,7 +97,7 @@ function ApplicationStatusRoutes(): VNode { ) { return ( - + setShowSettings(true)} /> ); @@ -98,7 +108,7 @@ function ApplicationStatusRoutes(): VNode { ) { return ( - + setShowSettings(true)} /> - + setShowSettings(true)} /> - + setShowSettings(true)} /> - + setShowSettings(true)} /> ; + if (showSettings) { + return + setShowSettings(true)} title="UI Settings" onLogout={clearTokenAndGoToRoot} /> + + + } + if (result.loading) return setShowSettings(true)} title="Loading..." />; let admin = true; let instanceNameByBackendURL; @@ -61,7 +69,7 @@ export function ApplicationReadyRoutes(): VNode { ) { return ( - + setShowSettings(true)} title="Login" onLogout={clearTokenAndGoToRoot} /> - + setShowSettings(true)} title="Error" onLogout={clearTokenAndGoToRoot} /> { + route("/settings") + }} path={path} onLogout={clearTokenAndGoToRoot} setInstanceName={setInstanceName} @@ -558,6 +564,7 @@ export function InstanceRoutes({ }} /> + {/** * Example pages */} diff --git a/packages/merchant-backoffice-ui/src/components/exception/login.tsx b/packages/merchant-backoffice-ui/src/components/exception/login.tsx index 984b6fe06..f2f94a7c5 100644 --- a/packages/merchant-backoffice-ui/src/components/exception/login.tsx +++ b/packages/merchant-backoffice-ui/src/components/exception/login.tsx @@ -229,7 +229,7 @@ export function LoginModal({ onConfirm, withMessage }: Props): VNode { ); } -function AsyncButton({onClick, children}:{onClick: () => Promise, children: ComponentChildren}):VNode { +function AsyncButton({ onClick, children }: { onClick: () => Promise, children: ComponentChildren }): VNode { const [running, setRunning] = useState(false) return