<!--
  ~ 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>Change Flow Version</h2>
@if (flowUpdateRequest$ | async; as versionChangeRequest) {
    @if (versionChangeRequest.request.complete && versionChangeRequest.request.failureReason) {
        <error-banner
            [messages]="[versionChangeRequest.request.failureReason]"
            [showErrorIcon]="true"
            [allowDismiss]="false"></error-banner>
    }
}
<div class="change-version-progress">
    <mat-dialog-content>
        <div class="flex flex-col gap-y-4">
            @if (flowUpdateRequest$ | async; as versionChangeRequest) {
                <div class="tertiary-color font-medium">
                    @if (versionChangeRequest.request.complete && versionChangeRequest.request.failureReason) {
                        There was an error changing versions.
                    } @else if (versionChangeRequest.request.complete) {
                        This Process Group version has changed.
                    } @else {
                        {{ versionChangeRequest.request.state }}
                    }
                </div>
                <div class="w-full flex flex-col items-center">
                    <mat-progress-bar
                        mode="determinate"
                        [value]="versionChangeRequest.request.percentCompleted"></mat-progress-bar>
                    <div class="tertiary-color font-medium">{{ versionChangeRequest.request.percentCompleted }}%</div>
                </div>
            }
        </div>
    </mat-dialog-content>
    <mat-dialog-actions align="end">
        @if (flowUpdateRequest$ | async; as versionChangeRequest) {
            <button
                [disabled]="!versionChangeRequest?.request?.complete"
                mat-flat-button
                mat-dialog-close
                (click)="close(versionChangeRequest)">
                Close
            </button>
        }
    </mat-dialog-actions>
</div>
