ActivityPub-federated video streaming platform using P2P directly in your web browser
Create an admin component to update channels
Chocobozzzd35f7ed6f70f
diff --git a/client/src/app/+my-library/my-ownership-changes/my-video-ownership-changes/accept-change-video-ownership.component.html b/client/src/app/+my-library/my-ownership-changes/my-video-ownership-changes/accept-change-video-ownership.component.htmlindex 00791fb298..8034b64f5a 100644--- a/client/src/app/+my-library/my-ownership-changes/my-video-ownership-changes/accept-change-video-ownership.component.html+++ b/client/src/app/+my-library/my-ownership-changes/my-video-ownership-changes/accept-change-video-ownership.component.html@@ -10,7 +10,7 @@<div class="modal-body" [formGroup]="form"><div class="form-group"><label i18n for="channel">{ ownershipChanges.length, plural, =1 {Select a channel to receive the video} other {Select a channel to receive the videos}}</label>- <my-select-channel class="d-block" inputId="channel" formControlName="channel" [items]="videoChannels"></my-select-channel>+ <my-select-channel-user class="d-block" inputId="channel" formControlName="channel" [items]="videoChannels"></my-select-channel-user>@if (formErrors.channel) {<div class="form-error" role="alert">{{ formErrors.channel }}</div>diff --git a/client/src/app/+my-library/my-ownership-changes/my-video-ownership-changes/accept-change-video-ownership.component.ts b/client/src/app/+my-library/my-ownership-changes/my-video-ownership-changes/accept-change-video-ownership.component.tsindex a2ef1a2ade..0dbbe26db0 100644--- a/client/src/app/+my-library/my-ownership-changes/my-video-ownership-changes/accept-change-video-ownership.component.ts+++ b/client/src/app/+my-library/my-ownership-changes/my-video-ownership-changes/accept-change-video-ownership.component.ts@@ -1,15 +1,15 @@-import { Component, ElementRef, OnInit, inject, output, viewChild, ChangeDetectionStrategy } from '@angular/core'+import { ChangeDetectionStrategy, Component, ElementRef, OnInit, inject, output, viewChild } from '@angular/core'import { FormsModule, ReactiveFormsModule } from '@angular/forms'import { AuthService, Notifier } from '@app/core'-import { formatICU, listUserChannelsForSelect } from '@app/helpers'+import { formatICU, listChannelsForSelect } from '@app/helpers'import { OWNERSHIP_CHANGE_CHANNEL_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators'+import { ChangeOwnershipService } from '@app/shared/shared-change-ownership/change-ownership.service'import { FormReactive } from '@app/shared/shared-forms/form-reactive'import { FormReactiveService } from '@app/shared/shared-forms/form-reactive.service'-import { ChangeOwnershipService } from '@app/shared/shared-change-ownership/change-ownership.service'import { NgbModal } from '@ng-bootstrap/ng-bootstrap'import { ChangeOwnership } from '@peertube/peertube-models'import { SelectChannelItem } from '@pt-types'-import { SelectChannelComponent } from '../../../shared/shared-forms/select/select-channel.component'+import { SelectChannelUserComponent } from '../../../shared/shared-forms/select/select-channel-user.component'import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'@Component({@@ -17,7 +17,7 @@ import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.cotemplateUrl: './accept-change-video-ownership.component.html',styleUrls: [ './accept-change-video-ownership.component.scss' ],changeDetection: ChangeDetectionStrategy.Eager,- imports: [ GlobalIconComponent, FormsModule, ReactiveFormsModule, SelectChannelComponent ]+ imports: [ GlobalIconComponent, FormsModule, ReactiveFormsModule, SelectChannelUserComponent ]})export class AcceptChangeVideoOwnershipComponent extends FormReactive implements OnInit {protected formReactiveService = inject(FormReactiveService)@@ -39,8 +39,10 @@ export class AcceptChangeVideoOwnershipComponent extends FormReactive implementsngOnInit () {this.videoChannels = []- listUserChannelsForSelect(this.authService, { includeCollaborations: false })- .subscribe(channels => this.videoChannels = channels)+ listChannelsForSelect({+ authService: this.authService,+ includeCollaborations: false+ }).subscribe(channels => this.videoChannels = channels)this.buildForm({channel: OWNERSHIP_CHANGE_CHANNEL_VALIDATORdiff --git a/client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.html b/client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.htmlindex def13f003f..fa63bdd4fe 100644--- a/client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.html+++ b/client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.html@@ -33,7 +33,7 @@<div class="form-group"><label i18n for="videoChannel">Video channel</label>- <my-select-channel inputId="videoChannel" [items]="userVideoChannels" formControlName="videoChannel"></my-select-channel>+ <my-select-channel-user inputId="videoChannel" [items]="channels" formControlName="videoChannel"></my-select-channel-user>@if (formErrors['videoChannel']) {<div class="form-error" role="alert">{{ formErrors['videoChannel'] }}</div>diff --git a/client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.scss b/client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.scssindex 96abdbb46f..05ae81b176 100644--- a/client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.scss+++ b/client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.scss@@ -1,14 +1,14 @@-@use '_variables' as *;-@use '_mixins' as *;-@use '_form-mixins' as *;+@use "_variables" as *;+@use "_mixins" as *;+@use "_form-mixins" as *;$form-base-input-width: 480px;-input[type=text] {+input[type="text"] {@include peertube-input-text($form-base-input-width);}-my-select-channel {+my-select-channel-user {display: block;max-width: $form-base-input-width;}diff --git a/client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.ts b/client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.tsindex 64b68851de..3c42ff0049 100644--- a/client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.ts+++ b/client/src/app/+my-library/my-video-channel-syncs/video-channel-sync-edit/video-channel-sync-edit.component.ts@@ -1,9 +1,9 @@import { NgClass } from '@angular/common'-import { Component, OnInit, inject, ChangeDetectionStrategy } from '@angular/core'+import { ChangeDetectionStrategy, Component, OnInit, inject } from '@angular/core'import { FormsModule, ReactiveFormsModule } from '@angular/forms'import { Router } from '@angular/router'import { AuthService, Notifier } from '@app/core'-import { listUserChannelsForSelect } from '@app/helpers'+import { listChannelsForSelect } from '@app/helpers'import { REQUIRED_VALIDATOR } from '@app/shared/form-validators/common-validators'import { VIDEO_CHANNEL_EXTERNAL_URL_VALIDATOR } from '@app/shared/form-validators/video-channel-validators'import { FormReactive } from '@app/shared/shared-forms/form-reactive'@@ -12,16 +12,16 @@ import { VideoChannelSyncService } from '@app/shared/shared-main/channel/video-cimport { VideoChannelService } from '@app/shared/shared-main/channel/video-channel.service'import { AlertComponent } from '@app/shared/shared-main/common/alert.component'import { VideoChannelSyncCreate } from '@peertube/peertube-models'-import { mergeMap } from 'rxjs'import { SelectChannelItem } from '@pt-types'-import { SelectChannelComponent } from '../../../shared/shared-forms/select/select-channel.component'+import { mergeMap } from 'rxjs'+import { SelectChannelUserComponent } from '../../../shared/shared-forms/select/select-channel-user.component'@Component({selector: 'my-video-channel-sync-edit',templateUrl: './video-channel-sync-edit.component.html',styleUrls: [ './video-channel-sync-edit.component.scss' ],changeDetection: ChangeDetectionStrategy.Eager,- imports: [ FormsModule, ReactiveFormsModule, NgClass, SelectChannelComponent, AlertComponent ]+ imports: [ FormsModule, ReactiveFormsModule, NgClass, SelectChannelUserComponent, AlertComponent ]})export class VideoChannelSyncEditComponent extends FormReactive implements OnInit {protected formReactiveService = inject(FormReactiveService)@@ -32,7 +32,7 @@ export class VideoChannelSyncEditComponent extends FormReactive implements OnIniprivate videoChannelService = inject(VideoChannelService)error: string- userVideoChannels: SelectChannelItem[] = []+ channels: SelectChannelItem[] = []existingVideosStrategy: stringngOnInit () {@@ -42,8 +42,10 @@ export class VideoChannelSyncEditComponent extends FormReactive implements OnIniexistingVideoStrategy: REQUIRED_VALIDATOR})- listUserChannelsForSelect(this.authService, { includeCollaborations: true })- .subscribe(channels => this.userVideoChannels = channels)+ listChannelsForSelect({+ authService: this.authService,+ includeCollaborations: true+ }).subscribe(channels => this.channels = channels)}getFormButtonTitle () {diff --git a/client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts b/client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.tsindex 79570d5227..873ed3acd4 100644--- a/client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts+++ b/client/src/app/+my-library/my-video-playlists/my-video-playlist-create.component.ts@@ -1,9 +1,9 @@import { CommonModule, NgClass } from '@angular/common'-import { Component, inject, OnInit, ChangeDetectionStrategy } from '@angular/core'+import { ChangeDetectionStrategy, Component, inject, OnInit } from '@angular/core'import { FormsModule, ReactiveFormsModule } from '@angular/forms'import { Router, RouterLink } from '@angular/router'import { AuthService, Notifier, ServerService } from '@app/core'-import { listUserChannelsForSelect } from '@app/helpers'+import { listChannelsForSelect } from '@app/helpers'import {setPlaylistChannelValidator,VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR,@@ -17,9 +17,9 @@ import { AlertComponent } from '@app/shared/shared-main/common/alert.component'import { VideoPlaylistService } from '@app/shared/shared-video-playlist/video-playlist.service'import { VideoPlaylistCreate, VideoPlaylistPrivacy } from '@peertube/peertube-models'import { of, switchMap } from 'rxjs'-import { MarkdownTextareaComponent } from '../../shared/shared-forms/markdown-textarea.component'import { ImageInputComponent } from '../../shared/shared-forms/image-input.component'-import { SelectChannelComponent } from '../../shared/shared-forms/select/select-channel.component'+import { MarkdownTextareaComponent } from '../../shared/shared-forms/markdown-textarea.component'+import { SelectChannelUserComponent } from '../../shared/shared-forms/select/select-channel-user.component'import { SelectOptionsComponent } from '../../shared/shared-forms/select/select-options.component'import { HelpComponent } from '../../shared/shared-main/buttons/help.component'import { MyVideoPlaylistEdit } from './my-video-playlist-edit'@@ -38,7 +38,7 @@ import { MyVideoPlaylistEdit } from './my-video-playlist-edit'HelpComponent,MarkdownTextareaComponent,SelectOptionsComponent,- SelectChannelComponent,+ SelectChannelUserComponent,AlertComponent,PeertubeCheckboxComponent]@@ -67,8 +67,10 @@ export class MyVideoPlaylistCreateComponent extends MyVideoPlaylistEdit implemensetPlaylistChannelValidator(this.form.get('videoChannelId'), privacy)})- listUserChannelsForSelect(this.authService, { includeCollaborations: true })- .subscribe(channels => this.userVideoChannels = channels)+ listChannelsForSelect({+ authService: this.authService,+ includeCollaborations: true+ }).subscribe(channels => this.channels = channels)this.serverService.getVideoPlaylistPrivacies().subscribe(videoPlaylistPrivacies => {@@ -97,7 +99,7 @@ export class MyVideoPlaylistCreateComponent extends MyVideoPlaylistEdit implemenswitchMap(({ videoPlaylist: { id } }) => {if (body.insertAtFirstPosition !== true || !body.videoChannelId) return of(true)- const channelName = this.userVideoChannels.find(c => c.id === body.videoChannelId)?.name+ const channelName = this.channels.find(c => c.id === body.videoChannelId)?.namereturn this.videoPlaylistService.getVideoPlaylist(id).pipe(diff --git a/client/src/app/+my-library/my-video-playlists/my-video-playlist-edit.component.html b/client/src/app/+my-library/my-video-playlists/my-video-playlist-edit.component.htmlindex 7640a277ee..7e6234170d 100644--- a/client/src/app/+my-library/my-video-playlists/my-video-playlist-edit.component.html+++ b/client/src/app/+my-library/my-video-playlists/my-video-playlist-edit.component.html@@ -84,7 +84,7 @@</div>}- <my-select-channel inputId="videoChannelId" [items]="userVideoChannels" formControlName="videoChannelId"></my-select-channel>+ <my-select-channel-user inputId="videoChannelId" [items]="channels" formControlName="videoChannelId"></my-select-channel-user>@if (formErrors['videoChannelId']) {<div class="form-error" role="alert">{{ formErrors['videoChannelId'] }}</div>diff --git a/client/src/app/+my-library/my-video-playlists/my-video-playlist-edit.component.scss b/client/src/app/+my-library/my-video-playlists/my-video-playlist-edit.component.scssindex 5591c3ac43..8d8bc84edc 100644--- a/client/src/app/+my-library/my-video-playlists/my-video-playlist-edit.component.scss+++ b/client/src/app/+my-library/my-video-playlists/my-video-playlist-edit.component.scss@@ -10,7 +10,7 @@ input[type="text"] {@include responsive-width(340px);}-my-select-channel,+my-select-channel-user,my-select-options {display: block;max-width: 340px;diff --git a/client/src/app/+my-library/my-video-playlists/my-video-playlist-edit.ts b/client/src/app/+my-library/my-video-playlists/my-video-playlist-edit.tsindex 3b0f0d93d4..8782eb4ad4 100644--- a/client/src/app/+my-library/my-video-playlists/my-video-playlist-edit.ts+++ b/client/src/app/+my-library/my-video-playlists/my-video-playlist-edit.ts@@ -6,7 +6,7 @@ import { SelectChannelItem } from '../../../types/select-options-item.model'export abstract class MyVideoPlaylistEdit extends FormReactive {// Declare it here to avoid errors in create templatevideoPlaylistToUpdate: VideoPlaylist- userVideoChannels: SelectChannelItem[] = []+ channels: SelectChannelItem[] = []videoPlaylistPrivacies: ConstantLabel<VideoPlaylistPrivacyType>[] = []abstract isCreation (): booleandiff --git a/client/src/app/+my-library/my-video-playlists/my-video-playlist-update.component.ts b/client/src/app/+my-library/my-video-playlists/my-video-playlist-update.component.tsindex 261f46134d..8dc7de2042 100644--- a/client/src/app/+my-library/my-video-playlists/my-video-playlist-update.component.ts+++ b/client/src/app/+my-library/my-video-playlists/my-video-playlist-update.component.ts@@ -1,9 +1,9 @@import { CommonModule, NgClass } from '@angular/common'-import { Component, inject, OnDestroy, OnInit, ChangeDetectionStrategy } from '@angular/core'+import { ChangeDetectionStrategy, Component, inject, OnDestroy, OnInit } from '@angular/core'import { FormsModule, ReactiveFormsModule } from '@angular/forms'import { ActivatedRoute, Router, RouterLink } from '@angular/router'import { AuthService, Notifier, ServerService } from '@app/core'-import { listUserChannelsForSelect } from '@app/helpers'+import { listChannelsForSelect } from '@app/helpers'import {setPlaylistChannelValidator,VIDEO_PLAYLIST_CHANNEL_ID_VALIDATOR,@@ -13,14 +13,14 @@ import {} from '@app/shared/form-validators/video-playlist-validators'import { FormReactiveService } from '@app/shared/shared-forms/form-reactive.service'import { PeertubeCheckboxComponent } from '@app/shared/shared-forms/peertube-checkbox.component'+import { SelectChannelUserComponent } from '@app/shared/shared-forms/select/select-channel-user.component'import { AlertComponent } from '@app/shared/shared-main/common/alert.component'import { VideoPlaylistService } from '@app/shared/shared-video-playlist/video-playlist.service'import { VideoPlaylistUpdate } from '@peertube/peertube-models'import { forkJoin, Subscription } from 'rxjs'-import { map, switchMap } from 'rxjs/operators'-import { MarkdownTextareaComponent } from '../../shared/shared-forms/markdown-textarea.component'+import { first, map, switchMap } from 'rxjs/operators'import { ImageInputComponent } from '../../shared/shared-forms/image-input.component'-import { SelectChannelComponent } from '../../shared/shared-forms/select/select-channel.component'+import { MarkdownTextareaComponent } from '../../shared/shared-forms/markdown-textarea.component'import { SelectOptionsComponent } from '../../shared/shared-forms/select/select-options.component'import { HelpComponent } from '../../shared/shared-main/buttons/help.component'import { MyVideoPlaylistEdit } from './my-video-playlist-edit'@@ -39,7 +39,7 @@ import { MyVideoPlaylistEdit } from './my-video-playlist-edit'HelpComponent,MarkdownTextareaComponent,SelectOptionsComponent,- SelectChannelComponent,+ SelectChannelUserComponent,AlertComponent,PeertubeCheckboxComponent]@@ -70,22 +70,31 @@ export class MyVideoPlaylistUpdateComponent extends MyVideoPlaylistEdit implemensetPlaylistChannelValidator(this.form.get('videoChannelId'), privacy)})- this.paramsSub = this.route.params+ this.paramsSub = this.authService.userInformationLoaded.pipe(+ first(),+ switchMap(() => this.route.params),map(routeParams => routeParams['videoPlaylistId']),switchMap(videoPlaylistId => {return forkJoin([- this.videoPlaylistService.getVideoPlaylist(videoPlaylistId),- this.serverService.getVideoPlaylistPrivacies(),- listUserChannelsForSelect(this.authService, { includeCollaborations: true })+ this.videoPlaylistService.getVideoPlaylist(videoPlaylistId)+ .pipe(+ switchMap(videoPlaylist => {+ return listChannelsForSelect({+ authService: this.authService,+ includeCollaborations: true+ }).pipe(map(channels => ({ videoPlaylist, channels })))+ })+ ),+ this.serverService.getVideoPlaylistPrivacies()])})).subscribe({- next: ([ videoPlaylistToUpdate, videoPlaylistPrivacies, channels ]) => {- this.videoPlaylistToUpdate = videoPlaylistToUpdate+ next: ([ { videoPlaylist, channels }, videoPlaylistPrivacies ]) => {+ this.videoPlaylistToUpdate = videoPlaylistthis.videoPlaylistPrivacies = videoPlaylistPrivacies- this.userVideoChannels = channels.filter(c => c.ownerAccountId === this.videoPlaylistToUpdate.ownerAccount.id)+ this.channels = channels.filter(c => c.ownerAccountId === this.videoPlaylistToUpdate.ownerAccount.id)this.hydrateFormFromPlaylist()},diff --git a/client/src/app/+videos-publish-manage/+video-manage/video-manage.resolver.ts b/client/src/app/+videos-publish-manage/+video-manage/video-manage.resolver.tsindex 8e8cfa01e0..38d6492b8e 100644--- a/client/src/app/+videos-publish-manage/+video-manage/video-manage.resolver.ts+++ b/client/src/app/+videos-publish-manage/+video-manage/video-manage.resolver.ts@@ -1,7 +1,7 @@import { Injectable, inject } from '@angular/core'import { ActivatedRouteSnapshot, Router } from '@angular/router'import { AuthService, ServerService, UserService } from '@app/core'-import { listUserChannelsForSelect } from '@app/helpers'+import { listChannelsForSelect } from '@app/helpers'import { VideoCaptionService } from '@app/shared/shared-main/video-caption/video-caption.service'import { VideoChapterService } from '@app/shared/shared-main/video/video-chapter.service'import { VideoDetails } from '@app/shared/shared-main/video/video-details.model'@@ -121,7 +121,10 @@ export class VideoManageResolver {this.videoService.getSource(video.id),- listUserChannelsForSelect(this.authService, { includeCollaborations: true }),+ listChannelsForSelect({+ authService: this.authService,+ includeCollaborations: true+ }),this.videoCaptionService.listCaptions(video.uuid)diff --git a/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.html b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.htmlindex 93c9a4d0fe..61cd895729 100644--- a/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.html+++ b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.html@@ -27,7 +27,7 @@<div class="form-group"><label i18n for="first-step-channel">Channel</label>- <my-select-channel inputId="first-step-channel" [items]="userChannels()" [(ngModel)]="firstStepChannelId"></my-select-channel>+ <my-select-channel-user inputId="first-step-channel" [items]="userChannels()" [(ngModel)]="firstStepChannelId"></my-select-channel-user></div><inputdiff --git a/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.ts b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.tsindex 88fba532d3..c73cfc7fa6 100644--- a/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.ts+++ b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.ts@@ -1,4 +1,4 @@-import { AfterViewInit, Component, ElementRef, OnInit, inject, input, output, viewChild, ChangeDetectionStrategy } from '@angular/core'+import { AfterViewInit, ChangeDetectionStrategy, Component, ElementRef, OnInit, inject, input, output, viewChild } from '@angular/core'import { FormsModule, ReactiveFormsModule } from '@angular/forms'import { ActivatedRoute } from '@angular/router'import { VideoEdit } from '@app/+videos-publish-manage/shared-manage/common/video-edit.model'@@ -12,10 +12,10 @@ import { VideoEmbedPrivacyService } from '@app/shared/shared-video/video-embed-pimport { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'import { LoadingBarService } from '@ngx-loading-bar/core'import { PeerTubeProblemDocument, ServerErrorCode, UserVideoQuota, VideoPrivacyType } from '@peertube/peertube-models'+import { SelectChannelItem } from '@pt-types'import debug from 'debug'import { forkJoin, switchMap } from 'rxjs'-import { SelectChannelItem } from '@pt-types'-import { SelectChannelComponent } from '../../../shared/shared-forms/select/select-channel.component'+import { SelectChannelUserComponent } from '../../../shared/shared-forms/select/select-channel-user.component'import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'import { HelpComponent } from '../../../shared/shared-main/buttons/help.component'import { VideoManageContainerComponent } from '../../shared-manage/video-manage-container.component'@@ -37,7 +37,7 @@ const debugLogger = debug('peertube:video-publish')HelpComponent,FormsModule,DragDropDirective,- SelectChannelComponent,+ SelectChannelUserComponent,ReactiveFormsModule,AlertComponent,VideoManageContainerComponentdiff --git a/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.html b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.htmlindex b48036100b..323a834c88 100644--- a/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.html+++ b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.html@@ -25,7 +25,7 @@<div class="form-group"><label i18n for="first-step-channel">Channel</label>- <my-select-channel inputId="first-step-channel" [items]="userChannels()" [(ngModel)]="firstStepChannelId"></my-select-channel>+ <my-select-channel-user inputId="first-step-channel" [items]="userChannels()" [(ngModel)]="firstStepChannelId"></my-select-channel-user></div><inputdiff --git a/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.ts b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.tsindex 77a566c827..6e6d3c429d 100644--- a/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.ts+++ b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.ts@@ -1,4 +1,4 @@-import { AfterViewInit, Component, OnInit, inject, input, output, ChangeDetectionStrategy } from '@angular/core'+import { AfterViewInit, ChangeDetectionStrategy, Component, OnInit, inject, input, output } from '@angular/core'import { FormsModule, ReactiveFormsModule } from '@angular/forms'import { ActivatedRoute, RouterLink } from '@angular/router'import { VideoEdit } from '@app/+videos-publish-manage/shared-manage/common/video-edit.model'@@ -13,11 +13,11 @@ import { PlayerSettingsService } from '@app/shared/shared-video/player-settings.import { VideoEmbedPrivacyService } from '@app/shared/shared-video/video-embed-privacy.service'import { LoadingBarService } from '@ngx-loading-bar/core'import { UserVideoQuota, VideoPrivacyType } from '@peertube/peertube-models'+import { SelectChannelItem } from '@pt-types'import debug from 'debug'import { forkJoin } from 'rxjs'import { map, switchMap } from 'rxjs/operators'-import { SelectChannelItem } from '@pt-types'-import { SelectChannelComponent } from '../../../shared/shared-forms/select/select-channel.component'+import { SelectChannelUserComponent } from '../../../shared/shared-forms/select/select-channel-user.component'import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'import { HelpComponent } from '../../../shared/shared-main/buttons/help.component'import { VideoManageContainerComponent } from '../../shared-manage/video-manage-container.component'@@ -34,7 +34,7 @@ const debugLogger = debug('peertube:video-publish')HelpComponent,FormsModule,RouterLink,- SelectChannelComponent,+ SelectChannelUserComponent,ReactiveFormsModule,AlertComponent,VideoManageContainerComponentdiff --git a/client/src/app/+videos-publish-manage/+video-publish/live/video-go-live.component.html b/client/src/app/+videos-publish-manage/+video-publish/live/video-go-live.component.htmlindex 2c2987afbf..ea63d9e065 100644--- a/client/src/app/+videos-publish-manage/+video-publish/live/video-go-live.component.html+++ b/client/src/app/+videos-publish-manage/+video-publish/live/video-go-live.component.html@@ -5,7 +5,7 @@<div class="form-group"><label i18n for="first-step-channel">Channel</label>- <my-select-channel inputId="first-step-channel" [items]="userChannels()" [(ngModel)]="firstStepChannelId"></my-select-channel>+ <my-select-channel-user inputId="first-step-channel" [items]="userChannels()" [(ngModel)]="firstStepChannelId"></my-select-channel-user></div><div class="form-group live-type">diff --git a/client/src/app/+videos-publish-manage/+video-publish/live/video-go-live.component.ts b/client/src/app/+videos-publish-manage/+video-publish/live/video-go-live.component.tsindex 36d410fe1f..1fd3e08c16 100644--- a/client/src/app/+videos-publish-manage/+video-publish/live/video-go-live.component.ts+++ b/client/src/app/+videos-publish-manage/+video-publish/live/video-go-live.component.ts@@ -1,4 +1,4 @@-import { AfterViewInit, Component, OnInit, inject, input, output, ChangeDetectionStrategy } from '@angular/core'+import { AfterViewInit, ChangeDetectionStrategy, Component, OnInit, inject, input, output } from '@angular/core'import { FormsModule, ReactiveFormsModule } from '@angular/forms'import { ActivatedRoute } from '@angular/router'import { VideoEdit } from '@app/+videos-publish-manage/shared-manage/common/video-edit.model'@@ -8,10 +8,10 @@ import { LiveVideoService } from '@app/shared/shared-video-live/live-video.serviimport { PlayerSettingsService } from '@app/shared/shared-video/player-settings.service'import { VideoEmbedPrivacyService } from '@app/shared/shared-video/video-embed-privacy.service'import { LiveVideoLatencyMode, PeerTubeProblemDocument, ServerErrorCode, UserVideoQuota, VideoPrivacyType } from '@peertube/peertube-models'+import { SelectChannelItem } from '@pt-types'import debug from 'debug'import { forkJoin, map, switchMap } from 'rxjs'-import { SelectChannelItem } from '@pt-types'-import { SelectChannelComponent } from '../../../shared/shared-forms/select/select-channel.component'+import { SelectChannelUserComponent } from '../../../shared/shared-forms/select/select-channel-user.component'import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'import { VideoManageContainerComponent } from '../../shared-manage/video-manage-container.component'@@ -27,7 +27,7 @@ const debugLogger = debug('peertube:video-publish')changeDetection: ChangeDetectionStrategy.Eager,imports: [GlobalIconComponent,- SelectChannelComponent,+ SelectChannelUserComponent,FormsModule,ReactiveFormsModule,VideoManageContainerComponentdiff --git a/client/src/app/+videos-publish-manage/+video-publish/shared/common-publish.scss b/client/src/app/+videos-publish-manage/+video-publish/shared/common-publish.scssindex bbb30beda1..20298f728d 100644--- a/client/src/app/+videos-publish-manage/+video-publish/shared/common-publish.scss+++ b/client/src/app/+videos-publish-manage/+video-publish/shared/common-publish.scss@@ -30,7 +30,7 @@ $width-size: 275px;@include responsive-width($width-size);}- my-select-channel,+ my-select-channel-user,my-select-options,.peertube-radio-container,.form-group-description {diff --git a/client/src/app/+videos-publish-manage/+video-publish/upload/video-upload.component.html b/client/src/app/+videos-publish-manage/+video-publish/upload/video-upload.component.htmlindex 0cd75667bb..f1553e26c1 100644--- a/client/src/app/+videos-publish-manage/+video-publish/upload/video-upload.component.html+++ b/client/src/app/+videos-publish-manage/+video-publish/upload/video-upload.component.html@@ -18,7 +18,7 @@<div class="form-group form-group-channel"><label i18n for="first-step-channel">Channel</label>- <my-select-channel inputId="first-step-channel" [items]="userChannels()" [(ngModel)]="firstStepChannelId"></my-select-channel>+ <my-select-channel-user inputId="first-step-channel" [items]="userChannels()" [(ngModel)]="firstStepChannelId"></my-select-channel-user></div>@if (uploadingAudioFile) {diff --git a/client/src/app/+videos-publish-manage/+video-publish/upload/video-upload.component.ts b/client/src/app/+videos-publish-manage/+video-publish/upload/video-upload.component.tsindex 9b94d6b70a..ae17048877 100644--- a/client/src/app/+videos-publish-manage/+video-publish/upload/video-upload.component.ts+++ b/client/src/app/+videos-publish-manage/+video-publish/upload/video-upload.component.ts@@ -23,7 +23,7 @@ import debug from 'debug'import { truncate } from 'lodash-es'import { Subscription } from 'rxjs'import { ImageInputComponent } from '../../../shared/shared-forms/image-input.component'-import { SelectChannelComponent } from '../../../shared/shared-forms/select/select-channel.component'+import { SelectChannelUserComponent } from '../../../shared/shared-forms/select/select-channel-user.component'import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'import { ButtonComponent } from '../../../shared/shared-main/buttons/button.component'import { VideoManageContainerComponent } from '../../shared-manage/video-manage-container.component'@@ -43,7 +43,7 @@ const debugLogger = debug('peertube:video-publish')DragDropDirective,GlobalIconComponent,NgbTooltip,- SelectChannelComponent,+ SelectChannelUserComponent,FormsModule,ImageInputComponent,ButtonComponent,diff --git a/client/src/app/+videos-publish-manage/+video-publish/video-publish.resolver.ts b/client/src/app/+videos-publish-manage/+video-publish/video-publish.resolver.tsindex 3bb811c5c8..488be75858 100644--- a/client/src/app/+videos-publish-manage/+video-publish/video-publish.resolver.ts+++ b/client/src/app/+videos-publish-manage/+video-publish/video-publish.resolver.ts@@ -1,7 +1,7 @@import { Injectable, inject } from '@angular/core'import { AuthService, ServerService, UserService } from '@app/core'-import { listUserChannelsForSelect } from '@app/helpers'-import { UserVideoQuota, ConstantLabel, VideoPrivacyType } from '@peertube/peertube-models'+import { listChannelsForSelect } from '@app/helpers'+import { ConstantLabel, UserVideoQuota, VideoPrivacyType } from '@peertube/peertube-models'import { forkJoin } from 'rxjs'import { map } from 'rxjs/operators'import { SelectChannelItem } from '../../../types'@@ -20,7 +20,10 @@ export class VideoPublishResolver {resolve () {return forkJoin([- listUserChannelsForSelect(this.authService, { includeCollaborations: true }),+ listChannelsForSelect({+ authService: this.authService,+ includeCollaborations: true+ }),this.userService.getMyVideoQuotaUsed(),this.serverService.getVideoPrivacies()]).pipe(map(([ videoChannels, userQuota, privacies ]) => ({ videoChannels, userQuota, privacies } satisfies VideoPublishResolverData)))diff --git a/client/src/app/+videos-publish-manage/shared-manage/common/video-edit.model.ts b/client/src/app/+videos-publish-manage/shared-manage/common/video-edit.model.tsindex e78d0e5a63..e7d9dda7e2 100644--- a/client/src/app/+videos-publish-manage/shared-manage/common/video-edit.model.ts+++ b/client/src/app/+videos-publish-manage/shared-manage/common/video-edit.model.ts@@ -196,6 +196,7 @@ export class VideoEdit {publishedAt: DateownerAccountId: number+ ownerAccountName: stringownerAccountDisplayName: stringlive: Pick<LiveVideo, 'rtmpUrl' | 'rtmpsUrl' | 'streamKey'>@@ -221,6 +222,7 @@ export class VideoEdit {blacklistedReason: stringownerAccountId: number+ ownerAccountName: stringownerAccountDisplayName: stringlive?: Pick<LiveVideo, 'rtmpUrl' | 'rtmpsUrl' | 'streamKey'>@@ -338,6 +340,7 @@ export class VideoEdit {this.metadata.likes = 0this.metadata.ownerAccountDisplayName = options.user.account.displayName+ this.metadata.ownerAccountName = options.user.account.namethis.metadata.ownerAccountId = options.user.account.idthis.updateAfterChange()@@ -464,6 +467,7 @@ export class VideoEdit {this.metadata.isLive = video.isLivethis.metadata.ownerAccountDisplayName = video.channel.ownerAccount.displayName+ this.metadata.ownerAccountName = video.channel.ownerAccount.namethis.metadata.ownerAccountId = video.channel.ownerAccount.id}@@ -1172,6 +1176,7 @@ export class VideoEdit {blacklistedReason: this.metadata.blacklistedReason,ownerAccountId: this.metadata.ownerAccountId,+ ownerAccountName: this.metadata.ownerAccountName,ownerAccountDisplayName: this.metadata.ownerAccountDisplayName,live: this.metadata.livediff --git a/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.html b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.htmlindex e4f4b2a934..c1f009d98d 100644--- a/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.html+++ b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.html@@ -95,7 +95,10 @@</div>}- <my-select-channel class="d-block" inputId="channel" [items]="userChannels" formControlName="channelId"></my-select-channel>+ <my-select-channel-auto+ class="d-block" inputId="adminChannel" formControlName="channelId"+ [ownerAccount]="{ name: initialOwner.accountName }" [ownerChannel]="{ id: initialOwner.channelId }"+ ></my-select-channel-auto></div><div class="form-group">diff --git a/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.ts b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.tsindex ea6873592c..492d8b9ec2 100644--- a/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.ts+++ b/client/src/app/+videos-publish-manage/shared-manage/main-info/video-main-info.component.ts@@ -1,5 +1,5 @@import { CommonModule } from '@angular/common'-import { ChangeDetectorRef, Component, inject, NgZone, OnDestroy, OnInit, viewChild, ChangeDetectionStrategy } from '@angular/core'+import { ChangeDetectionStrategy, ChangeDetectorRef, Component, inject, NgZone, OnDestroy, OnInit, viewChild } from '@angular/core'import { AbstractControl, FormArray, FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms'import { Router, RouterLink } from '@angular/router'import { AuthService, ConfirmService, HooksService, Notifier, PluginService, ServerService } from '@app/core'@@ -25,7 +25,7 @@ import { FormValidatorService } from '@app/shared/shared-forms/form-validator.seimport { InputTextComponent } from '@app/shared/shared-forms/input-text.component'import { MarkdownTextareaComponent } from '@app/shared/shared-forms/markdown-textarea.component'import { PeertubeCheckboxComponent } from '@app/shared/shared-forms/peertube-checkbox.component'-import { SelectChannelComponent } from '@app/shared/shared-forms/select/select-channel.component'+import { SelectChannelAutoComponent } from '@app/shared/shared-forms/select/select-channel-auto.component'import { SelectOptionsComponent } from '@app/shared/shared-forms/select/select-options.component'import { SelectTagsComponent } from '@app/shared/shared-forms/select/select-tags.component'import { ButtonComponent } from '@app/shared/shared-main/buttons/button.component'@@ -44,7 +44,6 @@ import {VideoPrivacyType} from '@peertube/peertube-models'import { SelectChannelItem } from '@pt-types'-import { logger } from '@root-helpers/logger'import { PluginInfo } from '@root-helpers/plugins-manager'import debug from 'debug'import { DatePickerModule } from 'primeng/datepicker'@@ -98,7 +97,6 @@ type Form = {PeerTubeTemplateDirective,SelectTagsComponent,MarkdownTextareaComponent,- SelectChannelComponent,SelectOptionsComponent,InputTextComponent,DatePickerModule,@@ -109,7 +107,8 @@ type Form = {RouterLink,AlertComponent,ButtonComponent,- SendChangeOwnershipComponent+ SendChangeOwnershipComponent,+ SelectChannelAutoComponent]})export class VideoMainInfoComponent implements OnInit, OnDestroy {@@ -169,6 +168,11 @@ export class VideoMainInfoComponent implements OnInit, OnDestroy {pendingOwnershipRequest: ChangeOwnership+ initialOwner: {+ channelId: number+ accountName: string+ }+private schedulerInterval: anyprivate updatedSub: Subscription@@ -189,6 +193,11 @@ export class VideoMainInfoComponent implements OnInit, OnDestroy {this.hideWaitTranscoding = hideWaitTranscodingthis.forbidScheduledPublication = forbidScheduledPublication+ this.initialOwner = {+ channelId: this.videoEdit.toCommonFormPatch().channelId,+ accountName: this.videoEdit.getVideoAttributes().ownerAccountName+ }+this.buildForm()this.pluginService.ensurePluginsAreLoaded('video-edit')@@ -462,8 +471,10 @@ export class VideoMainInfoComponent implements OnInit, OnDestroy {const oldChannelId = this.form.value.channelIdconst oldChannel = this.userChannels.find(c => c.id === oldChannelId)++ // Can happen if we change the channel to a new ownerif (!newChannel || !oldChannel) {- logger.error('Cannot find new or old channel.')+ debugLogger('Channel change: new or old channel not found', { newChannel, oldChannel })return}diff --git a/client/src/app/core/theme/primeng/components/select.ts b/client/src/app/core/theme/primeng/components/select.tsindex c375cedba6..88df782f09 100644--- a/client/src/app/core/theme/primeng/components/select.ts+++ b/client/src/app/core/theme/primeng/components/select.ts@@ -67,7 +67,7 @@ export default {borderRadius: '{list.option.border.radius}'},optionGroup: {- background: '{list.option.group.background}',+ background: '{list.option.background}',color: '{list.option.group.color}',fontWeight: '{list.option.group.font.weight}',padding: '{list.option.group.padding}'diff --git a/client/src/app/helpers/utils/channel.ts b/client/src/app/helpers/utils/channel.tsindex 1599481a36..4c44af8fa4 100644--- a/client/src/app/helpers/utils/channel.ts+++ b/client/src/app/helpers/utils/channel.ts@@ -3,26 +3,40 @@ import { VideoChannel } from '@peertube/peertube-models'import { first, map } from 'rxjs/operators'import { AuthService } from '../../core/auth'-export function listUserChannelsForSelect (authService: AuthService, options: { includeCollaborations: boolean }) {+// List channels of selected accountName+// Set the currentChannelId to correctly display channel editor/owner information+export function listChannelsForSelect (options: {+ authService: AuthService+ includeCollaborations: boolean+}) {+ const { authService } = options+return authService.userInformationLoaded.pipe(first(),- map(() => {- const user = authService.getUser()- const collaborate = user.isCollaboratingToChannels()-- const allChannels = options.includeCollaborations- ? [- ...formatChannels(user.videoChannels, { editor: false, owner: true, collaborate }),- ...formatChannels(user.videoChannelCollaborations, { editor: true, owner: false, collaborate })- ]- : formatChannels(user.videoChannels, { editor: false, owner: false, collaborate })-- return sortBy(allChannels, 'updatedAt').reverse()- })+ map(() => buildUserChannelsForSelect(options)))}+export function buildUserChannelsForSelect (options: {+ authService: AuthService+ includeCollaborations: boolean+}) {+ const { authService, includeCollaborations } = options++ const user = authService.getUser()+ const collaborate = user.isCollaboratingToChannels()++ const allChannels = includeCollaborations+ ? [+ ...formatChannels(user.videoChannels, { editor: false, owner: true, collaborate }),+ ...formatChannels(user.videoChannelCollaborations, { editor: true, owner: false, collaborate })+ ]+ : formatChannels(user.videoChannels, { editor: false, owner: false, collaborate })++ return sortBy(allChannels, 'updatedAt').reverse()+}+// ---------------------------------------------------------------------------// Private// ---------------------------------------------------------------------------diff --git a/client/src/app/shared/shared-forms/select/select-channel-admin.component.ts b/client/src/app/shared/shared-forms/select/select-channel-admin.component.tsnew file mode 100644index 0000000000..89bf2ab82d--- /dev/null+++ b/client/src/app/shared/shared-forms/select/select-channel-admin.component.ts@@ -0,0 +1,198 @@+import { ChangeDetectionStrategy, Component, forwardRef, inject, input, OnChanges, OnDestroy } from '@angular/core'+import { ControlValueAccessor, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'+import { AuthService, Notifier } from '@app/core'+import { VideoChannel } from '@app/shared/shared-main/channel/video-channel.model'+import { VideoChannelService } from '@app/shared/shared-main/channel/video-channel.service'+import { SearchService } from '@app/shared/shared-search/search.service'+import { VideoChannel as VideoChannelServer } from '@peertube/peertube-models'+import { findAppropriateImageFileUrl } from '@root-helpers/images'+import { first, forkJoin, map, Subscription } from 'rxjs'+import { SelectOptionsItem } from '../../../../types/select-options-item.model'+import { SelectOptionsComponent } from './select-options.component'++@Component({+ selector: 'my-select-channel-admin',+ template: `+<my-select-options+ [inputId]="inputId()"++ [items]="options"+ group="true"+ filter="true"+ resetFilterOnHide="true"++ [(ngModel)]="selectedId"+ (ngModelChange)="onModelChange()"++ [emptyFilterMessage]="getEmptyFilterMessage()"+ (onFilter)="onFilter($event)"++ (onHide)="onHide()"+>+</my-select-options>+ `,+ styleUrls: [ 'select-options.component.scss' ],+ providers: [+ {+ provide: NG_VALUE_ACCESSOR,+ useExisting: forwardRef(() => SelectChannelAdminComponent),+ multi: true+ },+ SearchService+ ],+ changeDetection: ChangeDetectionStrategy.Eager,+ imports: [ FormsModule, SelectOptionsComponent ]+})+export class SelectChannelAdminComponent implements ControlValueAccessor, OnChanges, OnDestroy {+ private auth = inject(AuthService)+ private channelService = inject(VideoChannelService)+ private searchService = inject(SearchService)+ private notifier = inject(Notifier)++ readonly inputId = input.required<string>()+ readonly ownerAccountName = input.required<string>()++ selectedId: number++ options: { label: string, value: string, items: SelectOptionsItem[] }[] = []+ baseOptions: { label: string, value: string, items: SelectOptionsItem[] }[] = []++ loading = false++ private loadingSub: Subscription++ ngOnChanges () {+ this.loading = true+ this.loadingSub?.unsubscribe()++ this.loadingSub = forkJoin([+ this.buildUserChannelObs(),+ this.buildOwnerChannelObs()+ ]).subscribe({+ next: ([ userChannels, ownerChannels ]) => {+ this.options = [+ {+ label: $localize`Owner channels`,+ value: 'owner',+ items: ownerChannels+ },+ {+ label: $localize`Your channels`,+ value: 'yours',+ items: userChannels+ }+ ]++ this.baseOptions = [ ...this.options ]++ this.loading = false+ },++ error: err => {+ this.loading = false++ this.notifier.error(err.message)+ }+ })+ }++ ngOnDestroy () {+ this.loadingSub?.unsubscribe()+ }++ getEmptyFilterMessage () {+ if (this.loading) return $localize`Loading...`++ return $localize`No results found`+ }++ private buildUserChannelObs () {+ return this.auth.userInformationLoaded.pipe(first())+ .pipe(map(() => this.auth.getUser().videoChannels.map(c => this.formatChannel({ channel: c, displayOwner: false }))))+ }++ private buildOwnerChannelObs () {+ return this.channelService.listAccountChannels({+ account: { nameWithHost: this.ownerAccountName() }+ }).pipe(map(({ data }) => data.map(c => this.formatChannel({ channel: c, displayOwner: false }))))+ }++ onHide () {+ this.options = [ ...this.baseOptions ]+ }++ onFilter ({ filter }: { filter: string }) {+ if (!filter) {+ this.options = [ ...this.baseOptions ]+ return+ }++ this.options = []++ this.loading = true++ this.loadingSub?.unsubscribe()++ this.loadingSub = this.searchService.searchVideoChannels({ search: filter })+ .subscribe({+ next: ({ data }) => {+ this.options = [+ {+ label: $localize`Searched channels`,+ value: 'search',+ items: data.map(c => this.formatChannel({ channel: c, displayOwner: true }))+ }+ ]++ this.loading = false+ },++ error: err => {+ this.loading = false++ this.notifier.error(err.message)+ }+ })+ }++ propagateChange = (_: any) => {+ // empty+ }++ writeValue (id: number | string) {+ this.selectedId = typeof id === 'string'+ ? parseInt(id, 10)+ : id+ }++ registerOnChange (fn: (_: any) => void) {+ this.propagateChange = fn+ }++ registerOnTouched () {+ // Unused+ }++ onModelChange () {+ this.propagateChange(this.selectedId)+ }++ private formatChannel (options: {+ channel: VideoChannelServer+ displayOwner: boolean+ }) {+ const { channel, displayOwner } = options++ return {+ id: channel.id,+ label: channel.displayName,+ description: displayOwner+ ? channel.ownerAccount.displayName+ : undefined,++ imageUrl: channel.avatars.length+ ? findAppropriateImageFileUrl(channel.avatars, 21)+ : VideoChannel.GET_DEFAULT_AVATAR_URL(21)+ }+ }+}diff --git a/client/src/app/shared/shared-forms/select/select-channel-auto.component.ts b/client/src/app/shared/shared-forms/select/select-channel-auto.component.tsnew file mode 100644index 0000000000..ee6266fc47--- /dev/null+++ b/client/src/app/shared/shared-forms/select/select-channel-auto.component.ts@@ -0,0 +1,107 @@+import { ChangeDetectionStrategy, Component, forwardRef, inject, input, OnChanges, OnDestroy } from '@angular/core'+import { ControlValueAccessor, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'+import { AuthService } from '@app/core'+import { buildUserChannelsForSelect } from '@app/helpers/utils/channel'+import { VideoChannel } from '@app/shared/shared-main/channel/video-channel.model'+import { Account } from '@peertube/peertube-models'+import { first, Subscription } from 'rxjs'+import { SelectChannelItem } from '../../../../types/select-options-item.model'+import { SelectChannelAdminComponent } from './select-channel-admin.component'+import { SelectChannelUserComponent } from './select-channel-user.component'++/**+ * Loads the admin channel selector (with instance-wide search) if the user is NOT the owner or editor of the current channel+ * Typically the case when an administrator is editing another user's content.+ * Otherwise loads the simpler user-only selector.+ */++@Component({+ selector: 'my-select-channel-auto',+ template: `+ @if (shouldLoadAdminSelect) {+ <my-select-channel-admin+ [inputId]="inputId()"+ [ownerAccountName]="ownerAccount().name"+ [(ngModel)]="selectedId"+ (ngModelChange)="onModelChange()"+ ></my-select-channel-admin>+ } @else {+ <my-select-channel-user+ [inputId]="inputId()"+ [items]="userChannels"+ [(ngModel)]="selectedId"+ (ngModelChange)="onModelChange()"+ ></my-select-channel-user>+ }+ `,+ providers: [+ {+ provide: NG_VALUE_ACCESSOR,+ useExisting: forwardRef(() => SelectChannelAutoComponent),+ multi: true+ }+ ],+ changeDetection: ChangeDetectionStrategy.Eager,+ imports: [ FormsModule, SelectChannelAdminComponent, SelectChannelUserComponent ]+})+export class SelectChannelAutoComponent implements ControlValueAccessor, OnChanges, OnDestroy {+ private readonly auth = inject(AuthService)++ readonly inputId = input.required<string>()+ readonly ownerChannel = input.required<Pick<VideoChannel, 'id'>>()+ readonly ownerAccount = input.required<Pick<Account, 'name'>>()++ userChannels: SelectChannelItem[]+ selectedId: number+ shouldLoadAdminSelect: boolean++ private loadSub: Subscription++ ngOnChanges () {+ this.loadSub?.unsubscribe()+ this.loadSub = this.auth.userInformationLoaded.pipe(first())+ .subscribe({+ next: () => {+ const user = this.auth.getUser()++ const ownerChannelId = this.ownerChannel().id+ if (user.isOwnerOfChannel({ id: ownerChannelId }) || user.isEditorOfChannel({ id: ownerChannelId })) {+ this.shouldLoadAdminSelect = false++ this.userChannels = buildUserChannelsForSelect({ authService: this.auth, includeCollaborations: true })+ } else {+ this.shouldLoadAdminSelect = true++ // Admin channels are automatically loaded by the component+ this.userChannels = []+ }+ }+ })+ }++ ngOnDestroy () {+ this.loadSub?.unsubscribe()+ }++ propagateChange = (_: any) => {+ // empty+ }++ writeValue (id: number | string) {+ this.selectedId = typeof id === 'string'+ ? parseInt(id, 10)+ : id+ }++ registerOnChange (fn: (_: any) => void) {+ this.propagateChange = fn+ }++ registerOnTouched () {+ // Unused+ }++ onModelChange () {+ this.propagateChange(this.selectedId)+ }+}diff --git a/client/src/app/shared/shared-forms/select/select-channel.component.ts b/client/src/app/shared/shared-forms/select/select-channel-user.component.tssimilarity index 84%rename from client/src/app/shared/shared-forms/select/select-channel.component.tsrename to client/src/app/shared/shared-forms/select/select-channel-user.component.tsindex c976e797a2..c668526de1 100644--- a/client/src/app/shared/shared-forms/select/select-channel.component.ts+++ b/client/src/app/shared/shared-forms/select/select-channel-user.component.ts@@ -1,12 +1,12 @@-import { Component, forwardRef, input, OnChanges, ChangeDetectionStrategy } from '@angular/core'+import { ChangeDetectionStrategy, Component, forwardRef, input, OnChanges } from '@angular/core'import { ControlValueAccessor, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'+import { CollaboratorStateComponent } from '@app/shared/shared-main/channel/collaborator-state.component'import { VideoChannel } from '@app/shared/shared-main/channel/video-channel.model'import { SelectChannelItem, SelectOptionsItem } from '../../../../types/select-options-item.model'import { SelectOptionsComponent } from './select-options.component'-import { CollaboratorStateComponent } from '@app/shared/shared-main/channel/collaborator-state.component'@Component({- selector: 'my-select-channel',+ selector: 'my-select-channel-user',template: `<my-select-options[inputId]="inputId()"@@ -32,14 +32,14 @@ import { CollaboratorStateComponent } from '@app/shared/shared-main/channel/collproviders: [{provide: NG_VALUE_ACCESSOR,- useExisting: forwardRef(() => SelectChannelComponent),+ useExisting: forwardRef(() => SelectChannelUserComponent),multi: true}],changeDetection: ChangeDetectionStrategy.Eager,imports: [ FormsModule, SelectOptionsComponent, CollaboratorStateComponent ]})-export class SelectChannelComponent implements ControlValueAccessor, OnChanges {+export class SelectChannelUserComponent implements ControlValueAccessor, OnChanges {readonly inputId = input.required<string>()readonly items = input<SelectChannelItem[]>([])@@ -77,8 +77,4 @@ export class SelectChannelComponent implements ControlValueAccessor, OnChanges {onModelChange () {this.propagateChange(this.selectedId)}-- getSelectedChannel () {- return (this.channels || []).find(c => c.id + '' === this.selectedId + '')- }}diff --git a/client/src/app/shared/shared-forms/select/select-options.component.html b/client/src/app/shared/shared-forms/select/select-options.component.htmlindex 8fbad47f2b..e91e69d342 100644--- a/client/src/app/shared/shared-forms/select/select-options.component.html+++ b/client/src/app/shared/shared-forms/select/select-options.component.html@@ -2,6 +2,7 @@[inputId]="inputId()"[options]="items()"+ [group]="group()"[(ngModel)]="selectedId"(ngModelChange)="onModelChange()"@@ -14,10 +15,7 @@[filter]="filter()"filterBy="label"-- i18n-filterPlaceholder filterPlaceholder="Search"- i18n-emptyFilterMessage emptyFilterMessage="No results found"- i18n-emptyMessage emptyMessage="No items available"+ [resetFilterOnHide]="resetFilterOnHide()"[virtualScroll]="virtualScroll()"[virtualScrollItemSize]="virtualScrollItemSize()"@@ -28,6 +26,12 @@[class.small]="small()"[placeholder]="placeholder()"+ [filterPlaceholder]="filterPlaceholder()"+ [emptyFilterMessage]="emptyFilterMessage()"+ [emptyMessage]="emptyMessage()"++ (onHide)="onHide.emit()"+ (onFilter)="onFilter.emit($event)"><ng-template #itemTemplate let-item let-description="description">@if (selectOptionTemplate) {@@ -40,7 +44,7 @@<div><div class="d-flex align-items-center item-label custom-item">@if (item?.imageUrl) {- <img alt="" class="me-2" [src]="item.imageUrl" />+ <img alt="" [src]="item.imageUrl" />}<span class="ellipsis" [ngClass]="item?.classes">{{ item?.label }}</span>@@ -51,7 +55,7 @@</div>@if (description) {- <span class="muted">{{ description }}</span>+ <span class="muted" [class.has-image]="item?.imageUrl">{{ description }}</span>}</div>}diff --git a/client/src/app/shared/shared-forms/select/select-options.component.scss b/client/src/app/shared/shared-forms/select/select-options.component.scssindex e3e3335dba..34bd76f50a 100644--- a/client/src/app/shared/shared-forms/select/select-options.component.scss+++ b/client/src/app/shared/shared-forms/select/select-options.component.scss@@ -1,11 +1,15 @@@use "_variables" as *;@use "_mixins" as *;+$image-size: 21px;+img {border-radius: 50%;- height: 21px;- width: 21px;+ height: $image-size;+ width: $image-size;margin-top: -1px;++ @include margin-right(0.5rem);}.muted {@@ -13,6 +17,10 @@ img {line-height: 1.2;display: block;white-space: normal;++ &.has-image {+ @include margin-left(calc(0.5rem + $image-size));+ }}.item-label {diff --git a/client/src/app/shared/shared-forms/select/select-options.component.ts b/client/src/app/shared/shared-forms/select/select-options.component.tsindex e14421124b..5e2ed8a9ca 100644--- a/client/src/app/shared/shared-forms/select/select-options.component.ts+++ b/client/src/app/shared/shared-forms/select/select-options.component.ts@@ -1,6 +1,7 @@import { CommonModule } from '@angular/common'import {booleanAttribute,+ ChangeDetectionStrategy,ChangeDetectorRef,Component,ContentChild,@@ -9,12 +10,13 @@ import {inject,input,numberAttribute,- TemplateRef,- ChangeDetectionStrategy+ output,+ TemplateRef} from '@angular/core'import { ControlValueAccessor, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'+import { SelectItemGroup } from 'primeng/api'import { SelectModule } from 'primeng/select'-import { SelectOptionsItem } from '../../../../types/select-options-item.model'+import { SelectOptionsGroup, SelectOptionsItem } from '../../../../types/select-options-item.model'@Component({selector: 'my-select-options',@@ -35,20 +37,32 @@ import { SelectOptionsItem } from '../../../../types/select-options-item.model'export class SelectOptionsComponent implements ControlValueAccessor {private cd = inject(ChangeDetectorRef)- readonly items = input<SelectOptionsItem[]>([])+ readonly items = input<SelectOptionsItem[] | SelectOptionsGroup[]>([])readonly inputId = input.required<string>()readonly clearable = input(false, { transform: booleanAttribute })readonly filter = input(false, { transform: booleanAttribute })+ readonly resetFilterOnHide = input(false, { transform: booleanAttribute })readonly small = input(false, { transform: booleanAttribute })readonly placeholder = input('')+ readonly group = input(false, { transform: booleanAttribute })++ readonly filterPlaceholder = input($localize`Search`)+ readonly emptyFilterMessage = input($localize`No results found`)+ readonly emptyMessage = input($localize`No items available`)+readonly appendTo = input<'body'>()readonly virtualScroll = input(false, { transform: booleanAttribute })readonly virtualScrollItemSize = input(39, { transform: numberAttribute })+ // eslint-disable-next-line @angular-eslint/no-output-on-prefix+ readonly onHide = output()+ // eslint-disable-next-line @angular-eslint/no-output-on-prefix+ readonly onFilter = output<{ filter: string }>()+@ContentChild('selectOption', { descendants: false })selectOptionTemplate: TemplateRef<any>@@ -107,6 +121,10 @@ export class SelectOptionsComponent implements ControlValueAccessor {}getSelectedItem () {- return this.items().find(i => i.id === this.selectedId)+ const items = this.group()+ ? (this.items() as unknown as SelectItemGroup[]).reduce((acc, group) => acc.concat(group.items), [])+ : this.items()++ return items.find(i => i.id === this.selectedId)}}diff --git a/client/src/app/shared/shared-main/channel/video-channel.model.ts b/client/src/app/shared/shared-main/channel/video-channel.model.tsindex da20759634..445cd45406 100644--- a/client/src/app/shared/shared-main/channel/video-channel.model.ts+++ b/client/src/app/shared/shared-main/channel/video-channel.model.ts@@ -1,3 +1,4 @@+import { getOriginUrl } from '@app/helpers'import { maxBy } from '@peertube/peertube-core-utils'import { ActorImage, Account as ServerAccount, VideoChannel as ServerVideoChannel, ViewsPerDate } from '@peertube/peertube-models'import { Actor } from '../account/actor.model'@@ -38,10 +39,10 @@ export class VideoChannel extends Actor implements ServerVideoChannel {static GET_DEFAULT_AVATAR_URL (size: number) {if (size <= 48) {- return `${window.location.origin}/client/assets/images/default-avatar-video-channel-48x48.png`+ return `${getOriginUrl()}/client/assets/images/default-avatar-video-channel-48x48.png`}- return `${window.location.origin}/client/assets/images/default-avatar-video-channel.png`+ return `${getOriginUrl()}/client/assets/images/default-avatar-video-channel.png`}static buildPublicUrl (channel: Pick<ServerVideoChannel, 'name' | 'host'>) {diff --git a/client/src/app/shared/shared-main/channel/video-channel.service.ts b/client/src/app/shared/shared-main/channel/video-channel.service.tsindex e39b9c1391..943455507f 100644--- a/client/src/app/shared/shared-main/channel/video-channel.service.ts+++ b/client/src/app/shared/shared-main/channel/video-channel.service.ts@@ -51,7 +51,7 @@ export class VideoChannelService {}listAccountChannels (options: {- account: Account+ account: Pick<Account, 'nameWithHost'>componentPagination?: ComponentPaginationLightwithStats?: booleansort?: stringdiff --git a/client/src/app/shared/shared-video/bulk-update-videos-modal.component.html b/client/src/app/shared/shared-video/bulk-update-videos-modal.component.htmlindex 2382909892..c77d8d2115 100644--- a/client/src/app/shared/shared-video/bulk-update-videos-modal.component.html+++ b/client/src/app/shared/shared-video/bulk-update-videos-modal.component.html@@ -35,12 +35,12 @@</div>@if (def.key === 'channelId') {- <my-select-channel+ <my-select-channel-user[inputId]="'bulk-' + def.key"[items]="userChannels"[formField]="bulkUpdateForm[def.key]">- </my-select-channel>+ </my-select-channel-user>} @else if (def.key === 'support') {<textarea class="form-control" rows="3" [formField]="bulkUpdateForm[def.key]"></textarea>} @else if (def.key === 'downloadEnabled') {diff --git a/client/src/app/shared/shared-video/bulk-update-videos-modal.component.ts b/client/src/app/shared/shared-video/bulk-update-videos-modal.component.tsindex f8b5dd90fa..da9ccad0be 100644--- a/client/src/app/shared/shared-video/bulk-update-videos-modal.component.ts+++ b/client/src/app/shared/shared-video/bulk-update-videos-modal.component.ts@@ -1,10 +1,10 @@import { CdkStepperModule } from '@angular/cdk/stepper'-import { Component, computed, ElementRef, inject, output, signal, viewChild, ChangeDetectionStrategy } from '@angular/core'+import { ChangeDetectionStrategy, Component, computed, ElementRef, inject, output, signal, viewChild } from '@angular/core'import { FormsModule } from '@angular/forms'import { form, FormField, required } from '@angular/forms/signals'import { AuthService, Notifier, ServerService } from '@app/core'import { formatICU } from '@app/helpers'-import { listUserChannelsForSelect } from '@app/helpers/utils/channel'+import { listChannelsForSelect } from '@app/helpers/utils/channel'import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal'import { ConstantLabel, Video, VideoCommentPolicyType, VideoPrivacy, VideoPrivacyType, VideoUpdate } from '@peertube/peertube-models'import { SelectChannelItem } from '@pt-types'@@ -12,7 +12,7 @@ import { concatMap, from, toArray } from 'rxjs'import { videoSupportValidator } from '../form-validators/video-validators'import { FormErrorComponent } from '../shared-forms/form-error.component'import { PeertubeCheckboxComponent } from '../shared-forms/peertube-checkbox.component'-import { SelectChannelComponent } from '../shared-forms/select/select-channel.component'+import { SelectChannelUserComponent } from '../shared-forms/select/select-channel-user.component'import { SelectOptionsComponent } from '../shared-forms/select/select-options.component'import { GlobalIconComponent } from '../shared-icons/global-icon.component'import { ButtonComponent } from '../shared-main/buttons/button.component'@@ -50,7 +50,7 @@ const BULK_PRIVACY_EXCLUDE = new Set<VideoPrivacyType>([ VideoPrivacy.PASSWORD_PGlobalIconComponent,ButtonComponent,SelectOptionsComponent,- SelectChannelComponent,+ SelectChannelUserComponent,PeertubeCheckboxComponent,FormErrorComponent,FormField,@@ -141,8 +141,10 @@ export class BulkUpdateVideosModalComponent {})// Load user channels- listUserChannelsForSelect(this.authService, { includeCollaborations: true })- .subscribe(channels => this.userChannels = channels)+ listChannelsForSelect({+ authService: this.authService,+ includeCollaborations: true+ }).subscribe(channels => this.userChannels = channels)this.openedModal = this.modalService.open(this.modal(), { centered: true, keyboard: false })}diff --git a/client/src/types/select-options-item.model.ts b/client/src/types/select-options-item.model.tsindex 75dc47d909..b937f2d538 100644--- a/client/src/types/select-options-item.model.ts+++ b/client/src/types/select-options-item.model.ts@@ -15,3 +15,9 @@ export interface SelectChannelItem extends SelectOptionsItem {editor: boolean}++export interface SelectOptionsGroup {+ label: string+ value: string+ items: SelectOptionsItem[]+}