Skip to content

Commit

Permalink
Use idp logo from theme
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexAndBear committed Oct 9, 2024
1 parent 9e978e2 commit 15864e0
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 15 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/enhancement-load-idp-logo-from-theme.md
Original file line number Diff line number Diff line change
@@ -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
57 changes: 45 additions & 12 deletions services/idp/src/App.jsx
Original file line number Diff line number Diff line change
@@ -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 <Spinner />;
}


return (
<div
className='oc-login-bg'
style={{ backgroundImage: bgImg ? `url(${bgImg})` : undefined }}
>
<MuiThemeProvider theme={theme}>
<Suspense fallback={<Spinner/>}>
<LazyMain/>
</Suspense>
</MuiThemeProvider>
</div>
<InfiniteScaleContext.Provider value={{ theme: theme, config: config }}>
<div
className='oc-login-bg'
style={{ backgroundImage: bgImg ? `url(${bgImg})` : undefined }}
>
<MuiThemeProvider theme={defaultTheme}>
<Suspense fallback={<Spinner />}>
<LazyMain />
</Suspense>
</MuiThemeProvider>
</div>
</InfiniteScaleContext.Provider>
);
}

Expand Down
9 changes: 6 additions & 3 deletions services/idp/src/components/ResponsiveScreen.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';

Expand All @@ -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: {
Expand Down Expand Up @@ -44,9 +45,11 @@ const ResponsiveScreen = (props) => {
className,
...other
} = props;
const { theme } = useContext(InfiniteScaleContext);

const logo = withoutLogo ? null :
<img src={process.env.PUBLIC_URL + '/static/logo.svg'} className="oc-logo" alt="ownCloud Logo"/>;
const logo = (theme && !withoutLogo) ? (
<img src={'/' + theme.common?.logo} className="oc-logo" alt="ownCloud Logo"/>
) : null;

const content = loading ? <Loading/> : (withoutPadding ? children : <DialogContent>{children}</DialogContent>);

Expand Down
6 changes: 6 additions & 0 deletions services/idp/src/infiniteScaleContext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { createContext } from 'react';

export const InfiniteScaleContext = createContext({
theme: null,
config: null,
});

0 comments on commit 15864e0

Please sign in to comment.