]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Plugins can register html/select settings
authorChocobozzz <me@florianbigard.com>
Fri, 9 Apr 2021 09:19:14 +0000 (11:19 +0200)
committerChocobozzz <me@florianbigard.com>
Fri, 9 Apr 2021 09:19:14 +0000 (11:19 +0200)
client/src/app/shared/shared-forms/dynamic-form-field.component.html
shared/models/plugins/register-client-form-field.model.ts
shared/models/plugins/register-server-setting.model.ts

index c358cb1193dd6ebcebeba5487488f27e2cfc1588..8e9ef5355708324c9bf17d53af3b90f36005e46e 100644 (file)
@@ -1,10 +1,16 @@
 <div [formGroup]="form">
-  <label *ngIf="setting.type !== 'input-checkbox'" [attr.for]="setting.name" [innerHTML]="setting.label"></label>
+  <label *ngIf="setting.label" [attr.for]="setting.name" [innerHTML]="setting.label"></label>
 
   <div *ngIf="setting.descriptionHTML" class="label-small-info" [innerHTML]="setting.descriptionHTML"></div>
 
   <input *ngIf="setting.type === 'input'" type="text" [id]="setting.name" [formControlName]="setting.name" />
 
+  <div *ngIf="setting.type === 'select'" class="peertube-select-container">
+    <select  [id]="setting.name" [formControlName]="setting.name" class="form-control">
+      <option *ngFor="let option of setting.options" [value]="option.value">{{ option.label }}</option>
+    </select>
+  </div>
+
   <my-input-toggle-hidden *ngIf="setting.type === 'input-password'" [formControlName]="setting.name" [inputId]="setting.name"></my-input-toggle-hidden>
 
   <textarea *ngIf="setting.type === 'input-textarea'" type="text" [id]="setting.name" [formControlName]="setting.name"></textarea>
@@ -32,6 +38,8 @@
     [labelInnerHTML]="setting.label"
   ></my-peertube-checkbox>
 
+  <div *ngIf="setting.type === 'html'" [innerHTML]="setting.html"></div>
+
   <div *ngIf="formErrors[setting.name]" class="form-error">
     {{ formErrors[setting.name] }}
   </div>
index 641d7490c806a734fe0a1a6f1d15334732eed82a..cdcdaa181d4abe3fa5b40b50efbbbab38914a1f4 100644 (file)
@@ -1,7 +1,13 @@
-export interface RegisterClientFormFieldOptions {
-  name: string
-  label: string
-  type: 'input' | 'input-checkbox' | 'input-password' | 'input-textarea' | 'markdown-text' | 'markdown-enhanced'
+export type RegisterClientFormFieldOptions = {
+  name?: string
+  label?: string
+  type: 'input' | 'input-checkbox' | 'input-password' | 'input-textarea' | 'markdown-text' | 'markdown-enhanced' | 'select' | 'html'
+
+  // For select type
+  options?: { value: string, label: string }[]
+
+  // For html type
+  html?: string
 
   descriptionHTML?: string
 
index 6872dc53e371a776d712218c2482f1deaf9229ef..6bc25b4aee3a661c65ff46781262700b135162b8 100644 (file)
@@ -1,6 +1,6 @@
 import { RegisterClientFormFieldOptions } from './register-client-form-field.model'
 
-export interface RegisterServerSettingOptions extends RegisterClientFormFieldOptions {
+export type RegisterServerSettingOptions = RegisterClientFormFieldOptions  & {
   // If the setting is not private, anyone can view its value (client code included)
   // If the setting is private, only server-side hooks can access it
   // Mainly used by the PeerTube client to get admin config