X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/095e176632bbf81d28a239742a1ecce12404bd2d..edcdf0ae72c56bf4aa05f93ed2877faa3a5e75c4:/services/workbench2/src/views/process-panel/process-cmd-card.tsx diff --git a/services/workbench2/src/views/process-panel/process-cmd-card.tsx b/services/workbench2/src/views/process-panel/process-cmd-card.tsx index d8368449cb..6cef09b4a8 100644 --- a/services/workbench2/src/views/process-panel/process-cmd-card.tsx +++ b/services/workbench2/src/views/process-panel/process-cmd-card.tsx @@ -18,10 +18,10 @@ import { import { ArvadosTheme } from 'common/custom-theme'; import { CloseIcon, CommandIcon, CopyIcon } from 'components/icon/icon'; import { MPVPanelProps } from 'components/multi-panel-view/multi-panel-view'; -import { DefaultCodeSnippet } from 'components/default-code-snippet/default-code-snippet'; +import { DefaultVirtualCodeSnippet } from 'components/default-code-snippet/default-virtual-code-snippet'; import { Process } from 'store/processes/process'; import shellescape from 'shell-escape'; -import CopyToClipboard from 'react-copy-to-clipboard'; +import CopyResultToClipboard from 'components/copy-to-clipboard/copy-result-to-clipboard'; type CssRules = 'card' | 'content' | 'title' | 'header' | 'avatar' | 'iconHeader'; @@ -31,7 +31,7 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ }, header: { paddingTop: theme.spacing.unit, - paddingBottom: theme.spacing.unit, + paddingBottom: 0, }, iconHeader: { fontSize: '1.875rem', @@ -42,8 +42,9 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ paddingTop: theme.spacing.unit * 0.5 }, content: { + height: `calc(100% - ${theme.spacing.unit * 6}px)`, padding: theme.spacing.unit * 1.0, - paddingTop: theme.spacing.unit * 0.5, + paddingTop: 0, '&:last-child': { paddingBottom: theme.spacing.unit * 1, } @@ -52,7 +53,7 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ overflow: 'hidden', paddingTop: theme.spacing.unit * 0.5, color: theme.customs.colors.greyD, - fontSize: '1.875rem' + fontSize: '1.875rem' }, }); @@ -70,18 +71,23 @@ export const ProcessCmdCard = withStyles(styles)( classes, doHidePanel, }: ProcessCmdCardProps) => { - const command = process.containerRequest.command.map((v) => - shellescape([v]) // Escape each arg separately - ); - let formattedCommand = [...command]; - formattedCommand.forEach((item, i, arr) => { + const formatLine = (lines: string[], index: number): string => { + // Escape each arg separately + let line = shellescape([lines[index]]) // Indent lines after the first - const indent = i > 0 ? ' ' : ''; - // Escape newlines on every non-last arg when there are multiple lines - const lineBreak = arr.length > 1 && i < arr.length - 1 ? ' \\' : ''; - arr[i] = `${indent}${item}${lineBreak}`; - }); + const indent = index > 0 ? ' ' : ''; + // Add backslash "escaped linebreak" + const lineBreak = lines.length > 1 && index < lines.length - 1 ? ' \\' : ''; + + return `${indent}${line}${lineBreak}`; + }; + + const formatClipboardText = (command: string[]) => (): string => ( + command.map((v) => + shellescape([v]) // Escape each arg separately + ).join(' ') + ); return ( @@ -100,14 +106,14 @@ export const ProcessCmdCard = withStyles(styles)( action={ - + - onCopy("Command copied to clipboard")} > - + @@ -127,7 +133,11 @@ export const ProcessCmdCard = withStyles(styles)( } /> - + );