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

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

Merged
merged 1 commit into from
Nov 22, 2022
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
20 changes: 20 additions & 0 deletions packages/editor-ui/src/components/WorkflowShareModal.ee.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
:eventBus="modalBus"
:name="WORKFLOW_SHARE_MODAL_KEY"
:center="true"
:beforeClose="onCloseModal"
>
<template #content>
<div :class="$style.container">
Expand Down Expand Up @@ -231,6 +232,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();
},
Expand Down
4 changes: 4 additions & 0 deletions packages/editor-ui/src/plugins/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,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.",
Expand Down