mirror of
https://github.com/nextcloud/server.git
synced 2026-06-10 09:13:19 -04:00
Merge pull request #45686 from nextcloud/feat/user-row-action-enabled
feat(settings): Add user row action enabled callback
This commit is contained in:
commit
0310df5d3b
6 changed files with 23 additions and 12 deletions
|
|
@ -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: {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
},
|
||||
|
|
|
|||
6
dist/settings-users-3239.js
vendored
6
dist/settings-users-3239.js
vendored
File diff suppressed because one or more lines are too long
2
dist/settings-users-3239.js.map
vendored
2
dist/settings-users-3239.js.map
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue