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 { StyleRulesCallback, Typography, WithStyles, withStyles } from '@material-ui/core';
21 import { ArvadosTheme } from 'common/custom-theme';
22 import { ProcessResource } from 'models/process';
23 import { SubprocessProgressBar } from 'components/subprocess-progress-bar/subprocess-progress-bar';
24 import { Process } from 'store/processes/process';
26 type CssRules = 'iconHeader' | 'cardHeader';
28 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
31 color: theme.customs.colors.greyL,
32 marginRight: theme.spacing.unit * 2,
39 export enum SubprocessPanelColumnNames {
42 CREATED_AT = "Created At",
46 export interface SubprocessPanelFilter extends DataTableFilterItem {
47 type: ResourceKind | ContainerRequestState;
50 export const subprocessPanelColumns: DataColumns<string, ProcessResource> = [
52 name: SubprocessPanelColumnNames.NAME,
55 sort: {direction: SortDirection.NONE, field: "name"},
56 filters: createTree(),
57 render: uuid => <ResourceName uuid={uuid} />
60 name: SubprocessPanelColumnNames.STATUS,
63 mutuallyExclusiveFilters: true,
64 filters: getInitialProcessStatusFilters(),
65 render: uuid => <ProcessStatus uuid={uuid} />,
68 name: SubprocessPanelColumnNames.CREATED_AT,
71 sort: {direction: SortDirection.DESC, field: "createdAt"},
72 filters: createTree(),
73 render: uuid => <ResourceCreatedAtDate uuid={uuid} />
76 name: SubprocessPanelColumnNames.RUNTIME,
79 filters: createTree(),
80 render: uuid => <ContainerRunTime uuid={uuid} />
84 export interface SubprocessPanelDataProps {
86 resources: ResourcesState;
89 export interface SubprocessPanelActionProps {
90 onRowClick: (item: string) => void;
91 onContextMenu: (event: React.MouseEvent<HTMLElement>, item: string, resources: ResourcesState) => void;
92 onItemDoubleClick: (item: string) => void;
95 type SubprocessPanelProps = SubprocessPanelActionProps & SubprocessPanelDataProps;
97 const DEFAULT_VIEW_MESSAGES = [
98 'No subprocesses available for listing.',
99 'The current process may not have any or none matches current filtering.'
102 type SubProcessesTitleProps = WithStyles<CssRules>;
104 const SubProcessesTitle = withStyles(styles)(
105 ({classes}: SubProcessesTitleProps) =>
106 <div className={classes.cardHeader}>
107 <ProcessIcon className={classes.iconHeader} /><span></span>
108 <Typography noWrap variant='h6' color='inherit'>
114 export const SubprocessPanelRoot = (props: SubprocessPanelProps & MPVPanelProps) => {
116 id={SUBPROCESS_PANEL_ID}
117 onRowClick={props.onRowClick}
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={<SubProcessesTitle/>}
129 progressBar={<SubprocessProgressBar parentResource={props.process} />}