<div i18n class="form-sub-title" *ngIf="isCreation() === true">Create user</div>
<div i18n class="form-sub-title" *ngIf="isCreation() === false">Edit user {{ username }}</div>

<div *ngIf="error" class="alert alert-danger">{{ error }}</div>

<form role="form" (ngSubmit)="formValidated()" [formGroup]="form">
  <div class="form-group" *ngIf="isCreation()">
    <label i18n for="username">Username</label>
    <input
      type="text" id="username" i18n-placeholder placeholder="john"
      formControlName="username" [ngClass]="{ 'input-error': formErrors['username'] }"
    >
    <div *ngIf="formErrors.username" class="form-error">
      {{ formErrors.username }}
    </div>
  </div>

  <div class="form-group">
    <label i18n for="email">Email</label>
    <input
      type="text" id="email" i18n-placeholder placeholder="mail@example.com"
      formControlName="email" [ngClass]="{ 'input-error': formErrors['email'] }"
    >
    <div *ngIf="formErrors.email" class="form-error">
      {{ formErrors.email }}
    </div>
  </div>

  <div class="form-group" *ngIf="isCreation()">
    <label i18n for="password">Password</label>
    <input
      type="password" id="password"
      formControlName="password" [ngClass]="{ 'input-error': formErrors['password'] }"
    >
    <div *ngIf="formErrors.password" class="form-error">
      {{ formErrors.password }}
    </div>
  </div>

  <div class="form-group">
    <label i18n for="role">Role</label>
    <div class="peertube-select-container">
      <select id="role" formControlName="role">
        <option *ngFor="let role of roles" [value]="role.value">
          {{ role.label }}
        </option>
      </select>
    </div>

    <div *ngIf="formErrors.role" class="form-error">
      {{ formErrors.role }}
    </div>
  </div>

  <div class="form-group">
    <label i18n for="videoQuota">Video quota</label>
    <div class="peertube-select-container">
      <select id="videoQuota" formControlName="videoQuota">
        <option *ngFor="let videoQuotaOption of videoQuotaOptions" [value]="videoQuotaOption.value">
          {{ videoQuotaOption.label }}
        </option>
      </select>
    </div>

    <div i18n class="transcoding-information" *ngIf="isTranscodingInformationDisplayed()">
      Transcoding is enabled on server. The video quota only take in account <strong>original</strong> video. <br />
      At most, this user could use ~ {{ computeQuotaWithTranscoding() | bytes: 0 }}.
    </div>
  </div>

  <input type="submit" value="{{ getFormButtonTitle() }}" [disabled]="!form.valid">
</form>
