Merge branch '14248_assigning_properties_to_projects_during_create'
[arvados-workbench2.git] / src / views / process-panel / process-panel-root.tsx
index 49ce98c03e4bd11dcad78b7c4dbbdc70029543f8..5fb6390c3a9737e4f27830299a8dd1835a4c650f 100644 (file)
@@ -9,83 +9,57 @@ import { DefaultView } from '~/components/default-view/default-view';
 import { ProcessIcon } from '~/components/icon/icon';
 import { Process } from '~/store/processes/process';
 import { SubprocessesCard } from './subprocesses-card';
-import { ProcessSubprocesses } from '~/views-components/process-subprocesses/process-subprocesses';
-import { SubprocessesStatus } from '~/views/process-panel/process-subprocesses';
-
-type CssRules = 'headerActive' | 'headerCompleted' | 'headerQueued' | 'headerFailed' | 'headerCanceled';
+import { ProcessSubprocesses } from '~/views/process-panel/process-subprocesses';
+import { SubprocessFilterDataProps } from '~/components/subprocess-filter/subprocess-filter';
 
 export interface ProcessPanelRootDataProps {
     process?: Process;
+    subprocesses: Array<Process>;
+    filters: Array<SubprocessFilterDataProps>;
+    totalSubprocessesLength: number;
 }
 
 export interface ProcessPanelRootActionProps {
-    onContextMenu: (event: React.MouseEvent<HTMLElement>) => void;
+    onContextMenu: (event: React.MouseEvent<HTMLElement>, process: Process) => void;
+    onToggle: (status: string) => void;
+    openProcessInputDialog: (uuid: string) => void;
+    navigateToOutput: (uuid: string) => void;
+    navigateToWorkflow: (uuid: string) => void;
 }
 
 export type ProcessPanelRootProps = ProcessPanelRootDataProps & ProcessPanelRootActionProps;
 
-export const ProcessPanelRoot = (props: ProcessPanelRootProps) =>
-    props.process
-        ? <Grid container spacing={16}>
-            <Grid item xs={7}>
+export const ProcessPanelRoot = ({ process, ...props }: ProcessPanelRootProps) =>
+    process
+        ? <Grid container spacing={16} alignItems="stretch">
+            <Grid item sm={12} md={7}>
                 <ProcessInformationCard
-                    process={props.process}
-                    onContextMenu={props.onContextMenu} />
+                    process={process}
+                    onContextMenu={event => props.onContextMenu(event, process)}
+                    openProcessInputDialog={props.openProcessInputDialog}
+                    navigateToOutput={props.navigateToOutput}
+                    navigateToWorkflow={props.navigateToWorkflow}
+            />
             </Grid>
-            <Grid item xs={5}>
+            <Grid item sm={12} md={5}>
                 <SubprocessesCard
-                    subprocesses={4}
-                    filters={[
-                        {
-                            key: 'queued',
-                            value: 1,
-                            label: 'Queued',
-                            checked: true
-                        }, {
-                            key: 'active',
-                            value: 2,
-                            label: 'Active',
-                            checked: true
-                        },
-                        {
-                            key: 'completed',
-                            value: 2,
-                            label: 'Completed',
-                            checked: true
-                        },
-                        {
-                            key: 'failed',
-                            value: 2,
-                            label: 'Failed',
-                            checked: true
-                        }
-                    ]}
-                    onToggle={() => { return; }}
+                    subprocessesAmount={props.totalSubprocessesLength}
+                    filters={props.filters}
+                    onToggle={props.onToggle}
                 />
             </Grid>
-            <ProcessSubprocesses />
+            <Grid item xs={12}>
+                <ProcessSubprocesses
+                    subprocesses={props.subprocesses}
+                    onContextMenu={props.onContextMenu} />
+            </Grid>
         </Grid>
         : <Grid container
             alignItems='center'
-            justify='center'>
+            justify='center'
+            style={{ minHeight: '100%' }}>
             <DefaultView
                 icon={ProcessIcon}
                 messages={['Process not found']} />
         </Grid>;
 
-export const getBackgroundColorStatus = (status: string, classes: Record<CssRules, string>) => {
-    switch (status) {
-        case SubprocessesStatus.COMPLETED:
-            return classes.headerCompleted;
-        case SubprocessesStatus.CANCELED:
-            return classes.headerCanceled;
-        case SubprocessesStatus.QUEUED:
-            return classes.headerQueued;
-        case SubprocessesStatus.FAILED:
-            return classes.headerFailed;
-        case SubprocessesStatus.ACTIVE:
-            return classes.headerActive;
-        default:
-            return classes.headerQueued;
-    }
-};