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 { DataTableFilterItem } from 'components/data-table-filters/data-table-filters';
8 import { ContainerRequestState } from 'models/container-request';
9 import { DataColumns, SortDirection } from 'components/data-table/data-column';
10 import { ResourceKind } from 'models/resource';
11 import { ResourceCreatedAtDate, ProcessStatus, ContainerRunTime } from 'views-components/data-explorer/renderers';
12 import { ProcessIcon } from 'components/icon/icon';
13 import { ResourceName } from 'views-components/data-explorer/renderers';
14 import { SUBPROCESS_PANEL_ID } from 'store/subprocess-panel/subprocess-panel-actions';
15 import { createTree } from 'models/tree';
16 import { getInitialProcessStatusFilters } from 'store/resource-type-filters/resource-type-filters';
17 import { ResourcesState } from 'store/resources/resources';
18 import { MPVPanelProps } from 'components/multi-panel-view/multi-panel-view';
19 import { CustomStyleRulesCallback } from 'common/custom-theme';
20 import { Typography } from '@mui/material';
21 import { WithStyles } from '@mui/styles';
22 import withStyles from '@mui/styles/withStyles';
23 import { ArvadosTheme } from 'common/custom-theme';
24 import { ProcessResource } from 'models/process';
25 import { SubprocessProgressBar } from 'components/subprocess-progress-bar/subprocess-progress-bar';
26 import { Process } from 'store/processes/process';
28 type CssRules = 'iconHeader' | 'cardHeader';
30 const styles: CustomStyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
33 color: theme.customs.colors.greyL,
34 marginRight: theme.spacing(2),
41 export enum SubprocessPanelColumnNames {
44 CREATED_AT = "Created At",
48 export interface SubprocessPanelFilter extends DataTableFilterItem {
49 type: ResourceKind | ContainerRequestState;
52 export const subprocessPanelColumns: DataColumns<string, ProcessResource> = [
54 name: SubprocessPanelColumnNames.NAME,
57 sort: {direction: SortDirection.NONE, field: "name"},
58 filters: createTree(),
59 render: uuid => <ResourceName uuid={uuid} />
62 name: SubprocessPanelColumnNames.STATUS,
65 mutuallyExclusiveFilters: true,
66 filters: getInitialProcessStatusFilters(),
67 render: uuid => <ProcessStatus uuid={uuid} />,
70 name: SubprocessPanelColumnNames.CREATED_AT,
73 sort: {direction: SortDirection.DESC, field: "createdAt"},
74 filters: createTree(),
75 render: uuid => <ResourceCreatedAtDate uuid={uuid} />
78 name: SubprocessPanelColumnNames.RUNTIME,
81 filters: createTree(),
82 render: uuid => <ContainerRunTime uuid={uuid} />
86 export interface SubprocessPanelDataProps {
88 resources: ResourcesState;
91 export interface SubprocessPanelActionProps {
92 onRowClick: (item: string) => void;
93 onContextMenu: (event: React.MouseEvent<HTMLElement>, item: string, resources: ResourcesState) => void;
94 onItemDoubleClick: (item: string) => void;
97 type SubprocessPanelProps = SubprocessPanelActionProps & SubprocessPanelDataProps;
99 const DEFAULT_VIEW_MESSAGES = [
100 'No subprocesses available for listing.',
101 'The current process may not have any or none matches current filtering.'
104 type SubProcessesTitleProps = WithStyles<CssRules>;
106 const SubProcessesTitle = withStyles(styles)(
107 ({classes}: SubProcessesTitleProps) =>
108 <div className={classes.cardHeader}>
109 <ProcessIcon className={classes.iconHeader} /><span></span>
110 <Typography noWrap variant='h6' color='inherit'>
116 export const SubprocessPanelRoot = (props: SubprocessPanelProps & MPVPanelProps) => {
118 id={SUBPROCESS_PANEL_ID}
119 onRowClick={props.onRowClick}
120 onRowDoubleClick={props.onItemDoubleClick}
121 onContextMenu={(event, item) => props.onContextMenu(event, item, props.resources)}
122 contextMenuColumn={true}
123 defaultViewIcon={ProcessIcon}
124 defaultViewMessages={DEFAULT_VIEW_MESSAGES}
125 doHidePanel={props.doHidePanel}
126 doMaximizePanel={props.doMaximizePanel}
127 doUnMaximizePanel={props.doUnMaximizePanel}
128 panelMaximized={props.panelMaximized}
129 panelName={props.panelName}
130 title={<SubProcessesTitle/>}
131 progressBar={<SubprocessProgressBar parentResource={props.process} />}