Skip to content

Commit

Permalink
Add external links that make some content easier to discover (#2068)
Browse files Browse the repository at this point in the history
* Add external links that make some content easier to discover

* Use appropriate icons for each external link

* Update snapshots

* Fix lint errors

* Add documentation link for compile pipeline in upload pipeline dialog

* Update snapshots
  • Loading branch information
Bobgy authored and k8s-ci-robot committed Nov 6, 2019
1 parent d315bf6 commit 4a0a420
Show file tree
Hide file tree
Showing 9 changed files with 411 additions and 23 deletions.
3 changes: 3 additions & 0 deletions frontend/src/assets.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Needed to import png files directly.
// Reference: https://github.com/wmonk/create-react-app-typescript/tree/master/template#adding-images-fonts-and-files
declare module '*.png';
19 changes: 19 additions & 0 deletions frontend/src/atoms/ExternalLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React, { DetailedHTMLProps, AnchorHTMLAttributes } from 'react';
import { stylesheet } from 'typestyle';
import { color } from '../Css';

const css = stylesheet({
link: {
$nest: {
'&:hover': {
textDecoration: 'underline',
},
},
color: color.theme,
textDecoration: 'none',
},
});

export const ExternalLink: React.FC<
DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>
> = props => <a {...props} className={css.link} target='_blank' rel='noreferrer noopener' />;
23 changes: 2 additions & 21 deletions frontend/src/components/Description.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,14 @@

import React from 'react';
import Markdown from 'markdown-to-jsx';
import { stylesheet } from 'typestyle';
import { color } from '../Css';
import { ExternalLink } from '../atoms/ExternalLink';

function preventEventBubbling(e: React.MouseEvent): void {
e.stopPropagation();
}

const css = stylesheet({
link: {
$nest: {
'&:hover': {
textDecoration: 'underline',
},
},
color: color.theme,
textDecoration: 'none',
},
});

const renderExternalLink = (props: {}) => (
<a
{...props}
className={css.link}
target='_blank'
rel='noreferrer noopener'
onClick={preventEventBubbling}
/>
<ExternalLink {...props} onClick={preventEventBubbling} />
);

const options = {
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/components/Router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export const RoutePage = {
RUN_DETAILS: `/runs/details/:${RouteParams.runId}`,
};

// tslint:disable-next-line:variable-name
export const RoutePageFactory = {
artifactDetails: (artifactType: string, artifactId: number) => {
return RoutePage.ARTIFACT_DETAILS.replace(
Expand All @@ -107,6 +106,12 @@ export const RoutePageFactory = {
},
};

export const ExternalLinks = {
AI_HUB: 'https://aihub.cloud.google.com/u/0/s?category=pipeline',
DOCUMENTATION: 'https://www.kubeflow.org/docs/pipelines/',
GITHUB: 'https://github.com/kubeflow/pipelines',
};

export interface DialogProps {
buttons?: Array<{ onClick?: () => any; text: string }>;
// TODO: This should be generalized to any react component.
Expand Down
70 changes: 69 additions & 1 deletion frontend/src/components/SideNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ import ExperimentsIcon from '../icons/experiments';
import IconButton from '@material-ui/core/IconButton';
import JupyterhubIcon from '@material-ui/icons/Code';
import OpenInNewIcon from '@material-ui/icons/OpenInNew';
import DescriptionIcon from '@material-ui/icons/Description';
import GitHubIcon from '../icons/GitHub-Mark-120px-plus.png';
import PipelinesIcon from '../icons/pipelines';
import Tooltip from '@material-ui/core/Tooltip';
import { Apis } from '../lib/Apis';
import { Link } from 'react-router-dom';
import { LocalStorage, LocalStorageKey } from '../lib/LocalStorage';
import { RoutePage, RoutePrefix } from '../components/Router';
import { RoutePage, RoutePrefix, ExternalLinks } from '../components/Router';
import { RouterProps } from 'react-router';
import { classes, stylesheet } from 'typestyle';
import { fontsize, commonCss } from '../Css';
Expand Down Expand Up @@ -91,6 +93,12 @@ export const css = stylesheet({
collapsedChevron: {
transform: 'rotate(180deg)',
},
collapsedExternalLabel: {
// Hide text when collapsing, but do it with a transition of both height and
// opacity
height: 0,
opacity: 0,
},
collapsedLabel: {
// Hide text when collapsing, but do it with a transition
opacity: 0,
Expand All @@ -101,6 +109,13 @@ export const css = stylesheet({
collapsedSeparator: {
margin: '20px !important',
},
icon: {
height: 20,
width: 20,
},
iconImage: {
opacity: 0.6, // Images are too colorful there by default, reduce their color.
},
indicator: {
borderBottom: '3px solid transparent',
borderLeft: `3px solid ${sideNavColors.fgActive}`,
Expand Down Expand Up @@ -408,6 +423,32 @@ export default class SideNav extends React.Component<SideNavProps, SideNavState>
</Link>
</Tooltip>
<hr className={classes(css.separator, collapsed && css.collapsedSeparator)} />
<ExternalUri
title={'Documentation'}
to={ExternalLinks.DOCUMENTATION}
collapsed={collapsed}
icon={className => <DescriptionIcon className={className} />}
/>
<ExternalUri
title={'Github Repo'}
to={ExternalLinks.GITHUB}
collapsed={collapsed}
icon={className => (
<img src={GitHubIcon} className={classes(className, css.iconImage)} />
)}
/>
<ExternalUri
title={'AI Hub Samples'}
to={ExternalLinks.AI_HUB}
collapsed={collapsed}
icon={className => (
<img
src='https://www.gstatic.com/aihub/aihub_favicon.png'
className={classes(className, css.iconImage)}
/>
)}
/>
<hr className={classes(css.separator, collapsed && css.collapsedSeparator)} />
<IconButton
className={classes(css.chevron, collapsed && css.collapsedChevron)}
onClick={this._toggleNavClicked.bind(this)}
Expand Down Expand Up @@ -485,3 +526,30 @@ export default class SideNav extends React.Component<SideNavProps, SideNavState>
}
}
}

interface ExternalUriProps {
title: string;
to: string;
collapsed: boolean;
icon: (className: string) => React.ReactNode;
}

// tslint:disable-next-line:variable-name
const ExternalUri: React.FC<ExternalUriProps> = ({ title, to, collapsed, icon }) => (
<Tooltip
title={title}
enterDelay={300}
placement={'right-start'}
disableFocusListener={!collapsed}
disableHoverListener={!collapsed}
disableTouchListener={!collapsed}
>
<a href={to} className={commonCss.unstyled} target='_blank' rel='noopener noreferrer'>
<Button className={classes(css.button, collapsed && css.collapsedButton)}>
{icon(css.icon)}
<span className={classes(collapsed && css.collapsedLabel, css.label)}>{title}</span>
<OpenInNewIcon className={css.openInNewTabIcon} />
</Button>
</a>
</Tooltip>
);
13 changes: 13 additions & 0 deletions frontend/src/components/UploadPipelineDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import Radio from '@material-ui/core/Radio';
import { TextFieldProps } from '@material-ui/core/TextField';
import { padding, commonCss, zIndex, color } from '../Css';
import { stylesheet, classes } from 'typestyle';
import { ExternalLink } from '../atoms/ExternalLink';

const css = stylesheet({
dropOverlay: {
Expand Down Expand Up @@ -154,6 +155,7 @@ class UploadPipelineDialog extends React.Component<
<br />
You can also drag and drop the file here.
</div>
<DocumentationCompilePipeline />
<Input
onChange={this.handleChange('fileName')}
value={fileName}
Expand Down Expand Up @@ -182,6 +184,7 @@ class UploadPipelineDialog extends React.Component<
{importMethod === ImportMethod.URL && (
<React.Fragment>
<div className={padding(10, 'b')}>URL must be publicly accessible.</div>
<DocumentationCompilePipeline />
<Input
onChange={this.handleChange('fileUrl')}
value={fileUrl}
Expand Down Expand Up @@ -277,3 +280,13 @@ class UploadPipelineDialog extends React.Component<
}

export default UploadPipelineDialog;

const DocumentationCompilePipeline: React.FC = () => (
<div className={padding(10, 'b')}>
For expected file format, refer to{' '}
<ExternalLink href='https://www.kubeflow.org/docs/pipelines/sdk/build-component/#compile-the-pipeline'>
Compile Pipeline Documentation
</ExternalLink>
.
</div>
);
Loading

0 comments on commit 4a0a420

Please sign in to comment.