INFRA-3897 | Abhishek | Add changes to delete particular gateway attributes
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -57,7 +57,7 @@ export const FormikCardList = (props: FormikCardListProps) => {
|
||||
<Grid container justifyContent="space-between" direction={direction}>
|
||||
<DeleteResource
|
||||
name={name}
|
||||
fieldPath={name}
|
||||
fieldPath={`${name}.${i}`}
|
||||
onDelete={deleteItem}
|
||||
disabled={removeCondition?.[i]}
|
||||
index={i}
|
||||
|
||||
@@ -39,6 +39,7 @@ export const path = {
|
||||
efs: 'deployment.efs',
|
||||
fsx: 'deployment.fsx',
|
||||
elasticCache: 'extraResources.elasticCache',
|
||||
gatewayAttributes: 'deployment.commonApiGateways.0.gatewayAttributes',
|
||||
deploymentController: 'deployment.controller',
|
||||
deploymentStrategy: 'deployment.strategy',
|
||||
deploymentStrategyConfig: 'deployment.strategyConfig',
|
||||
|
||||
Reference in New Issue
Block a user