Skip to content

Commit

Permalink
feat(ws): Notebooks 2.0 // Frontend // Workspaces table // Add MUI Su…
Browse files Browse the repository at this point in the history
…pport (#183)

Signed-off-by: Jenny <[email protected]>

apply env var to activate MUI theme

remove masthead toggle, fix padding

add bottom padding

Signed-off-by: Jenny <[email protected]>

apply latest changes from MR and npm run test:fix
  • Loading branch information
jenny-s51 authored Jan 22, 2025
1 parent 2d12989 commit 9479c7b
Show file tree
Hide file tree
Showing 11 changed files with 1,941 additions and 97 deletions.
1,127 changes: 1,051 additions & 76 deletions workspaces/frontend/package-lock.json

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions workspaces/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
},
"devDependencies": {
"@cypress/code-coverage": "^3.13.5",
"@mui/icons-material": "^6.3.1",
"@mui/material": "^6.3.1",
"@mui/types": "^7.2.21",
"@testing-library/cypress": "^10.0.1",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^5.16.5",
Expand Down Expand Up @@ -72,6 +75,8 @@
"react-router-dom": "^6.26.1",
"regenerator-runtime": "^0.13.11",
"rimraf": "^6.0.1",
"sass": "^1.83.1",
"sass-loader": "^16.0.4",
"serve": "^14.2.1",
"style-loader": "^3.3.4",
"svg-url-loader": "^8.0.0",
Expand Down Expand Up @@ -100,6 +105,8 @@
"sirv-cli": "^2.0.2"
},
"optionalDependencies": {
"@emotion/react": "^11.14.0",
"@emotion/styled": "^11.14.0",
"@typescript-eslint/eslint-plugin": "^8.8.1",
"@typescript-eslint/parser": "^8.12.2",
"eslint": "^8.57.0",
Expand Down
24 changes: 18 additions & 6 deletions workspaces/frontend/src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Flex,
Masthead,
MastheadContent,
MastheadMain,
MastheadToggle,
Page,
PageToggleButton,
Expand All @@ -16,16 +17,27 @@ import { NamespaceContextProvider } from './context/NamespaceContextProvider';
import AppRoutes from './AppRoutes';
import NavSidebar from './NavSidebar';
import { NotebookContextProvider } from './context/NotebookContext';
import { isMUITheme, Theme } from './const';

const App: React.FC = () => {
React.useEffect(() => {
// Apply the theme based on the value of STYLE_THEME
if (isMUITheme()) {
document.documentElement.classList.add(Theme.MUI);
} else {
document.documentElement.classList.remove(Theme.MUI);
}
}, []);

const masthead = (
<Masthead>
<MastheadToggle>
<PageToggleButton id="page-nav-toggle" variant="plain" aria-label="Dashboard navigation">
<BarsIcon />
</PageToggleButton>
</MastheadToggle>

<MastheadMain>
<MastheadToggle>
<PageToggleButton id="page-nav-toggle" variant="plain" aria-label="Dashboard navigation">
<BarsIcon />
</PageToggleButton>
</MastheadToggle>
</MastheadMain>
<MastheadContent>
<Flex>
<Title headingLevel="h2" size="3xl">
Expand Down
1 change: 1 addition & 0 deletions workspaces/frontend/src/app/AppRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Route, Routes } from 'react-router-dom';
import { NotFound } from './pages/notFound/NotFound';
import { Debug } from './pages/Debug/Debug';
import { Workspaces } from './pages/Workspaces/Workspaces';
import '~/shared/style/MUI-theme.scss';

export const isNavDataGroup = (navItem: NavDataItem): navItem is NavDataGroup =>
'children' in navItem;
Expand Down
9 changes: 9 additions & 0 deletions workspaces/frontend/src/app/NavSidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import { NavLink } from 'react-router-dom';
import {
Brand,
Nav,
NavExpandable,
NavItem,
Expand Down Expand Up @@ -42,11 +43,19 @@ const NavGroup: React.FC<{ item: NavDataGroup }> = ({ item }) => {

const NavSidebar: React.FC = () => {
const navData = useNavData();

return (
<PageSidebar>
<PageSidebarBody>
<Nav id="nav-primary-simple">
<NavList id="nav-list-simple">
<NavItem>
<Brand
className="kubeflow_brand"
src={`${window.location.origin}/images/logo.svg`}
alt="Kubeflow Logo"
/>
</NavItem>
{navData.map((item) =>
isNavDataGroup(item) ? (
<NavGroup key={item.label} item={item} />
Expand Down
9 changes: 9 additions & 0 deletions workspaces/frontend/src/app/const.ts
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
export const BFF_API_VERSION = 'v1';

export enum Theme {
Default = 'default-theme',
MUI = 'mui-theme',
// Future themes can be added here
}

export const isMUITheme = (): boolean => STYLE_THEME === Theme.MUI;
const STYLE_THEME = process.env.STYLE_THEME || Theme.MUI;
9 changes: 6 additions & 3 deletions workspaces/frontend/src/app/pages/Workspaces/Workspaces.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
TimestampTooltipVariant,
Timestamp,
Label,
Title,
PaginationVariant,
Pagination,
Button,
Expand Down Expand Up @@ -372,8 +371,11 @@ export const Workspaces: React.FunctionComponent = () => {
<DrawerContent panelContent={workspaceDetailsContent}>
<DrawerContentBody>
<PageSection isFilled>
<Title headingLevel="h1">Kubeflow Workspaces</Title>
<p>View your existing workspaces or create new workspaces.</p>
<Content>
<h1>Kubeflow Workspaces</h1>
<p>View your existing workspaces or create new workspaces.</p>
</Content>
<br />
<Content style={{ display: 'flex', alignItems: 'flex-start', columnGap: '20px' }}>
<Filter id="filter-workspaces" onFilter={onFilter} columnNames={filterableColumns} />
<Button variant="primary" ouiaId="Primary">
Expand Down Expand Up @@ -443,6 +445,7 @@ export const Workspaces: React.FunctionComponent = () => {
perPage={perPage}
page={page}
variant={PaginationVariant.bottom}
isCompact
onSetPage={onSetPage}
onPerPageSelect={onPerPageSelect}
/>
Expand Down
20 changes: 10 additions & 10 deletions workspaces/frontend/src/images/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions workspaces/frontend/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<html lang="en-US">

<head>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap" rel="stylesheet">
<meta charset="utf-8">
<title>Kubeflow Workspaces</title>
<meta content="Kubeflow Workspaces" id="appName" name="application-name">
Expand Down
8 changes: 6 additions & 2 deletions workspaces/frontend/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import { BrowserRouter as Router } from 'react-router-dom';
import { ThemeProvider, createTheme } from '@mui/material/styles';
import App from './app/App';

const root = ReactDOM.createRoot(document.getElementById('root'));
const theme = createTheme({ cssVariables: true });
const root = ReactDOM.createRoot(document.getElementById('root')!);

root.render(
<React.StrictMode>
<Router>
<App />
<ThemeProvider theme={theme}>
<App />
</ThemeProvider>
</Router>
</React.StrictMode>,
);
Loading

0 comments on commit 9479c7b

Please sign in to comment.