<app-common-dialog [dialogContent]="dialogContent" [dialogRef]="dialogRef">
  <ng-template #dialogContent>
    <div *ngIf="migrateOptions && migrateOptions.hypervisors.length === 0" i18n>No other hosts available</div>
    <form appFormSubmit (ngSubmit)="migrate()" [formGroup]="instanceMigrateForm" layoutDirection="column"
          *ngIf="migrateOptions && migrateOptions.hypervisors.length > 0">
      <app-form-errors #formErrors [formGroup]="instanceMigrateForm"></app-form-errors>
      <mat-form-field>
        <mat-label i18n>Hypervisor</mat-label>
        <mat-select formControlName="hypervisor" placeholder="Hypervisor" i18n-placeholder required>
          <mat-option *ngFor="let hypervisor of migrateOptions.hypervisors" [value]="hypervisor">
            {{hypervisor.name}}
          </mat-option>
        </mat-select>
        <mat-error>{{backendErrors['hypervisor'] || fieldRequiredTxt }}</mat-error>
      </mat-form-field>
      <div>
        <mat-checkbox [color]="'primary'" formControlName="live_migrate" i18n>
          Live migrate
        </mat-checkbox>
      </div>
      <mat-radio-group
        *ngIf="instanceMigrateForm.controls.live_migrate.value === true"
        class="fl-margin-top"
        aria-labelledby="Block migration"
        i18n-aria-labelledby
        formControlName="block_migration">
        <mat-radio-button [color]="'primary'" class="block-migration-radio-choices" [value]="false" i18n>
          Shared migration
        </mat-radio-button>
        <mat-radio-button class="fl-margin-left" [color]="'primary'" [value]="true" i18n>Block migration</mat-radio-button>
      </mat-radio-group>
      <div class="fl-margin-top" *ngIf="instanceMigrateForm.controls.live_migrate.value === true">
        <mat-checkbox [color]="'primary'" formControlName="over_commit" i18n>
           Disk overcommit
        </mat-checkbox>
      </div>
    </form>
    <p i18n>
      To follow migration status, check instance status and hypervisor. To debug migration failures,
      check instance history log in Fleio and logs in OpenStack.
    </p>
    <div class="fl-margin-top" i18n>Note that migration may fail if target hypervisor does not have enough disk
      space. Use live migration if you want to overcommit.</div>
  </ng-template>
</app-common-dialog>
