feat: Conditionally render masthead on Production and Standalone modes (#516)
Signed-off-by: Charles Thao <cthao@redhat.com>
This commit is contained in:
parent
ede4708f1a
commit
03c14dd2d7
|
|
@ -2,11 +2,14 @@
|
||||||
|
|
||||||
const { merge } = require('webpack-merge');
|
const { merge } = require('webpack-merge');
|
||||||
const common = require('./webpack.common.js');
|
const common = require('./webpack.common.js');
|
||||||
|
const { EnvironmentPlugin } = require('webpack');
|
||||||
const { stylePaths } = require('./stylePaths');
|
const { stylePaths } = require('./stylePaths');
|
||||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||||
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
||||||
const TerserJSPlugin = require('terser-webpack-plugin');
|
const TerserJSPlugin = require('terser-webpack-plugin');
|
||||||
|
|
||||||
|
const PRODUCTION = process.env.PRODUCTION || 'false';
|
||||||
|
|
||||||
module.exports = merge(common('production'), {
|
module.exports = merge(common('production'), {
|
||||||
mode: 'production',
|
mode: 'production',
|
||||||
devtool: 'source-map',
|
devtool: 'source-map',
|
||||||
|
|
@ -25,6 +28,9 @@ module.exports = merge(common('production'), {
|
||||||
filename: '[name].css',
|
filename: '[name].css',
|
||||||
chunkFilename: '[name].bundle.css',
|
chunkFilename: '[name].bundle.css',
|
||||||
}),
|
}),
|
||||||
|
new EnvironmentPlugin({
|
||||||
|
PRODUCTION,
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
"build:bundle-profile": "webpack --config ./config/webpack.prod.js --profile --json > ./bundle.stats.json",
|
"build:bundle-profile": "webpack --config ./config/webpack.prod.js --profile --json > ./bundle.stats.json",
|
||||||
"build:bundle-analyze": "webpack-bundle-analyzer ./bundle.stats.json",
|
"build:bundle-analyze": "webpack-bundle-analyzer ./bundle.stats.json",
|
||||||
"build:clean": "rimraf ./dist",
|
"build:clean": "rimraf ./dist",
|
||||||
"build:prod": "webpack --config ./config/webpack.prod.js",
|
"build:prod": "cross-env PRODUCTION=true webpack --config ./config/webpack.prod.js",
|
||||||
"generate:api": "./scripts/generate-api.sh && npm run prettier",
|
"generate:api": "./scripts/generate-api.sh && npm run prettier",
|
||||||
"start:dev": "cross-env STYLE_THEME=$npm_config_theme webpack serve --hot --color --config ./config/webpack.dev.js",
|
"start:dev": "cross-env STYLE_THEME=$npm_config_theme webpack serve --hot --color --config ./config/webpack.dev.js",
|
||||||
"start:dev:mock": "cross-env MOCK_API_ENABLED=true STYLE_THEME=$npm_config_theme npm run start:dev",
|
"start:dev:mock": "cross-env MOCK_API_ENABLED=true STYLE_THEME=$npm_config_theme npm run start:dev",
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,11 @@ import {
|
||||||
MastheadMain,
|
MastheadMain,
|
||||||
MastheadToggle,
|
MastheadToggle,
|
||||||
} from '@patternfly/react-core/dist/esm/components/Masthead';
|
} from '@patternfly/react-core/dist/esm/components/Masthead';
|
||||||
import { Page, PageToggleButton } from '@patternfly/react-core/dist/esm/components/Page';
|
import {
|
||||||
|
Page,
|
||||||
|
PageSidebar,
|
||||||
|
PageToggleButton,
|
||||||
|
} from '@patternfly/react-core/dist/esm/components/Page';
|
||||||
import { Title } from '@patternfly/react-core/dist/esm/components/Title';
|
import { Title } from '@patternfly/react-core/dist/esm/components/Title';
|
||||||
import { BarsIcon } from '@patternfly/react-icons/dist/esm/icons/bars-icon';
|
import { BarsIcon } from '@patternfly/react-icons/dist/esm/icons/bars-icon';
|
||||||
import ErrorBoundary from '~/app/error/ErrorBoundary';
|
import ErrorBoundary from '~/app/error/ErrorBoundary';
|
||||||
|
|
@ -25,6 +29,8 @@ import { NotebookContextProvider } from './context/NotebookContext';
|
||||||
import { isMUITheme, Theme } from './const';
|
import { isMUITheme, Theme } from './const';
|
||||||
import { BrowserStorageContextProvider } from './context/BrowserStorageContext';
|
import { BrowserStorageContextProvider } from './context/BrowserStorageContext';
|
||||||
|
|
||||||
|
const isStandalone = process.env.PRODUCTION !== 'true';
|
||||||
|
|
||||||
const App: React.FC = () => {
|
const App: React.FC = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Apply the theme based on the value of STYLE_THEME
|
// Apply the theme based on the value of STYLE_THEME
|
||||||
|
|
@ -43,14 +49,12 @@ const App: React.FC = () => {
|
||||||
<BarsIcon />
|
<BarsIcon />
|
||||||
</PageToggleButton>
|
</PageToggleButton>
|
||||||
</MastheadToggle>
|
</MastheadToggle>
|
||||||
{!isMUITheme() ? (
|
{!isMUITheme() && (
|
||||||
<MastheadBrand>
|
<MastheadBrand>
|
||||||
<MastheadLogo component="a">
|
<MastheadLogo component="a">
|
||||||
<Brand src={logoDarkTheme} alt="Kubeflow" heights={{ default: '36px' }} />
|
<Brand src={logoDarkTheme} alt="Kubeflow" heights={{ default: '36px' }} />
|
||||||
</MastheadLogo>
|
</MastheadLogo>
|
||||||
</MastheadBrand>
|
</MastheadBrand>
|
||||||
) : (
|
|
||||||
''
|
|
||||||
)}
|
)}
|
||||||
</MastheadMain>
|
</MastheadMain>
|
||||||
<MastheadContent>
|
<MastheadContent>
|
||||||
|
|
@ -63,6 +67,7 @@ const App: React.FC = () => {
|
||||||
</MastheadContent>
|
</MastheadContent>
|
||||||
</Masthead>
|
</Masthead>
|
||||||
);
|
);
|
||||||
|
const sidebar = <PageSidebar isSidebarOpen={false} />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ErrorBoundary>
|
<ErrorBoundary>
|
||||||
|
|
@ -71,10 +76,11 @@ const App: React.FC = () => {
|
||||||
<NamespaceContextProvider>
|
<NamespaceContextProvider>
|
||||||
<Page
|
<Page
|
||||||
mainContainerId="primary-app-container"
|
mainContainerId="primary-app-container"
|
||||||
masthead={masthead}
|
masthead={isStandalone ? masthead : ''}
|
||||||
isContentFilled
|
isContentFilled
|
||||||
isManagedSidebar
|
sidebar={isStandalone ? <NavSidebar /> : sidebar}
|
||||||
sidebar={<NavSidebar />}
|
isManagedSidebar={isStandalone}
|
||||||
|
className={isStandalone ? '' : 'embedded'}
|
||||||
>
|
>
|
||||||
<AppRoutes />
|
<AppRoutes />
|
||||||
</Page>
|
</Page>
|
||||||
|
|
|
||||||
|
|
@ -887,6 +887,12 @@
|
||||||
/* Move content area below the app bar */
|
/* Move content area below the app bar */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mui-theme .pf-v6-c-page.embedded {
|
||||||
|
.pf-v6-c-page__main-container {
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Hide Masthead Toggle by default */
|
/* Hide Masthead Toggle by default */
|
||||||
.mui-theme .pf-v6-c-masthead__toggle {
|
.mui-theme .pf-v6-c-masthead__toggle {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue