fixes after review
This commit is contained in:
parent
cd417ddefa
commit
efafef6da6
|
@ -40,6 +40,7 @@ import {
|
||||||
import { TableExpanderIconComponent } from '../../../../shared/shared-tables/table-expander-icon.component'
|
import { TableExpanderIconComponent } from '../../../../shared/shared-tables/table-expander-icon.component'
|
||||||
import { UserEmailInfoComponent } from '../../../shared/user-email-info.component'
|
import { UserEmailInfoComponent } from '../../../shared/user-email-info.component'
|
||||||
import { shortCacheObservable } from '@root-helpers/utils'
|
import { shortCacheObservable } from '@root-helpers/utils'
|
||||||
|
import { lastValueFrom } from 'rxjs'
|
||||||
|
|
||||||
type UserForList = User & {
|
type UserForList = User & {
|
||||||
rawVideoQuota: number
|
rawVideoQuota: number
|
||||||
|
@ -181,7 +182,7 @@ export class UserListComponent extends RestTable <User> implements OnInit, OnDes
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
this.bulkActions = await this.hooks.wrapObject(bulkActions, 'admin-users', 'filter:admin-user-list.bulk-actions.create.result')
|
this.bulkActions = await this.hooks.wrapObject(bulkActions, 'admin-users', 'filter:admin-users-list.bulk-actions.create.result')
|
||||||
|
|
||||||
this.columns = [
|
this.columns = [
|
||||||
{ id: 'username', label: $localize`Username` },
|
{ id: 'username', label: $localize`Username` },
|
||||||
|
@ -377,7 +378,7 @@ export class UserListComponent extends RestTable <User> implements OnInit, OnDes
|
||||||
error: err => this.notifier.error(err.message)
|
error: err => this.notifier.error(err.message)
|
||||||
})
|
})
|
||||||
|
|
||||||
return obs
|
return lastValueFrom(obs)
|
||||||
}
|
}
|
||||||
|
|
||||||
private loadMutedStatus () {
|
private loadMutedStatus () {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import { VideoComment } from '@app/shared/shared-video-comment/video-comment.mod
|
||||||
import { VideoCommentService } from '@app/shared/shared-video-comment/video-comment.service'
|
import { VideoCommentService } from '@app/shared/shared-video-comment/video-comment.service'
|
||||||
import { NgbDropdown, NgbDropdownButtonItem, NgbDropdownItem, NgbDropdownMenu, NgbDropdownToggle } from '@ng-bootstrap/ng-bootstrap'
|
import { NgbDropdown, NgbDropdownButtonItem, NgbDropdownItem, NgbDropdownMenu, NgbDropdownToggle } from '@ng-bootstrap/ng-bootstrap'
|
||||||
import { PeerTubeProblemDocument, ServerErrorCode, VideoCommentPolicy } from '@peertube/peertube-models'
|
import { PeerTubeProblemDocument, ServerErrorCode, VideoCommentPolicy } from '@peertube/peertube-models'
|
||||||
import { Subject, Subscription } from 'rxjs'
|
import { lastValueFrom, Subject, Subscription } from 'rxjs'
|
||||||
import { InfiniteScrollerDirective } from '../../../../shared/shared-main/common/infinite-scroller.directive'
|
import { InfiniteScrollerDirective } from '../../../../shared/shared-main/common/infinite-scroller.directive'
|
||||||
import { FeedComponent } from '../../../../shared/shared-main/feeds/feed.component'
|
import { FeedComponent } from '../../../../shared/shared-main/feeds/feed.component'
|
||||||
import { LoaderComponent } from '../../../../shared/shared-main/common/loader.component'
|
import { LoaderComponent } from '../../../../shared/shared-main/common/loader.component'
|
||||||
|
@ -151,13 +151,14 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
loadMoreThreads (reset = false) {
|
loadMoreThreads (reset = false) {
|
||||||
|
if (reset === true) {
|
||||||
|
this.componentPagination.currentPage = 1
|
||||||
|
}
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
videoId: this.video.uuid,
|
videoId: this.video.uuid,
|
||||||
videoPassword: this.videoPassword,
|
videoPassword: this.videoPassword,
|
||||||
componentPagination: {
|
componentPagination: this.componentPagination,
|
||||||
...this.componentPagination,
|
|
||||||
currentPage: reset === true ? 1 : this.componentPagination.currentPage
|
|
||||||
},
|
|
||||||
sort: this.sort
|
sort: this.sort
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +186,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
error: err => this.notifier.error(err.message)
|
error: err => this.notifier.error(err.message)
|
||||||
})
|
})
|
||||||
|
|
||||||
return obs
|
return lastValueFrom(obs)
|
||||||
}
|
}
|
||||||
|
|
||||||
onCommentThreadCreated (comment: VideoComment) {
|
onCommentThreadCreated (comment: VideoComment) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { forkJoin, from } from 'rxjs'
|
import { forkJoin } from 'rxjs'
|
||||||
import { filter, first, map } from 'rxjs/operators'
|
import { filter, first, map } from 'rxjs/operators'
|
||||||
import { DOCUMENT, getLocaleDirection, NgClass, NgIf, PlatformLocation } from '@angular/common'
|
import { DOCUMENT, getLocaleDirection, NgClass, NgIf, PlatformLocation } from '@angular/common'
|
||||||
import { AfterViewInit, Component, Inject, LOCALE_ID, OnDestroy, OnInit, ViewChild } from '@angular/core'
|
import { AfterViewInit, Component, Inject, LOCALE_ID, OnDestroy, OnInit, ViewChild } from '@angular/core'
|
||||||
|
@ -150,12 +150,12 @@ export class AppComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||||
this.pluginService.addAction('application:increment-loader', () => {
|
this.pluginService.addAction('application:increment-loader', () => {
|
||||||
this.loadingBar.useRef('plugins').start()
|
this.loadingBar.useRef('plugins').start()
|
||||||
|
|
||||||
return from([])
|
return Promise.resolve()
|
||||||
})
|
})
|
||||||
this.pluginService.addAction('application:decrement-loader', () => {
|
this.pluginService.addAction('application:decrement-loader', () => {
|
||||||
this.loadingBar.useRef('plugins').complete()
|
this.loadingBar.useRef('plugins').complete()
|
||||||
|
|
||||||
return from([])
|
return Promise.resolve()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ export class PluginService implements ClientHook {
|
||||||
|
|
||||||
private pluginsManager: PluginsManager
|
private pluginsManager: PluginsManager
|
||||||
|
|
||||||
private actions: { [name in ClientDoActionName]?: ClientDoActionCallback } = {}
|
private actions = new Map<ClientDoActionName, ClientDoActionCallback>()
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
|
@ -85,11 +85,11 @@ export class PluginService implements ClientHook {
|
||||||
}
|
}
|
||||||
|
|
||||||
addAction (actionName: ClientDoActionName, callback: ClientDoActionCallback) {
|
addAction (actionName: ClientDoActionName, callback: ClientDoActionCallback) {
|
||||||
this.actions[actionName] = callback
|
this.actions.set(actionName, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
removeAction (actionName: ClientDoActionName) {
|
removeAction (actionName: ClientDoActionName) {
|
||||||
delete this.actions[actionName]
|
this.actions.delete(actionName)
|
||||||
}
|
}
|
||||||
|
|
||||||
initializePlugins () {
|
initializePlugins () {
|
||||||
|
@ -199,11 +199,15 @@ export class PluginService implements ClientHook {
|
||||||
}
|
}
|
||||||
|
|
||||||
private doAction (actionName: ClientDoActionName) {
|
private doAction (actionName: ClientDoActionName) {
|
||||||
try {
|
if (!this.actions.has(actionName)) {
|
||||||
return this.actions[actionName]()
|
|
||||||
} catch (err: any) {
|
|
||||||
logger.warn(`Plugin tried to do unknown action: ${actionName}`)
|
logger.warn(`Plugin tried to do unknown action: ${actionName}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return this.actions.get(actionName)()
|
||||||
|
} catch (err: any) {
|
||||||
|
logger.warn(`Cannot run action ${actionName}`, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private onFormFields (
|
private onFormFields (
|
||||||
|
|
|
@ -30,6 +30,7 @@ import { AbuseMessageModalComponent } from './abuse-message-modal.component'
|
||||||
import { ModerationCommentModalComponent } from './moderation-comment-modal.component'
|
import { ModerationCommentModalComponent } from './moderation-comment-modal.component'
|
||||||
import { ProcessedAbuse } from './processed-abuse.model'
|
import { ProcessedAbuse } from './processed-abuse.model'
|
||||||
import { shortCacheObservable } from '@root-helpers/utils'
|
import { shortCacheObservable } from '@root-helpers/utils'
|
||||||
|
import { lastValueFrom } from 'rxjs'
|
||||||
|
|
||||||
const debugLogger = debug('peertube:moderation:AbuseListTableComponent')
|
const debugLogger = debug('peertube:moderation:AbuseListTableComponent')
|
||||||
|
|
||||||
|
@ -293,7 +294,7 @@ export class AbuseListTableComponent extends RestTable implements OnInit, OnDest
|
||||||
error: err => this.notifier.error(err.message)
|
error: err => this.notifier.error(err.message)
|
||||||
})
|
})
|
||||||
|
|
||||||
return observable
|
return lastValueFrom(observable)
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildInternalActions (): DropdownAction<ProcessedAbuse>[] {
|
private buildInternalActions (): DropdownAction<ProcessedAbuse>[] {
|
||||||
|
|
|
@ -286,7 +286,7 @@ export class UserModerationDropdownComponent implements OnInit, OnChanges {
|
||||||
if (myAccountModerationActions.length !== 0) userActions.push(myAccountModerationActions)
|
if (myAccountModerationActions.length !== 0) userActions.push(myAccountModerationActions)
|
||||||
if (instanceModerationActions.length !== 0) userActions.push(instanceModerationActions)
|
if (instanceModerationActions.length !== 0) userActions.push(instanceModerationActions)
|
||||||
|
|
||||||
this.userActions = await this.hooks.wrapObject(userActions, 'admin-users', 'filter:admin-user-moderation.actions.create.result')
|
this.userActions = await this.hooks.wrapObject(userActions, 'moderation', 'filter:user-moderation.actions.create.result')
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildMyAccountModerationActions () {
|
private buildMyAccountModerationActions () {
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { AutoColspanDirective } from '../shared-main/common/auto-colspan.directi
|
||||||
import { PTDatePipe } from '../shared-main/common/date.pipe'
|
import { PTDatePipe } from '../shared-main/common/date.pipe'
|
||||||
import { TableExpanderIconComponent } from '../shared-tables/table-expander-icon.component'
|
import { TableExpanderIconComponent } from '../shared-tables/table-expander-icon.component'
|
||||||
import { shortCacheObservable } from '@root-helpers/utils'
|
import { shortCacheObservable } from '@root-helpers/utils'
|
||||||
|
import { lastValueFrom } from 'rxjs'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-video-comment-list-admin-owner',
|
selector: 'my-video-comment-list-admin-owner',
|
||||||
|
@ -102,7 +103,7 @@ export class VideoCommentListAdminOwnerComponent extends RestTable <VideoComment
|
||||||
this.videoCommentActions = await this.hooks.wrapObject(
|
this.videoCommentActions = await this.hooks.wrapObject(
|
||||||
videoCommentActions,
|
videoCommentActions,
|
||||||
'admin-comments',
|
'admin-comments',
|
||||||
'filter:admin-video-comment-list.actions.create.result'
|
'filter:admin-video-comments-list.actions.create.result'
|
||||||
)
|
)
|
||||||
|
|
||||||
const bulkActions: DropdownAction<VideoCommentForAdminOrUser[]>[] = [
|
const bulkActions: DropdownAction<VideoCommentForAdminOrUser[]>[] = [
|
||||||
|
@ -119,11 +120,16 @@ export class VideoCommentListAdminOwnerComponent extends RestTable <VideoComment
|
||||||
iconName: 'tick'
|
iconName: 'tick'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
this.bulkActions = await this.hooks.wrapObject(
|
|
||||||
bulkActions,
|
if (this.mode === 'admin') {
|
||||||
'admin-comments',
|
this.bulkActions = await this.hooks.wrapObject(
|
||||||
'filter:admin-video-comment-list.bulk-actions.create.result'
|
bulkActions,
|
||||||
)
|
'admin-comments',
|
||||||
|
'filter:admin-video-comments-list.bulk-actions.create.result'
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
this.bulkActions = bulkActions
|
||||||
|
}
|
||||||
|
|
||||||
if (this.mode === 'admin') {
|
if (this.mode === 'admin') {
|
||||||
this.inputFilters = [
|
this.inputFilters = [
|
||||||
|
@ -202,7 +208,7 @@ export class VideoCommentListAdminOwnerComponent extends RestTable <VideoComment
|
||||||
error: err => this.notifier.error(err.message)
|
error: err => this.notifier.error(err.message)
|
||||||
})
|
})
|
||||||
|
|
||||||
return obs
|
return lastValueFrom(obs)
|
||||||
}
|
}
|
||||||
|
|
||||||
private approveComments (comments: VideoCommentForAdminOrUser[]) {
|
private approveComments (comments: VideoCommentForAdminOrUser[]) {
|
||||||
|
|
|
@ -74,7 +74,8 @@ class PluginsManager {
|
||||||
'video-channel': new ReplaySubject<boolean>(1),
|
'video-channel': new ReplaySubject<boolean>(1),
|
||||||
'my-account': new ReplaySubject<boolean>(1),
|
'my-account': new ReplaySubject<boolean>(1),
|
||||||
'admin-users': new ReplaySubject<boolean>(1),
|
'admin-users': new ReplaySubject<boolean>(1),
|
||||||
'admin-comments': new ReplaySubject<boolean>(1)
|
'admin-comments': new ReplaySubject<boolean>(1),
|
||||||
|
'moderation': new ReplaySubject<boolean>(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly doAction: ClientDoAction
|
private readonly doAction: ClientDoAction
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import { Observable } from 'rxjs'
|
|
||||||
|
|
||||||
// Data from API hooks: {hookType}:api.{location}.{elementType}.{actionType}.{target}
|
// Data from API hooks: {hookType}:api.{location}.{elementType}.{actionType}.{target}
|
||||||
// Data in internal functions: {hookType}:{location}.{elementType}.{actionType}.{target}
|
// Data in internal functions: {hookType}:{location}.{elementType}.{actionType}.{target}
|
||||||
|
|
||||||
|
@ -106,16 +104,16 @@ export const clientFilterHookObject = {
|
||||||
'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 bulk actions in user list
|
||||||
'filter:admin-user-list.bulk-actions.create.result': true,
|
'filter:admin-users-list.bulk-actions.create.result': true,
|
||||||
|
|
||||||
// Filter actions in comment list
|
// Filter actions in comment list
|
||||||
'filter:admin-video-comment-list.actions.create.result': true,
|
'filter:admin-video-comments-list.actions.create.result': true,
|
||||||
|
|
||||||
// Filter bulk actions in comment list
|
// Filter bulk actions in comment list
|
||||||
'filter:admin-video-comment-list.bulk-actions.create.result': true,
|
'filter:admin-video-comments-list.bulk-actions.create.result': true,
|
||||||
|
|
||||||
// Filter user moderation actions
|
// Filter user moderation actions
|
||||||
'filter:admin-user-moderation.actions.create.result': true,
|
'filter:user-moderation.actions.create.result': true,
|
||||||
|
|
||||||
// Filter actions in abuse list
|
// Filter actions in abuse list
|
||||||
'filter:admin-abuse-list.actions.create.result': true
|
'filter:admin-abuse-list.actions.create.result': true
|
||||||
|
@ -226,5 +224,5 @@ export const clientDoActionObject = {
|
||||||
|
|
||||||
export type ClientDoActionName = keyof typeof clientDoActionObject
|
export type ClientDoActionName = keyof typeof clientDoActionObject
|
||||||
|
|
||||||
export type ClientDoActionCallback = () => Observable<any>
|
export type ClientDoActionCallback = () => Promise<any>
|
||||||
export type ClientDoAction = (actionName: ClientDoActionName) => Observable<any>
|
export type ClientDoAction = (actionName: ClientDoActionName) => Promise<any>
|
||||||
|
|
|
@ -11,4 +11,5 @@ export type PluginClientScope =
|
||||||
'video-channel' |
|
'video-channel' |
|
||||||
'my-account' |
|
'my-account' |
|
||||||
'admin-users' |
|
'admin-users' |
|
||||||
'admin-comments'
|
'admin-comments' |
|
||||||
|
'moderation'
|
||||||
|
|
Loading…
Reference in New Issue