From 311be95e28f74b4be321170410b5b9714cfec6b2 Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Wed, 14 Apr 2021 19:07:30 -0500 Subject: [PATCH 1/6] GH-191: Get CMS theme class and add to body --- client/src/components/Workbench/index.js | 14 ++++++++++++++ client/src/utils/cmsSettings.js | 14 ++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 client/src/utils/cmsSettings.js diff --git a/client/src/components/Workbench/index.js b/client/src/components/Workbench/index.js index b75a123f2..c43111053 100644 --- a/client/src/components/Workbench/index.js +++ b/client/src/components/Workbench/index.js @@ -2,6 +2,9 @@ import { hot } from 'react-hot-loader/root'; import React, { useEffect } from 'react'; import { useDispatch } from 'react-redux'; import { BrowserRouter as Router, Route } from 'react-router-dom'; + +import getCMSSettings from 'utils/cmsSettings'; + import Workbench from './Workbench'; import * as ROUTES from '../../constants/routes'; import TicketStandaloneCreate from '../Tickets/TicketStandaloneCreate'; @@ -15,6 +18,17 @@ function AppRouter() { dispatch({ type: 'FETCH_WELCOME' }); dispatch({ type: 'FETCH_AUTHENTICATED_USER' }); }, []); + + const cmsSettings = getCMSSettings(); + const bodyClassName = cmsSettings.themeClassName; + useEffect(() => { + if (bodyClassName) document.body.classList.add(bodyClassName); + + return function cleanup() { + if (bodyClassName) document.body.classList.remove(bodyClassName); + }; + }, [bodyClassName]); + return ( diff --git a/client/src/utils/cmsSettings.js b/client/src/utils/cmsSettings.js new file mode 100644 index 000000000..85e1f64e3 --- /dev/null +++ b/client/src/utils/cmsSettings.js @@ -0,0 +1,14 @@ +import { fetchUtil } from 'utils/fetchUtil'; + +/** + * Fetch CMS settings + * @async + * @returns {Object.} + */ +async function get() { + const res = await fetchUtil({ url: '/cms/api/settings/' }); + const json = res.response; + return json; +} + +export default get; From 1572a877fc561626065d285e6137c96e41e6bc73 Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Wed, 14 Apr 2021 19:56:43 -0500 Subject: [PATCH 2/6] GH-191: Add CMS theme class to html, not body --- client/src/components/Workbench/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client/src/components/Workbench/index.js b/client/src/components/Workbench/index.js index c43111053..7f3bfcb95 100644 --- a/client/src/components/Workbench/index.js +++ b/client/src/components/Workbench/index.js @@ -20,14 +20,16 @@ function AppRouter() { }, []); const cmsSettings = getCMSSettings(); - const bodyClassName = cmsSettings.themeClassName; + const { themeClassName } = cmsSettings; useEffect(() => { - if (bodyClassName) document.body.classList.add(bodyClassName); + const root = document.documentElement; + + if (themeClassName) root.classList.add(themeClassName); return function cleanup() { - if (bodyClassName) document.body.classList.remove(bodyClassName); + if (themeClassName) root.documentElement.classList.remove(themeClassName); }; - }, [bodyClassName]); + }, [themeClassName]); return ( From 2196c4ad551bda6fab0941d23a46bfb9cacaa17b Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Thu, 15 Apr 2021 13:36:49 -0500 Subject: [PATCH 3/6] GH-191: Use CMS script to add theme class --- client/src/components/Workbench/index.js | 15 --------------- client/src/utils/cmsSettings.js | 14 -------------- server/portal/templates/base.html | 3 ++- 3 files changed, 2 insertions(+), 30 deletions(-) delete mode 100644 client/src/utils/cmsSettings.js diff --git a/client/src/components/Workbench/index.js b/client/src/components/Workbench/index.js index 7f3bfcb95..9a17a0096 100644 --- a/client/src/components/Workbench/index.js +++ b/client/src/components/Workbench/index.js @@ -2,9 +2,6 @@ import { hot } from 'react-hot-loader/root'; import React, { useEffect } from 'react'; import { useDispatch } from 'react-redux'; import { BrowserRouter as Router, Route } from 'react-router-dom'; - -import getCMSSettings from 'utils/cmsSettings'; - import Workbench from './Workbench'; import * as ROUTES from '../../constants/routes'; import TicketStandaloneCreate from '../Tickets/TicketStandaloneCreate'; @@ -19,18 +16,6 @@ function AppRouter() { dispatch({ type: 'FETCH_AUTHENTICATED_USER' }); }, []); - const cmsSettings = getCMSSettings(); - const { themeClassName } = cmsSettings; - useEffect(() => { - const root = document.documentElement; - - if (themeClassName) root.classList.add(themeClassName); - - return function cleanup() { - if (themeClassName) root.documentElement.classList.remove(themeClassName); - }; - }, [themeClassName]); - return ( diff --git a/client/src/utils/cmsSettings.js b/client/src/utils/cmsSettings.js deleted file mode 100644 index 85e1f64e3..000000000 --- a/client/src/utils/cmsSettings.js +++ /dev/null @@ -1,14 +0,0 @@ -import { fetchUtil } from 'utils/fetchUtil'; - -/** - * Fetch CMS settings - * @async - * @returns {Object.} - */ -async function get() { - const res = await fetchUtil({ url: '/cms/api/settings/' }); - const json = res.response; - return json; -} - -export default get; diff --git a/server/portal/templates/base.html b/server/portal/templates/base.html index 3b8504cdf..288aafda5 100644 --- a/server/portal/templates/base.html +++ b/server/portal/templates/base.html @@ -16,8 +16,9 @@ {% block head_extra %}{% endblock %} - + + {# FP-526: Stop using Font Awesome icons; start using Cortal icons #} From a5a791da039ce888bf71813ce35d8c55e87e35cf Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Thu, 15 Apr 2021 13:37:08 -0500 Subject: [PATCH 4/6] GH-191: Update CMS sample secrets --- server/conf/cms/secrets.sample.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/server/conf/cms/secrets.sample.py b/server/conf/cms/secrets.sample.py index 4472049d5..0d3f8fbb3 100644 --- a/server/conf/cms/secrets.sample.py +++ b/server/conf/cms/secrets.sample.py @@ -134,10 +134,22 @@ } ######################## -# BRANDING & LOGOS & FAVICON +# BRANDING SETTINGS ######################## # TODO: GH-59: Use Dict Not Array for Branding Settings +# Visual theme for the CMS + +""" +Optional theming of CMS (certain themes may only affect some elements) + +Usage: +- None (standard theme) +- 'has-dark-logo' +""" + +_THEME = None + # Branding settings for portal and navigation. """ From da7780856ecbf4bf9ca668c62ff4a45c5b2376a1 Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Fri, 16 Apr 2021 09:24:28 -0500 Subject: [PATCH 5/6] GH-191: Noop: Remove new line I had added --- client/src/components/Workbench/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/client/src/components/Workbench/index.js b/client/src/components/Workbench/index.js index 9a17a0096..b75a123f2 100644 --- a/client/src/components/Workbench/index.js +++ b/client/src/components/Workbench/index.js @@ -15,7 +15,6 @@ function AppRouter() { dispatch({ type: 'FETCH_WELCOME' }); dispatch({ type: 'FETCH_AUTHENTICATED_USER' }); }, []); - return ( From d2ec48f41998ca775d144804bc97fbb6354d0098 Mon Sep 17 00:00:00 2001 From: Wesley Bomar Date: Fri, 16 Apr 2021 09:48:54 -0500 Subject: [PATCH 6/6] GH-191: Changge Docs image (should I do this?) --- server/conf/docker/docker-compose-dev.all.debug.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/conf/docker/docker-compose-dev.all.debug.yml b/server/conf/docker/docker-compose-dev.all.debug.yml index ed0525664..af976dc29 100644 --- a/server/conf/docker/docker-compose-dev.all.debug.yml +++ b/server/conf/docker/docker-compose-dev.all.debug.yml @@ -125,7 +125,7 @@ services: container_name: core_portal_workers docs: - image: taccwma/frontera-docs:7af12ae + image: taccwma/frontera-docs:aea2e4f volumes: - ../../docs:/docs/site command: ["mkdocs", "build"]