<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one or more
  ~ contributor license agreements.  See the NOTICE file distributed with
  ~ this work for additional information regarding copyright ownership.
  ~ The ASF licenses this file to You 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.
  -->

<h2 mat-dialog-title>Create New {{ portTypeLabel }}</h2>
<form class="create-port-form" [formGroup]="createPortForm">
    <banner></banner>
    <mat-dialog-content>
        <mat-form-field>
            <mat-label>{{ portTypeLabel }} Name</mat-label>
            <input matInput formControlName="newPortName" type="text" />
        </mat-form-field>
        <mat-form-field *ngIf="!isRootProcessGroup">
            <mat-label>Receive From</mat-label>
            <mat-select formControlName="newPortAllowRemoteAccess">
                <ng-container *ngFor="let option of allowRemoteAccessOptions">
                    <mat-option
                        *ngIf="option.description; else noDescription"
                        [value]="option.value"
                        nifiTooltip
                        [tooltipComponentType]="TextTip"
                        [tooltipInputData]="getSelectOptionTipData(option)"
                        [delayClose]="false"
                        >{{ option.text }}</mat-option
                    >
                    <ng-template #noDescription>
                        <mat-option [value]="option.value">{{ option.text }}</mat-option>
                    </ng-template>
                </ng-container>
            </mat-select>
        </mat-form-field>
    </mat-dialog-content>
    <mat-dialog-actions align="end" *ngIf="{ value: (saving$ | async)! } as saving">
        <button color="accent" mat-raised-button mat-dialog-close>Cancel</button>
        <button
            [disabled]="!createPortForm.dirty || createPortForm.invalid || saving.value"
            type="button"
            color="primary"
            (click)="createPort()"
            mat-raised-button>
            <span *nifiSpinner="saving.value">Add</span>
        </button>
    </mat-dialog-actions>
</form>
