diff options
author | Pytal <24800714+Pytal@users.noreply.github.com> | 2024-06-06 17:00:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-06 17:00:37 -0700 |
commit | 0310df5d3b7c43352f35a2eef0aa906f1d7d8d93 (patch) | |
tree | 8ed99d18db03118b48a9e61b0fb9cbb24c979eb4 /apps | |
parent | 512753aaf662632bc599b51870ab408613b6e933 (diff) | |
parent | d15ed3f723dbc2904e8889a5c3b854f9d28a1cd7 (diff) | |
download | nextcloud-server-0310df5d3b7c43352f35a2eef0aa906f1d7d8d93.tar.gz nextcloud-server-0310df5d3b7c43352f35a2eef0aa906f1d7d8d93.zip |
Merge pull request #45686 from nextcloud/feat/user-row-action-enabled
feat(settings): Add user row action enabled callback
Diffstat (limited to 'apps')
-rw-r--r-- | apps/settings/src/components/Users/UserRowActions.vue | 15 | ||||
-rw-r--r-- | apps/settings/src/views/UserManagement.vue | 4 |
2 files changed, 15 insertions, 4 deletions
diff --git a/apps/settings/src/components/Users/UserRowActions.vue b/apps/settings/src/components/Users/UserRowActions.vue index 9fde67bb45b..c3c6b239a0c 100644 --- a/apps/settings/src/components/Users/UserRowActions.vue +++ b/apps/settings/src/components/Users/UserRowActions.vue @@ -15,11 +15,12 @@ <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 }} </NcActionButton> @@ -38,8 +39,9 @@ import SvgPencil from '@mdi/svg/svg/pencil.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({ @@ -87,9 +89,16 @@ 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: { diff --git a/apps/settings/src/views/UserManagement.vue b/apps/settings/src/views/UserManagement.vue index a332de1d92d..4c1797d8b90 100644 --- a/apps/settings/src/views/UserManagement.vue +++ b/apps/settings/src/views/UserManagement.vue @@ -80,13 +80,15 @@ export default defineComponent({ * @param {string} icon the icon class * @param {string} text the text to display * @param {Function} action the function to run + * @param {(user: Record<string, unknown>) => boolean} enabled return true if the action is enabled for the user * @return {Array} */ - registerAction(icon, text, action) { + registerAction(icon, text, action, enabled) { this.externalActions.push({ icon, text, action, + enabled, }) return this.externalActions }, |