// SPDX-FileCopyrightText: 2024 John Livingston // // SPDX-License-Identifier: AGPL-3.0-only import type { ChannelConfigurationElement } from '../channel-configuration' import type { DynamicFormHeader, DynamicFormSchema } from '../../../lib/elements/dynamic-table-form' import { ptTr } from '../../../lib/directives/translation' import { html, TemplateResult } from 'lit' import { classMap } from 'lit/directives/class-map.js' export function tplChannelConfiguration (el: ChannelConfigurationElement): TemplateResult { const tableHeaderList: {[key: string]: DynamicFormHeader} = { forbiddenWords: { entries: { colName: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_LABEL), description: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_DESC2) }, regexp: { colName: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_REGEXP_LABEL), description: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_REGEXP_DESC) }, applyToModerators: { colName: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_APPLYTOMODERATORS_LABEL), description: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_APPLYTOMODERATORS_DESC) }, label: { colName: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_LABEL_LABEL), description: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_LABEL_DESC) }, reason: { colName: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_REASON_LABEL), description: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_REASON_DESC) }, comments: { colName: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_COMMENTS_LABEL), description: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_FORBIDDEN_WORDS_COMMENTS_DESC) } }, quotes: { messages: { colName: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_LABEL2), description: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_DESC2) }, delay: { colName: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_DELAY_LABEL), description: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_QUOTE_DELAY_DESC) } }, commands: { command: { colName: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_CMD_LABEL), description: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_CMD_DESC) }, message: { colName: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_MESSAGE_LABEL), description: ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_COMMAND_MESSAGE_DESC) } } } const tableSchema: {[key: string]: DynamicFormSchema} = { forbiddenWords: { entries: { inputType: 'tags', default: [], separator: '\n' }, regexp: { inputType: 'checkbox', default: false }, applyToModerators: { inputType: 'checkbox', default: false }, label: { inputType: 'text', default: '' }, reason: { inputType: 'text', default: '' }, comments: { inputType: 'textarea', default: '' } }, quotes: { messages: { inputType: 'textarea', default: [], separator: '\n' }, delay: { inputType: 'number', default: 10 } }, commands: { command: { inputType: 'text', default: '' }, message: { inputType: 'text', default: '' } } } return html`

${el.channelConfiguration?.channel.displayName} ${el.channelConfiguration?.channel.name}

${ptTr(LOC_LIVECHAT_CONFIGURATION_CHANNEL_DESC)}

${el.renderFeedback('peertube-livechat-slowmode-duration-feedback', 'slowMode.duration')}
${!el.channelConfiguration?.configuration.bot.enabled ? '' : html`
{ if (event?.target && el.channelConfiguration) { el.channelConfiguration.configuration.bot.nickname = (event.target as HTMLInputElement).value } el.requestUpdate('channelConfiguration') } } value="${el.channelConfiguration?.configuration.bot.nickname ?? ''}" /> ${el.renderFeedback('peertube-livechat-bot-nickname-feedback', 'bot.nickname')}
{ el.resetValidation(e) if (el.channelConfiguration) { el.channelConfiguration.configuration.bot.forbiddenWords = e.detail el.requestUpdate('channelConfiguration') } } } .formName=${'forbidden-words'} > { el.resetValidation(e) if (el.channelConfiguration) { el.channelConfiguration.configuration.bot.quotes = e.detail el.requestUpdate('channelConfiguration') } } } .formName=${'quote'} > { el.resetValidation(e) if (el.channelConfiguration) { el.channelConfiguration.configuration.bot.commands = e.detail el.requestUpdate('channelConfiguration') } } } .formName=${'command'} > `}
` }