diff options
author | Anna <anna@nextcloud.com> | 2024-04-03 12:16:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-03 12:16:20 +0200 |
commit | 7e0b7b4300c2677dd292f099888185f5c187880b (patch) | |
tree | da3af0732a954bfa121d84524d52a63b5385b73c /src | |
parent | bf205cc357349867208bf55af38668df5d060ce0 (diff) | |
parent | 5d730e100c67eb40d44fb88f2be231838d782640 (diff) |
Merge pull request #3837 from nextcloud/enh/rename-delete-to-unshare-for-shared-addressbooks
enh(sharing): Rename `delete` to `unshare from me` for shared address books
Diffstat (limited to 'src')
-rw-r--r-- | src/components/AppNavigation/Settings/SettingsAddressbook.vue | 28 | ||||
-rw-r--r-- | src/main.js | 6 | ||||
-rw-r--r-- | src/store/principals.js | 34 | ||||
-rw-r--r-- | src/views/Contacts.vue | 4 |
4 files changed, 67 insertions, 5 deletions
diff --git a/src/components/AppNavigation/Settings/SettingsAddressbook.vue b/src/components/AppNavigation/Settings/SettingsAddressbook.vue index c972b202..1f81fd33 100644 --- a/src/components/AppNavigation/Settings/SettingsAddressbook.vue +++ b/src/components/AppNavigation/Settings/SettingsAddressbook.vue @@ -105,9 +105,16 @@ </template> </ActionInput> </template> - <!-- delete addressbook --> - <ActionButton v-if="hasMultipleAddressbooks" + <ActionButton v-if="hasMultipleAddressbooks && addressbook.owner !== principalUrl && addressbook.owner !== '/remote.php/dav/principals/system/system/'" + @click="confirmUnshare"> + <template #icon> + <IconLoading v-if="deleteAddressbookLoading" :size="20" /> + <IconDelete :size="20" /> + </template> + {{ t('contacts', 'Unshare from me') }} + </ActionButton> + <ActionButton v-else-if="hasMultipleAddressbooks && addressbook.owner !== '/remote.php/dav/principals/system/system/'" @click="confirmDeletion"> <template #icon> <IconLoading v-if="deleteAddressbookLoading" :size="20" /> @@ -116,7 +123,6 @@ {{ t('contacts', 'Delete') }} </ActionButton> </Actions> - <!-- sharing input --> <ShareAddressBook v-if="shareOpen && !addressbook.readOnly" :addressbook="addressbook" /> </li> @@ -143,6 +149,8 @@ import { showError } from '@nextcloud/dialogs' import CopyToClipboardMixin from '../../../mixins/CopyToClipboardMixin.js' +import usePrincipalsStore from '../../../store/principals.js' + export default { name: 'SettingsAddressbook', @@ -241,6 +249,10 @@ export default { groupsCount() { return this.groups.length }, + principalUrl() { + const principalsStore = usePrincipalsStore() + return principalsStore.currentUserPrincipal.principalUrl + }, }, watch: { menuOpen() { @@ -277,7 +289,6 @@ export default { this.toggleEnabledLoading = false } }, - confirmDeletion() { OC.dialogs.confirm( t('contacts', 'This will delete the address book and every contacts within it'), @@ -286,7 +297,14 @@ export default { true, ) }, - + confirmUnshare() { + OC.dialogs.confirm( + t('contacts', 'This will unshare the address book and every contacts within it'), + t('contacts', 'Unshare {addressbook}?', { addressbook: this.addressbook.displayName }), + this.deleteAddressbook, + true, + ) + }, async deleteAddressbook(confirm) { if (confirm) { // change to loading status diff --git a/src/main.js b/src/main.js index d95c40b5..ab3c61eb 100644 --- a/src/main.js +++ b/src/main.js @@ -40,6 +40,8 @@ import '../css/contacts.scss' // Dialogs css import '@nextcloud/dialogs/style.css' +import { createPinia, PiniaVuePlugin } from 'pinia' + // CSP config for webpack dynamic chunk loading // eslint-disable-next-line __webpack_nonce__ = btoa(getRequestToken()) @@ -51,6 +53,9 @@ __webpack_nonce__ = btoa(getRequestToken()) // eslint-disable-next-line __webpack_public_path__ = generateFilePath('contacts', '', 'js/') +Vue.use(PiniaVuePlugin) +const pinia = createPinia() + // Register global directives Vue.directive('ClickOutside', ClickOutside) Vue.directive('Tooltip', VTooltip) @@ -81,4 +86,5 @@ export default new Vue({ router, store, render: h => h(App), + pinia, }) diff --git a/src/store/principals.js b/src/store/principals.js new file mode 100644 index 00000000..1523dd6f --- /dev/null +++ b/src/store/principals.js @@ -0,0 +1,34 @@ +/** + * @copyright Copyright (c) 2024 Grigory Vodyanov <scratchx@gmx.com> + * + * @author Grigory Vodyanov <scratchx@gmx.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +import { defineStore } from 'pinia' + +export default defineStore('principals', { + state: () => ({ + currentUserPrincipal: null, + }), + actions: { + setCurrentUserPrincipal(client) { + this.currentUserPrincipal = client?.currentUserPrincipal + }, + }, +}) diff --git a/src/views/Contacts.vue b/src/views/Contacts.vue index 01981f66..9d52e130 100644 --- a/src/views/Contacts.vue +++ b/src/views/Contacts.vue @@ -96,6 +96,8 @@ import rfcProps from '../models/rfcProps.js' import client from '../services/cdav.js' import isCirclesEnabled from '../services/isCirclesEnabled.js' +import usePrincipalsStore from '../store/principals.js' + export default { name: 'Contacts', @@ -250,6 +252,8 @@ export default { // get addressbooks then get contacts client.connect({ enableCardDAV: true }).then(() => { this.logger.debug('Connected to dav!', { client }) + const principalsStore = usePrincipalsStore() + principalsStore.setCurrentUserPrincipal(client) this.$store.dispatch('getAddressbooks') .then((addressbooks) => { const writeableAddressBooks = addressbooks.filter(addressbook => !addressbook.readOnly) |