Skip to content

Commit

Permalink
fix(editor): Prevent error from showing-up when duplicating unsaved w…
Browse files Browse the repository at this point in the history
…orkflow
  • Loading branch information
OlegIvaniv committed Mar 30, 2023
1 parent 58fda25 commit 67d948d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/editor-ui/src/components/DuplicateWorkflowDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,18 @@ export default mixins(showMessage, workflowHelpers, restApi).extend({
computed: {
...mapStores(useUsersStore, useSettingsStore, useWorkflowsStore),
workflowPermissions(): IPermissions {
return getWorkflowPermissions(
this.usersStore.currentUser,
this.workflowsStore.getWorkflowById(this.data.id),
);
const isEmptyWorkflow = this.data.id === PLACEHOLDER_EMPTY_WORKFLOW_ID;
const isCurrentWorkflowEmpty =
this.workflowsStore.workflow.id === PLACEHOLDER_EMPTY_WORKFLOW_ID;
// If the workflow to be duplicated is empty and the current workflow is also empty
// we need to use the current workflow to get the permissions
const currentWorkflow =
isEmptyWorkflow && isCurrentWorkflowEmpty
? this.workflowsStore.workflow
: this.workflowsStore.getWorkflowById(this.data.id);
return getWorkflowPermissions(this.usersStore.currentUser, currentWorkflow);
},
},
watch: {
Expand Down

0 comments on commit 67d948d

Please sign in to comment.