<!--
  ~ 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>
    <div class="flex justify-between items-baseline">
        <div>Edit Registry Client</div>
        <div class="text-sm">
            {{ formatType(request.registryClient) }}
        </div>
    </div>
</h2>
<form class="edit-registry-client-form" [formGroup]="editRegistryClientForm">
    <error-banner></error-banner>
    <mat-tab-group>
        <mat-tab label="Settings">
            <mat-dialog-content>
                <div class="dialog-tab-content flex flex-col">
                    <div class="flex flex-col mb-5">
                        <div>Id</div>
                        <div class="accent-color font-medium">
                            {{ request.registryClient.id }}
                        </div>
                    </div>
                    <div>
                        <mat-form-field>
                            <mat-label>Name</mat-label>
                            <input matInput formControlName="name" type="text" />
                        </mat-form-field>
                    </div>
                    <div class="flex flex-col mb-5">
                        <div>Type</div>
                        <div class="accent-color font-medium">
                            {{ formatType(request.registryClient) }}
                        </div>
                    </div>
                    <div>
                        <mat-form-field>
                            <mat-label>Description</mat-label>
                            <textarea matInput formControlName="description" type="text" rows="5"></textarea>
                        </mat-form-field>
                    </div>
                </div>
            </mat-dialog-content>
        </mat-tab>
        <mat-tab label="Properties">
            <mat-dialog-content>
                <div class="dialog-tab-content">
                    <property-table
                        formControlName="properties"
                        [createNewProperty]="createNewProperty"
                        [createNewService]="createNewService"
                        [goToService]="goToService"
                        [supportsSensitiveDynamicProperties]="
                            request.registryClient.component.supportsSensitiveDynamicProperties
                        "></property-table>
                </div>
            </mat-dialog-content>
        </mat-tab>
    </mat-tab-group>
    @if ({ value: (saving$ | async)! }; as saving) {
        <mat-dialog-actions align="end">
            <button mat-button mat-dialog-close>Cancel</button>
            <button
                [disabled]="!editRegistryClientForm.dirty || editRegistryClientForm.invalid || saving.value"
                type="button"
                color="primary"
                (click)="submitForm()"
                mat-button>
                <span *nifiSpinner="saving.value">Apply</span>
            </button>
        </mat-dialog-actions>
    }
</form>
