1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { WorkflowIcon } from 'components/icon/icon';
7 import { WorkflowResource } from 'models/workflow';
8 import { DetailsData } from "./details-data";
9 import { DetailsAttribute } from 'components/details-attribute/details-attribute';
10 import { ResourceWithName } from 'views-components/data-explorer/renderers';
11 import { formatDate } from "common/formatters";
12 import { Grid } from '@material-ui/core';
13 import { withStyles, StyleRulesCallback, WithStyles, Button } from '@material-ui/core';
14 import { openRunProcess } from "store/workflow-panel/workflow-panel-actions";
15 import { Dispatch } from 'redux';
16 import { connect } from 'react-redux';
17 import { ArvadosTheme } from 'common/custom-theme';
19 export interface WorkflowDetailsCardDataProps {
20 workflow?: WorkflowResource;
23 export interface WorkflowDetailsCardActionProps {
24 onClick: (wf: WorkflowResource) => () => void;
27 const mapDispatchToProps = (dispatch: Dispatch) => ({
28 onClick: (wf: WorkflowResource) =>
29 () => wf && dispatch<any>(openRunProcess(wf.uuid, wf.ownerUuid, wf.name)),
32 type CssRules = 'runButton';
34 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
37 padding: '2px 10px 2px 5px',
42 export const WorkflowDetailsAttributes = connect(null, mapDispatchToProps)(
44 ({ workflow, onClick, classes }: WorkflowDetailsCardDataProps & WorkflowDetailsCardActionProps & WithStyles<CssRules>) => {
45 return <Grid container>
46 <Button onClick={workflow && onClick(workflow)} className={classes.runButton} variant='contained'
47 data-cy='details-panel-run-btn' color='primary' size='small'>
50 {workflow && workflow.description !== "" && <Grid item xs={12} >
53 value={workflow?.description} />
57 label={"Workflow UUID"}
58 linkToUuid={workflow?.uuid} />
62 label='Owner' linkToUuid={workflow?.ownerUuid}
63 uuidEnhancer={(uuid: string) => <ResourceWithName uuid={uuid} />} />
66 <DetailsAttribute label='Created at' value={formatDate(workflow?.createdAt)} />
69 <DetailsAttribute label='Last modified' value={formatDate(workflow?.modifiedAt)} />
73 label='Last modified by user' linkToUuid={workflow?.modifiedByUserUuid}
74 uuidEnhancer={(uuid: string) => <ResourceWithName uuid={uuid} />} />
79 export class WorkflowDetails extends DetailsData<WorkflowResource> {
80 getIcon(className?: string) {
81 return <WorkflowIcon className={className} />;
85 return <WorkflowDetailsAttributes workflow={this.item} />;