diff options
author | dartcafe <github@dartcafe.de> | 2022-04-27 11:36:02 +0300 |
---|---|---|
committer | dartcafe <github@dartcafe.de> | 2022-04-27 11:36:02 +0300 |
commit | 8fcd39431d3cf91da9334c6a069f163daab88cdc (patch) | |
tree | 023f565c82549e35c0f34cd7872f881ab591c8c4 /src | |
parent | 7c69c996d175cc4fd9a00e4de58abc9d51c31946 (diff) |
Add option to hide local mail addresses #2392
Signed-off-by: dartcafe <github@dartcafe.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/js/components/Settings/AdminSettings/AdminHideMailAddresses.vue | 145 | ||||
-rw-r--r-- | src/js/store/modules/appSettings.js | 26 | ||||
-rw-r--r-- | src/js/views/AdminSettingsPage.vue | 3 |
3 files changed, 162 insertions, 12 deletions
diff --git a/src/js/components/Settings/AdminSettings/AdminHideMailAddresses.vue b/src/js/components/Settings/AdminSettings/AdminHideMailAddresses.vue new file mode 100644 index 00000000..e9151515 --- /dev/null +++ b/src/js/components/Settings/AdminSettings/AdminHideMailAddresses.vue @@ -0,0 +1,145 @@ +<!-- + - @copyright Copyright (c) 2018 René Gieling <github@dartcafe.de> + - + - @author René Gieling <github@dartcafe.de> + - + - @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/>. + - + --> + +<template> + <div class="user_settings"> + <CheckboxRadioSwitch :checked.sync="hideMailAddresses" type="switch"> + {{ t('polls', 'Hide email addresses of internal users') }} + </CheckboxRadioSwitch> + <div v-if="hideMailAddresses" class="settings_details"> + <div>{{ t('polls','Show email Addresses for for the following groups') }}</div> + <Multiselect v-model="showMailAddressesGroups" + class="stretch" + label="displayName" + track-by="id" + :options="groups" + :user-select="true" + :clear-on-select="false" + :preserve-search="true" + :multiple="true" + :loading="isLoading" + :placeholder="t('polls', 'Leave empty to disallow for all.')" + @search-change="loadGroups" /> + </div> + </div> +</template> + +<script> + +import debounce from 'lodash/debounce' +import { mapState } from 'vuex' +import axios from '@nextcloud/axios' +import { generateUrl } from '@nextcloud/router' +import { CheckboxRadioSwitch, Multiselect } from '@nextcloud/vue' + +export default { + name: 'AdminHideMailAddresses', + + components: { + CheckboxRadioSwitch, + Multiselect, + }, + + data() { + return { + searchToken: null, + groups: [], + isLoading: false, + } + }, + + computed: { + ...mapState({ + appSettings: (state) => state.appSettings, + }), + + // Add bindings + hideMailAddresses: { + get() { + return !this.appSettings.showMailAddresses + }, + set(value) { + this.writeValue({ showMailAddresses: !value }) + }, + }, + showMailAddressesGroups: { + get() { + return this.appSettings.showMailAddressesGroups + }, + set(value) { + this.writeValue({ showMailAddressesGroups: value }) + }, + }, + }, + + created() { + this.loadGroups('') + }, + + methods: { + async writeValue(value) { + await this.$store.commit('appSettings/set', value) + this.$store.dispatch('appSettings/write') + }, + + loadGroups: debounce(async function(query) { + let endPoint = generateUrl(`apps/polls/groups/${query}`) + + if (!query.trim()) { + endPoint = generateUrl('apps/polls/groups') + } + this.isLoading = true + + if (this.searchToken) { + this.searchToken.cancel() + } + this.searchToken = axios.CancelToken.source() + try { + const response = await axios.get(endPoint, { cancelToken: this.searchToken.token }) + this.groups = response.data.groups + this.isLoading = false + } catch (e) { + if (axios.isCancel(e)) { + // request was cancelled + } else { + console.error(e.response) + this.isLoading = false + } + } + }, 250), + }, +} +</script> + +<style lang="scss"> + .user_settings { + padding-top: 16px; + } + + .settings_details { + padding-bottom: 16px; + margin-left: 36px; + input, .stretch { + width: 100%; + } + } +</style> diff --git a/src/js/store/modules/appSettings.js b/src/js/store/modules/appSettings.js index 3dd78d31..de3c0627 100644 --- a/src/js/store/modules/appSettings.js +++ b/src/js/store/modules/appSettings.js @@ -25,30 +25,32 @@ import axios from '@nextcloud/axios' import { generateUrl } from '@nextcloud/router' const defaultAppSettings = () => ({ + allAccessGroups: [], allowCombo: true, allowPublicShares: true, allowAllAccess: true, allowPollCreation: true, allowPollDownload: true, - showLogin: true, - allAccessGroups: [], - publicSharesGroups: [], - pollCreationGroups: [], - comboGroups: [], - pollDownloadGroups: [], autoArchive: false, autoArchiveOffset: 30, + defaultPrivacyUrl: '', + defaultImprintUrl: '', + disclaimer: '', + imprintUrl: '', + legalTermsInEmail: false, + privacyUrl: '', + showMailAddresses: 'false', + showLogin: true, updateType: 'longPolling', useActivity: false, useCollaboration: true, - privacyUrl: '', - imprintUrl: '', usePrivacyUrl: '', useImprintUrl: '', - legalTermsInEmail: false, - defaultPrivacyUrl: '', - defaultImprintUrl: '', - disclaimer: '', + comboGroups: [], + publicSharesGroups: [], + pollCreationGroups: [], + pollDownloadGroups: [], + showMailAddressesGroups: [], }) const state = defaultAppSettings() diff --git a/src/js/views/AdminSettingsPage.vue b/src/js/views/AdminSettingsPage.vue index 77e5a863..41d02af4 100644 --- a/src/js/views/AdminSettingsPage.vue +++ b/src/js/views/AdminSettingsPage.vue @@ -47,6 +47,7 @@ <AdminMisc /> <AdminCombo /> <AdminPollDownload /> + <AdminHideMailAddresses /> </SettingsSection> <SettingsSection :title="t('polls', 'Performance settings')" @@ -65,6 +66,7 @@ import AdminPerformance from '../components/Settings/AdminSettings/AdminPerforma import AdminPollCreation from '../components/Settings/AdminSettings/AdminPollCreation.vue' import AdminPollDownload from '../components/Settings/AdminSettings/AdminPollDownload.vue' import AdminShareSettings from '../components/Settings/AdminSettings/AdminShareSettings.vue' +import AdminHideMailAddresses from '../components/Settings/AdminSettings/AdminHideMailAddresses.vue' import { SettingsSection } from '@nextcloud/vue' import '../assets/scss/markdown.scss' @@ -80,6 +82,7 @@ export default { AdminPollCreation, AdminPollDownload, AdminShareSettings, + AdminHideMailAddresses, SettingsSection, }, |