-
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
index f51f52160..34119f7ab 100644
--- a/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
+++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.ts
@@ -2,7 +2,7 @@ import { forkJoin } from 'rxjs'
import { map } from 'rxjs/operators'
import { SelectChannelItem } from 'src/types/select-options-item.model'
import { Component, EventEmitter, Input, NgZone, OnDestroy, OnInit, Output, ViewChild } from '@angular/core'
-import { FormArray, FormControl, FormGroup, ValidatorFn, Validators } from '@angular/forms'
+import { FormArray, FormControl, FormGroup, Validators } from '@angular/forms'
import { HooksService, PluginService, ServerService } from '@app/core'
import { removeElementFromArray } from '@app/helpers'
import {
@@ -21,13 +21,17 @@ import {
import { FormReactiveValidationMessages, FormValidatorService } from '@app/shared/shared-forms'
import { InstanceService } from '@app/shared/shared-instance'
import { VideoCaptionEdit, VideoEdit, VideoService } from '@app/shared/shared-main'
-import { LiveVideo, ServerConfig, VideoConstant, VideoPrivacy } from '@shared/models'
+import { LiveVideo, ServerConfig, VideoConstant, VideoDetails, VideoPrivacy } from '@shared/models'
import { RegisterClientFormFieldOptions, RegisterClientVideoFieldOptions } from '@shared/models/plugins/register-client-form-field.model'
import { I18nPrimengCalendarService } from './i18n-primeng-calendar.service'
import { VideoCaptionAddModalComponent } from './video-caption-add-modal.component'
import { VideoEditType } from './video-edit.type'
type VideoLanguages = VideoConstant
& { group?: string }
+type PluginField = {
+ commonOptions: RegisterClientFormFieldOptions
+ videoFormOptions: RegisterClientVideoFieldOptions
+}
@Component({
selector: 'my-video-edit',
@@ -38,9 +42,14 @@ export class VideoEditComponent implements OnInit, OnDestroy {
@Input() form: FormGroup
@Input() formErrors: { [ id: string ]: string } = {}
@Input() validationMessages: FormReactiveValidationMessages = {}
+
+ @Input() videoToUpdate: VideoDetails
+
@Input() userVideoChannels: SelectChannelItem[] = []
@Input() schedulePublicationPossible = true
+
@Input() videoCaptions: (VideoCaptionEdit & { captionPath?: string })[] = []
+
@Input() waitTranscodingEnabled = true
@Input() type: VideoEditType
@Input() liveVideo: LiveVideo
@@ -57,9 +66,6 @@ export class VideoEditComponent implements OnInit, OnDestroy {
videoLicences: VideoConstant[] = []
videoLanguages: VideoLanguages[] = []
- tagValidators: ValidatorFn[]
- tagValidatorsMessages: { [ name: string ]: string }
-
pluginDataFormGroup: FormGroup
schedulePublicationEnabled = false
@@ -73,10 +79,7 @@ export class VideoEditComponent implements OnInit, OnDestroy {
serverConfig: ServerConfig
- pluginFields: {
- commonOptions: RegisterClientFormFieldOptions
- videoFormOptions: RegisterClientVideoFieldOptions
- }[] = []
+ pluginFields: PluginField[] = []
private schedulerInterval: any
private firstPatchDone = false
@@ -92,7 +95,6 @@ export class VideoEditComponent implements OnInit, OnDestroy {
private ngZone: NgZone,
private hooks: HooksService
) {
- this.calendarLocale = this.i18nPrimengCalendarService.getCalendarLocale()
this.calendarTimezone = this.i18nPrimengCalendarService.getTimezone()
this.calendarDateFormat = this.i18nPrimengCalendarService.getDateFormat()
}
@@ -251,6 +253,16 @@ export class VideoEditComponent implements OnInit, OnDestroy {
return this.form.value['permanentLive'] === true
}
+ isPluginFieldHidden (pluginField: PluginField) {
+ if (typeof pluginField.commonOptions.hidden !== 'function') return false
+
+ return pluginField.commonOptions.hidden({
+ formValues: this.form.value,
+ videoToUpdate: this.videoToUpdate,
+ liveVideo: this.liveVideo
+ })
+ }
+
private sortVideoCaptions () {
this.videoCaptions.sort((v1, v2) => {
if (v1.language.label < v2.language.label) return -1
diff --git a/client/src/app/+videos/+video-edit/video-update.component.html b/client/src/app/+videos/+video-edit/video-update.component.html
index 41501714f..3ce3e623e 100644
--- a/client/src/app/+videos/+video-edit/video-update.component.html
+++ b/client/src/app/+videos/+video-edit/video-update.component.html
@@ -11,7 +11,7 @@
[validationMessages]="validationMessages" [userVideoChannels]="userVideoChannels"
[videoCaptions]="videoCaptions" [waitTranscodingEnabled]="isWaitTranscodingEnabled()"
type="update" (pluginFieldsAdded)="hydratePluginFieldsFromVideo()"
- [liveVideo]="liveVideo"
+ [liveVideo]="liveVideo" [videoToUpdate]="videoDetails"
>
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts
index 103014bb0..3a90fdc58 100644
--- a/client/src/standalone/videos/embed.ts
+++ b/client/src/standalone/videos/embed.ts
@@ -777,6 +777,7 @@ export class PeerTubeEmbed {
getSettings: unimplemented,
isLoggedIn: unimplemented,
+ getAuthHeader: unimplemented,
notifier: {
info: unimplemented,
diff --git a/shared/models/plugins/register-client-form-field.model.ts b/shared/models/plugins/register-client-form-field.model.ts
index db61dbc88..2df071337 100644
--- a/shared/models/plugins/register-client-form-field.model.ts
+++ b/shared/models/plugins/register-client-form-field.model.ts
@@ -13,6 +13,9 @@ export type RegisterClientFormFieldOptions = {
// Default setting value
default?: string | boolean
+
+ // Not supported by plugin setting registration, use registerSettingsScript instead
+ hidden?: (options: any) => boolean
}
export interface RegisterClientVideoFieldOptions {
diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md
index ca951c781..8d85092e7 100644
--- a/support/doc/plugins/guide.md
+++ b/support/doc/plugins/guide.md
@@ -623,7 +623,13 @@ async function register ({ registerVideoField, peertubeHelpers }) {
label: 'My added field',
descriptionHTML: 'Optional description',
type: 'input-textarea',
- default: ''
+ default: '',
+ // Optional, to hide a field depending on the current form state
+ // liveVideo is in the options object when the user is creating/updating a live
+ // videoToUpdate is in the options object when the user is updating a video
+ hidden: ({ formValues, videoToUpdate, liveVideo }) => {
+ return formValues.pluginData['other-field'] === 'toto'
+ }
}
for (const type of [ 'upload', 'import-url', 'import-torrent', 'update', 'go-live' ]) {