From 3745be4c3cc2dce0a67ee83a190cf08f18326fea Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Fri, 17 Apr 2020 10:24:56 +0200 Subject: [PATCH] Use nc/dialogs instead of OCP.Toast Signed-off-by: Georg Ehrke --- package-lock.json | 21 +++++++++++++++++++++ package.json | 1 + src/components/Admins.vue | 7 ++++--- src/components/Encryption.vue | 3 ++- src/components/Location.vue | 3 ++- src/components/Shares.vue | 3 ++- src/main.js | 3 ++- 7 files changed, 34 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index ad8a5256..0c72cb35 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1283,6 +1283,22 @@ "integrity": "sha512-f+sKpdLZXkODV+OY39K1M+Spmd4RgxmtEXmNn4Bviv4R7uBFHXuw+JX9ZdfDeOryfHjJ/TRQxQEp0GMpBwZFUw==", "dev": true }, + "@nextcloud/dialogs": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@nextcloud/dialogs/-/dialogs-1.2.2.tgz", + "integrity": "sha512-N8A8J8UKSvz/hqNcm7gwpm70uAAsx0wurjhdYZ989jaMho+H/Hinjd2jkbV8UnsYYw0x/vWvEX5t6Lwbv08K0g==", + "requires": { + "core-js": "3.6.4", + "toastify-js": "^1.7.0" + }, + "dependencies": { + "core-js": { + "version": "3.6.4", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.4.tgz", + "integrity": "sha512-4paDGScNgZP2IXXilaffL9X7968RuvwlkK3xWtZRVqgd8SYNiVKRJvkFd1aqqEuPfN7E68ZHEp9hDj6lHj4Hyw==" + } + } + }, "@nextcloud/eslint-config": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@nextcloud/eslint-config/-/eslint-config-2.0.0.tgz", @@ -8903,6 +8919,11 @@ "repeat-string": "^1.6.1" } }, + "toastify-js": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/toastify-js/-/toastify-js-1.7.0.tgz", + "integrity": "sha512-GmPy4zJ/ulCfmCHlfCtgcB+K2xhx2AXW3T/ZZOSjyjaIGevhz+uvR8HSCTay/wBq4tt2mUnBqlObP1sSWGlsnQ==" + }, "trim": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz", diff --git a/package.json b/package.json index c19257ce..74d1c065 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "@babel/polyfill": "^7.8.7", "@nextcloud/auth": "^1.2.3", "@nextcloud/axios": "^1.3.2", + "@nextcloud/dialogs": "^1.2.2", "@nextcloud/initial-state": "^1.1.2", "@nextcloud/l10n": "^1.2.3", "@nextcloud/router": "^1.0.2", diff --git a/src/components/Admins.vue b/src/components/Admins.vue index 0765dcb9..0c00657f 100644 --- a/src/components/Admins.vue +++ b/src/components/Admins.vue @@ -64,6 +64,7 @@ import Vue from 'vue' import ClickOutside from 'vue-click-outside' import HttpClient from '@nextcloud/axios' import { generateUrl } from '@nextcloud/router' +import { showError } from '@nextcloud/dialogs' import Actions from '@nextcloud/vue/dist/Components/Actions' import ActionButton from '@nextcloud/vue/dist/Components/ActionButton' import Avatar from '@nextcloud/vue/dist/Components/Avatar' @@ -99,7 +100,7 @@ export default { Vue.set(this, 'admins', resp.data) } catch (error) { console.error(error) - this.$toast('Error loading additional administrator.') + showError('Error loading additional administrator.') } finally { this.isLoading = false } @@ -132,7 +133,7 @@ export default { this.admins.push(response.data) } catch (error) { console.error(error) - this.$toast('Error adding new administrator.') + showError('Error adding new administrator.') } finally { this.isSavingChanges = false this.isAdding = false @@ -157,7 +158,7 @@ export default { } } catch (error) { console.error(error) - this.$toast('Error deleting new administrator.') + showError('Error deleting new administrator.') } }, }, diff --git a/src/components/Encryption.vue b/src/components/Encryption.vue index ec6d8f50..75002279 100644 --- a/src/components/Encryption.vue +++ b/src/components/Encryption.vue @@ -51,6 +51,7 @@ import { generateUrl } from '@nextcloud/router' import Actions from '@nextcloud/vue/dist/Components/Actions' import ActionButton from '@nextcloud/vue/dist/Components/ActionButton' import { loadState } from '@nextcloud/initial-state' +import { showError } from '@nextcloud/dialogs' export default { name: 'Encryption', @@ -123,7 +124,7 @@ export default { await HttpClient.post(url, { enabled: this.fullDiskEncryptionEnabled ? '1' : '0' }) } catch (error) { console.error(error) - this.$toast('Error saving new state of full-disk-encryption') + showError('Error saving new state of full-disk-encryption') // Reset state this.fullDiskEncryptionEnabled = !this.fullDiskEncryptionEnabled diff --git a/src/components/Location.vue b/src/components/Location.vue index 17fb1318..1b02bc39 100644 --- a/src/components/Location.vue +++ b/src/components/Location.vue @@ -52,6 +52,7 @@ import Multiselect from '@nextcloud/vue/dist/Components/Multiselect' import Actions from '@nextcloud/vue/dist/Components/Actions' import ActionButton from '@nextcloud/vue/dist/Components/ActionButton' import { loadState } from '@nextcloud/initial-state' +import { showError } from '@nextcloud/dialogs' import { getCountryList, @@ -136,7 +137,7 @@ export default { this.selectedCountry = value.code } catch (error) { console.error(error) - this.$toast('Error saving new location of the server') + showError('Error saving new location of the server') } finally { this.isEditingLocation = false this.isSavingChanges = false diff --git a/src/components/Shares.vue b/src/components/Shares.vue index b0079c6f..af7ccecc 100644 --- a/src/components/Shares.vue +++ b/src/components/Shares.vue @@ -39,6 +39,7 @@ import Vue from 'vue' import HttpClient from '@nextcloud/axios' import { generateOcsUrl } from '@nextcloud/router' import { getCurrentUser } from '@nextcloud/auth' +import { showError } from '@nextcloud/dialogs' import Avatar from '@nextcloud/vue/dist/Components/Avatar' export default { @@ -92,7 +93,7 @@ export default { }) } catch (error) { console.error(error) - this.$toast('Error loading information about shares.') + showError('Error loading information about shares.') } finally { this.isLoading = false } diff --git a/src/main.js b/src/main.js index 3602517f..10aa4d20 100644 --- a/src/main.js +++ b/src/main.js @@ -22,6 +22,7 @@ import 'core-js/stable' import Vue from 'vue' import { linkTo } from '@nextcloud/router' import { translate, translatePlural } from '@nextcloud/l10n' +import { getRequestToken } from '@nextcloud/auth' const Admins = () => import('./components/Admins.vue') const Location = () => import('./components/Location.vue') @@ -30,7 +31,7 @@ const Shares = () => import('./components/Shares.vue') // CSP config for webpack dynamic chunk loading // eslint-disable-next-line -__webpack_nonce__ = btoa(OC.requestToken) +__webpack_nonce__ = btoa(getRequestToken()) // Correct the root of the app for chunk loading // OC.linkTo matches the apps folders