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 { StyleRulesCallback, Typography, WithStyles, withStyles } from '@material-ui/core';
21 import { ArvadosTheme } from 'common/custom-theme';
22 import { ProcessResource } from 'models/process';
24 type CssRules = 'iconHeader' | 'cardHeader';
26 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
29 color: theme.customs.colors.greyL,
30 marginRight: theme.spacing.unit * 2,
37 export enum WorkflowProcessesPanelColumnNames {
40 CREATED_AT = "Created At",
44 export interface WorkflowProcessesPanelFilter extends DataTableFilterItem {
45 type: ResourceKind | ContainerRequestState;
48 export const workflowProcessesPanelColumns: DataColumns<string, ProcessResource> = [
50 name: WorkflowProcessesPanelColumnNames.NAME,
53 sort: { direction: SortDirection.NONE, field: "name" },
54 filters: createTree(),
55 render: uuid => <ResourceName uuid={uuid} />
58 name: WorkflowProcessesPanelColumnNames.STATUS,
61 mutuallyExclusiveFilters: true,
62 filters: getInitialProcessStatusFilters(),
63 render: uuid => <ProcessStatus uuid={uuid} />,
66 name: WorkflowProcessesPanelColumnNames.CREATED_AT,
69 sort: { direction: SortDirection.DESC, field: "createdAt" },
70 filters: createTree(),
71 render: uuid => <ResourceCreatedAtDate uuid={uuid} />
74 name: WorkflowProcessesPanelColumnNames.RUNTIME,
77 filters: createTree(),
78 render: uuid => <ContainerRunTime uuid={uuid} />
82 export interface WorkflowProcessesPanelDataProps {
83 resources: ResourcesState;
86 export interface WorkflowProcessesPanelActionProps {
87 onItemClick: (item: string) => void;
88 onContextMenu: (event: React.MouseEvent<HTMLElement>, item: string, resources: ResourcesState) => void;
89 onItemDoubleClick: (item: string) => void;
92 type WorkflowProcessesPanelProps = WorkflowProcessesPanelActionProps & WorkflowProcessesPanelDataProps;
94 const DEFAULT_VIEW_MESSAGES = [
95 'No processes available for listing.',
96 'The current process may not have any or none matches current filtering.'
99 type WorkflowProcessesTitleProps = WithStyles<CssRules>;
101 const WorkflowProcessesTitle = withStyles(styles)(
102 ({ classes }: WorkflowProcessesTitleProps) =>
103 <div className={classes.cardHeader}>
104 <ProcessIcon className={classes.iconHeader} /><span></span>
105 <Typography noWrap variant='h6' color='inherit'>
111 export const WorkflowProcessesPanelRoot = (props: WorkflowProcessesPanelProps & MPVPanelProps) => {
113 id={WORKFLOW_PROCESSES_PANEL_ID}
114 onRowClick={props.onItemClick}
115 onRowDoubleClick={props.onItemDoubleClick}
116 onContextMenu={(event, item) => props.onContextMenu(event, item, props.resources)}
117 contextMenuColumn={true}
118 defaultViewIcon={ProcessIcon}
119 defaultViewMessages={DEFAULT_VIEW_MESSAGES}
120 doHidePanel={props.doHidePanel}
121 doMaximizePanel={props.doMaximizePanel}
122 doUnMaximizePanel={props.doUnMaximizePanel}
123 panelMaximized={props.panelMaximized}
124 panelName={props.panelName}
125 title={<WorkflowProcessesTitle />}
126 forceMultiSelectMode />;