22174: removed action columns per review feedback
[arvados.git] / services / workbench2 / src / views / workflow-panel / workflow-processes-panel-root.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import React from 'react';
6 import { DataExplorer } from "views-components/data-explorer/data-explorer";
7 import { DataColumns } from 'components/data-table/data-table';
8 import { DataTableFilterItem } from 'components/data-table-filters/data-table-filters';
9 import { ContainerRequestState } from 'models/container-request';
10 import { SortDirection } from 'components/data-table/data-column';
11 import { ResourceKind } from 'models/resource';
12 import { ResourceCreatedAtDate, ProcessStatus, ContainerRunTime } from 'views-components/data-explorer/renderers';
13 import { ProcessIcon } from 'components/icon/icon';
14 import { ResourceName } from 'views-components/data-explorer/renderers';
15 import { WORKFLOW_PROCESSES_PANEL_ID } from 'store/workflow-panel/workflow-panel-actions';
16 import { createTree } from 'models/tree';
17 import { getInitialProcessStatusFilters } from 'store/resource-type-filters/resource-type-filters';
18 import { ResourcesState } from 'store/resources/resources';
19 import { MPVPanelProps } from 'components/multi-panel-view/multi-panel-view';
20 import { CustomStyleRulesCallback } from 'common/custom-theme';
21 import { Typography } from '@mui/material';
22 import { WithStyles } from '@mui/styles';
23 import withStyles from '@mui/styles/withStyles';
24 import { ArvadosTheme } from 'common/custom-theme';
25 import { ProcessResource } from 'models/process';
26
27 type CssRules = 'iconHeader' | 'cardHeader';
28
29 const styles: CustomStyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
30     iconHeader: {
31         fontSize: '1.875rem',
32         color: theme.customs.colors.greyL,
33         marginRight: theme.spacing(2),
34     },
35     cardHeader: {
36         display: 'flex',
37     },
38 });
39
40 export enum WorkflowProcessesPanelColumnNames {
41     NAME = "Name",
42     STATUS = "Status",
43     CREATED_AT = "Created At",
44     RUNTIME = "Run Time"
45 }
46
47 export interface WorkflowProcessesPanelFilter extends DataTableFilterItem {
48     type: ResourceKind | ContainerRequestState;
49 }
50
51 export const workflowProcessesPanelColumns: DataColumns<string, ProcessResource> = [
52     {
53         name: WorkflowProcessesPanelColumnNames.NAME,
54         selected: true,
55         configurable: true,
56         sort: { direction: SortDirection.NONE, field: "name" },
57         filters: createTree(),
58         render: uuid => <ResourceName uuid={uuid} />
59     },
60     {
61         name: WorkflowProcessesPanelColumnNames.STATUS,
62         selected: true,
63         configurable: true,
64         mutuallyExclusiveFilters: true,
65         filters: getInitialProcessStatusFilters(),
66         render: uuid => <ProcessStatus uuid={uuid} />,
67     },
68     {
69         name: WorkflowProcessesPanelColumnNames.CREATED_AT,
70         selected: true,
71         configurable: true,
72         sort: { direction: SortDirection.DESC, field: "createdAt" },
73         filters: createTree(),
74         render: uuid => <ResourceCreatedAtDate uuid={uuid} />
75     },
76     {
77         name: WorkflowProcessesPanelColumnNames.RUNTIME,
78         selected: true,
79         configurable: true,
80         filters: createTree(),
81         render: uuid => <ContainerRunTime uuid={uuid} />
82     }
83 ];
84
85 export interface WorkflowProcessesPanelDataProps {
86     resources: ResourcesState;
87 }
88
89 export interface WorkflowProcessesPanelActionProps {
90     onItemClick: (item: string) => void;
91     onContextMenu: (event: React.MouseEvent<HTMLElement>, item: string, resources: ResourcesState) => void;
92     onItemDoubleClick: (item: string) => void;
93 }
94
95 type WorkflowProcessesPanelProps = WorkflowProcessesPanelActionProps & WorkflowProcessesPanelDataProps;
96
97 const DEFAULT_VIEW_MESSAGES = [
98     'No processes available for listing.',
99     'The current process may not have any or none matches current filtering.'
100 ];
101
102 type WorkflowProcessesTitleProps = WithStyles<CssRules>;
103
104 const WorkflowProcessesTitle = withStyles(styles)(
105     ({ classes }: WorkflowProcessesTitleProps) =>
106         <div className={classes.cardHeader}>
107             <ProcessIcon className={classes.iconHeader} /><span></span>
108             <Typography noWrap variant='h6' color='inherit'>
109                 Run History
110             </Typography>
111         </div>
112 );
113
114 export const WorkflowProcessesPanelRoot = (props: WorkflowProcessesPanelProps & MPVPanelProps) => {
115     return <DataExplorer
116         id={WORKFLOW_PROCESSES_PANEL_ID}
117         onRowClick={props.onItemClick}
118         onRowDoubleClick={props.onItemDoubleClick}
119         onContextMenu={(event, item) => props.onContextMenu(event, item, props.resources)}
120         contextMenuColumn={false}
121         defaultViewIcon={ProcessIcon}
122         defaultViewMessages={DEFAULT_VIEW_MESSAGES}
123         doHidePanel={props.doHidePanel}
124         doMaximizePanel={props.doMaximizePanel}
125         doUnMaximizePanel={props.doUnMaximizePanel}
126         panelMaximized={props.panelMaximized}
127         panelName={props.panelName}
128         title={<WorkflowProcessesTitle />}
129         forceMultiSelectMode />;
130 };