From 3c065fe3b3e1385d59ad1980251d14b712648155 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 22 Dec 2021 18:02:36 +0100 Subject: Enhance plugin video fields Add video form tab selection Add ability to display an error --- support/doc/plugins/guide.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'support/doc') diff --git a/support/doc/plugins/guide.md b/support/doc/plugins/guide.md index 26fcb8987..5c1f6a2af 100644 --- a/support/doc/plugins/guide.md +++ b/support/doc/plugins/guide.md @@ -692,16 +692,31 @@ async function register ({ registerVideoField, peertubeHelpers }) { type: 'input-textarea', 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' + }, + + // Optional, to display an error depending on the form state + error: ({ formValues, value }) => { + if (formValues['privacy'] !== 1 && formValues['privacy'] !== 2) return { error: false } + if (value === true) return { error: false } + + return { error: true, text: 'Should be enabled' } } } + const videoFormOptions = { + // Optional, to choose to put your setting in a specific tab in video form + // type: 'main' | 'plugin-settings' + tab: 'main' + } + for (const type of [ 'upload', 'import-url', 'import-torrent', 'update', 'go-live' ]) { - registerVideoField(commonOptions, { type }) + registerVideoField(commonOptions, { type, ...videoFormOptions }) } } ``` -- cgit v1.2.3