diff --git a/shell.nix b/shell.nix index 5b75c22..66094ba 100644 --- a/shell.nix +++ b/shell.nix @@ -1,4 +1,7 @@ -with import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/24.05.tar.gz") { }; +with import + (fetchTarball + "https://github.com/NixOS/nixpkgs/archive/release-24.11.tar.gz") +{ }; stdenv.mkDerivation { name = "decaf-react"; diff --git a/src/DecafApp.tsx b/src/DecafApp.tsx index f0d7d29..5e3a522 100644 --- a/src/DecafApp.tsx +++ b/src/DecafApp.tsx @@ -5,7 +5,7 @@ import DecafVersionChecker from './DecafVersionChecker'; import { DecafWebappController } from './DecafWebappController'; import { OfflineNotifier } from './OfflineChecker'; import ZendeskWidget from './ZendeskWidget'; -import { DecafContext, Principal, PublicConfig } from './context'; +import { DecafContext, Principal, PrivateConfig, PublicConfig } from './context'; export interface DecafAppConfig { /** version of the application */ @@ -33,6 +33,7 @@ export default function DecafApp(props: DecafAppProps) { const [client, setClient] = React.useState(undefined); const [me, setMe] = React.useState(undefined); const [publicConfig, setPublicConfig] = React.useState(undefined); + const [privateConfig, setPrivateConfig] = React.useState(undefined); const [loading, setLoading] = React.useState(true); const [redirectReason, setRedirectReason] = React.useState('not-authenticated'); const authInterval = React.useRef(undefined); @@ -54,11 +55,16 @@ export default function DecafApp(props: DecafAppProps) { const client = controller.getDecafClient(); if (client) { - Promise.all([client.barista.get('/me/'), client.barista.get('/conf/public/')]) - .then(([meResp, configResp]) => { + Promise.all([ + client.barista.get('/me/'), + client.barista.get('/conf/public/'), + client.barista.get('/conf/private/'), + ]) + .then(([meResp, configResp, privateConfig]) => { setClient(client); setMe(meResp.data); setPublicConfig(configResp.data); + setPrivateConfig(privateConfig.data); setLoading(false); }) .catch(() => { @@ -94,11 +100,11 @@ export default function DecafApp(props: DecafAppProps) { if (loading) { return <>{controller.loadingComponent}; - } else if (client === undefined || me === undefined || publicConfig === undefined) { + } else if (client === undefined || me === undefined || publicConfig === undefined || privateConfig === undefined) { return controller.onInvalidSession(redirectReason); } else { return ( - + {props.config?.currentVersion && ( ({ client: undefined as unknown as DecafClient, me: undefined as unknown as Principal, publicConfig: undefined as unknown as PublicConfig, + privateConfig: undefined as unknown as PrivateConfig, controller: undefined as unknown as DecafAppController, }); @@ -23,6 +24,7 @@ export interface DecafContextType { client: DecafClient; me: Principal; publicConfig: PublicConfig; + privateConfig: PrivateConfig; controller: DecafAppController; } @@ -73,3 +75,32 @@ export interface PublicConfig { /** password reset feature should be enabled or not */ pwdreset: true; } + +/** + * Type encoding for global private deployment configuration. + * + * This configuration value is instantiated during runtime from + * `/api/conf/private/` API endpoint. + */ +export interface PrivateConfig { + functions: { + portmngt: boolean; + fundmngt: boolean; + ebanking: boolean; + pretrade: boolean; + }; + beanbag?: string; + releasenotes: string; + documentation: Resource[]; +} + +/** + * Type encoding for a single documentation item. + */ +export interface Resource { + title: string; + description: string; + role: 'privileged' | 'internal' | '*'; + authed: boolean; + document: { type: 'internal' | 'external'; link: string }; +} diff --git a/src/index.spec.tsx b/src/index.spec.tsx index de9fc10..2d06253 100644 --- a/src/index.spec.tsx +++ b/src/index.spec.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import * as React from 'react'; import { createRoot } from 'react-dom/client'; import { DecafApp, DecafSpinner } from './';