Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions apps/settings/src/components/Users/UserRowActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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({
Expand Down Expand Up @@ -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: {
Expand Down
4 changes: 3 additions & 1 deletion apps/settings/src/views/UserManagement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
6 changes: 3 additions & 3 deletions dist/settings-users-3239.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-users-3239.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/settings-vue-settings-apps-users-management.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-apps-users-management.js.map

Large diffs are not rendered by default.