diff --git a/apps/st2-workflows/store.js b/apps/st2-workflows/store.js index 6e5aab833..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, + } = state; state = { @@ -149,10 +147,9 @@ const flowReducer = (state = {}, input) => { panels, actions, notifications, - navigation, - dirty, + }; switch (input.type) { diff --git a/apps/st2-workflows/workflows.component.js b/apps/st2-workflows/workflows.component.js index a344fe510..4cf8b8924 100644 --- a/apps/st2-workflows/workflows.component.js +++ b/apps/st2-workflows/workflows.component.js @@ -292,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 } = 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) => { @@ -318,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()}> + 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 7ee3e51f7..bfa583546 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 }); - - if(autoSave) { + const x = points.x; + const y = points.y; + const coords = {x, y}; + this.props.issueModelCommand('updateTask', task, { coords }); + + if(autoSave && !this.props.dirtyflag) { await this.props.fetchActionscalled(); this.props.saveData(); } + } handleTaskSelect = (task: TaskRefInterface) => {