feat: Add save confirmation modal when leaving sharing modal (#4683)

This commit is contained in:
Alex Grozav 2022-11-22 13:03:15 +02:00 committed by GitHub
parent 249b7eba15
commit 173badc4e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View file

@ -5,6 +5,7 @@
:eventBus="modalBus"
:name="WORKFLOW_SHARE_MODAL_KEY"
:center="true"
:beforeClose="onCloseModal"
>
<template #content>
<div :class="$style.container">
@ -242,6 +243,25 @@ export default mixins(
this.onRemoveSharee(user.id);
}
},
async onCloseModal() {
if (this.isDirty) {
const shouldSave = await this.confirmMessage(
this.$locale.baseText(
'workflows.shareModal.saveBeforeClose.message',
),
this.$locale.baseText('workflows.shareModal.saveBeforeClose.title'),
'warning',
this.$locale.baseText('workflows.shareModal.saveBeforeClose.confirmButtonText'),
this.$locale.baseText('workflows.shareModal.saveBeforeClose.cancelButtonText'),
);
if (shouldSave) {
return await this.onSave();
}
}
return true;
},
async loadUsers() {
await this.usersStore.fetchUsers();
},

View file

@ -1378,6 +1378,10 @@
"workflows.shareModal.list.delete.confirm.message": "<strong>This might cause the workflow to stop working:</strong> if {name} is the only user with access to credentials used in this workflow, those credentials will also be removed from {workflow}.",
"workflows.shareModal.list.delete.confirm.confirmButtonText": "Remove access",
"workflows.shareModal.list.delete.confirm.cancelButtonText": "Cancel",
"workflows.shareModal.saveBeforeClose.title": "Save sharing changes?",
"workflows.shareModal.saveBeforeClose.message": "You have unsaved changes. Do you want to save them before closing?",
"workflows.shareModal.saveBeforeClose.confirmButtonText": "Save",
"workflows.shareModal.saveBeforeClose.cancelButtonText": "Close without saving",
"workflows.shareModal.save": "Save",
"workflows.shareModal.changesHint": "You made changes",
"workflows.shareModal.notAvailable": "Sharing workflows with others is currently available only on n8n cloud, our hosted offering.",