From 1b23b3da43133cc7218602941fb7ed96175f3a38 Mon Sep 17 00:00:00 2001 From: Shashank <83878475+shashank-cloudknit-io@users.noreply.github.com> Date: Fri, 27 Oct 2023 18:43:19 +0530 Subject: [PATCH] disables cancel button when reconciliation is not in progress. (#355) --- .../organisms/treeview/TerminateReconcile.tsx | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/web/src/components/organisms/treeview/TerminateReconcile.tsx b/web/src/components/organisms/treeview/TerminateReconcile.tsx index 10b3aa56..801b1335 100644 --- a/web/src/components/organisms/treeview/TerminateReconcile.tsx +++ b/web/src/components/organisms/treeview/TerminateReconcile.tsx @@ -1,25 +1,36 @@ import { Environment } from 'models/entity.type'; import { ReactComponent as TerminateIcon } from 'assets/images/icons/card-status/sync/Not Sync.svg'; import { AuditService } from 'services/audit/audit.service'; -import { useContext } from 'react'; +import { useContext, useEffect, useState } from 'react'; import { Context } from 'context/argo/ArgoUi'; import { NotificationType } from 'components/argo-core'; import { ZSyncStatus } from 'models/argo.models'; +import { ArgoStreamService } from 'services/argo/ArgoStream.service'; export type TerminateReconcileProps = { environment: Environment; }; export const TerminateReconcile: React.FC = ({ environment }) => { const notifications = useContext(Context)?.notifications; - const inProgress = [ZSyncStatus.Initializing, ZSyncStatus.Destroying, ZSyncStatus.Provisioning].includes( - environment.status as ZSyncStatus - ); + const [reconciling, setReconciling] = useState(false); + + useEffect(() => { + const ecd = ArgoStreamService.streamEnvironment(environment.argoId); + const watcherSub = ecd.listen().subscribe((e: any) => { + const healthStatus = e?.data?.result?.application?.status?.health?.status; + setReconciling(healthStatus === 'Progressing'); + }); + + return () => { + watcherSub.unsubscribe(); + } + }, [environment]); return (