From 0105739160cf6283e24c0e051a187e281673a533 Mon Sep 17 00:00:00 2001 From: Jan Ackermann Date: Wed, 9 Oct 2024 15:02:21 +0200 Subject: [PATCH] Use idp logo from theme --- .../enhancement-load-idp-logo-from-theme.md | 6 ++ services/idp/src/App.jsx | 57 +++++++++++++++---- .../idp/src/components/ResponsiveScreen.jsx | 9 ++- services/idp/src/infiniteScaleContext.js | 6 ++ 4 files changed, 63 insertions(+), 15 deletions(-) create mode 100644 changelog/unreleased/enhancement-load-idp-logo-from-theme.md create mode 100644 services/idp/src/infiniteScaleContext.js diff --git a/changelog/unreleased/enhancement-load-idp-logo-from-theme.md b/changelog/unreleased/enhancement-load-idp-logo-from-theme.md new file mode 100644 index 000000000..9294e3d4b --- /dev/null +++ b/changelog/unreleased/enhancement-load-idp-logo-from-theme.md @@ -0,0 +1,6 @@ +Enhancement: Load IDP logo from theme + +We now load the IDP logo from the theme file. + +https://github.com/owncloud/ocis/pull/10274 +https://github.com/owncloud/web/issues/11603 diff --git a/services/idp/src/App.jsx b/services/idp/src/App.jsx index 672be4deb..50cc7b55e 100644 --- a/services/idp/src/App.jsx +++ b/services/idp/src/App.jsx @@ -1,31 +1,64 @@ -import React, { ReactElement, Suspense, lazy } from 'react'; +import React, { ReactElement, Suspense, lazy, useState, useEffect } from 'react'; import PropTypes from 'prop-types'; import { MuiThemeProvider } from '@material-ui/core/styles'; -import { defaultTheme as theme } from 'kpop/es/theme'; +import { defaultTheme } from 'kpop/es/theme'; import 'kpop/static/css/base.css'; import 'kpop/static/css/scrollbar.css'; import Spinner from './components/Spinner'; import * as version from './version'; +import { InfiniteScaleContext } from './infiniteScaleContext'; const LazyMain = lazy(() => import(/* webpackChunkName: "identifier-main" */ './Main')); console.info(`Kopano Identifier build version: ${version.build}`); // eslint-disable-line no-console const App = ({ bgImg }): ReactElement => { + const [theme, setTheme] = useState(null); + const [config, setConfig] = useState(null); + const [loading, setLoading] = useState(true); + + useEffect(() => { + const fetchData = async () => { + try { + const configResponse = await fetch('/config.json'); + const configData = await configResponse.json(); + setConfig(configData); + + const themeResponse = await fetch(configData.theme); + const themeData = await themeResponse.json(); + setTheme(themeData); + } catch (error) { + console.error('Error fetching config/theme data:', error); + } finally { + setLoading(false); + } + }; + + fetchData(); + }, []); + + + if (loading) { + return ; + } + + return ( -
- - }> - - - -
+ +
+ + }> + + + +
+
); } diff --git a/services/idp/src/components/ResponsiveScreen.jsx b/services/idp/src/components/ResponsiveScreen.jsx index d5c3218e4..affa68630 100644 --- a/services/idp/src/components/ResponsiveScreen.jsx +++ b/services/idp/src/components/ResponsiveScreen.jsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useContext } from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; @@ -9,6 +9,7 @@ import Grid from '@material-ui/core/Grid'; import DialogContent from '@material-ui/core/DialogContent'; import Loading from './Loading'; +import { InfiniteScaleContext } from "../infiniteScaleContext"; const styles = theme => ({ root: { @@ -44,9 +45,11 @@ const ResponsiveScreen = (props) => { className, ...other } = props; + const { theme } = useContext(InfiniteScaleContext); - const logo = withoutLogo ? null : - ownCloud Logo; + const logo = (theme && !withoutLogo) ? ( + ownCloud Logo + ) : null; const content = loading ? : (withoutPadding ? children : {children}); diff --git a/services/idp/src/infiniteScaleContext.js b/services/idp/src/infiniteScaleContext.js new file mode 100644 index 000000000..d7d6f9fc4 --- /dev/null +++ b/services/idp/src/infiniteScaleContext.js @@ -0,0 +1,6 @@ +import { createContext } from 'react'; + +export const InfiniteScaleContext = createContext({ + theme: null, + config: null, +});