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