From 2857fd2d8537106893f7cf7511f1c03a1ca57cf7 Mon Sep 17 00:00:00 2001 From: Shital Raut Date: Mon, 7 Dec 2020 17:49:17 +0400 Subject: [PATCH 1/2] save indicator gets light up on rearrangeing the tasks --- apps/st2-workflows/store.js | 5 +++-- apps/st2-workflows/workflows.component.js | 9 +++++---- modules/st2flow-canvas/index.js | 20 ++++++++++++-------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/apps/st2-workflows/store.js b/apps/st2-workflows/store.js index 6e5aab833..7a61fb96a 100644 --- a/apps/st2-workflows/store.js +++ b/apps/st2-workflows/store.js @@ -129,8 +129,8 @@ const flowReducer = (state = {}, input) => { notifications = [], navigation = {}, - dirty = false, + rearrangeflag = false, } = state; state = { @@ -151,8 +151,8 @@ const flowReducer = (state = {}, input) => { notifications, navigation, - dirty, + rearrangeflag, }; switch (input.type) { @@ -199,6 +199,7 @@ const flowReducer = (state = {}, input) => { ...state, ...workflowModelGetter(workflowModel), dirty: true, + rearrangeflag:true, }; } diff --git a/apps/st2-workflows/workflows.component.js b/apps/st2-workflows/workflows.component.js index a344fe510..33682b224 100644 --- a/apps/st2-workflows/workflows.component.js +++ b/apps/st2-workflows/workflows.component.js @@ -49,8 +49,8 @@ const POLL_INTERVAL = 5000; @connect( ({ flow: { - panels, actions, meta, metaSource, workflowSource, pack, input, dirty, - } }) => ({ isCollapsed: panels, actions, meta, metaSource, workflowSource, pack, input, dirty }), + panels, actions, meta, metaSource, workflowSource, pack, input, dirty,rearrangeflag, + } }) => ({ isCollapsed: panels, actions, meta, metaSource, workflowSource, pack, input, dirty,rearrangeflag }), (dispatch) => ({ fetchActions: () => dispatch({ type: 'FETCH_ACTIONS', @@ -76,6 +76,7 @@ export default class Workflows extends Component { input: PropTypes.array, workflowSource: PropTypes.string, dirty: PropTypes.bool, + rearrangeflag:PropTypes.bool, isCollapsed: PropTypes.object, actions: PropTypes.array, fetchActions: PropTypes.func, @@ -292,7 +293,7 @@ export default class Workflows extends Component { render() { // const { isCollapsed = {}, toggleCollapse, actions, undo, redo, layout, meta, input, dirty } = this.props; - const { isCollapsed = {}, actions, undo, redo, layout, meta, input, dirty } = this.props; + const { isCollapsed = {}, actions, undo, redo, layout, meta, input, dirty,rearrangeflag } = this.props; const { runningWorkflow, showForm } = this.state; const autoFormData = input && input.reduce((acc, value) => { @@ -318,7 +319,7 @@ export default class Workflows extends Component { attach={document.body} handlers={guardKeyHandlers(this.props, [ 'undo', 'redo' ])} > - this.props.fetchActions()} saveData={e => this.save()}> + this.props.fetchActions()} saveData={e => this.save()} rearrangeTasks={this.props.rearrangeflag}> undo()} /> redo()} /> diff --git a/modules/st2flow-canvas/index.js b/modules/st2flow-canvas/index.js index 7ee3e51f7..2c4271cec 100644 --- a/modules/st2flow-canvas/index.js +++ b/modules/st2flow-canvas/index.js @@ -43,9 +43,11 @@ import { ORBIT_DISTANCE } from './const'; import { Toolbar, ToolbarButton } from './toolbar'; import makeRoutingGraph from './routing-graph'; import PoissonRectangleSampler from './poisson-rect'; + import { origin } from './const'; -import style from './style.css'; +import style from './style.css'; +import store from '../../apps/st2-workflows/store'; type DOMMatrix = { m11: number, m22: number @@ -80,6 +82,7 @@ function weightedOrderedTaskSort(a, b) { return 0; } } + // given tasks and their undirected connections to other tasks, // sort the tasks into buckets of connected tasks. // This helps layout because it ensures that connected tasks can be drawn @@ -207,7 +210,6 @@ function constructPathOrdering( type: 'CHANGE_NAVIGATION', navigation, }), - }) ) @@ -557,7 +559,8 @@ export default class Canvas extends Component { } const { action, handle } = JSON.parse(e.dataTransfer.getData('application/json')); - const coords = new Vector(e.offsetX, e.offsetY).subtract(new Vector(handle)).subtract(new Vector(origin)); + const coords = new Vector(e.offsetX , e.offsetY).subtract(new Vector(handle)).subtract(new Vector(origin)); + this.props.issueModelCommand('addTask', { name: this.props.nextTask, action: action.ref, @@ -568,15 +571,16 @@ export default class Canvas extends Component { } handleTaskMove = async (task: TaskRefInterface, points: CanvasPoint,autoSave) => { - let x = points.x; - let y = points.y; - const coords = {x, y}; - this.props.issueModelCommand('updateTask', task, { coords }); + const x = points.x; + const y = points.y; + const coords = {x, y}; + this.props.issueModelCommand('updateTask', task, { coords }); - if(autoSave) { + if(autoSave && !this.props.rearrangeTasks) { await this.props.fetchActionscalled(); this.props.saveData(); } + } handleTaskSelect = (task: TaskRefInterface) => { From bd346a3e2deafb1f91b141a298cf2662230eeead Mon Sep 17 00:00:00 2001 From: Shital Raut Date: Thu, 10 Dec 2020 09:58:19 +0400 Subject: [PATCH 2/2] save indicator light up modification with same dirty flag --- apps/st2-workflows/store.js | 8 ++------ apps/st2-workflows/workflows.component.js | 9 ++++----- modules/st2flow-canvas/index.js | 4 ++-- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/apps/st2-workflows/store.js b/apps/st2-workflows/store.js index 7a61fb96a..db7b2678d 100644 --- a/apps/st2-workflows/store.js +++ b/apps/st2-workflows/store.js @@ -123,14 +123,12 @@ const flowReducer = (state = {}, input) => { vars = [], ranges = {}, nextTask = 'task1', - panels = {}, actions = [], notifications = [], - navigation = {}, dirty = false, - rearrangeflag = false, + } = state; state = { @@ -149,10 +147,9 @@ const flowReducer = (state = {}, input) => { panels, actions, notifications, - navigation, dirty, - rearrangeflag, + }; switch (input.type) { @@ -199,7 +196,6 @@ const flowReducer = (state = {}, input) => { ...state, ...workflowModelGetter(workflowModel), dirty: true, - rearrangeflag:true, }; } diff --git a/apps/st2-workflows/workflows.component.js b/apps/st2-workflows/workflows.component.js index 33682b224..4cf8b8924 100644 --- a/apps/st2-workflows/workflows.component.js +++ b/apps/st2-workflows/workflows.component.js @@ -49,8 +49,8 @@ const POLL_INTERVAL = 5000; @connect( ({ flow: { - panels, actions, meta, metaSource, workflowSource, pack, input, dirty,rearrangeflag, - } }) => ({ isCollapsed: panels, actions, meta, metaSource, workflowSource, pack, input, dirty,rearrangeflag }), + panels, actions, meta, metaSource, workflowSource, pack, input, dirty, + } }) => ({ isCollapsed: panels, actions, meta, metaSource, workflowSource, pack, input, dirty }), (dispatch) => ({ fetchActions: () => dispatch({ type: 'FETCH_ACTIONS', @@ -76,7 +76,6 @@ export default class Workflows extends Component { input: PropTypes.array, workflowSource: PropTypes.string, dirty: PropTypes.bool, - rearrangeflag:PropTypes.bool, isCollapsed: PropTypes.object, actions: PropTypes.array, fetchActions: PropTypes.func, @@ -293,7 +292,7 @@ export default class Workflows extends Component { render() { // const { isCollapsed = {}, toggleCollapse, actions, undo, redo, layout, meta, input, dirty } = this.props; - const { isCollapsed = {}, actions, undo, redo, layout, meta, input, dirty,rearrangeflag } = this.props; + const { isCollapsed = {}, actions, undo, redo, layout, meta, input, dirty} = this.props; const { runningWorkflow, showForm } = this.state; const autoFormData = input && input.reduce((acc, value) => { @@ -319,7 +318,7 @@ export default class Workflows extends Component { attach={document.body} handlers={guardKeyHandlers(this.props, [ 'undo', 'redo' ])} > - this.props.fetchActions()} saveData={e => this.save()} rearrangeTasks={this.props.rearrangeflag}> + this.props.fetchActions()} saveData={e => this.save()} dirtyflag={this.props.dirty}> undo()} /> redo()} /> diff --git a/modules/st2flow-canvas/index.js b/modules/st2flow-canvas/index.js index 2c4271cec..bfa583546 100644 --- a/modules/st2flow-canvas/index.js +++ b/modules/st2flow-canvas/index.js @@ -575,8 +575,8 @@ export default class Canvas extends Component { const y = points.y; const coords = {x, y}; this.props.issueModelCommand('updateTask', task, { coords }); - - if(autoSave && !this.props.rearrangeTasks) { + + if(autoSave && !this.props.dirtyflag) { await this.props.fetchActionscalled(); this.props.saveData(); }