diff options
Diffstat (limited to 'apps/settings/src/components/Users/UserRowActions.vue')
-rw-r--r-- | apps/settings/src/components/Users/UserRowActions.vue | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/apps/settings/src/components/Users/UserRowActions.vue b/apps/settings/src/components/Users/UserRowActions.vue index fc7881aba6a..efd70d879a7 100644 --- a/apps/settings/src/components/Users/UserRowActions.vue +++ b/apps/settings/src/components/Users/UserRowActions.vue @@ -1,28 +1,10 @@ <!-- - - @copyright 2023 Ferdinand Thiessen <opensource@fthiessen.de> - - - - @author Christopher Ng <chrng8@gmail.com> - - @author Ferdinand Thiessen <opensource@fthiessen.de> - - - - @license AGPL-3.0-or-later - - - - 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/>. - - + - SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors + - SPDX-License-Identifier: AGPL-3.0-or-later --> <template> - <NcActions :aria-label="t('settings', 'Toggle user actions menu')" + <NcActions :aria-label="t('settings', 'Toggle account actions menu')" :disabled="disabled" :inline="1"> <NcActionButton :data-cy-user-list-action-toggle-edit="`${edit}`" @@ -33,30 +15,37 @@ <NcIconSvgWrapper :key="editSvg" :svg="editSvg" aria-hidden="true" /> </template> </NcActionButton> - <NcActionButton v-for="({ action, icon, text }, index) in actions" + <NcActionButton v-for="({ action, icon, text }, index) in enabledActions" :key="index" :disabled="disabled" :aria-label="text" :icon="icon" + close-after-click @click="(event) => action(event, { ...user })"> {{ text }} + <template v-if="isSvg(icon)" #icon> + <NcIconSvgWrapper :svg="icon" aria-hidden="true" /> + </template> </NcActionButton> </NcActions> </template> <script lang="ts"> -import { PropType, defineComponent } from 'vue' +import type { PropType } from 'vue' +import { defineComponent } from 'vue' +import isSvg from 'is-svg' -import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js' -import NcActions from '@nextcloud/vue/dist/Components/NcActions.js' -import NcIconSvgWrapper from '@nextcloud/vue/dist/Components/NcIconSvgWrapper.js' +import NcActionButton from '@nextcloud/vue/components/NcActionButton' +import NcActions from '@nextcloud/vue/components/NcActions' +import NcIconSvgWrapper from '@nextcloud/vue/components/NcIconSvgWrapper' import SvgCheck from '@mdi/svg/svg/check.svg?raw' -import SvgPencil from '@mdi/svg/svg/pencil.svg?raw' +import SvgPencil from '@mdi/svg/svg/pencil-outline.svg?raw' interface UserAction { action: (event: MouseEvent, user: Record<string, unknown>) => void, + enabled?: (user: Record<string, unknown>) => boolean, icon: string, - text: string + text: string, } export default defineComponent({ @@ -104,12 +93,21 @@ export default defineComponent({ /** * Current MDI logo to show for edit toggle */ - editSvg() { + editSvg(): string { return this.edit ? SvgCheck : SvgPencil }, + + /** + * Enabled user row actions + */ + enabledActions(): UserAction[] { + return this.actions.filter(action => typeof action.enabled === 'function' ? action.enabled(this.user) : true) + }, }, methods: { + isSvg, + /** * Toggle edit mode by emitting the update event */ |