X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/c324b64f3b26e79b4640b6f0cf55671f1a261bca..6ddc4f58120358fa12de736c49be69f8373b4068:/src/components/code-snippet/code-snippet.tsx

diff --git a/src/components/code-snippet/code-snippet.tsx b/src/components/code-snippet/code-snippet.tsx
index 6cba299f..fd44b5fc 100644
--- a/src/components/code-snippet/code-snippet.tsx
+++ b/src/components/code-snippet/code-snippet.tsx
@@ -2,37 +2,46 @@
 //
 // 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 * as classNames from 'classnames';
+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',
         overflow: 'auto',
         padding: theme.spacing.unit
+    },
+    space: {
+        marginLeft: '15px'
     }
 });
 
 export interface CodeSnippetDataProps {
     lines: string[];
     className?: string;
+    apiResponse?: boolean;
+    containerClassName?: string;
+    fontSize?: number;
+    customRenderer?: (line: string) => React.ReactNode;
 }
 
 type CodeSnippetProps = CodeSnippetDataProps & WithStyles<CssRules>;
 
 export const CodeSnippet = withStyles(styles)(
-    ({ classes, lines, className }: CodeSnippetProps) =>
-        <Typography 
-        component="div" 
-        className={classNames(classes.root, className)}>
-            {
-                lines.map((line: string, index: number) => {
-                    return <Typography key={index} component="pre">{line}</Typography>;
-                })
-            }
+    ({ classes, lines, className, containerClassName,
+        apiResponse, fontSize, customRenderer }: CodeSnippetProps) =>
+        <Typography component="div"
+            className={classNames(classes.root, containerClassName, className)}>
+            { lines.map((line: string, index: number) => {
+            return <Typography key={index} style={{ fontSize: fontSize }}
+                className={apiResponse ? classes.space : className}
+                component="pre">
+                {customRenderer ? customRenderer(line) : line}
+            </Typography>;
+            }) }
         </Typography>
     );
\ No newline at end of file
