diff --git a/CHANGELOG.md b/CHANGELOG.md index f708d1831..adb22b0b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - Create build script for GitHub pages with GitHub actions to allow for custom building [#1203](https://github.com/nextcloud/cookbook/pull/1203) @christianlupus - Added a new client and badges to the readme @TheMBeat +- Replace native alert and confirm dialogs with custom ones from nextcloud vue + [#1261](https://github.com/nextcloud/cookbook/pull/1261) @MarcelRobitaille ### Fixed - Added new public page styling in preparation for NC25 diff --git a/package-lock.json b/package-lock.json index 6d3278147..edc12dfce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "vue": "^2.6.11", "vue-i18n": "^8.17.1", "vue-material-design-icons": "^5.1.2", + "vue-modal-dialogs": "3.0.0", "vue-router": "^3.1.6", "vue-showdown": "^2.4.1", "vuex": "^3.1.3" @@ -9848,6 +9849,11 @@ "resolved": "https://registry.npmjs.org/vue-material-design-icons/-/vue-material-design-icons-5.1.2.tgz", "integrity": "sha512-nD1qFM2qAkMlVoe23EfNKIeMfYl6YjHZjSty9q0mwc2gXmPmvEhixywJQhM+VF5KVBI1zAkVTNLoUEERPY10pA==" }, + "node_modules/vue-modal-dialogs": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/vue-modal-dialogs/-/vue-modal-dialogs-3.0.0.tgz", + "integrity": "sha512-52x3DR3mfDLV0yubhoyiXuljRVNpu5EjHAWoKXPIqpVNx3E8DEs4mbXmDYP6xPIlIYfFiYN2aAlEhoMgXkjrBg==" + }, "node_modules/vue-multiselect": { "version": "2.1.6", "resolved": "https://registry.npmjs.org/vue-multiselect/-/vue-multiselect-2.1.6.tgz", @@ -18317,6 +18323,11 @@ "resolved": "https://registry.npmjs.org/vue-material-design-icons/-/vue-material-design-icons-5.1.2.tgz", "integrity": "sha512-nD1qFM2qAkMlVoe23EfNKIeMfYl6YjHZjSty9q0mwc2gXmPmvEhixywJQhM+VF5KVBI1zAkVTNLoUEERPY10pA==" }, + "vue-modal-dialogs": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/vue-modal-dialogs/-/vue-modal-dialogs-3.0.0.tgz", + "integrity": "sha512-52x3DR3mfDLV0yubhoyiXuljRVNpu5EjHAWoKXPIqpVNx3E8DEs4mbXmDYP6xPIlIYfFiYN2aAlEhoMgXkjrBg==" + }, "vue-multiselect": { "version": "2.1.6", "resolved": "https://registry.npmjs.org/vue-multiselect/-/vue-multiselect-2.1.6.tgz", diff --git a/package.json b/package.json index 93814d1da..d6698f38a 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "vue": "^2.6.11", "vue-i18n": "^8.17.1", "vue-material-design-icons": "^5.1.2", + "vue-modal-dialogs": "3.0.0", "vue-router": "^3.1.6", "vue-showdown": "^2.4.1", "vuex": "^3.1.3" diff --git a/src/components/AppControls/AppControls.vue b/src/components/AppControls/AppControls.vue index 9603c42cd..cc634c6f3 100644 --- a/src/components/AppControls/AppControls.vue +++ b/src/components/AppControls/AppControls.vue @@ -153,8 +153,6 @@ + + diff --git a/src/components/SimpleConfirmModal.vue b/src/components/SimpleConfirmModal.vue new file mode 100644 index 000000000..2ed40ff7b --- /dev/null +++ b/src/components/SimpleConfirmModal.vue @@ -0,0 +1,47 @@ + + + + + diff --git a/src/js/helper.js b/src/js/helper.js index 8f2a45f96..a8a1a1a15 100644 --- a/src/js/helper.js +++ b/src/js/helper.js @@ -1,3 +1,5 @@ +import { showSimpleAlertModal } from "cookbook/js/modals" + // Check if two routes point to the same component but have different content function shouldReloadContent(url1, url2) { if (url1 === url2) { @@ -141,8 +143,7 @@ function notify(title, options) { // eslint-disable-next-line no-unused-vars const notification = new Notification(title, options) } else { - // eslint-disable-next-line no-alert - alert(title) + showSimpleAlertModal(title) } }) } diff --git a/src/js/modals.js b/src/js/modals.js new file mode 100644 index 000000000..ae9569223 --- /dev/null +++ b/src/js/modals.js @@ -0,0 +1,11 @@ +import { create } from "vue-modal-dialogs" + +import SimpleAlertModal from "../components/SimpleAlertModal.vue" +import SimpleConfirmModal from "../components/SimpleConfirmModal.vue" + +export const showSimpleAlertModal = create(SimpleAlertModal, "content", "title") +export const showSimpleConfirmModal = create( + SimpleConfirmModal, + "content", + "title" +) diff --git a/src/main.js b/src/main.js index bf72c48b1..e47631af1 100644 --- a/src/main.js +++ b/src/main.js @@ -10,6 +10,8 @@ import VueShowdown from "vue-showdown" import Vue from "vue" +import * as ModalDialogs from "vue-modal-dialogs" + import helpers from "cookbook/js/helper" import router from "./router" @@ -46,6 +48,10 @@ Vue.use(VueShowdown, { flavor: "vanilla", }) +// TODO: Equivalent library for Vue3 when we make that transition: +// https://github.com/rlemaigre/vue3-promise-dialog +Vue.use(ModalDialogs) + // Pass translation engine to Vue Vue.prototype.t = window.t