Fix admin config form for auto follow
authorChocobozzz <me@florianbigard.com>
Tue, 21 Jan 2020 09:47:56 +0000 (10:47 +0100)
committerChocobozzz <me@florianbigard.com>
Tue, 21 Jan 2020 09:47:56 +0000 (10:47 +0100)
client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html
client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
client/src/app/shared/forms/markdown-textarea.component.html
client/src/app/shared/forms/markdown-textarea.component.ts

index f6159367771ee9b7bb752756cbdb5491b4deca12..e5340234b121450dc1ebc86a89093a796bcb9d82 100644 (file)
@@ -30,7 +30,7 @@
           <div class="form-group">
             <label i18n for="instanceDescription">Description</label><my-help helpType="markdownText"></my-help>
             <my-markdown-textarea
-              id="instanceDescription" formControlName="description" textareaWidth="500px" [previewColumn]="true"
+              name="instanceDescription" formControlName="description" textareaWidth="500px" [previewColumn]="true"
               [classes]="{ 'input-error': formErrors['instance.description'] }"
             ></my-markdown-textarea>
             <div *ngIf="formErrors.instance.description" class="form-error">{{ formErrors.instance.description }}</div>
           <div class="form-group">
             <label i18n for="instanceTerms">Terms</label><my-help helpType="markdownText"></my-help>
             <my-markdown-textarea
-              id="instanceTerms" formControlName="terms" textareaWidth="500px" [previewColumn]="true"
+              name="instanceTerms" formControlName="terms" textareaWidth="500px" [previewColumn]="true"
               [ngClass]="{ 'input-error': formErrors['instance.terms'] }"
             ></my-markdown-textarea>
             <div *ngIf="formErrors.instance.terms" class="form-error">{{ formErrors.instance.terms }}</div>
           <div class="form-group">
             <label i18n for="instanceCodeOfConduct">Code of conduct</label><my-help helpType="markdownText"></my-help>
             <my-markdown-textarea
-              id="instanceCodeOfConduct" formControlName="codeOfConduct" textareaWidth="500px" [previewColumn]="true"
+              name="instanceCodeOfConduct" formControlName="codeOfConduct" textareaWidth="500px" [previewColumn]="true"
               [ngClass]="{ 'input-error': formErrors['instance.codeOfConduct'] }"
             ></my-markdown-textarea>
             <div *ngIf="formErrors.instance.codeOfConduct" class="form-error">{{ formErrors.instance.codeOfConduct }}</div>
             <div class="label-small-info">Who moderates the instance? What is the policy regarding NSFW videos? Political videos? etc</div>
 
             <my-markdown-textarea
-              id="instanceModerationInformation" formControlName="moderationInformation" textareaWidth="500px" [previewColumn]="true"
+              name="instanceModerationInformation" formControlName="moderationInformation" textareaWidth="500px" [previewColumn]="true"
               [ngClass]="{ 'input-error': formErrors['instance.moderationInformation'] }"
             ></my-markdown-textarea>
             <div *ngIf="formErrors.instance.moderationInformation" class="form-error">{{ formErrors.instance.moderationInformation }}</div>
             <div class="label-small-info">A single person? A non-profit? A company?</div>
 
             <my-markdown-textarea
-              id="instanceAdministrator" formControlName="administrator" textareaWidth="500px" textareaHeight="75px" [previewColumn]="true"
+              name="instanceAdministrator" formControlName="administrator" textareaWidth="500px" textareaHeight="75px" [previewColumn]="true"
               [classes]="{ 'input-error': formErrors['instance.administrator'] }"
             ></my-markdown-textarea>
 
             <div class="label-small-info">2vCore 2GB RAM/or directly the link to the server you rent etc</div>
 
             <my-markdown-textarea
-              id="instanceHardwareInformation" formControlName="hardwareInformation" textareaWidth="500px" textareaHeight="75px" [previewColumn]="true"
+              name="instanceHardwareInformation" formControlName="hardwareInformation" textareaWidth="500px" textareaHeight="75px" [previewColumn]="true"
               [classes]="{ 'input-error': formErrors['instance.hardwareInformation'] }"
             ></my-markdown-textarea>
 
                   inputName="signupRequiresEmailVerification" formControlName="requiresEmailVerification"
                   i18n-labelText labelText="Signup requires email verification"
                 ></my-peertube-checkbox>
-      
+
                 <div [ngClass]="{ 'disabled-checkbox-extra': !isSignupEnabled() }" class="mt-3">
                   <label i18n for="signupLimit">Signup limit</label>
                   <input
                 <my-peertube-checkbox
                   inputName="followingsInstanceAutoFollowIndexEnabled" formControlName="enabled"
                   i18n-labelText labelText="Automatically follow instances of the public index"
-                  [(ngModel)]="isAutoFollowIndexEnabled"
                 >
                   <ng-container ngProjectAs="description">
                     <span i18n>⚠️ This functionality requires a lot of attention and extra moderation.</span>
                   </ng-container>
 
                   <ng-container ngProjectAs="extra">
-                    <div [ngClass]="{ 'disabled-checkbox-extra': !isAutoFollowIndexEnabled }">
+                    <div [ngClass]="{ 'disabled-checkbox-extra': !isAutoFollowIndexEnabled() }">
                       <label i18n for="followingsInstanceAutoFollowIndexUrl">Index URL</label>
                       <input
                         type="text" id="followingsInstanceAutoFollowIndexUrl"
index 1bc907b7311e6fca6804d8401789b1e0856fe2f3..c88e81c01453e0ce56961a276e715a5f5acf51b1 100644 (file)
@@ -24,8 +24,6 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
   languageItems: SelectItem[] = []
   categoryItems: SelectItem[] = []
 
-  isAutoFollowIndexEnabled = false
-
   private serverConfig: ServerConfig
 
   constructor (
@@ -236,6 +234,10 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit {
     return this.form.value['signup']['enabled'] === true
   }
 
+  isAutoFollowIndexEnabled () {
+    return this.form.value['followings']['instance']['autoFollowIndex']['enabled'] === true
+  }
+
   async formValidated () {
     this.configService.updateCustomConfig(this.form.getRawValue())
       .subscribe(
index 3de3b6fcdc41cc4c24f3b98f0d04ed96293511ca..0925b9ad5b2a2449a33b85d0bbc3ae6177c926d8 100644 (file)
@@ -2,7 +2,7 @@
   <textarea
     [(ngModel)]="content" (ngModelChange)="onModelChange()"
     [ngClass]="classes" [ngStyle]="{ width: textareaWidth, height: textareaHeight, 'margin-right': textareaMarginRight }"
-    id="description" name="description">
+    [id]="name" [name]="name">
   </textarea>
 
   <ngb-tabset *ngIf="arePreviewsDisplayed()" class="previews" type="pills">
index 0c57888997ddf4b147665220e59a5b30df719189..19cd37573213d01cb30ae66a5b4d2ecd5848df40 100644 (file)
@@ -28,6 +28,7 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit {
   @Input() truncate: number
   @Input() markdownType: 'text' | 'enhanced' = 'text'
   @Input() markdownVideo = false
+  @Input() name = 'description'
 
   textareaMarginRight = '0'
   flexDirection = 'column'