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, WithStyles, withStyles } from '@material-ui/core';
22 import { ArvadosTheme } from 'common/custom-theme';
23 import { ProcessResource } from 'models/process';
24 import { SubprocessProgressBar } from 'components/subprocess-progress-bar/subprocess-progress-bar';
25 import { Process } from 'store/processes/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 SubprocessPanelColumnNames {
43 CREATED_AT = "Created At",
47 export interface SubprocessPanelFilter extends DataTableFilterItem {
48 type: ResourceKind | ContainerRequestState;
51 export const subprocessPanelColumns: DataColumns<string, ProcessResource> = [
53 name: SubprocessPanelColumnNames.NAME,
56 sort: {direction: SortDirection.NONE, field: "name"},
57 filters: createTree(),
58 render: uuid => <ResourceName uuid={uuid} />
61 name: SubprocessPanelColumnNames.STATUS,
64 mutuallyExclusiveFilters: true,
65 filters: getInitialProcessStatusFilters(),
66 render: uuid => <ProcessStatus uuid={uuid} />,
69 name: SubprocessPanelColumnNames.CREATED_AT,
72 sort: {direction: SortDirection.DESC, field: "createdAt"},
73 filters: createTree(),
74 render: uuid => <ResourceCreatedAtDate uuid={uuid} />
77 name: SubprocessPanelColumnNames.RUNTIME,
80 filters: createTree(),
81 render: uuid => <ContainerRunTime uuid={uuid} />
85 export interface SubprocessPanelDataProps {
87 resources: ResourcesState;
90 export interface SubprocessPanelActionProps {
91 onRowClick: (item: string) => void;
92 onContextMenu: (event: React.MouseEvent<HTMLElement>, item: string, resources: ResourcesState) => void;
93 onItemDoubleClick: (item: string) => void;
96 type SubprocessPanelProps = SubprocessPanelActionProps & SubprocessPanelDataProps;
98 const DEFAULT_VIEW_MESSAGES = [
99 'No subprocesses available for listing.',
100 'The current process may not have any or none matches current filtering.'
103 type SubProcessesTitleProps = WithStyles<CssRules>;
105 const SubProcessesTitle = withStyles(styles)(
106 ({classes}: SubProcessesTitleProps) =>
107 <div className={classes.cardHeader}>
108 <ProcessIcon className={classes.iconHeader} /><span></span>
109 <Typography noWrap variant='h6' color='inherit'>
115 export const SubprocessPanelRoot = (props: SubprocessPanelProps & MPVPanelProps) => {
117 id={SUBPROCESS_PANEL_ID}
118 onRowClick={props.onRowClick}
119 onRowDoubleClick={props.onItemDoubleClick}
120 onContextMenu={(event, item) => props.onContextMenu(event, item, props.resources)}
121 contextMenuColumn={true}
122 defaultViewIcon={ProcessIcon}
123 defaultViewMessages={DEFAULT_VIEW_MESSAGES}
124 doHidePanel={props.doHidePanel}
125 doMaximizePanel={props.doMaximizePanel}
126 doUnMaximizePanel={props.doUnMaximizePanel}
127 panelMaximized={props.panelMaximized}
128 panelName={props.panelName}
129 title={<SubProcessesTitle/>}
130 progressBar={<SubprocessProgressBar process={props.process} />} />;