]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
register: hide channel step if upload quota is 0
authorkontrollanten <6680299+kontrollanten@users.noreply.github.com>
Thu, 3 Dec 2020 06:59:37 +0000 (07:59 +0100)
committerChocobozzz <chocobozzz@cpy.re>
Thu, 3 Dec 2020 08:54:41 +0000 (09:54 +0100)
fix #782

client/src/app/+signup/+register/custom-stepper.component.html
client/src/app/+signup/+register/register-step-user.component.html
client/src/app/+signup/+register/register-step-user.component.ts
client/src/app/+signup/+register/register.component.html
client/src/app/+signup/+register/register.component.ts

index 57374d41e59e311eaf5c8da2b5b277004bca21bd..4cfe54152d5826993d6cfc1cbd348b5a0fd5a72c 100644 (file)
@@ -1,5 +1,5 @@
 <section class="container">
-  <header>
+  <header *ngIf="steps.length > 2">
     <ng-container *ngFor="let step of steps; let i = index; let isLast = last;">
       <div
         class="step-info" [ngClass]="{ active: selectedIndex === i, completed: isCompleted(step) }" [attr.aria-current]="selectedIndex === i"
index edb93b8ede6dcc56d1002abde1f9d7c9c99cd7b6..55fc097d0fbeff9567fe9c4cb217b7c4dd4235b0 100644 (file)
@@ -1,5 +1,9 @@
 <form role="form" [formGroup]="form">
 
+  <div class="capability-information alert alert-info" i18n *ngIf="videoUploadDisabled">
+    Video uploads are disabled on this instance, hence your account won't be able to upload videos.
+  </div>
+
   <div class="form-group">
     <label for="displayName" i18n>Display name</label>
 
index 65536568bcbc9c7b6fd81f95a9ffc16b362653be..9193540b4e2e446e360706c84b940361ada2d1bf 100644 (file)
@@ -19,6 +19,7 @@ import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 })
 export class RegisterStepUserComponent extends FormReactive implements OnInit {
   @Input() hasCodeOfConduct = false
+  @Input() videoUploadDisabled = false
 
   @Output() formBuilt = new EventEmitter<FormGroup>()
   @Output() termsClick = new EventEmitter<void>()
index fa9838ba617180a1bf36c5f34ebc161864cf86e5..7e3704124d370853676b9bd71760cd85ebbc2af5 100644 (file)
         <cdk-step [stepControl]="formStepUser" i18n-label label="User">
           <my-register-step-user
             [hasCodeOfConduct]="!!aboutHtml.codeOfConduct"
+            [videoUploadDisabled]="videoUploadDisabled"
             (formBuilt)="onUserFormBuilt($event)" (termsClick)="onTermsClick()" (codeOfConductClick)="onCodeOfConductClick()"
           >
           </my-register-step-user>
 
-          <button i18n cdkStepperNext [disabled]="!formStepUser || !formStepUser.valid">Next</button>
+          <button i18n cdkStepperNext [disabled]="!formStepUser || !formStepUser.valid"
+            (click)="signup()">{{ videoUploadDisabled ? 'Signup' : 'Next' }}</button>
         </cdk-step>
 
-        <cdk-step [stepControl]="formStepChannel" i18n-label label="Channel">
+        <cdk-step [stepControl]="formStepChannel" i18n-label label="Channel" *ngIf="!videoUploadDisabled">
           <my-register-step-channel (formBuilt)="onChannelFormBuilt($event)" [username]="getUsername()"></my-register-step-channel>
 
           <button i18n cdkStepperNext (click)="signup()"
index 153a6d2b580ea57f0fd7811783038729b9b6810e..5b6762631dcb7074866a02179fecc2b4d283f3b5 100644 (file)
@@ -30,6 +30,8 @@ export class RegisterComponent implements OnInit {
     administrator: ''
   }
 
+  videoUploadDisabled: boolean
+
   formStepUser: FormGroup
   formStepChannel: FormGroup
 
@@ -52,6 +54,8 @@ export class RegisterComponent implements OnInit {
   ngOnInit (): void {
     this.serverConfig = this.route.snapshot.data.serverConfig
 
+    this.videoUploadDisabled = this.serverConfig.user.videoQuota === 0
+
     this.instanceService.getAbout()
       .subscribe(
         async about => {
@@ -102,7 +106,7 @@ export class RegisterComponent implements OnInit {
     this.error = null
 
     const body: UserRegister = await this.hooks.wrapObject(
-      Object.assign(this.formStepUser.value, { channel: this.formStepChannel.value }),
+      Object.assign(this.formStepUser.value, { channel: this.videoUploadDisabled ? undefined : this.formStepChannel.value }),
       'signup',
       'filter:api.signup.registration.create.params'
     )