From c2db23824f18b6da963bf4d7549b453fa01b0b35 Mon Sep 17 00:00:00 2001 From: Sivert Kronen Hatteberg <skh@uio.no> Date: Thu, 25 Nov 2021 09:30:21 +0100 Subject: [PATCH] Merge appTheme and appInst into appInst No need for two config variables. Use the appInst config to get the correct theme. --- frontend/src/appConfig.ts | 7 +------ frontend/src/components/debug/index.tsx | 6 +++--- frontend/src/components/logobars/LogoBar.tsx | 8 +++----- frontend/src/themes/index.ts | 6 ++---- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/frontend/src/appConfig.ts b/frontend/src/appConfig.ts index a28e40c6..4af122b8 100644 --- a/frontend/src/appConfig.ts +++ b/frontend/src/appConfig.ts @@ -16,14 +16,9 @@ export const appTimezone: string = 'Europe/Oslo' export const appVersion: string = process.env.REACT_APP_VERSION as string export const appName: string = process.env.REACT_APP_NAME as string -/* Institution */ +/* Institution (used for features and theming */ export const appInst: string = env.REACT_APP_INST as string -/* Theming */ -export const appTheme: string = env.REACT_APP_THEME - ? (env.REACT_APP_THEME as string) - : 'default' - /* Show warning in the footer about this being a staging/test system */ export const appStagingWarning: boolean = env.REACT_APP_STAGING_WARNING === 'true' diff --git a/frontend/src/components/debug/index.tsx b/frontend/src/components/debug/index.tsx index ef0ec007..3b781fd5 100644 --- a/frontend/src/components/debug/index.tsx +++ b/frontend/src/components/debug/index.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react' +import { useState } from 'react' import { useTranslation } from 'react-i18next' import CheckIcon from '@mui/icons-material/Check' @@ -15,7 +15,7 @@ import { Divider, } from '@mui/material' -import { appTheme, appTimezone, appVersion, appInst } from 'appConfig' +import { appInst, appTimezone, appVersion, appInst } from 'appConfig' import { Link } from 'react-router-dom' const Yes = () => <CheckIcon color="success" /> @@ -139,7 +139,7 @@ export const Debug = () => { ['Version', appVersion], ['Timezone', appTimezone], ['Language', i18n.language], - ['Theme', appTheme], + ['Theme', appInst], ['Institution', appInst], ['API reachable?', apiHealth === 'yes' ? <Yes /> : apiHealth], ['Authenticated?', isAuthenticated ? <Yes /> : <No />], diff --git a/frontend/src/components/logobars/LogoBar.tsx b/frontend/src/components/logobars/LogoBar.tsx index 2af512f3..7d1f0fa9 100644 --- a/frontend/src/components/logobars/LogoBar.tsx +++ b/frontend/src/components/logobars/LogoBar.tsx @@ -1,11 +1,9 @@ -import React from 'react' -import { appTheme } from 'appConfig' +import { appInst } from 'appConfig' import UiOLogoBar from './UiO' import UiBLogoBar from './UiB' - function LogoBar() { - switch (appTheme) { + switch (appInst) { case 'uio': return <UiOLogoBar /> case 'uib': @@ -15,4 +13,4 @@ function LogoBar() { } } -export default LogoBar \ No newline at end of file +export default LogoBar diff --git a/frontend/src/themes/index.ts b/frontend/src/themes/index.ts index 08fe70e7..ba7369c0 100644 --- a/frontend/src/themes/index.ts +++ b/frontend/src/themes/index.ts @@ -5,7 +5,7 @@ import uibTheme from 'themes/uib' import uioTheme from 'themes/uio' import mainTheme from 'themes/main' -import { appTheme } from 'appConfig' +import { appInst } from 'appConfig' declare module '@mui/material/styles' { interface Theme { @@ -33,13 +33,11 @@ declare module '@mui/material/styles' { export const defaultTheme = createTheme(mainTheme) function getTheme() { - switch (appTheme) { + switch (appInst) { case 'uib': return createTheme(deepmerge(mainTheme, uibTheme)) case 'uio': return createTheme(deepmerge(mainTheme, uioTheme)) - case 'default': - return defaultTheme default: return defaultTheme } -- GitLab