Skip to content

Commit

Permalink
remove all dependencies on argo-ui/v2
Browse files Browse the repository at this point in the history
Signed-off-by: Remington Breeze <[email protected]>
  • Loading branch information
rbreeze authored and zachaller committed Apr 21, 2023
1 parent ebb8ba4 commit 1b22985
Show file tree
Hide file tree
Showing 12 changed files with 353 additions and 256 deletions.
55 changes: 26 additions & 29 deletions ui/src/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {ThemeDiv, ThemeProvider} from 'argo-ui/v2';
import {Header} from './components/header/header';
import {createBrowserHistory} from 'history';
import * as React from 'react';
Expand All @@ -11,7 +10,7 @@ import {Rollout} from './components/rollout/rollout';
import {RolloutsList} from './components/rollouts-list/rollouts-list';
import {Shortcut, Shortcuts} from './components/shortcuts/shortcuts';
import {ConfigProvider} from 'antd';
import { theme } from '../config/theme';
import {theme} from '../config/theme';

const bases = document.getElementsByTagName('base');
const base = bases.length > 0 ? bases[0].getAttribute('href') || '/' : '/';
Expand All @@ -21,7 +20,7 @@ const Page = (props: {path: string; component: React.ReactNode; exact?: boolean;
const [showShortcuts, setShowShortcuts] = React.useState(false);
return (
<ConfigProvider theme={theme}>
<ThemeDiv className='rollouts'>
<div className='rollouts'>
{showShortcuts && (
<Modal hide={() => setShowShortcuts(false)}>
<Shortcuts shortcuts={props.shortcuts} />
Expand All @@ -41,7 +40,7 @@ const Page = (props: {path: string; component: React.ReactNode; exact?: boolean;
{props.component}
</React.Fragment>
</Route>
</ThemeDiv>
</div>
</ConfigProvider>
);
};
Expand Down Expand Up @@ -77,31 +76,29 @@ const App = () => {
};

return (
<ThemeProvider>
{namespace && (
<NamespaceContext.Provider value={{namespace, availableNamespaces}}>
<KeybindingProvider>
<Router history={history}>
<Switch>
<Page
exact
path='/:namespace?'
component={<RolloutsList />}
shortcuts={[
{key: '/', description: 'Search'},
{key: 'TAB', description: 'Search, navigate search items'},
{key: ['fa-arrow-left', 'fa-arrow-right', 'fa-arrow-up', 'fa-arrow-down'], description: 'Navigate rollouts list', icon: true},
{key: ['SHIFT', 'H'], description: 'Show help menu', combo: true},
]}
changeNamespace={changeNamespace}
/>
<Page path='/rollout/:namespace?/:name' component={<Rollout />} changeNamespace={changeNamespace} />
</Switch>
</Router>
</KeybindingProvider>
</NamespaceContext.Provider>
)}
</ThemeProvider>
namespace && (
<NamespaceContext.Provider value={{namespace, availableNamespaces}}>
<KeybindingProvider>
<Router history={history}>
<Switch>
<Page
exact
path='/:namespace?'
component={<RolloutsList />}
shortcuts={[
{key: '/', description: 'Search'},
{key: 'TAB', description: 'Search, navigate search items'},
{key: ['fa-arrow-left', 'fa-arrow-right', 'fa-arrow-up', 'fa-arrow-down'], description: 'Navigate rollouts list', icon: true},
{key: ['SHIFT', 'H'], description: 'Show help menu', combo: true},
]}
changeNamespace={changeNamespace}
/>
<Page path='/rollout/:namespace?/:name' component={<Rollout />} changeNamespace={changeNamespace} />
</Switch>
</Router>
</KeybindingProvider>
</NamespaceContext.Provider>
)
);
};

Expand Down
4 changes: 2 additions & 2 deletions ui/src/app/components/ellipsis-middle/ellipsis-middle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import * as React from 'react';
import {Typography} from 'antd';

const {Text} = Typography;
export const EllipsisMiddle: React.FC<{suffixCount: number; children: string}> = ({suffixCount, children}) => {
export const EllipsisMiddle: React.FC<{suffixCount: number; children: string; style: React.CSSProperties}> = ({suffixCount, children, style}) => {
const start = children.slice(0, children.length - suffixCount).trim();
const suffix = children.slice(-suffixCount).trim();
return (
<Text style={{maxWidth: '100%'}} ellipsis={{suffix}}>
<Text style={{...style, maxWidth: '100%'}} ellipsis={{suffix}}>
{start}
</Text>
);
Expand Down
19 changes: 3 additions & 16 deletions ui/src/app/components/header/header.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
import * as React from 'react';

import {Theme, ThemeContext, ThemeDiv} from 'argo-ui/v2';
import {useParams} from 'react-router';
import {NamespaceContext, RolloutAPIContext} from '../../shared/context/api';

import './header.scss';
import {Link, useHistory} from 'react-router-dom';
import {AutoComplete, Button, Input, Tooltip} from 'antd';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import {faBook, faKeyboard, faMoon, faSun} from '@fortawesome/free-solid-svg-icons';

export const ThemeToggle = () => {
const dmCtx = React.useContext(ThemeContext);
const isDark = dmCtx.theme === Theme.Dark;
const icon = isDark ? faSun : faMoon;
return <Button onClick={() => dmCtx.set(isDark ? Theme.Light : Theme.Dark)} icon={<FontAwesomeIcon icon={icon} />} />;
};
import {faBook, faKeyboard} from '@fortawesome/free-solid-svg-icons';

const Logo = () => <img src='assets/images/argo-icon-color-square.png' style={{width: '37px', height: '37px', margin: '0 12px'}} alt='Argo Logo' />;

Expand Down Expand Up @@ -61,12 +53,7 @@ export const Header = (props: {pageHasShortcuts: boolean; changeNamespace: (val:
<Button icon={<FontAwesomeIcon icon={faBook} />} style={{marginRight: '10px'}} />
</a>
</Tooltip>
<span style={{marginRight: '7px'}}>
<Tooltip title='Toggle Dark Mode'>
<ThemeToggle />
</Tooltip>
</span>
<ThemeDiv className='rollouts-header__namespace'>
<div className='rollouts-header__namespace'>
<div className='rollouts-header__label'>NAMESPACE</div>
{(namespaceInfo.availableNamespaces || []).length == 0 ? (
<Input value={namespaceInfo.namespace} disabled={true} style={{color: 'black', cursor: 'default', backgroundColor: 'white'}} />
Expand All @@ -85,7 +72,7 @@ export const Header = (props: {pageHasShortcuts: boolean; changeNamespace: (val:
value={nsInput}
/>
)}
</ThemeDiv>
</div>
</div>
</header>
);
Expand Down
80 changes: 80 additions & 0 deletions ui/src/app/components/info-item/info-item.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
@import 'node_modules/argo-ui/v2/styles/colors';

.info-item {
background-color: $argo-color-gray-4;
border-radius: 3px;
border: 1px solid $argo-color-gray-5;
padding: 5px 7px;
margin-right: 5px;
color: $argo-color-gray-8;
display: flex;
align-items: center;
min-width: 0;

&--lightweight {
border: none;
background: none;
font-weight: 500;
padding-left: 0;
padding-right: 0;
}

&--dark {
background-color: $fog;
border: 1px solid $silver-lining;
color: $dull-shine;
}

&--colored {
background-color: $sherbert;
border: 1px solid $sherbert;
color: white;
}

&--dark#{&}--colored {
background-color: $spray-tan;
border: 1px solid $sherbert;
color: white;
}

&--canary {
background-color: $canary;
border: 1px solid $canary;
color: $space;
}

&--bluegreen {
background-color: $sea;
border: 1px solid $sea;
color: white;
}

&--monospace {
font-family: ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono', 'Roboto Mono', 'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro', 'Fira Mono',
'Droid Sans Mono', 'Courier New', monospace;
font-size: 14px;
}

&--row {
display: flex;
align-items: center;
flex-grow: 1;
label {
margin-right: auto;
padding-right: 5px;
}
.info-item {
margin: 0.25em 0;
margin-left: 5px;
}

&__container {
margin-left: auto;
display: flex;
min-width: 0;
padding-left: 25px;
flex-wrap: wrap;
justify-content: flex-end;
}
}
}
61 changes: 61 additions & 0 deletions ui/src/app/components/info-item/info-item.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import * as React from 'react';
import './info-item.scss';
import { Tooltip } from 'antd';

export enum InfoItemKind {
Default = 'default',
Colored = 'colored',
Monospace = 'monospace',
Canary = 'canary',
BlueGreen = 'bluegreen',
}

export interface InfoItemProps {
content?: string;
icon?: string;
style?: React.CSSProperties;
kind?: InfoItemKind;
truncate?: boolean;
lightweight?: boolean;
}

/**
* Displays a small piece encapsulated piece of data
*/
export const InfoItem = (props: InfoItemProps) => {
const truncateStyle = props.truncate ? {overflow: 'hidden', whiteSpace: 'nowrap', textOverflow: 'ellipsis'} : {};
const item = (
<div className={`info-item${props.kind ? ` info-item--${props.kind}` : ''} ${props.lightweight ? 'info-item--lightweight' : ''}`} style={props.style}>
{props.icon && (
<span style={props.content && {marginRight: '5px'}}>
<i className={`fa ${props.icon}`} />
</span>
)}
<div style={truncateStyle as React.CSSProperties}>{props.content}</div>
</div>
);
return props.truncate ? <Tooltip title={props.content}>{item}</Tooltip> : item;
};

/**
* Displays a right justified InfoItem (or multiple InfoItems) and a left justfied label
*/
export const InfoItemRow = (props: {label: string | React.ReactNode; items?: InfoItemProps | InfoItemProps[]; lightweight?: boolean}) => {
let {label, items} = props;
let itemComponents = null;
if (!Array.isArray(items)) {
items = [items];
}
itemComponents = items.map((c, i) => <InfoItem key={`${c} ${i}`} {...c} lightweight={c.lightweight === undefined ? props.lightweight : c.lightweight} />);

return (
<div className='info-item--row'>
{props.label && (
<div>
<label>{label}</label>
</div>
)}
{props.items && <div className='info-item--row__container'>{itemComponents}</div>}
</div>
);
};
5 changes: 1 addition & 4 deletions ui/src/app/components/pods/pods.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ $POD_SIZE: 30px;
font-size: 16px;
font-weight: 500;
display: flex;
max-width: 100%;
align-items: center;
&__tags {
margin-left: auto;
Expand All @@ -25,10 +26,6 @@ $POD_SIZE: 30px;
.pod-icon {
margin: 3px;
}
&--dark {
border-color: $silver-lining;
background-color: $space;
}
}
}

Expand Down
Loading

0 comments on commit 1b22985

Please sign in to comment.