Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate UI of toolbars for AllRunsList and ExperimentList #124

Merged
merged 2 commits into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions frontend/src/components/SideNav.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ describe('SideNav', () => {
expect(tree).toMatchSnapshot();
});

it('renders experiments as active page', () => {
const tree = shallow(<SideNav page={RoutePage.EXPERIMENTS} {...routerProps} />);
it('renders Pipelines as active when on PipelineDetails page', () => {
const tree = shallow(<SideNav page={RoutePage.PIPELINE_DETAILS} {...routerProps} />);
expect(tree).toMatchSnapshot();
});

it('renders Pipelines as active when on PipelineDetails page', () => {
const tree = shallow(<SideNav page={RoutePage.PIPELINE_DETAILS} {...routerProps} />);
it('renders experiments as active page', () => {
const tree = shallow(<SideNav page={RoutePage.EXPERIMENTS} {...routerProps} />);
expect(tree).toMatchSnapshot();
});

Expand All @@ -63,11 +63,36 @@ describe('SideNav', () => {
expect(tree).toMatchSnapshot();
});

it('renders nothing as active page', () => {
it('renders experiments as active page when on NewExperiment page', () => {
const tree = shallow(<SideNav page={RoutePage.NEW_EXPERIMENT} {...routerProps} />);
expect(tree).toMatchSnapshot();
});

it('renders experiments as active page when on Compare page', () => {
const tree = shallow(<SideNav page={RoutePage.COMPARE} {...routerProps} />);
expect(tree).toMatchSnapshot();
});

it('renders experiments as active page when on AllRuns page', () => {
const tree = shallow(<SideNav page={RoutePage.RUNS} {...routerProps} />);
expect(tree).toMatchSnapshot();
});

it('renders experiments as active page when on RunDetails page', () => {
const tree = shallow(<SideNav page={RoutePage.RUN_DETAILS} {...routerProps} />);
expect(tree).toMatchSnapshot();
});

it('renders experiments as active page when on RecurringRunDetails page', () => {
const tree = shallow(<SideNav page={RoutePage.RECURRING_RUN} {...routerProps} />);
expect(tree).toMatchSnapshot();
});

it('renders experiments as active page when on NewRun page', () => {
const tree = shallow(<SideNav page={RoutePage.NEW_RUN} {...routerProps} />);
expect(tree).toMatchSnapshot();
});

it('show jupyterhub link if accessible', () => {
const tree = shallow(<SideNav page={RoutePage.COMPARE} {...routerProps} />);
tree.setState({ jupyterHubAvailable: true });
Expand Down
25 changes: 17 additions & 8 deletions frontend/src/components/SideNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,27 +172,27 @@ class SideNav extends React.Component<SideNavProps, SideNavState> {
Kubeflow
</span>
</div>
<Link id='pipelinesBtn' to={RoutePage.PIPELINES} className={commonCss.unstyled}>
<Button className={classes(css.button,
<Link id='pipelinesLink' to={RoutePage.PIPELINES} className={commonCss.unstyled}>
<Button id='sideNavPipelinesBtn' className={classes(css.button,
yebrahim marked this conversation as resolved.
Show resolved Hide resolved
page.startsWith(RoutePage.PIPELINES) && css.active,
collapsed && css.collapsedButton)}>
<PipelinesIcon color={page.startsWith(RoutePage.PIPELINES) ? iconColor.active : iconColor.inactive} />
<span className={classes(collapsed && css.collapsedLabel, css.label)}>Pipelines</span>
</Button>
</Link>
<Link id='experimentsBtn' to={RoutePage.EXPERIMENTS} className={commonCss.unstyled}>
<Button className={
<Link id='experimentsLink' to={RoutePage.EXPERIMENTS} className={commonCss.unstyled}>
<Button id='sideNavExperimentsBtn' className={
classes(
css.button,
page.startsWith(RoutePage.EXPERIMENTS) && css.active,
this._highlightExperimentsButton(page) && css.active,
collapsed && css.collapsedButton)}>
<ExperimentsIcon color={page.startsWith(RoutePage.EXPERIMENTS) ? iconColor.active : iconColor.inactive} />
<ExperimentsIcon color={this._highlightExperimentsButton(page) ? iconColor.active : iconColor.inactive} />
<span className={classes(collapsed && css.collapsedLabel, css.label)}>Experiments</span>
</Button>
</Link>
{this.state.jupyterHubAvailable && (
<a id='jupyterhubBtn' href={this._HUB_ADDRESS} className={commonCss.unstyled} target='_blank'>
<Button className={
<a id='jupyterhubLink' href={this._HUB_ADDRESS} className={commonCss.unstyled} target='_blank'>
<Button id='sideNavJupyterhubBtn'className={
classes(css.button, collapsed && css.collapsedButton)}>
<JupyterhubIcon style={{ height: 20, width: 20 }} />
<span className={classes(collapsed && css.collapsedLabel, css.label)}>Notebooks</span>
Expand All @@ -209,6 +209,15 @@ class SideNav extends React.Component<SideNavProps, SideNavState> {
);
}

private _highlightExperimentsButton(page: string): boolean {
yebrahim marked this conversation as resolved.
Show resolved Hide resolved
return page.startsWith(RoutePage.EXPERIMENTS)
|| page.startsWith(RoutePage.RUNS)
// TODO: Router should have a constant for this, but it doesn't follow the naming convention
// of the other pages
|| page.startsWith('/recurringrun')
yebrahim marked this conversation as resolved.
Show resolved Hide resolved
|| page.startsWith(RoutePage.COMPARE);
}

private _toggleNavClicked() {
this.setState({
collapsed: !this.state.collapsed,
Expand Down
Loading