[ARVADOS-WORKBENCH2] created: 1.4.1-292-g2a69173e

Git user git at public.arvados.org
Fri Feb 28 11:43:01 UTC 2020


        at  2a69173eb3cf50c23753905ed30aa35f82aa95bc (commit)


commit 2a69173eb3cf50c23753905ed30aa35f82aa95bc
Author: PiotrAleksander <piotrhugonow at gmail.com>
Date:   Fri Feb 28 12:42:50 2020 +0100

    WIP ProcessInformationCard turned to class component, containerRequest.properties view and deletion added, typescript compiler issue (withStyles theme not recognized)

diff --git a/src/views/process-panel/process-information-card.tsx b/src/views/process-panel/process-information-card.tsx
index be1b92a9..fc26a748 100644
--- a/src/views/process-panel/process-information-card.tsx
+++ b/src/views/process-panel/process-information-card.tsx
@@ -15,8 +15,11 @@ import { getProcessStatus, getProcessStatusColor } from '~/store/processes/proce
 import { formatDate } from '~/common/formatters';
 import * as classNames from 'classnames';
 import { ContainerState } from '~/models/container';
+import { connect, DispatchProp } from 'react-redux';
+import { deleteCollectionTag } from '~/store/collection-panel/collection-panel-action';
+import { getPropertyChip } from '~/views-components/resource-properties-form/property-chip';
 
-type CssRules = 'card' | 'iconHeader' | 'label' | 'value' | 'chip' | 'link' | 'content' | 'title' | 'avatar' | 'cancelButton';
+type CssRules = 'card' | 'iconHeader' | 'label' | 'value' | 'chip' | 'link' | 'content' | 'title' | 'avatar' | 'cancelButton' | 'tag';
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     card: {
@@ -71,7 +74,11 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
         "&:hover": {
             cursor: 'pointer'
         }
-    }
+    },
+    tag: {
+        marginRight: theme.spacing.unit,
+        marginBottom: theme.spacing.unit
+    },
 });
 
 export interface ProcessInformationCardDataProps {
@@ -83,77 +90,113 @@ export interface ProcessInformationCardDataProps {
     cancelProcess: (uuid: string) => void;
 }
 
-type ProcessInformationCardProps = ProcessInformationCardDataProps & WithStyles<CssRules, true>;
+type ProcessInformationCardProps = ProcessInformationCardDataProps & DispatchProp & WithStyles<CssRules, true>;
+
+export const ProcessInformationCard = withStyles(styles)(
+    connect()(
+        class extends React.Component<ProcessInformationCardProps> {
+
+            render() {
+                const { classes, process, onContextMenu, theme, openProcessInputDialog, navigateToOutput, openWorkflow, cancelProcess } = this.props;
+                const { container, containerRequest } = process;
+                const startedAt = container ? formatDate(container.startedAt) : 'N/A';
+                const finishedAt = container ? formatDate(container.finishedAt) : 'N/A';
 
-export const ProcessInformationCard = withStyles(styles, { withTheme: true })(
-    ({ classes, process, onContextMenu, theme, openProcessInputDialog, navigateToOutput, openWorkflow, cancelProcess }: ProcessInformationCardProps) => {
-        const { container } = process;
-        const startedAt = container ? formatDate(container.startedAt) : 'N/A';
-        const finishedAt = container ? formatDate(container.finishedAt) : 'N/A';
-        return <Card className={classes.card}>
-            <CardHeader
-                classes={{
-                    content: classes.title,
-                    avatar: classes.avatar
-                }}
-                avatar={<ProcessIcon className={classes.iconHeader} />}
-                action={
-                    <div>
-                        {process.container && process.container.state === ContainerState.RUNNING &&
-                            <span className={classes.cancelButton} onClick={() => cancelProcess(process.containerRequest.uuid)}>Cancel</span>}
-                        <Chip label={getProcessStatus(process)}
-                            className={classes.chip}
-                            style={{ backgroundColor: getProcessStatusColor(getProcessStatus(process), theme as ArvadosTheme) }} />
-                        <Tooltip title="More options" disableFocusListener>
-                            <IconButton
-                                aria-label="More options"
-                                onClick={event => onContextMenu(event)}>
-                                <MoreOptionsIcon />
-                            </IconButton>
-                        </Tooltip>
-                    </div>
-                }
-                title={
-                    <Tooltip title={process.containerRequest.name} placement="bottom-start">
-                        <Typography noWrap variant='h6' color='inherit'>
-                            {process.containerRequest.name}
-                        </Typography>
-                    </Tooltip>
-                }
-                subheader={
-                    <Tooltip title={getDescription(process)} placement="bottom-start">
-                        <Typography noWrap variant='body1' color='inherit'>
-                            {getDescription(process)}
-                        </Typography>
-                    </Tooltip>} />
-            <CardContent className={classes.content}>
-                <Grid container>
-                    <Grid item xs={6}>
-                        <DetailsAttribute classLabel={classes.label} classValue={classes.value}
-                            label='From'
-                            value={startedAt} />
-                        <DetailsAttribute classLabel={classes.label} classValue={classes.value}
-                            label='To'
-                            value={finishedAt} />
-                        {process.containerRequest.properties.workflowUuid &&
-                            <span onClick={() => openWorkflow(process.containerRequest.properties.workflowUuid)}>
-                                <DetailsAttribute classLabel={classes.label} classValue={classNames(classes.value, classes.link)}
-                                    label='Workflow' value={process.containerRequest.properties.workflowName} />
-                            </span>}
-                    </Grid>
-                    <Grid item xs={6}>
-                        <span onClick={() => navigateToOutput(process.containerRequest.outputUuid!)}>
-                            <DetailsAttribute classLabel={classes.link} label='Outputs' />
-                        </span>
-                        <span onClick={() => openProcessInputDialog(process.containerRequest.uuid)}>
-                            <DetailsAttribute classLabel={classes.link} label='Inputs' />
-                        </span>
-                    </Grid>
-                </Grid>
-            </CardContent>
-        </Card>;
-    }
-);
+                return <>
+                    <Card className={classes.card}>
+                        <CardHeader
+                            classes={{
+                                content: classes.title,
+                                avatar: classes.avatar
+                            }}
+                            avatar={<ProcessIcon className={classes.iconHeader} />}
+                            action={
+                                <div>
+                                    {process.container && process.container.state === ContainerState.RUNNING &&
+                                        <span className={classes.cancelButton} onClick={() => cancelProcess(process.containerRequest.uuid)}>Cancel</span>}
+                                    <Chip label={getProcessStatus(process)}
+                                        className={classes.chip}
+                                        style={{ backgroundColor: getProcessStatusColor(getProcessStatus(process), theme as ArvadosTheme) }} />
+                                    <Tooltip title="More options" disableFocusListener>
+                                        <IconButton
+                                            aria-label="More options"
+                                            onClick={event => onContextMenu(event)}>
+                                            <MoreOptionsIcon />
+                                        </IconButton>
+                                    </Tooltip>
+                                </div>
+                            }
+                            title={
+                                <Tooltip title={process.containerRequest.name} placement="bottom-start">
+                                    <Typography noWrap variant='h6' color='inherit'>
+                                        {process.containerRequest.name}
+                                    </Typography>
+                                </Tooltip>
+                            }
+                            subheader={
+                                <Tooltip title={this.getDescription(process)} placement="bottom-start">
+                                    <Typography noWrap variant='body1' color='inherit'>
+                                        {this.getDescription(process)}
+                                    </Typography>
+                                </Tooltip>} />
+                        <CardContent className={classes.content}>
+                            <Grid container>
+                                <Grid item xs={6}>
+                                    <DetailsAttribute classLabel={classes.label} classValue={classes.value}
+                                        label='From'
+                                        value={startedAt} />
+                                    <DetailsAttribute classLabel={classes.label} classValue={classes.value}
+                                        label='To'
+                                        value={finishedAt} />
+                                    {process.containerRequest.properties.workflowUuid &&
+                                        <span onClick={() => openWorkflow(process.containerRequest.properties.workflowUuid)}>
+                                            <DetailsAttribute classLabel={classes.label} classValue={classNames(classes.value, classes.link)}
+                                                label='Workflow' value={process.containerRequest.properties.workflowName} />
+                                        </span>}
+                                </Grid>
+                                <Grid item xs={6}>
+                                    <span onClick={() => navigateToOutput(process.containerRequest.outputUuid!)}>
+                                        <DetailsAttribute classLabel={classes.link} label='Outputs' />
+                                    </span>
+                                    <span onClick={() => openProcessInputDialog(process.containerRequest.uuid)}>
+                                        <DetailsAttribute classLabel={classes.link} label='Inputs' />
+                                    </span>
+                                </Grid>
+                            </Grid>
+                        </CardContent>
+                    </Card>
 
-const getDescription = (process: Process) =>
-    process.containerRequest.description || '(no-description)';
+                    <Card className={classes.card}>
+                        <CardHeader title="Properties" />
+                        <CardContent>
+                            <Grid container direction="column">
+                                <Grid item xs={12}>
+                                    {Object.keys(containerRequest.properties).map(k =>
+                                        Array.isArray(containerRequest.properties[k])
+                                            ? containerRequest.properties[k].map((v: string) =>
+                                                getPropertyChip(
+                                                    k, v,
+                                                    this.handleDelete(k, v),
+                                                    classes.tag))
+                                            : getPropertyChip(
+                                                k, containerRequest.properties[k],
+                                                this.handleDelete(k, containerRequest.properties[k]),
+                                                classes.tag)
+                                    )}
+                                </Grid>
+                            </Grid>
+                        </CardContent>
+                    </Card>
+                </>;
+            }
+
+            handleDelete = (key: string, value: string) => () => {
+                this.props.dispatch<any>(deleteCollectionTag(key, value));
+            }
+
+            getDescription = (process: Process) =>
+                process.containerRequest.description || '(no-description)'
+
+        }
+    )
+);
\ No newline at end of file

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list