Merge branch 'master' of git.curoverse.com:arvados-workbench2 into 14347-advance...
[arvados.git] / src / views / process-panel / process-panel-root.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as React from 'react';
6 import { Grid } from '@material-ui/core';
7 import { ProcessInformationCard } from './process-information-card';
8 import { DefaultView } from '~/components/default-view/default-view';
9 import { ProcessIcon } from '~/components/icon/icon';
10 import { Process } from '~/store/processes/process';
11 import { SubprocessesCard } from './subprocesses-card';
12 import { ProcessSubprocesses } from '~/views/process-panel/process-subprocesses';
13 import { SubprocessFilterDataProps } from '~/components/subprocess-filter/subprocess-filter';
14
15 export interface ProcessPanelRootDataProps {
16     process?: Process;
17     subprocesses: Array<Process>;
18     filters: Array<SubprocessFilterDataProps>;
19     totalSubprocessesLength: number;
20 }
21
22 export interface ProcessPanelRootActionProps {
23     onContextMenu: (event: React.MouseEvent<HTMLElement>, process: Process) => void;
24     onToggle: (status: string) => void;
25 }
26
27 export type ProcessPanelRootProps = ProcessPanelRootDataProps & ProcessPanelRootActionProps;
28
29 export const ProcessPanelRoot = ({process, ...props}: ProcessPanelRootProps) =>
30     process
31         ? <Grid container spacing={16} alignItems="stretch">
32             <Grid item sm={12} md={7}>
33                 <ProcessInformationCard
34                     process={process}
35                     onContextMenu={event => props.onContextMenu(event, process)} />
36             </Grid>
37             <Grid item sm={12} md={5}>
38                 <SubprocessesCard
39                     subprocessesAmount={props.totalSubprocessesLength}
40                     filters={props.filters}
41                     onToggle={props.onToggle}
42                 />
43             </Grid>
44             <Grid item xs={12}>
45                 <ProcessSubprocesses
46                     subprocesses={props.subprocesses}
47                     onContextMenu={props.onContextMenu} />
48             </Grid>
49         </Grid>
50         : <Grid container
51             alignItems='center'
52             justify='center'
53             style={{ minHeight: '100%' }}>
54             <DefaultView
55                 icon={ProcessIcon}
56                 messages={['Process not found']} />
57         </Grid>;
58