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 { SUBPROCESS_PANEL_ID } from 'store/subprocess-panel/subprocess-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 import { SubprocessProgressBar } from 'components/subprocess-progress-bar/subprocess-progress-bar';
27 import { Process } from 'store/processes/process';
29 type CssRules = 'iconHeader' | 'cardHeader';
31 const styles: CustomStyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
34 color: theme.customs.colors.greyL,
35 marginRight: theme.spacing(2),
42 export enum SubprocessPanelColumnNames {
45 CREATED_AT = "Created At",
49 export interface SubprocessPanelFilter extends DataTableFilterItem {
50 type: ResourceKind | ContainerRequestState;
53 export const subprocessPanelColumns: DataColumns<string, ProcessResource> = [
55 name: SubprocessPanelColumnNames.NAME,
58 sort: {direction: SortDirection.NONE, field: "name"},
59 filters: createTree(),
60 render: uuid => <ResourceName uuid={uuid} />
63 name: SubprocessPanelColumnNames.STATUS,
66 mutuallyExclusiveFilters: true,
67 filters: getInitialProcessStatusFilters(),
68 render: uuid => <ProcessStatus uuid={uuid} />,
71 name: SubprocessPanelColumnNames.CREATED_AT,
74 sort: {direction: SortDirection.DESC, field: "createdAt"},
75 filters: createTree(),
76 render: uuid => <ResourceCreatedAtDate uuid={uuid} />
79 name: SubprocessPanelColumnNames.RUNTIME,
82 filters: createTree(),
83 render: uuid => <ContainerRunTime uuid={uuid} />
87 export interface SubprocessPanelDataProps {
89 resources: ResourcesState;
92 export interface SubprocessPanelActionProps {
93 onRowClick: (item: string) => void;
94 onContextMenu: (event: React.MouseEvent<HTMLElement>, item: string, resources: ResourcesState) => void;
95 onItemDoubleClick: (item: string) => void;
98 type SubprocessPanelProps = SubprocessPanelActionProps & SubprocessPanelDataProps;
100 const DEFAULT_VIEW_MESSAGES = [
101 'No subprocesses available for listing.',
102 'The current process may not have any or none matches current filtering.'
105 type SubProcessesTitleProps = WithStyles<CssRules>;
107 const SubProcessesTitle = withStyles(styles)(
108 ({classes}: SubProcessesTitleProps) =>
109 <div className={classes.cardHeader}>
110 <ProcessIcon className={classes.iconHeader} /><span></span>
111 <Typography noWrap variant='h6' color='inherit'>
117 export const SubprocessPanelRoot = (props: SubprocessPanelProps & MPVPanelProps) => {
119 id={SUBPROCESS_PANEL_ID}
120 onRowClick={props.onRowClick}
121 onRowDoubleClick={props.onItemDoubleClick}
122 onContextMenu={(event, item) => props.onContextMenu(event, item, props.resources)}
123 contextMenuColumn={false}
124 defaultViewIcon={ProcessIcon}
125 defaultViewMessages={DEFAULT_VIEW_MESSAGES}
126 doHidePanel={props.doHidePanel}
127 doMaximizePanel={props.doMaximizePanel}
128 doUnMaximizePanel={props.doUnMaximizePanel}
129 panelMaximized={props.panelMaximized}
130 panelName={props.panelName}
131 title={<SubProcessesTitle/>}
132 progressBar={<SubprocessProgressBar parentResource={props.process} />}