<!--

    Copyright (c) 2015-2018 Red Hat, Inc.
    This program and the accompanying materials are made
    available under the terms of the Eclipse Public License 2.0
    which is available at https://www.eclipse.org/legal/epl-2.0/

    SPDX-License-Identifier: EPL-2.0

    Contributors:
      Red Hat, Inc. - initial API and implementation

-->
<che-popup title="{{editCommandDialogController.index === -1 ? 'Add a new command' : 'Edit the command'}}"
           on-close="editCommandDialogController.hide()">
  <ng-form name="commandForm" class="edit-command-form">
    <div class="form-input-fields">
      <che-input type="text"
                 che-form="commandForm"
                 che-label-name="Name"
                 che-name="name"
                 che-place-holder="Enter command's name"
                 custom-validator="editCommandDialogController.isUnique($value)"
                 ng-model="editCommandDialogController.name"
                 ng-maxlength="256"
                 required>
        <div ng-message="required">Command's name is required.</div>
        <div ng-message="customValidator">This command's name is already in use.</div>
        <div ng-message="maxlength">Command's name should be less than 256 characters long.</div>
      </che-input>
      <che-input che-form="commandForm"
                 che-label-name="Command"
                 che-name="command"
                 che-place-holder="Enter command's line"
                 type="text"
                 ng-model="editCommandDialogController.commandLine"
                 ng-maxlength="256"
                 required>
        <div ng-message="required">Command's line is required.</div>
        <div ng-message="maxlength">Command's line should be less than 256 characters long.</div>
      </che-input>
      <che-input che-form="commandForm"
                 che-name="previewUrl"
                 che-label-name="Preview URL"
                 che-place-holder="Enter preview URL"
                 ng-maxlength="256"
                 type="text"
                 ng-model="editCommandDialogController.previewUrl">
        <div ng-message="maxlength">Command's preview URL should be less than 256 characters long.</div>
      </che-input>
    </div>
    <che-button-primary che-button-title="{{editCommandDialogController.index === -1 ? 'Add' : 'Save'}}"
                        ng-click="editCommandDialogController.updateCommand()"
                        ng-disabled="commandForm.$invalid">
    </che-button-primary>
    <che-button-notice che-button-title="Cancel"
                       ng-click="editCommandDialogController.hide()">
    </che-button-notice>
  </ng-form>
</che-popup>
