Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use idp logo from theme #10274

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, 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,
});