16070: Replace process command dialog with command card
[arvados-workbench2.git] / src / components / code-snippet / code-snippet.tsx
index dda607cd898a54b5e7386de529b09a227545236c..f156e3e8e6e7ad26258662617f6ce3aafd60b960 100644 (file)
@@ -2,36 +2,39 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from 'react';
-import { StyleRulesCallback, WithStyles, Typography, withStyles, Theme } from '@material-ui/core';
-import { ArvadosTheme } from '~/common/custom-theme';
+import React from 'react';
+import { StyleRulesCallback, WithStyles, Typography, withStyles } from '@material-ui/core';
+import { ArvadosTheme } from 'common/custom-theme';
+import classNames from 'classnames';
 
-type CssRules = 'root';
+type CssRules = 'root' | 'space';
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     root: {
         boxSizing: 'border-box',
-        width: '100%',
-        height: 'auto',
-        maxHeight: '550px',
-        overflow: 'scroll',
+        overflow: 'auto',
         padding: theme.spacing.unit
+    },
+    space: {
+        marginLeft: '15px'
     }
 });
 
 export interface CodeSnippetDataProps {
     lines: string[];
+    className?: string;
+    apiResponse?: boolean;
 }
 
 type CodeSnippetProps = CodeSnippetDataProps & WithStyles<CssRules>;
 
 export const CodeSnippet = withStyles(styles)(
-    ({ classes, lines }: CodeSnippetProps) =>
-        <Typography component="div" className={classes.root}>
-            {
-                lines.map((line: string, index: number) => {
-                    return <Typography key={index} component="div">{line}</Typography>;
-                })
-            }
+    ({ classes, lines, className, apiResponse }: CodeSnippetProps) =>
+        <Typography
+        component="div"
+        className={classNames(classes.root, className)}>
+            <Typography className={apiResponse ? classes.space : className} component="pre">
+                {lines.join('\n')}
+            </Typography>
         </Typography>
-    );
\ No newline at end of file
+    );