1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
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';
27 type CssRules = 'iconHeader' | 'cardHeader';
29 const styles: CustomStyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
32 color: theme.customs.colors.greyL,
33 marginRight: theme.spacing(2),
40 export enum WorkflowProcessesPanelColumnNames {
43 CREATED_AT = "Created At",
47 export interface WorkflowProcessesPanelFilter extends DataTableFilterItem {
48 type: ResourceKind | ContainerRequestState;
51 export const workflowProcessesPanelColumns: DataColumns<string, ProcessResource> = [
53 name: WorkflowProcessesPanelColumnNames.NAME,
56 sort: { direction: SortDirection.NONE, field: "name" },
57 filters: createTree(),
58 render: uuid => <ResourceName uuid={uuid} />
61 name: WorkflowProcessesPanelColumnNames.STATUS,
64 mutuallyExclusiveFilters: true,
65 filters: getInitialProcessStatusFilters(),
66 render: uuid => <ProcessStatus uuid={uuid} />,
69 name: WorkflowProcessesPanelColumnNames.CREATED_AT,
72 sort: { direction: SortDirection.DESC, field: "createdAt" },
73 filters: createTree(),
74 render: uuid => <ResourceCreatedAtDate uuid={uuid} />
77 name: WorkflowProcessesPanelColumnNames.RUNTIME,
80 filters: createTree(),
81 render: uuid => <ContainerRunTime uuid={uuid} />
85 export interface WorkflowProcessesPanelDataProps {
86 resources: ResourcesState;
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;
95 type WorkflowProcessesPanelProps = WorkflowProcessesPanelActionProps & WorkflowProcessesPanelDataProps;
97 const DEFAULT_VIEW_MESSAGES = [
98 'No processes available for listing.',
99 'The current process may not have any or none matches current filtering.'
102 type WorkflowProcessesTitleProps = WithStyles<CssRules>;
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'>
114 export const WorkflowProcessesPanelRoot = (props: WorkflowProcessesPanelProps & MPVPanelProps) => {
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={true}
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 />} />;