Fix graph content not being refreshed on workflow change, adjust graph's tab height
authorDaniel Kos <daniel.kos@contractors.roche.com>
Thu, 8 Nov 2018 21:37:01 +0000 (22:37 +0100)
committerDaniel Kos <daniel.kos@contractors.roche.com>
Thu, 8 Nov 2018 21:37:01 +0000 (22:37 +0100)
Bug #14463

Arvados-DCO-1.1-Signed-off-by: Daniel Kos <daniel.kos@contractors.roche.com>

src/views/workflow-panel/workflow-description-card.tsx
src/views/workflow-panel/workflow-graph.tsx

index b4b9f20ae42d6c7043a6d0343e6ff842780eb649..02408b06bb7b6fcb03b76760ccfebbb6055f28eb 100644 (file)
@@ -22,7 +22,7 @@ import { DataTableDefaultView } from '~/components/data-table-default-view/data-
 import { WorkflowResource, parseWorkflowDefinition, getWorkflowInputs, getInputLabel, stringifyInputType } from '~/models/workflow';
 import { WorkflowGraph } from "~/views/workflow-panel/workflow-graph";
 
-export type CssRules = 'root' | 'tab' | 'inputTab' | 'descriptionTab' | 'inputsTable';
+export type CssRules = 'root' | 'tab' | 'inputTab' | 'graphTab' | 'descriptionTab' | 'inputsTable';
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     root: {
@@ -39,6 +39,11 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
             paddingBottom: theme.spacing.unit / 2,
         }
     },
+    graphTab: {
+        overflow: 'auto',
+        height: '450px',
+        marginTop: theme.spacing.unit,
+    },
     descriptionTab: {
         overflow: 'auto',
         maxHeight: '300px',
@@ -67,6 +72,9 @@ export const WorkflowDetailsCard = withStyles(styles)(
 
         render() {
             const { classes, workflow } = this.props;
+            if (workflow) {
+                console.log(workflow.definition);
+            }
             const { value } = this.state;
             return <div className={classes.root}>
                 <Tabs value={value} onChange={this.handleChange} centered={true}>
@@ -91,7 +99,7 @@ export const WorkflowDetailsCard = withStyles(styles)(
                             messages={['Please select a workflow to see its inputs.']} />
                     }
                 </CardContent>}
-                {value === 2 && <CardContent className={classes.inputTab}>
+                {value === 2 && <CardContent className={classes.graphTab}>
                     {workflow
                         ? <WorkflowGraph workflow={workflow} />
                         : <DataTableDefaultView
index de2903288f6e8520e6fc1beab935aab8a008a460..a2faf322fc0f41d333c0b9948620fedbecd372c4 100644 (file)
@@ -20,7 +20,7 @@ interface WorkflowGraphProps {
 export class WorkflowGraph extends React.Component<WorkflowGraphProps, {}> {
     private svgRoot: React.RefObject<SVGSVGElement> = React.createRef();
 
-    componentDidMount(): void {
+    setGraph() {
         const graphs = yaml.safeLoad(this.props.workflow.definition, { json: true });
 
         let workflowGraph = graphs;
@@ -37,7 +37,7 @@ export class WorkflowGraph extends React.Component<WorkflowGraphProps, {}> {
                 new SVGArrangePlugin(),
                 new SVGEdgeHoverPlugin(),
                 new SVGNodeMovePlugin({
-                    movementSpeed: 10
+                    movementSpeed: 2
                 }),
                 new SVGPortDragPlugin(),
                 new SelectionPlugin(),
@@ -47,6 +47,14 @@ export class WorkflowGraph extends React.Component<WorkflowGraphProps, {}> {
         workflow.draw();
     }
 
+    componentDidMount() {
+        this.setGraph();
+    }
+
+    componentDidUpdate() {
+        this.setGraph();
+    }
+
     render() {
         return <svg
             ref={this.svgRoot}