16073: Show loading indicator when process io params are not loaded
[arvados-workbench2.git] / src / views / process-panel / process-io-card.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import React, { ReactElement, useState } from 'react';
6 import { Dispatch } from 'redux';
7 import {
8     StyleRulesCallback,
9     WithStyles,
10     withStyles,
11     Card,
12     CardHeader,
13     IconButton,
14     CardContent,
15     Tooltip,
16     Typography,
17     Tabs,
18     Tab,
19     Table,
20     TableHead,
21     TableBody,
22     TableRow,
23     TableCell,
24     Paper,
25     Grid,
26     Chip,
27     CircularProgress,
28 } from '@material-ui/core';
29 import { ArvadosTheme } from 'common/custom-theme';
30 import { CloseIcon, ImageIcon, InputIcon, ImageOffIcon, OutputIcon, MaximizeIcon } from 'components/icon/icon';
31 import { MPVPanelProps } from 'components/multi-panel-view/multi-panel-view';
32 import {
33   BooleanCommandInputParameter,
34   CommandInputParameter,
35   CWLType,
36   Directory,
37   DirectoryArrayCommandInputParameter,
38   DirectoryCommandInputParameter,
39   EnumCommandInputParameter,
40   FileArrayCommandInputParameter,
41   FileCommandInputParameter,
42   FloatArrayCommandInputParameter,
43   FloatCommandInputParameter,
44   IntArrayCommandInputParameter,
45   IntCommandInputParameter,
46   isArrayOfType,
47   isPrimitiveOfType,
48   StringArrayCommandInputParameter,
49   StringCommandInputParameter,
50 } from "models/workflow";
51 import { CommandOutputParameter } from 'cwlts/mappings/v1.0/CommandOutputParameter';
52 import { File } from 'models/workflow';
53 import { getInlineFileUrl } from 'views-components/context-menu/actions/helpers';
54 import { AuthState } from 'store/auth/auth-reducer';
55 import mime from 'mime';
56 import { DefaultView } from 'components/default-view/default-view';
57 import { getNavUrl } from 'routes/routes';
58 import { Link as RouterLink } from 'react-router-dom';
59 import { Link as MuiLink } from '@material-ui/core';
60 import { InputCollectionMount } from 'store/processes/processes-actions';
61 import { connect } from 'react-redux';
62 import { RootState } from 'store/store';
63 import { ProcessOutputCollectionFiles } from './process-output-collection-files';
64 import { Process } from 'store/processes/process';
65 import { navigateTo } from 'store/navigation/navigation-action';
66
67 type CssRules =
68   | "card"
69   | "content"
70   | "title"
71   | "header"
72   | "avatar"
73   | "iconHeader"
74   | "tableWrapper"
75   | "tableRoot"
76   | "paramValue"
77   | "keepLink"
78   | "collectionLink"
79   | "imagePreview"
80   | "valArray"
81   | "emptyValue"
82   | "halfRow"
83   | "symmetricTabs"
84   | "imagePlaceholder"
85   | "rowWithPreview";
86
87 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
88     card: {
89         height: '100%'
90     },
91     header: {
92         paddingTop: theme.spacing.unit,
93         paddingBottom: theme.spacing.unit,
94     },
95     iconHeader: {
96         fontSize: '1.875rem',
97         color: theme.customs.colors.green700,
98     },
99     avatar: {
100         alignSelf: 'flex-start',
101         paddingTop: theme.spacing.unit * 0.5
102     },
103     content: {
104         height: `calc(100% - ${theme.spacing.unit * 7}px - ${theme.spacing.unit * 1.5}px)`,
105         padding: theme.spacing.unit * 1.0,
106         paddingTop: theme.spacing.unit * 0.5,
107         '&:last-child': {
108             paddingBottom: theme.spacing.unit * 1,
109         }
110     },
111     title: {
112         overflow: 'hidden',
113         paddingTop: theme.spacing.unit * 0.5
114     },
115     tableWrapper: {
116         height: `calc(100% - ${theme.spacing.unit * 6}px)`,
117         overflow: 'auto',
118     },
119     tableRoot: {
120         width: '100%',
121         '& thead th': {
122             verticalAlign: 'bottom',
123             paddingBottom: '10px',
124         },
125         '& td, & th': {
126             paddingRight: '25px',
127         }
128     },
129     paramValue: {
130         display: 'flex',
131         alignItems: 'flex-start',
132         flexDirection: 'column',
133     },
134     keepLink: {
135         color: theme.palette.primary.main,
136         textDecoration: 'none',
137         overflowWrap: 'break-word',
138         cursor: 'pointer',
139     },
140     collectionLink: {
141         margin: '10px',
142         '& a': {
143             color: theme.palette.primary.main,
144             textDecoration: 'none',
145             overflowWrap: 'break-word',
146             cursor: 'pointer',
147         }
148     },
149     imagePreview: {
150         maxHeight: '15em',
151         maxWidth: '15em',
152         marginBottom: theme.spacing.unit,
153     },
154     valArray: {
155         display: 'flex',
156         gap: '10px',
157         flexWrap: 'wrap',
158         '& span': {
159             display: 'inline',
160         }
161     },
162     emptyValue: {
163         color: theme.customs.colors.grey500,
164     },
165     halfRow: {
166         '& td': {
167             borderBottom: 'none',
168         }
169     },
170     symmetricTabs: {
171         '& button': {
172             flexBasis: '0',
173         }
174     },
175     imagePlaceholder: {
176         width: '60px',
177         height: '60px',
178         display: 'flex',
179         alignItems: 'center',
180         justifyContent: 'center',
181         backgroundColor: '#cecece',
182         borderRadius: '10px',
183     },
184     rowWithPreview: {
185         verticalAlign: 'bottom',
186     }
187 });
188
189 export enum ProcessIOCardType {
190     INPUT = 'Inputs',
191     OUTPUT = 'Outputs',
192 }
193 export interface ProcessIOCardDataProps {
194     process: Process;
195     label: ProcessIOCardType;
196     params?: ProcessIOParameter[];
197     raw?: any;
198     mounts?: InputCollectionMount[];
199     outputUuid?: string;
200 }
201
202 export interface ProcessIOCardActionProps {
203     navigateTo: (uuid: string) => void;
204 }
205
206 const mapDispatchToProps = (dispatch: Dispatch): ProcessIOCardActionProps => ({
207     navigateTo: (uuid) => dispatch<any>(navigateTo(uuid)),
208 });
209
210 type ProcessIOCardProps = ProcessIOCardDataProps & ProcessIOCardActionProps & WithStyles<CssRules> & MPVPanelProps;
211
212 export const ProcessIOCard = withStyles(styles)(connect(null, mapDispatchToProps)(
213     ({ classes, label, params, raw, mounts, outputUuid, doHidePanel, doMaximizePanel, panelMaximized, panelName, process, navigateTo }: ProcessIOCardProps) => {
214         const [mainProcTabState, setMainProcTabState] = useState(0);
215         const handleMainProcTabChange = (event: React.MouseEvent<HTMLElement>, value: number) => {
216             setMainProcTabState(value);
217         }
218
219         const [showImagePreview, setShowImagePreview] = useState(false);
220
221         const PanelIcon = label === ProcessIOCardType.INPUT ? InputIcon : OutputIcon;
222         const mainProcess = !process.containerRequest.requestingContainerUuid;
223
224         return <Card className={classes.card} data-cy="process-io-card">
225             <CardHeader
226                 className={classes.header}
227                 classes={{
228                     content: classes.title,
229                     avatar: classes.avatar,
230                 }}
231                 avatar={<PanelIcon className={classes.iconHeader} />}
232                 title={
233                     <Typography noWrap variant='h6' color='inherit'>
234                         {label}
235                     </Typography>
236                 }
237                 action={
238                     <div>
239                         { mainProcess && <Tooltip title={"Toggle Image Preview"} disableFocusListener>
240                             <IconButton data-cy="io-preview-image-toggle" onClick={() =>{setShowImagePreview(!showImagePreview)}}>{showImagePreview ? <ImageIcon /> : <ImageOffIcon />}</IconButton>
241                         </Tooltip> }
242                         { doMaximizePanel && !panelMaximized &&
243                         <Tooltip title={`Maximize ${panelName || 'panel'}`} disableFocusListener>
244                             <IconButton onClick={doMaximizePanel}><MaximizeIcon /></IconButton>
245                         </Tooltip> }
246                         { doHidePanel &&
247                         <Tooltip title={`Close ${panelName || 'panel'}`} disableFocusListener>
248                             <IconButton onClick={doHidePanel}><CloseIcon /></IconButton>
249                         </Tooltip> }
250                     </div>
251                 } />
252             <CardContent className={classes.content}>
253                 {mainProcess ?
254                     (<>
255                         {params === undefined && <Grid container item alignItems='center' justify='center'>
256                             <CircularProgress />
257                         </Grid>}
258                         {params && params.length > 0 &&
259                             <>
260                                 <Tabs value={mainProcTabState} onChange={handleMainProcTabChange} variant="fullWidth" className={classes.symmetricTabs}>
261                                     <Tab label="Parameters" />
262                                     <Tab label="JSON" />
263                                 </Tabs>
264                                 {mainProcTabState === 0 && <div className={classes.tableWrapper}>
265                                         <ProcessIOPreview data={params} showImagePreview={showImagePreview} />
266                                     </div>}
267                                 {mainProcTabState === 1 && <div className={classes.tableWrapper}>
268                                         <ProcessIORaw data={raw || params} />
269                                     </div>}
270                             </>}
271                         {params && params.length === 0 && <Grid container item alignItems='center' justify='center'>
272                             <DefaultView messages={["No parameters found"]} />
273                         </Grid>}
274                     </>) :
275                     // Subprocess
276                     (<>
277                         {((mounts && mounts.length) || outputUuid) ?
278                             <>
279                                 <Tabs value={0} variant="fullWidth" className={classes.symmetricTabs}>
280                                     {label === ProcessIOCardType.INPUT && <Tab label="Collections" />}
281                                     {label === ProcessIOCardType.OUTPUT && <Tab label="Collection" />}
282                                 </Tabs>
283                                 <div className={classes.tableWrapper}>
284                                     {label === ProcessIOCardType.INPUT && <ProcessInputMounts mounts={mounts || []} />}
285                                     {label === ProcessIOCardType.OUTPUT && <>
286                                         {outputUuid && <Typography className={classes.collectionLink}>
287                                             Output Collection: <MuiLink className={classes.keepLink} onClick={() => {navigateTo(outputUuid || "")}}>
288                                             {outputUuid}
289                                         </MuiLink></Typography>}
290                                         <ProcessOutputCollectionFiles isWritable={false} currentItemUuid={outputUuid} />
291                                     </>}
292                                 </div>
293                             </> :
294                             <Grid container item alignItems='center' justify='center'>
295                                 <DefaultView messages={["No collection(s) found"]} />
296                             </Grid>
297                         }
298                     </>)
299                 }
300             </CardContent>
301         </Card>;
302     }
303 ));
304
305 export type ProcessIOValue = {
306     display: ReactElement<any, any>;
307     imageUrl?: string;
308     collection?: ReactElement<any, any>;
309 }
310
311 export type ProcessIOParameter = {
312     id: string;
313     label: string;
314     value: ProcessIOValue[];
315 }
316
317 interface ProcessIOPreviewDataProps {
318     data: ProcessIOParameter[];
319     showImagePreview: boolean;
320 }
321
322 type ProcessIOPreviewProps = ProcessIOPreviewDataProps & WithStyles<CssRules>;
323
324 const ProcessIOPreview = withStyles(styles)(
325     ({ classes, data, showImagePreview }: ProcessIOPreviewProps) => {
326         const showLabel = data.some((param: ProcessIOParameter) => param.label);
327         return <Table className={classes.tableRoot} aria-label="Process IO Preview">
328             <TableHead>
329                 <TableRow>
330                     <TableCell>Name</TableCell>
331                     {showLabel && <TableCell>Label</TableCell>}
332                     <TableCell>Value</TableCell>
333                     <TableCell>Collection</TableCell>
334                 </TableRow>
335             </TableHead>
336             <TableBody>
337                 {data.map((param: ProcessIOParameter) => {
338                     const firstVal = param.value.length > 0 ? param.value[0] : undefined;
339                     const rest = param.value.slice(1);
340                     const rowClass = rest.length > 0 ? classes.halfRow : undefined;
341
342                     return <>
343                         <TableRow className={rowClass} data-cy="process-io-param">
344                             <TableCell>
345                                 {param.id}
346                             </TableCell>
347                             {showLabel && <TableCell >{param.label}</TableCell>}
348                             <TableCell>
349                                 {firstVal && <ProcessValuePreview value={firstVal} showImagePreview={showImagePreview} />}
350                             </TableCell>
351                             <TableCell className={firstVal?.imageUrl ? classes.rowWithPreview : undefined}>
352                                 <Typography className={classes.paramValue}>
353                                     {firstVal?.collection}
354                                 </Typography>
355                             </TableCell>
356                         </TableRow>
357                         {rest.map((val, i) => (
358                             <TableRow className={(i < rest.length-1) ? rowClass : undefined}>
359                                 <TableCell />
360                                 {showLabel && <TableCell />}
361                                 <TableCell>
362                                     <ProcessValuePreview value={val} showImagePreview={showImagePreview} />
363                                 </TableCell>
364                                 <TableCell className={firstVal?.imageUrl ? classes.rowWithPreview : undefined}>
365                                     <Typography className={classes.paramValue}>
366                                         {val.collection}
367                                     </Typography>
368                                 </TableCell>
369                             </TableRow>
370                         ))}
371                     </>;
372                 })}
373             </TableBody>
374         </Table>;
375 });
376
377 interface ProcessValuePreviewProps {
378     value: ProcessIOValue;
379     showImagePreview: boolean;
380 }
381
382 const ProcessValuePreview = withStyles(styles)(
383     ({value, showImagePreview, classes}: ProcessValuePreviewProps & WithStyles<CssRules>) =>
384         <Typography className={classes.paramValue}>
385             {value.imageUrl && showImagePreview ? <img className={classes.imagePreview} src={value.imageUrl} alt="Inline Preview" /> : ""}
386             {value.imageUrl && !showImagePreview ? <ImagePlaceholder /> : ""}
387             <span className={classes.valArray}>
388                 {value.display}
389             </span>
390         </Typography>
391 )
392
393 const handleClick = (url) => {
394     window.open(url, '_blank');
395 }
396
397
398 interface ProcessIORawDataProps {
399     data: ProcessIOParameter[];
400 }
401
402 const ProcessIORaw = withStyles(styles)(
403     ({ data }: ProcessIORawDataProps) =>
404         <Paper elevation={0}>
405             <pre>
406                 {JSON.stringify(data, null, 2)}
407             </pre>
408         </Paper>
409 );
410
411 interface ProcessInputMountsDataProps {
412     mounts: InputCollectionMount[];
413 }
414
415 type ProcessInputMountsProps = ProcessInputMountsDataProps & WithStyles<CssRules>;
416
417 const ProcessInputMounts = withStyles(styles)(connect((state: RootState) => ({
418     auth: state.auth,
419 }))(({ mounts, classes, auth }: ProcessInputMountsProps & { auth: AuthState }) => (
420     <Table className={classes.tableRoot} aria-label="Process Input Mounts">
421         <TableHead>
422             <TableRow>
423                 <TableCell>Path</TableCell>
424                 <TableCell>Portable Data Hash</TableCell>
425             </TableRow>
426         </TableHead>
427         <TableBody>
428             {mounts.map(mount => (
429                 <TableRow key={mount.path}>
430                     <TableCell><pre>{mount.path}</pre></TableCell>
431                     <TableCell>
432                         <RouterLink to={getNavUrl(mount.pdh, auth)} className={classes.keepLink}>{mount.pdh}</RouterLink>
433                     </TableCell>
434                 </TableRow>
435             ))}
436         </TableBody>
437     </Table>
438 )));
439
440 type FileWithSecondaryFiles = {
441     secondaryFiles: File[];
442 }
443
444 export const getIOParamDisplayValue = (auth: AuthState, input: CommandInputParameter | CommandOutputParameter, pdh?: string): ProcessIOValue[] => {
445     switch (true) {
446         case isPrimitiveOfType(input, CWLType.BOOLEAN):
447             const boolValue = (input as BooleanCommandInputParameter).value;
448
449             return boolValue !== undefined &&
450                     !(Array.isArray(boolValue) && boolValue.length === 0) ?
451                 [{display: <pre>{String(boolValue)}</pre> }] :
452                 [{display: <EmptyValue />}];
453
454         case isPrimitiveOfType(input, CWLType.INT):
455         case isPrimitiveOfType(input, CWLType.LONG):
456             const intValue = (input as IntCommandInputParameter).value;
457
458             return intValue !== undefined &&
459                     // Missing values are empty array
460                     !(Array.isArray(intValue) && intValue.length === 0) ?
461                 [{display: <pre>{String(intValue)}</pre> }]
462                 : [{display: <EmptyValue />}];
463
464         case isPrimitiveOfType(input, CWLType.FLOAT):
465         case isPrimitiveOfType(input, CWLType.DOUBLE):
466             const floatValue = (input as FloatCommandInputParameter).value;
467
468             return floatValue !== undefined &&
469                     !(Array.isArray(floatValue) && floatValue.length === 0) ?
470                 [{display: <pre>{String(floatValue)}</pre> }]:
471                 [{display: <EmptyValue />}];
472
473         case isPrimitiveOfType(input, CWLType.STRING):
474             const stringValue = (input as StringCommandInputParameter).value || undefined;
475
476             return stringValue !== undefined &&
477                     !(Array.isArray(stringValue) && stringValue.length === 0) ?
478                 [{display: <pre>{stringValue}</pre> }] :
479                 [{display: <EmptyValue />}];
480
481         case isPrimitiveOfType(input, CWLType.FILE):
482             const mainFile = (input as FileCommandInputParameter).value;
483             // secondaryFiles: File[] is not part of CommandOutputParameter so we cast to access secondaryFiles
484             const secondaryFiles = ((mainFile as unknown) as FileWithSecondaryFiles)?.secondaryFiles || [];
485             const files = [
486                 ...(mainFile && !(Array.isArray(mainFile) && mainFile.length === 0) ? [mainFile] : []),
487                 ...secondaryFiles
488             ];
489
490             return files.length ?
491                 files.map(file => fileToProcessIOValue(file, auth, pdh)) :
492                 [{display: <EmptyValue />}];
493
494         case isPrimitiveOfType(input, CWLType.DIRECTORY):
495             const directory = (input as DirectoryCommandInputParameter).value;
496
497             return directory !== undefined &&
498                     !(Array.isArray(directory) && directory.length === 0) ?
499                 [directoryToProcessIOValue(directory, auth, pdh)] :
500                 [{display: <EmptyValue />}];
501
502         case typeof input.type === 'object' &&
503             !(input.type instanceof Array) &&
504             input.type.type === 'enum':
505             const enumValue = (input as EnumCommandInputParameter).value;
506
507             return enumValue !== undefined ?
508                 [{ display: <pre>{(input as EnumCommandInputParameter).value || ''}</pre> }] :
509                 [{display: <EmptyValue />}];
510
511         case isArrayOfType(input, CWLType.STRING):
512             const strArray = (input as StringArrayCommandInputParameter).value || [];
513             return strArray.length ?
514                 [{ display: <>{((input as StringArrayCommandInputParameter).value || []).map((val) => <Chip label={val} />)}</> }] :
515                 [{display: <EmptyValue />}];
516
517         case isArrayOfType(input, CWLType.INT):
518         case isArrayOfType(input, CWLType.LONG):
519             const intArray = (input as IntArrayCommandInputParameter).value || [];
520
521             return intArray.length ?
522                 [{ display: <>{((input as IntArrayCommandInputParameter).value || []).map((val) => <Chip label={val} />)}</> }] :
523                 [{display: <EmptyValue />}];
524
525         case isArrayOfType(input, CWLType.FLOAT):
526         case isArrayOfType(input, CWLType.DOUBLE):
527             const floatArray = (input as FloatArrayCommandInputParameter).value || [];
528
529             return floatArray.length ?
530                 [{ display: <>{floatArray.map((val) => <Chip label={val} />)}</> }] :
531                 [{display: <EmptyValue />}];
532
533         case isArrayOfType(input, CWLType.FILE):
534             const fileArrayMainFile = ((input as FileArrayCommandInputParameter).value || []);
535             const fileArraySecondaryFiles = fileArrayMainFile.map((file) => (
536                 ((file as unknown) as FileWithSecondaryFiles)?.secondaryFiles || []
537             )).reduce((acc: File[], params: File[]) => (acc.concat(params)), []);
538
539             const fileArrayFiles = [
540                 ...fileArrayMainFile,
541                 ...fileArraySecondaryFiles
542             ];
543
544             return fileArrayFiles.length ?
545                 fileArrayFiles.map(file => fileToProcessIOValue(file, auth, pdh)) :
546                 [{display: <EmptyValue />}];
547
548         case isArrayOfType(input, CWLType.DIRECTORY):
549             const directories = (input as DirectoryArrayCommandInputParameter).value || [];
550
551             return directories.length ?
552                 directories.map(directory => directoryToProcessIOValue(directory, auth, pdh)) :
553                 [{display: <EmptyValue />}];
554
555         default:
556             return [];
557     }
558 };
559
560 /*
561  * @returns keep url without keep: prefix
562  */
563 const getKeepUrl = (file: File | Directory, pdh?: string): string => {
564     const isKeepUrl = file.location?.startsWith('keep:') || false;
565     const keepUrl = isKeepUrl ?
566                         file.location?.replace('keep:', '') :
567                         pdh ? `${pdh}/${file.location}` : file.location;
568     return keepUrl || '';
569 };
570
571 interface KeepUrlProps {
572     auth: AuthState;
573     res: File | Directory;
574     pdh?: string;
575 }
576
577 const KeepUrlBase = withStyles(styles)(({auth, res, pdh, classes}: KeepUrlProps & WithStyles<CssRules>) => {
578     const keepUrl = getKeepUrl(res, pdh);
579     const pdhUrl = keepUrl ? keepUrl.split('/').slice(0, 1)[0] : '';
580     // Passing a pdh always returns a relative wb2 collection url
581     const pdhWbPath = getNavUrl(pdhUrl, auth);
582     return pdhUrl && pdhWbPath ?
583         <Tooltip title={"View collection in Workbench"}><RouterLink to={pdhWbPath} className={classes.keepLink}>{pdhUrl}</RouterLink></Tooltip> :
584         <></>;
585 });
586
587 const KeepUrlPath = withStyles(styles)(({auth, res, pdh, classes}: KeepUrlProps & WithStyles<CssRules>) => {
588     const keepUrl = getKeepUrl(res, pdh);
589     const keepUrlParts = keepUrl ? keepUrl.split('/') : [];
590     const keepUrlPath = keepUrlParts.length > 1 ? keepUrlParts.slice(1).join('/') : '';
591
592     const keepUrlPathNav = getKeepNavUrl(auth, res, pdh);
593     return keepUrlPath && keepUrlPathNav ?
594         <Tooltip title={"View in keep-web"}><a className={classes.keepLink} href={keepUrlPathNav} target="_blank">{keepUrlPath}</a></Tooltip> :
595         // Show No value for root collection io that lacks path part
596         <EmptyValue />;
597 });
598
599 const getKeepNavUrl = (auth: AuthState, file: File | Directory, pdh?: string): string => {
600     let keepUrl = getKeepUrl(file, pdh);
601     return (getInlineFileUrl(`${auth.config.keepWebServiceUrl}/c=${keepUrl}?api_token=${auth.apiToken}`, auth.config.keepWebServiceUrl, auth.config.keepWebInlineServiceUrl));
602 };
603
604 const getImageUrl = (auth: AuthState, file: File, pdh?: string): string => {
605     const keepUrl = getKeepUrl(file, pdh);
606     return getInlineFileUrl(`${auth.config.keepWebServiceUrl}/c=${keepUrl}?api_token=${auth.apiToken}`, auth.config.keepWebServiceUrl, auth.config.keepWebInlineServiceUrl);
607 };
608
609 const isFileImage = (basename?: string): boolean => {
610     return basename ? (mime.getType(basename) || "").startsWith('image/') : false;
611 };
612
613 const normalizeDirectoryLocation = (directory: Directory): Directory => {
614     if (!directory.location) {
615         return directory;
616     }
617     return {
618         ...directory,
619         location: (directory.location || '').endsWith('/') ? directory.location : directory.location + '/',
620     };
621 };
622
623 const directoryToProcessIOValue = (directory: Directory, auth: AuthState, pdh?: string): ProcessIOValue => {
624     const normalizedDirectory = normalizeDirectoryLocation(directory);
625     return {
626         display: <KeepUrlPath auth={auth} res={normalizedDirectory} pdh={pdh}/>,
627         collection: <KeepUrlBase auth={auth} res={normalizedDirectory} pdh={pdh}/>,
628     };
629 };
630
631 const fileToProcessIOValue = (file: File, auth: AuthState, pdh?: string): ProcessIOValue => {
632     return {
633         display: <KeepUrlPath auth={auth} res={file} pdh={pdh}/>,
634         imageUrl: isFileImage(file.basename) ? getImageUrl(auth, file, pdh) : undefined,
635         collection: <KeepUrlBase auth={auth} res={file} pdh={pdh}/>,
636     }
637 };
638
639 const EmptyValue = withStyles(styles)(
640     ({classes}: WithStyles<CssRules>) => <span className={classes.emptyValue}>No value</span>
641 );
642
643 const ImagePlaceholder = withStyles(styles)(
644     ({classes}: WithStyles<CssRules>) => <span className={classes.imagePlaceholder}><ImageIcon /></span>
645 );