Settings: hide unnecessary settings depending on webchat mode (requires Peertube 3.2.0).
This commit is contained in:
parent
df5f8e0f73
commit
07ab2a80ed
@ -6,6 +6,7 @@
|
||||
|
||||
* Don't display webchat when viewing a playlist (requires Peertube 3.2.0).
|
||||
* Better default values for settings.
|
||||
* Settings: hide unnecessary settings depending on webchat mode (requires Peertube 3.2.0).
|
||||
|
||||
### Fixes
|
||||
|
||||
|
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
|
||||
}
|
@ -16,6 +16,12 @@
|
||||
"scopes": [
|
||||
"common"
|
||||
]
|
||||
},
|
||||
{
|
||||
"script": "dist/client/admin-plugin-client-plugin.js",
|
||||
"scopes": [
|
||||
"admin-plugin"
|
||||
]
|
||||
}
|
||||
],
|
||||
"css": [
|
||||
|
@ -7,7 +7,8 @@ const packagejson = require('./package.json')
|
||||
|
||||
const clientFiles = [
|
||||
'common-client-plugin',
|
||||
'videowatch-client-plugin'
|
||||
'videowatch-client-plugin',
|
||||
'admin-plugin-client-plugin'
|
||||
]
|
||||
|
||||
let config = clientFiles.map(f => ({
|
||||
|
Loading…
x
Reference in New Issue
Block a user