<form appFormSubmit (ngSubmit)="objectController.actionCallback(primaryAction)"
      [formGroup]="sshKeyForm" class="fl-content">
  <app-form-errors #formErrors [formGroup]="sshKeyForm"></app-form-errors>
  <app-credit-warning *ngIf="!object?.id" resourceName="SSH key" i18n-resourceName></app-credit-warning>
  <div layoutDirection="column">
    <mat-form-field>
      <mat-label i18n>Name</mat-label>
      <input matInput placeholder="Name" i18n-placeholder type="text" formControlName="name" required>
      <mat-error>{{fieldErrors['name']}}</mat-error>
    </mat-form-field>
    <mat-form-field>
      <mat-label i18n>Public key</mat-label>
      <textarea (keydown.control.enter)="objectController.actionCallback(primaryAction)"
                matInput rows="10" #publicKey
                placeholder="Public key" i18n-placeholder type="text" formControlName="public_key" required>
      </textarea>
      <mat-error>{{fieldErrors['public_key']}}</mat-error>
    </mat-form-field>
    <a *ngIf="generatedKey" mat-button color="primary" class="fl-margin-bottom"
            (click)="clipboard.copyTextAreaToClipboard(publicKey)" i18n>
      Copy public key to clipboard
    </a>
    <ng-container *ngIf="generatedKey">
      <mat-form-field>
        <mat-label i18n>Private key</mat-label>
        <p class="fl-detail" i18n>Private key. You should save this key locally, it will not be saved on server.</p>
        <textarea (keydown.control.enter)="objectController.actionCallback(primaryAction)"
                  matInput rows="10" #privateKey
                  placeholder="Private key" i18n-placeholder type="text" formControlName="private_key" readonly>
        </textarea>
      </mat-form-field>
      <a mat-button color="primary" (click)="clipboard.copyTextAreaToClipboard(privateKey)" i18n>
        Copy private key to clipboard
      </a>
    </ng-container>
  </div>
</form>
