<!--
Copyright 2017 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<div class="kd-namespace-select-title kd-muted"
     i18n>Namespace</div>
<mat-form-field class="kd-namespace-select-input-container">
  <mat-select (openedChange)="onNamespaceToggle($event)"
              [(ngModel)]="selectedNamespace">
    <div [ngClass]="{'kd-namespace-select-input-border': namespaces.length > 0}">
      <input #namespaceInput
             i18n-placeholder
             placeholder="Select namespace..."
             [(ngModel)]="selectNamespaceInput"
             name="selectNamespaceInput"
             class="kd-namespace-select-input"
             autocomplete="off"
             (keydown)="$event.keyCode === 13 ? selectNamespace() : null">
    </div>
    <mat-option *ngIf="namespaces.length"
                [value]="allNamespacesKey"
                i18n>All namespaces</mat-option>
    <mat-optgroup label="NAMESPACES"
                  i18n-label
                  *ngIf="(namespaces | filterBy: selectNamespaceInput).length">
      <mat-option *ngFor="let namespace of namespaces | filterBy: selectNamespaceInput"
                  [value]="namespace">
        {{namespace}}
      </mat-option>
    </mat-optgroup>
    <mat-option class="kd-hidden"
                [value]="selectedNamespace">{{formatNamespaceName(selectedNamespace)}}</mat-option>
  </mat-select>
</mat-form-field>
