From 0bf70e01a997d87ec2ce7d3083e5020474e5c6a6 Mon Sep 17 00:00:00 2001 From: Abhishek Katiyar Date: Mon, 11 Nov 2024 05:20:12 +0530 Subject: [PATCH] INFRA-3897 | Abhishek | Add changes to delete particular gateway attributes --- src/components/common/DeleteResource.tsx | 34 +++++++++++++----------- src/components/common/FormikCardList.tsx | 2 +- src/models/Manifest.ts | 1 + 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/components/common/DeleteResource.tsx b/src/components/common/DeleteResource.tsx index 7004540..9d804ad 100644 --- a/src/components/common/DeleteResource.tsx +++ b/src/components/common/DeleteResource.tsx @@ -219,6 +219,10 @@ const KubeObjectTypeMap = { cronJobs: { name: 'cronHpa', }, + gatewayAttributes: { + name: 'gatewayAttributes', + uniqueIdentifier: 'pathName', + }, }; const DeleteImplementedMap = { @@ -227,6 +231,7 @@ const DeleteImplementedMap = { commonApiGateways: true, cronJobs: true, serviceMonitor: true, + gatewayAttributes: true, }; const DeleteResource = (props: DeleteResourceProps) => { @@ -252,49 +257,47 @@ const DeleteResource = (props: DeleteResourceProps) => { props.fieldPath, ); const fieldName = getFieldNameFromPath(pathWithoutIndex); - let k8sResourceName = fieldName; + let resourceName = fieldName; if (KubeObjectTypeMap.hasOwnProperty(fieldName)) { - k8sResourceName = KubeObjectTypeMap[fieldName]['name']; + resourceName = KubeObjectTypeMap[fieldName]['name']; } let getObjectEndpoint = API_GET_K8S_RESOURCE_STATUS( manifestId, - k8sResourceName, + resourceName, undefined, undefined, ); let deleteObjectEndpoint = API_DELETE_K8S_RESOURCE( manifestId, - k8sResourceName, + resourceName, undefined, undefined, ); if (index !== undefined) { - k8sResourceName = KubeObjectTypeMap[fieldName]['name']; + resourceName = KubeObjectTypeMap[fieldName]['name']; let uniqueIdentifierName = - KubeObjectTypeMap[fieldName]['uniqueIdentifierName'] !== undefined - ? KubeObjectTypeMap[fieldName]['uniqueIdentifierName'] + KubeObjectTypeMap[fieldName]['uniqueIdentifier'] !== undefined + ? KubeObjectTypeMap[fieldName]['uniqueIdentifier'] : fieldName; - let uniqueIdentiferValue = - getIn(values, props.fieldPath) !== undefined - ? getIn(values, props.fieldPath)[uniqueIdentifierName] - : undefined; + + let uniqueIdentiferValue = getIn(getIn(values, props.fieldPath), uniqueIdentifierName); getObjectEndpoint = API_GET_K8S_RESOURCE_STATUS( manifestId, - k8sResourceName, + resourceName, uniqueIdentifierName, uniqueIdentiferValue, ); deleteObjectEndpoint = API_GET_K8S_RESOURCE_STATUS( manifestId, - k8sResourceName, + resourceName, uniqueIdentifierName, uniqueIdentiferValue, ); } const checkIfDeployed = () => { - if (!DeleteImplementedMap.hasOwnProperty(k8sResourceName)) { + if (!DeleteImplementedMap.hasOwnProperty(resourceName)) { props.onDelete(); return; } @@ -322,6 +325,7 @@ const DeleteResource = (props: DeleteResourceProps) => { }); } else { setLoading(false); + setOpenPopup(false); toast.error( 'Could not check if resource is deployed on kubernetes, please reach out to Cloud-Platform team', ); @@ -351,7 +355,7 @@ const DeleteResource = (props: DeleteResourceProps) => { setLoading={setLoading} manifestId={manifestId} isResourceDeployed={isResourceDeployed} - k8sResourceName={k8sResourceName} + k8sResourceName={resourceName} deleteObjectEndpoint={deleteObjectEndpoint} handleClose={() => { setOpenPopup(false); diff --git a/src/components/common/FormikCardList.tsx b/src/components/common/FormikCardList.tsx index b6d4a45..fcc8663 100644 --- a/src/components/common/FormikCardList.tsx +++ b/src/components/common/FormikCardList.tsx @@ -57,7 +57,7 @@ export const FormikCardList = (props: FormikCardListProps) => {