Skip to content

Commit

Permalink
Merge pull request #845 from shital-orchestral/save-chanegs-modification
Browse files Browse the repository at this point in the history
save indicator gets light up on rearrangeing the tasks
  • Loading branch information
m4dcoder authored Dec 11, 2020
2 parents 94202df + bd346a3 commit 438d522
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
7 changes: 2 additions & 5 deletions apps/st2-workflows/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,12 @@ const flowReducer = (state = {}, input) => {
vars = [],
ranges = {},
nextTask = 'task1',

panels = {},
actions = [],
notifications = [],

navigation = {},

dirty = false,

} = state;

state = {
Expand All @@ -149,10 +147,9 @@ const flowReducer = (state = {}, input) => {
panels,
actions,
notifications,

navigation,

dirty,

};

switch (input.type) {
Expand Down
4 changes: 2 additions & 2 deletions apps/st2-workflows/workflows.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -318,7 +318,7 @@ export default class Workflows extends Component {
attach={document.body}
handlers={guardKeyHandlers(this.props, [ 'undo', 'redo' ])}
>
<Canvas className="canvas" location={location} match={match} fetchActionscalled={e => this.props.fetchActions()} saveData={e => this.save()}>
<Canvas className="canvas" location={location} match={match} fetchActionscalled={e => this.props.fetchActions()} saveData={e => this.save()} dirtyflag={this.props.dirty}>
<Toolbar>
<ToolbarButton key="undo" icon="icon-redirect" title="Undo" errorMessage="Could not undo." onClick={() => undo()} />
<ToolbarButton key="redo" icon="icon-redirect2" title="Redo" errorMessage="Could not redo." onClick={() => redo()} />
Expand Down
22 changes: 13 additions & 9 deletions modules/st2flow-canvas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -207,7 +210,6 @@ function constructPathOrdering(
type: 'CHANGE_NAVIGATION',
navigation,
}),

})
)

Expand Down Expand Up @@ -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,
Expand All @@ -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) => {
Expand Down

0 comments on commit 438d522

Please sign in to comment.