Skip to content

Commit 03c14dd

Browse files
authored
feat: Conditionally render masthead on Production and Standalone modes (#516)
Signed-off-by: Charles Thao <[email protected]>
1 parent ede4708 commit 03c14dd

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

workspaces/frontend/config/webpack.prod.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
const { merge } = require('webpack-merge');
44
const common = require('./webpack.common.js');
5+
const { EnvironmentPlugin } = require('webpack');
56
const { stylePaths } = require('./stylePaths');
67
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
78
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
89
const TerserJSPlugin = require('terser-webpack-plugin');
910

11+
const PRODUCTION = process.env.PRODUCTION || 'false';
12+
1013
module.exports = merge(common('production'), {
1114
mode: 'production',
1215
devtool: 'source-map',
@@ -25,6 +28,9 @@ module.exports = merge(common('production'), {
2528
filename: '[name].css',
2629
chunkFilename: '[name].bundle.css',
2730
}),
31+
new EnvironmentPlugin({
32+
PRODUCTION,
33+
}),
2834
],
2935
module: {
3036
rules: [

workspaces/frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"build:bundle-profile": "webpack --config ./config/webpack.prod.js --profile --json > ./bundle.stats.json",
1919
"build:bundle-analyze": "webpack-bundle-analyzer ./bundle.stats.json",
2020
"build:clean": "rimraf ./dist",
21-
"build:prod": "webpack --config ./config/webpack.prod.js",
21+
"build:prod": "cross-env PRODUCTION=true webpack --config ./config/webpack.prod.js",
2222
"generate:api": "./scripts/generate-api.sh && npm run prettier",
2323
"start:dev": "cross-env STYLE_THEME=$npm_config_theme webpack serve --hot --color --config ./config/webpack.dev.js",
2424
"start:dev:mock": "cross-env MOCK_API_ENABLED=true STYLE_THEME=$npm_config_theme npm run start:dev",

workspaces/frontend/src/app/App.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ import {
1212
MastheadMain,
1313
MastheadToggle,
1414
} from '@patternfly/react-core/dist/esm/components/Masthead';
15-
import { Page, PageToggleButton } from '@patternfly/react-core/dist/esm/components/Page';
15+
import {
16+
Page,
17+
PageSidebar,
18+
PageToggleButton,
19+
} from '@patternfly/react-core/dist/esm/components/Page';
1620
import { Title } from '@patternfly/react-core/dist/esm/components/Title';
1721
import { BarsIcon } from '@patternfly/react-icons/dist/esm/icons/bars-icon';
1822
import ErrorBoundary from '~/app/error/ErrorBoundary';
@@ -25,6 +29,8 @@ import { NotebookContextProvider } from './context/NotebookContext';
2529
import { isMUITheme, Theme } from './const';
2630
import { BrowserStorageContextProvider } from './context/BrowserStorageContext';
2731

32+
const isStandalone = process.env.PRODUCTION !== 'true';
33+
2834
const App: React.FC = () => {
2935
useEffect(() => {
3036
// Apply the theme based on the value of STYLE_THEME
@@ -43,14 +49,12 @@ const App: React.FC = () => {
4349
<BarsIcon />
4450
</PageToggleButton>
4551
</MastheadToggle>
46-
{!isMUITheme() ? (
52+
{!isMUITheme() && (
4753
<MastheadBrand>
4854
<MastheadLogo component="a">
4955
<Brand src={logoDarkTheme} alt="Kubeflow" heights={{ default: '36px' }} />
5056
</MastheadLogo>
5157
</MastheadBrand>
52-
) : (
53-
''
5458
)}
5559
</MastheadMain>
5660
<MastheadContent>
@@ -63,6 +67,7 @@ const App: React.FC = () => {
6367
</MastheadContent>
6468
</Masthead>
6569
);
70+
const sidebar = <PageSidebar isSidebarOpen={false} />;
6671

6772
return (
6873
<ErrorBoundary>
@@ -71,10 +76,11 @@ const App: React.FC = () => {
7176
<NamespaceContextProvider>
7277
<Page
7378
mainContainerId="primary-app-container"
74-
masthead={masthead}
79+
masthead={isStandalone ? masthead : ''}
7580
isContentFilled
76-
isManagedSidebar
77-
sidebar={<NavSidebar />}
81+
sidebar={isStandalone ? <NavSidebar /> : sidebar}
82+
isManagedSidebar={isStandalone}
83+
className={isStandalone ? '' : 'embedded'}
7884
>
7985
<AppRoutes />
8086
</Page>

workspaces/frontend/src/shared/style/MUI-theme.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,12 @@
887887
/* Move content area below the app bar */
888888
}
889889

890+
.mui-theme .pf-v6-c-page.embedded {
891+
.pf-v6-c-page__main-container {
892+
margin: 0px;
893+
}
894+
}
895+
890896
/* Hide Masthead Toggle by default */
891897
.mui-theme .pf-v6-c-masthead__toggle {
892898
display: none;

0 commit comments

Comments
 (0)