From c1a890415435dd2207813a0cd0b71b1030aeb925 Mon Sep 17 00:00:00 2001 From: kontrollanten <6680299+kontrollanten@users.noreply.github.com> Date: Thu, 14 Mar 2024 06:50:09 +0100 Subject: [PATCH] feat(plugins): add filter:admin-user-list.bulk-actions.create.result --- .../overview/users/user-list/user-list.component.ts | 13 +++++++++---- client/src/root-helpers/plugins-manager.ts | 3 ++- .../models/src/plugins/client/client-hook.model.ts | 5 ++++- .../src/plugins/client/plugin-client-scope.type.ts | 3 ++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/client/src/app/+admin/overview/users/user-list/user-list.component.ts b/client/src/app/+admin/overview/users/user-list/user-list.component.ts index 3122fc00e..7add918a9 100644 --- a/client/src/app/+admin/overview/users/user-list/user-list.component.ts +++ b/client/src/app/+admin/overview/users/user-list/user-list.component.ts @@ -2,7 +2,7 @@ import { DatePipe, NgClass, NgIf } from '@angular/common' import { Component, OnInit, ViewChild } from '@angular/core' import { FormsModule } from '@angular/forms' import { ActivatedRoute, Router, RouterLink } from '@angular/router' -import { AuthService, ConfirmService, LocalStorageService, Notifier, RestPagination, RestTable } from '@app/core' +import { AuthService, ConfirmService, HooksService, LocalStorageService, Notifier, PluginService, RestPagination, RestTable } from '@app/core' import { formatICU, getAPIHost } from '@app/helpers' import { Actor } from '@app/shared/shared-main/account/actor.model' import { BlocklistService } from '@app/shared/shared-moderation/blocklist.service' @@ -114,7 +114,9 @@ export class UserListComponent extends RestTable implements OnInit { private auth: AuthService, private blocklist: BlocklistService, private userAdminService: UserAdminService, - private peertubeLocalStorage: LocalStorageService + private peertubeLocalStorage: LocalStorageService, + private hooks: HooksService, + private pluginService: PluginService ) { super() } @@ -133,10 +135,11 @@ export class UserListComponent extends RestTable implements OnInit { this.saveSelectedColumns() } - ngOnInit () { + async ngOnInit () { this.initialize() + await this.pluginService.ensurePluginsAreLoaded('admin-users') - this.bulkActions = [ + const bulkActions: DropdownAction[][] = [ [ { label: $localize`Delete`, @@ -167,6 +170,8 @@ export class UserListComponent extends RestTable implements OnInit { ] ] + this.bulkActions = await this.hooks.wrapObject(bulkActions, 'admin-users', 'filter:admin-user-list.bulk-actions.create.result') + this.columns = [ { id: 'username', label: $localize`Username` }, { id: 'role', label: $localize`Role` }, diff --git a/client/src/root-helpers/plugins-manager.ts b/client/src/root-helpers/plugins-manager.ts index 01d23c3e3..5e846ed8f 100644 --- a/client/src/root-helpers/plugins-manager.ts +++ b/client/src/root-helpers/plugins-manager.ts @@ -71,7 +71,8 @@ class PluginsManager { 'embed': new ReplaySubject(1), 'my-library': new ReplaySubject(1), 'video-channel': new ReplaySubject(1), - 'my-account': new ReplaySubject(1) + 'my-account': new ReplaySubject(1), + 'admin-users': new ReplaySubject(1) } private readonly peertubeHelpersFactory: PeertubeHelpersFactory diff --git a/packages/models/src/plugins/client/client-hook.model.ts b/packages/models/src/plugins/client/client-hook.model.ts index 4a0818c99..f007f3e77 100644 --- a/packages/models/src/plugins/client/client-hook.model.ts +++ b/packages/models/src/plugins/client/client-hook.model.ts @@ -97,7 +97,10 @@ export const clientFilterHookObject = { 'filter:internal.player.videojs.options.result': true, // Filter p2p media loader options built for PeerTube player - 'filter:internal.player.p2p-media-loader.options.result': true + 'filter:internal.player.p2p-media-loader.options.result': true, + + // Filter bulk actions in user list + 'filter:admin-user-list.bulk-actions.create.result': true } export type ClientFilterHookName = keyof typeof clientFilterHookObject diff --git a/packages/models/src/plugins/client/plugin-client-scope.type.ts b/packages/models/src/plugins/client/plugin-client-scope.type.ts index 56f1ba42d..0577286ec 100644 --- a/packages/models/src/plugins/client/plugin-client-scope.type.ts +++ b/packages/models/src/plugins/client/plugin-client-scope.type.ts @@ -9,4 +9,5 @@ export type PluginClientScope = 'admin-plugin' | 'my-library' | 'video-channel' | - 'my-account' + 'my-account' | + 'admin-users'