Skip to content

Commit

Permalink
Update bundle CTA UI. (#4210)
Browse files Browse the repository at this point in the history
* Update bundle CTA UI.

* Fix command margin for killed bundles.

* Apply margin to command when bundle is loading.

* Disable download button for run bundle that are not ready yet.
  • Loading branch information
leilenah authored Aug 16, 2022
1 parent e0fd849 commit 58d74fb
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 57 deletions.
4 changes: 2 additions & 2 deletions frontend/src/components/CodeSnippet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ class CodeSnippet extends React.Component {
render() {
const { classes, code, copyMessage, expanded, href } = this.props;
const maxHeight = expanded ? 'none' : 300;
const marginBottom = this.props.noMargin ? 0 : 16;
return (
<Grid item xs={12}>
<div className={classes.snippet} style={{ maxHeight }}>
<div className={classes.snippet} style={{ maxHeight, marginBottom }}>
<div>{code}</div>
{copyMessage && <Copy message={copyMessage} text={code} />}
{href && <NewWindowLink href={href} />}
Expand All @@ -40,7 +41,6 @@ const styles = (theme) => ({
overflow: 'auto',
whiteSpace: 'pre-wrap',
backgroundColor: theme.color.grey.lightest,
marginBottom: 16,
},
});

Expand Down
73 changes: 25 additions & 48 deletions frontend/src/components/worksheets/BundleDetail/BundleActions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,55 +96,35 @@ class BundleActions extends React.Component<{
bundleInfo.state !== 'created' &&
bundleInfo.state !== 'staged';

return isRunBundle ? (
<div className={classes.actionsContainer}>
<Button
classes={{ root: classes.actionButton }}
variant='outlined'
color='primary'
disabled={!isDownloadableRunBundle}
onClick={() => {
window.open(bundleDownloadUrl, '_blank');
}}
>
<span className='glyphicon glyphicon-download-alt' />
</Button>
{editPermission && (
return (
<div>
{isRunBundle && editPermission && (
<>
<Snackbar
classes={{ root: classes.snackbar }}
open={this.state.killSnackbarIsOpen}
onClose={this.handleCloseKillSnackbar}
message='Executing kill command...'
action={this.killSnackbarAction}
/>
<Button
classes={{ root: classes.actionButton }}
variant='outlined'
classes={{ root: classes.killButton }}
variant='text'
color='primary'
onClick={this.rerun}
disabled={!isKillableBundle}
onClick={this.kill}
>
Edit & Rerun
Kill
</Button>
<Button variant='contained' color='primary' onClick={this.rerun}>
Rerun
</Button>
{isKillableBundle && (
<>
<Button
classes={{ root: classes.actionButton }}
variant='contained'
color='primary'
onClick={this.kill}
>
Kill
</Button>
<Snackbar
classes={{ root: classes.snackbar }}
open={this.state.killSnackbarIsOpen}
onClose={this.handleCloseKillSnackbar}
message='Executing kill command...'
action={this.killSnackbarAction}
/>
</>
)}
</>
)}
</div>
) : (
<div className={classes.actionsContainer}>
<Button
classes={{ root: classes.actionButton }}
classes={{ root: classes.downloadButton }}
style={!isRunBundle || !editPermission ? { marginLeft: 0 } : {}}
disabled={isRunBundle ? !isDownloadableRunBundle : false}
variant='outlined'
color='primary'
onClick={() => {
Expand All @@ -159,15 +139,12 @@ class BundleActions extends React.Component<{
}

const styles = () => ({
actionsContainer: {
padding: '0 10px',
killButton: {
minWidth: 50,
},
actionButton: {
downloadButton: {
minWidth: 'auto',
padding: '8px 10px',
marginLeft: '0 !important', // override default
marginRight: 12,
lineHeight: '14px',
padding: '10px 11px',
},
snackbar: {
marginBottom: 40,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { findDOMNode } from 'react-dom';
import useSWR from 'swr';
import { apiWrapper, fetchFileSummary } from '../../../util/apiWrapper';

import ConfigurationPanel from '../ConfigPanel';
import ConfigPanel from '../ConfigPanel';
import ErrorMessage from '../ErrorMessage';
import MainContent from './MainContent';
import BundleDetailSideBar from './BundleDetailSideBar';
Expand Down Expand Up @@ -215,7 +215,7 @@ const BundleDetail = ({
}

return (
<ConfigurationPanel
<ConfigPanel
// The ref is created only once, and that this is the only way to properly create the ref before componentDidMount().
ref={(node) => scrollToNewlyOpenedDetail(node)}
buttons={
Expand Down Expand Up @@ -249,7 +249,7 @@ const BundleDetail = ({
contentType={contentType}
expanded={contentExpanded}
/>
</ConfigurationPanel>
</ConfigPanel>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class MainContent extends React.Component<{
code={command}
expanded={expanded}
copyMessage='Command Copied!'
noMargin={!isLoading && !stdout && !stderr && !contentType}
/>
)}
</Grid>
Expand Down Expand Up @@ -161,6 +162,7 @@ class MainContent extends React.Component<{
<CodeSnippet
code={fileContents}
expanded={expanded}
noMargin
/>
) : (
<FileBrowserLite
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ConfigCodeInput extends React.Component<{
autoFocus={autoFocus}
onFocus={this.moveFocusToEnd}
onKeyDown={onKeyDown}
margin='dense'
margin='none'
variant='filled'
fullWidth
InputProps={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ class ConfigLabel extends React.Component<{
}> {
render() {
const { classes, label, tooltip, inline, optional } = this.props;
const marginBottom = this.props.hasMargin ? 4 : 0;
const contents = (
<span className={classes.label}>
<span className={classes.label} style={{ marginBottom }}>
<Typography variant='subtitle2' inline>
{label}
</Typography>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const styles = (theme) => ({
maxWidth: '100%',
},
content: {
justifyContent: 'flex-start',
backgroundColor: 'white',
padding: theme.spacing.larger,
maxHeight: '100%',
Expand All @@ -92,10 +93,10 @@ const styles = (theme) => ({
},
buttons: {
'& button': {
marginLeft: theme.spacing.larger,
marginLeft: 14,
},
paddingBottom: theme.spacing.large,
paddingTop: theme.spacing.larger,
paddingTop: 24,
maxWidth: '90%',
},
border: {
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/worksheets/NewRun/NewRun.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ class NewRun extends React.Component<
label='Dependencies'
tooltip='Map an entire bundle or a file/directory inside to a name that
can be referenced in the terminal command.'
hasMargin
/>
<DependencyEditor
addDependency={(dep) => this.addDependency(dep)}
Expand All @@ -553,6 +554,7 @@ class NewRun extends React.Component<
tooltip='Terminal command to run within the Docker container. It can use
data from other bundles by referencing the aliases specified in the
dependencies section.'
hasMargin
/>
<ConfigCodeInput
value={this.state.command}
Expand Down

0 comments on commit 58d74fb

Please sign in to comment.