Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[21.01] Fix bug to prevent workflow refactor indices from being wrong. #11527

Merged
merged 2 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions client/src/components/Workflow/Editor/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ export default {
hasChanges: false,
nodeIndex: 0,
nodes: {},
requiresReindex: false, // track if node has been added or remove and backend may re-index nodes (hasChanges tracks a much more broad set of changes)
datatypesMapper: null,
datatypes: [],
report: {},
Expand Down Expand Up @@ -342,10 +343,11 @@ export default {
},
async onRefactor(response) {
await fromSimple(this, response.workflow);
this._loadEditorData(response);
this._loadEditorData(response.workflow);
},
onAdd(node) {
this.nodes[node.id] = node;
this.requiresReindex = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too aggressive and forces a reload even when you just loaded the workflow

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh - I did not test that.

This would have been a great feature to have UI tests for 😅.

Copy link
Member

@mvdbeek mvdbeek Mar 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly looked fine on first glance 😆

},
onUpdate(node) {
getModule({
Expand All @@ -366,6 +368,7 @@ export default {
this.canvasManager.drawOverview();
this.activeNode = null;
this.hasChanges = true;
this.requiresReindex = true;
showAttributes();
},
onEditSubworkflow(contentId) {
Expand Down Expand Up @@ -428,10 +431,20 @@ export default {
node.onUnhighlight();
},
onLint() {
this._ensureParametersSet();
// See notes in Lint.vue about why refresh is needed.
this.$refs.lint.refresh();
showLint();
if (this.requiresReindex) {
const r = window.confirm(
"Workflow steps have been added or removed since last save, the workflow needs to be saved before best practices can be analzyed. Save workflow?"
);
if (r == false) {
return;
}
this.onSave(true);
} else {
this._ensureParametersSet();
// See notes in Lint.vue about why refresh is needed.
this.$refs.lint.refresh();
showLint();
}
},
onEdit() {
this.isCanvas = true;
Expand Down
3 changes: 3 additions & 0 deletions client/src/components/Workflow/Editor/Options.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ export default {
hasChanges: {
type: Boolean,
},
requiredReindex: {
type: Boolean,
},
},
};
</script>
1 change: 1 addition & 0 deletions client/src/components/Workflow/Editor/modules/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export async function saveWorkflow(workflow) {
const { data } = await axios.put(`${getAppRoot()}api/workflows/${workflow.id}`, requestData);
workflow.name = data.name;
workflow.hasChanges = false;
workflow.requiresReindex = false;
workflow.stored = true;
workflow.version = data.version;
workflow.annotation = data.annotation;
Expand Down