Paper,
Grid,
Chip,
+ CircularProgress,
} from '@material-ui/core';
import { ArvadosTheme } from 'common/custom-theme';
import { CloseIcon, ImageIcon, InputIcon, ImageOffIcon, OutputIcon, MaximizeIcon } from 'components/icon/icon';
import { ProcessOutputCollectionFiles } from './process-output-collection-files';
import { Process } from 'store/processes/process';
import { navigateTo } from 'store/navigation/navigation-action';
+import classNames from 'classnames';
type CssRules =
| "card"
| "collectionLink"
| "imagePreview"
| "valArray"
+ | "secondaryVal"
| "emptyValue"
| "halfRow"
| "symmetricTabs"
| "imagePlaceholder"
- | "rowWithPreview";
+ | "rowWithPreview"
+ | "labelColumn";
const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
card: {
display: 'inline',
}
},
+ secondaryVal: {
+ paddingLeft: '20px',
+ },
emptyValue: {
color: theme.customs.colors.grey500,
},
},
rowWithPreview: {
verticalAlign: 'bottom',
- }
+ },
+ labelColumn: {
+ minWidth: '120px',
+ },
});
export enum ProcessIOCardType {
export interface ProcessIOCardDataProps {
process: Process;
label: ProcessIOCardType;
- params: ProcessIOParameter[];
+ params?: ProcessIOParameter[];
raw?: any;
mounts?: InputCollectionMount[];
outputUuid?: string;
const PanelIcon = label === ProcessIOCardType.INPUT ? InputIcon : OutputIcon;
const mainProcess = !process.containerRequest.requestingContainerUuid;
+ const loading = raw === undefined || params === undefined;
+ const hasRaw = !!(raw && Object.keys(raw).length > 0);
+ const hasParams = !!(params && params.length > 0);
+
return <Card className={classes.card} data-cy="process-io-card">
<CardHeader
className={classes.header}
<CardContent className={classes.content}>
{mainProcess ?
(<>
- {params.length ?
+ {/* raw is undefined until params are loaded */}
+ {loading && <Grid container item alignItems='center' justify='center'>
+ <CircularProgress />
+ </Grid>}
+ {/* Once loaded, either raw or params may still be empty
+ * Raw when all params are empty
+ * Params when raw is provided by containerRequest properties but workflow mount is absent for preview
+ */}
+ {(!loading && (hasRaw || hasParams)) &&
<>
<Tabs value={mainProcTabState} onChange={handleMainProcTabChange} variant="fullWidth" className={classes.symmetricTabs}>
- <Tab label="Parameters" />
+ {/* params will be empty on processes without workflow definitions in mounts, so we only show raw */}
+ {hasParams && <Tab label="Parameters" />}
<Tab label="JSON" />
</Tabs>
- {mainProcTabState === 0 && <div className={classes.tableWrapper}>
+ {(mainProcTabState === 0 && params && hasParams) && <div className={classes.tableWrapper}>
<ProcessIOPreview data={params} showImagePreview={showImagePreview} />
</div>}
- {mainProcTabState === 1 && <div className={classes.tableWrapper}>
- <ProcessIORaw data={raw || params} />
+ {(mainProcTabState === 1 || !hasParams) && <div className={classes.tableWrapper}>
+ <ProcessIORaw data={raw} />
</div>}
- </> :
- <Grid container item alignItems='center' justify='center'>
- <DefaultView messages={["No parameters found"]} />
- </Grid>
- }
+ </>}
+ {!loading && !hasRaw && !hasParams && <Grid container item alignItems='center' justify='center'>
+ <DefaultView messages={["No parameters found"]} />
+ </Grid>}
</>) :
+ // Subprocess
(<>
{((mounts && mounts.length) || outputUuid) ?
<>
display: ReactElement<any, any>;
imageUrl?: string;
collection?: ReactElement<any, any>;
+ secondary?: boolean;
}
export type ProcessIOParameter = {
<TableHead>
<TableRow>
<TableCell>Name</TableCell>
- {showLabel && <TableCell>Label</TableCell>}
+ {showLabel && <TableCell className={classes.labelColumn}>Label</TableCell>}
<TableCell>Value</TableCell>
<TableCell>Collection</TableCell>
</TableRow>
<Typography className={classes.paramValue}>
{value.imageUrl && showImagePreview ? <img className={classes.imagePreview} src={value.imageUrl} alt="Inline Preview" /> : ""}
{value.imageUrl && !showImagePreview ? <ImagePlaceholder /> : ""}
- <span className={classes.valArray}>
+ <span className={classNames(classes.valArray, value.secondary && classes.secondaryVal)}>
{value.display}
</span>
</Typography>
)
-const handleClick = (url) => {
- window.open(url, '_blank');
-}
-
-
interface ProcessIORawDataProps {
data: ProcessIOParameter[];
}
...(mainFile && !(Array.isArray(mainFile) && mainFile.length === 0) ? [mainFile] : []),
...secondaryFiles
];
+ const mainFilePdhUrl = mainFile ? getResourcePdhUrl(mainFile, pdh) : "";
return files.length ?
- files.map(file => fileToProcessIOValue(file, auth, pdh)) :
+ files.map((file, i) => fileToProcessIOValue(file, (i > 0), auth, pdh, (i > 0 ? mainFilePdhUrl : ""))) :
[{display: <EmptyValue />}];
case isPrimitiveOfType(input, CWLType.DIRECTORY):
[{display: <EmptyValue />}];
case isArrayOfType(input, CWLType.FILE):
- const fileArrayMainFile = ((input as FileArrayCommandInputParameter).value || []);
- const fileArraySecondaryFiles = fileArrayMainFile.map((file) => (
- ((file as unknown) as FileWithSecondaryFiles)?.secondaryFiles || []
- )).reduce((acc: File[], params: File[]) => (acc.concat(params)), []);
-
- const fileArrayFiles = [
- ...fileArrayMainFile,
- ...fileArraySecondaryFiles
- ];
-
- return fileArrayFiles.length ?
- fileArrayFiles.map(file => fileToProcessIOValue(file, auth, pdh)) :
+ const fileArrayMainFiles = ((input as FileArrayCommandInputParameter).value || []);
+ const firstMainFilePdh = (fileArrayMainFiles.length > 0 && fileArrayMainFiles[0]) ? getResourcePdhUrl(fileArrayMainFiles[0], pdh) : "";
+
+ // Convert each main file into separate arrays of ProcessIOValue to preserve secondaryFile grouping
+ const fileArrayValues = fileArrayMainFiles.map((mainFile: File, i): ProcessIOValue[] => {
+ const secondaryFiles = ((mainFile as unknown) as FileWithSecondaryFiles)?.secondaryFiles || [];
+ return [
+ // Pass firstMainFilePdh to secondary files and every main file besides the first to hide pdh if equal
+ ...(mainFile ? [fileToProcessIOValue(mainFile, false, auth, pdh, i > 0 ? firstMainFilePdh : "")] : []),
+ ...(secondaryFiles.map(file => fileToProcessIOValue(file, true, auth, pdh, firstMainFilePdh)))
+ ];
+ // Reduce each mainFile/secondaryFile group into single array preserving ordering
+ }).reduce((acc: ProcessIOValue[], mainFile: ProcessIOValue[]) => (acc.concat(mainFile)), []);
+
+ return fileArrayValues.length ?
+ fileArrayValues :
[{display: <EmptyValue />}];
case isArrayOfType(input, CWLType.DIRECTORY):
pdh?: string;
}
-const KeepUrlBase = withStyles(styles)(({auth, res, pdh, classes}: KeepUrlProps & WithStyles<CssRules>) => {
+const getResourcePdhUrl = (res: File | Directory, pdh?: string): string => {
const keepUrl = getKeepUrl(res, pdh);
- const pdhUrl = keepUrl ? keepUrl.split('/').slice(0, 1)[0] : '';
+ return keepUrl ? keepUrl.split('/').slice(0, 1)[0] : '';
+};
+
+const KeepUrlBase = withStyles(styles)(({auth, res, pdh, classes}: KeepUrlProps & WithStyles<CssRules>) => {
+ const pdhUrl = getResourcePdhUrl(res, pdh);
// Passing a pdh always returns a relative wb2 collection url
const pdhWbPath = getNavUrl(pdhUrl, auth);
return pdhUrl && pdhWbPath ?
const keepUrlPathNav = getKeepNavUrl(auth, res, pdh);
return keepUrlPath && keepUrlPathNav ?
- <Tooltip title={"View in keep-web"}><MuiLink className={classes.keepLink} onClick={() => handleClick(keepUrlPathNav)}>{keepUrlPath}</MuiLink></Tooltip> :
+ <Tooltip title={"View in keep-web"}><a className={classes.keepLink} href={keepUrlPathNav} target="_blank" rel="noopener noreferrer">{keepUrlPath}</a></Tooltip> :
// Show No value for root collection io that lacks path part
<EmptyValue />;
});
};
};
-const fileToProcessIOValue = (file: File, auth: AuthState, pdh?: string): ProcessIOValue => {
+const fileToProcessIOValue = (file: File, secondary: boolean, auth: AuthState, pdh: string | undefined, mainFilePdh: string): ProcessIOValue => {
+ const resourcePdh = getResourcePdhUrl(file, pdh);
return {
display: <KeepUrlPath auth={auth} res={file} pdh={pdh}/>,
+ secondary,
imageUrl: isFileImage(file.basename) ? getImageUrl(auth, file, pdh) : undefined,
- collection: <KeepUrlBase auth={auth} res={file} pdh={pdh}/>,
+ collection: (resourcePdh !== mainFilePdh) ? <KeepUrlBase auth={auth} res={file} pdh={pdh}/> : <></>,
}
};