Skip to content

Commit

Permalink
feat: Add button that links to docs to header (#1086)
Browse files Browse the repository at this point in the history
Signed-off-by: Remington Breeze <[email protected]>
  • Loading branch information
rbreeze authored Apr 14, 2021
1 parent 74e1f0f commit 3a2936e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ Then visit `localhost:3100` to view the user interface.

## Individual Rollout view

![Rollouts List](dashboard/rollouts-ui.png)
![Rollouts List](dashboard/rollout-ui.png)
4 changes: 4 additions & 0 deletions ui/src/app/components/action-button/action-button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
@mixin dark-background {
border: 1px solid $silver-lining;
background-color: $fog;
color: $silver-lining;
}

&--dark > &__background {
Expand All @@ -31,6 +32,7 @@
border-radius: 20px;
border: 1px solid $argo-color-gray-6;
background-color: $argo-color-gray-6;
color: $argo-color-gray-6;

&--dark {
@include dark-background;
Expand All @@ -41,11 +43,13 @@
&--selected > &__background {
background-color: $sherbert;
border-color: $sherbert;
color: $sherbert;
transform: scale(1.02);
}

&--dark:hover > &__background,
&--selected#{&}--dark > &__background {
color: $sherbert;
background-color: $spray-tan;
border-color: $sherbert;
}
Expand Down
22 changes: 17 additions & 5 deletions ui/src/app/components/header/header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {faQuestion} from '@fortawesome/free-solid-svg-icons';
import {faBook, faKeyboard} from '@fortawesome/free-solid-svg-icons';
import * as React from 'react';
import {Link, useParams} from 'react-router-dom';
import {RolloutNamespaceInfo, RolloutServiceApi} from '../../../models/rollout/generated';
Expand All @@ -7,6 +7,7 @@ import {useServerData} from '../../shared/utils/utils';
import {ActionButton} from '../action-button/action-button';
import {InfoItemRow} from '../info-item/info-item';
import {ThemeToggle} from '../theme-toggle/theme-toggle';
import {Tooltip} from '../tooltip/tooltip';

import './header.scss';

Expand Down Expand Up @@ -36,7 +37,7 @@ const Brand = (props: {path?: string}) => {

export const Header = (props: {pageHasShortcuts: boolean; showHelp: () => void}) => {
const getNs = React.useCallback(() => new RolloutServiceApi().rolloutServiceGetNamespace(), []);
const nsData = useServerData<RolloutNamespaceInfo>(getNs);
const namespace = useServerData<RolloutNamespaceInfo>(getNs).namespace || 'Unknown';
const {name} = useParams<{name: string}>();
const api = React.useContext(RolloutAPIContext);
const [version, setVersion] = React.useState('v?');
Expand All @@ -51,11 +52,22 @@ export const Header = (props: {pageHasShortcuts: boolean; showHelp: () => void})
<header className='rollouts-header'>
<Brand path={name} />
<div className='rollouts-header__info'>
{props.pageHasShortcuts && <ActionButton icon={faQuestion} action={props.showHelp} dark />}
{props.pageHasShortcuts && (
<Tooltip content='Keyboard Shortcuts' inverted>
<ActionButton icon={faKeyboard} action={props.showHelp} dark />
</Tooltip>
)}
<Tooltip content='Documentation' inverted>
<a href='https://argoproj.github.io/argo-rollouts/' target='_blank' rel='noreferrer'>
<ActionButton icon={faBook} dark />
</a>
</Tooltip>
<span style={{marginRight: '7px'}}>
<ThemeToggle />
<Tooltip content='Toggle Dark Mode' inverted>
<ThemeToggle />
</Tooltip>
</span>
<InfoItemRow label={'NS:'} items={{content: nsData.namespace}} />
<InfoItemRow label={'NS:'} items={{content: namespace}} />
<div className='rollouts-header__version'>{version}</div>
</div>
</header>
Expand Down
6 changes: 6 additions & 0 deletions ui/src/app/components/tooltip/tooltip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@
background-color: $slate;
white-space: nowrap;
color: white;
border: 1px solid $slate;
&--dark {
border: 1px solid $dull-shine;
}

&--inverted {
top: 100%;
bottom: auto;
}
}
4 changes: 2 additions & 2 deletions ui/src/app/components/tooltip/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ export const useHover = (): [React.MutableRefObject<any>, boolean] => {
return [ref, show];
};

export const Tooltip = (props: {content: React.ReactNode | string} & React.PropsWithRef<any>) => {
export const Tooltip = (props: {content: React.ReactNode | string; inverted?: boolean} & React.PropsWithRef<any>) => {
const [tooltip, showTooltip] = useHover();
return (
<div style={{position: 'relative'}}>
<ThemeDiv hidden={!showTooltip} className='tooltip'>
<ThemeDiv hidden={!showTooltip} className={`tooltip ${props.inverted ? 'tooltip--inverted' : ''}`}>
{props.content}
</ThemeDiv>
<div ref={tooltip}>{props.children}</div>
Expand Down

0 comments on commit 3a2936e

Please sign in to comment.