Settings: hide unnecessary settings depending on webchat mode (requires Peertube 3.2.0).
This commit is contained in:
17
client/@types/peertube.d.ts
vendored
17
client/@types/peertube.d.ts
vendored
@ -29,9 +29,26 @@ interface RegisterClientHelpers {
|
||||
translate: (toTranslate: string) => Promise<string>
|
||||
}
|
||||
|
||||
interface RegisterClientFormFieldOptions {
|
||||
name: string
|
||||
label: string
|
||||
type: 'input' | 'input-checkbox' | 'input-password' | 'input-textarea' | 'markdown-text' | 'markdown-enhanced'
|
||||
descriptionHTML?: string
|
||||
default?: string | boolean
|
||||
private: boolean
|
||||
}
|
||||
interface RegisterClientSettingsScript {
|
||||
isSettingHidden: (options: {
|
||||
setting: RegisterClientFormFieldOptions
|
||||
formValues: { [name: string]: any }
|
||||
}) => boolean
|
||||
}
|
||||
|
||||
interface RegisterOptions {
|
||||
registerHook: (options: RegisterClientHookOptions) => void
|
||||
peertubeHelpers: RegisterClientHelpers
|
||||
// registerSettingsScript comes with Peertube 3.2.0.
|
||||
registerSettingsScript?: (options: RegisterClientSettingsScript) => void
|
||||
}
|
||||
|
||||
interface Video {
|
||||
|
33
client/admin-plugin-client-plugin.ts
Normal file
33
client/admin-plugin-client-plugin.ts
Normal file
@ -0,0 +1,33 @@
|
||||
const prosodySettings = ['prosody-port']
|
||||
const converseSettings = ['chat-server', 'chat-room', 'chat-bosh-uri', 'chat-ws-uri']
|
||||
const otherSettings: string[] = []
|
||||
|
||||
function register ({ registerSettingsScript }: RegisterOptions): void {
|
||||
if (registerSettingsScript) {
|
||||
registerSettingsScript({
|
||||
isSettingHidden: options => {
|
||||
const name = options.setting.name
|
||||
if (prosodySettings.includes(name)) {
|
||||
return options.formValues['chat-use-prosody'] !== true
|
||||
}
|
||||
if (name === 'chat-use-builtin') {
|
||||
return options.formValues['chat-use-prosody'] === true
|
||||
}
|
||||
if (converseSettings.includes(name)) {
|
||||
return options.formValues['chat-use-builtin'] !== true || options.formValues['chat-use-prosody'] === true
|
||||
}
|
||||
if (name === 'chat-uri') {
|
||||
return options.formValues['chat-use-prosody'] === true || options.formValues['chat-use-builtin'] === true
|
||||
}
|
||||
if (otherSettings.includes(name)) {
|
||||
return options.formValues['chat-use-builtin'] === true || options.formValues['chat-use-prosody'] === true
|
||||
}
|
||||
return false
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
register
|
||||
}
|
Reference in New Issue
Block a user