diff --git a/changelog/unreleased/enhancement-add-cancel-button-to-unsaved-changes-dialog b/changelog/unreleased/enhancement-add-cancel-button-to-unsaved-changes-dialog new file mode 100644 index 00000000000..4ad391e2fc4 --- /dev/null +++ b/changelog/unreleased/enhancement-add-cancel-button-to-unsaved-changes-dialog @@ -0,0 +1,6 @@ +Enhancement: Add cancel button to unsaved changes dialog + +We've added a cancel button to the unsaved changes dialog to allow users to cancel the action. + +https://github.com/owncloud/web/pull/11644 +https://github.com/owncloud/web/issues/11636 diff --git a/packages/web-pkg/src/components/AppTemplates/AppWrapper.vue b/packages/web-pkg/src/components/AppTemplates/AppWrapper.vue index c189c1f4788..3b36b956aec 100644 --- a/packages/web-pkg/src/components/AppTemplates/AppWrapper.vue +++ b/packages/web-pkg/src/components/AppTemplates/AppWrapper.vue @@ -90,6 +90,7 @@ import { DavPermission } from '@ownclouders/web-client/webdav' import { HttpError } from '@ownclouders/web-client' import { dirname } from 'path' import { useFileActionsOpenWithApp } from '../../composables/actions/files/useFileActionsOpenWithApp' +import { UnsavedChangesModal } from '../Modals' export default defineComponent({ name: 'AppWrapper', @@ -544,15 +545,17 @@ export default defineComponent({ onBeforeRouteLeave((_to, _from, next) => { if (unref(isDirty)) { dispatchModal({ - variation: 'danger', - icon: 'warning', + icon: 'error-warning', title: $gettext('Unsaved changes'), - message: $gettext('Your changes were not saved. Do you want to save them?'), - cancelText: $gettext("Don't Save"), - confirmText: $gettext('Save'), + customComponent: UnsavedChangesModal, focusTrapInitial: '.oc-modal-body-actions-confirm', - onCancel() { - next() + hideActions: true, + customComponentAttrs: () => { + return { + closeCallback: async () => { + next() + } + } }, async onConfirm() { await save() diff --git a/packages/web-pkg/src/components/Modals/UnsavedChangesModal.vue b/packages/web-pkg/src/components/Modals/UnsavedChangesModal.vue new file mode 100644 index 00000000000..35851db4dc3 --- /dev/null +++ b/packages/web-pkg/src/components/Modals/UnsavedChangesModal.vue @@ -0,0 +1,57 @@ + + + diff --git a/packages/web-pkg/src/components/Modals/index.ts b/packages/web-pkg/src/components/Modals/index.ts index 607684e2c33..168e7def6b5 100644 --- a/packages/web-pkg/src/components/Modals/index.ts +++ b/packages/web-pkg/src/components/Modals/index.ts @@ -3,3 +3,4 @@ export { default as SpaceMoveInfoModal } from './SpaceMoveInfoModal.vue' export { default as EmojiPickerModal } from './EmojiPickerModal.vue' export { default as FilePickerModal } from './FilePickerModal.vue' export { default as SaveAsModal } from './SaveAsModal.vue' +export { default as UnsavedChangesModal } from './UnsavedChangesModal.vue' diff --git a/packages/web-runtime/src/components/Topbar/TopBar.vue b/packages/web-runtime/src/components/Topbar/TopBar.vue index a545dba0af1..11243a7c7ea 100644 --- a/packages/web-runtime/src/components/Topbar/TopBar.vue +++ b/packages/web-runtime/src/components/Topbar/TopBar.vue @@ -10,12 +10,7 @@ :menu-items="appMenuExtensions" /> - +