INFRA-3897 | Abhishek | Fix deletion of commonApiGateways
This commit is contained in:
@@ -22,7 +22,6 @@ import {
|
||||
API_DELETE_K8S_RESOURCE,
|
||||
API_GET_K8S_RESOURCE_STATUS,
|
||||
API_TO_POST_MANIFEST,
|
||||
DELETE_K8S_RESOURCE_API,
|
||||
} from '@src/constants/Endpoints';
|
||||
import { forEach } from 'lodash';
|
||||
import { getFieldNameFromPath } from '@src/models/Manifest';
|
||||
@@ -96,7 +95,7 @@ const ConfirmationPopup = (props: ConfirmationPopupProps) => {
|
||||
const { handleClose, onDelete } = props;
|
||||
const [notifyDelete, setNotifyDelete] = useState(false);
|
||||
const [deleteMessage, setDeleteMessage] = useState<string>();
|
||||
let [deleteFromManifest, setDeleteFromManifest] = useState(false);
|
||||
let [deleteFromManifest, setDeleteFromManifest] = useState(true);
|
||||
const { submitForm }: { submitForm: any } = useFormikContext();
|
||||
|
||||
const toggleDeleteFromManifest = () => {
|
||||
@@ -129,28 +128,26 @@ const ConfirmationPopup = (props: ConfirmationPopupProps) => {
|
||||
const NotifyDelete = () => {
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<Card className={classes.card}>
|
||||
<Grid container direction="row" alignItems="center" spacing={4}>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="h6" className={classes.cardContent}>
|
||||
{deleteMessage}
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={12} className={classes.buttonRow}>
|
||||
<Grid spacing={4}></Grid>
|
||||
<Button
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
className={classes.button}
|
||||
onClick={() => {
|
||||
props.handleClose();
|
||||
}}
|
||||
>
|
||||
Close
|
||||
</Button>
|
||||
</Grid>
|
||||
<Grid container direction="row" alignItems="center" spacing={4}>
|
||||
<Grid item xs={12}>
|
||||
<Typography variant="h6" className={classes.cardContent}>
|
||||
{deleteMessage}
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Card>
|
||||
<Grid item xs={12} className={classes.buttonRow}>
|
||||
<Grid spacing={4}></Grid>
|
||||
<Button
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
className={classes.button}
|
||||
onClick={() => {
|
||||
props.handleClose();
|
||||
}}
|
||||
>
|
||||
Close
|
||||
</Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -167,7 +164,7 @@ const ConfirmationPopup = (props: ConfirmationPopupProps) => {
|
||||
<br />
|
||||
<br />
|
||||
<Grid item xs={12} className={classes.buttonRow}>
|
||||
<Grid container spacing={4}></Grid>
|
||||
<Grid container spacing={6}></Grid>
|
||||
<FormControlLabel
|
||||
control={<Checkbox />}
|
||||
label="Delete from manifest also"
|
||||
@@ -242,7 +239,6 @@ const DeleteResource = (props: DeleteResourceProps) => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
function getPathAndIndex(fieldPath) {
|
||||
console.log(fieldPath);
|
||||
const match = fieldPath.match(/\.(\d+)$/);
|
||||
const index = match ? parseInt(match[1], 10) : undefined;
|
||||
const pathWithoutIndex = match ? fieldPath.slice(0, fieldPath.lastIndexOf('.')) : fieldPath;
|
||||
@@ -298,8 +294,7 @@ const DeleteResource = (props: DeleteResourceProps) => {
|
||||
}
|
||||
|
||||
const checkIfDeployed = () => {
|
||||
if (!DeleteImplementedMap.hasOwnProperty(fieldName)) {
|
||||
console.log('checking', fieldName);
|
||||
if (!DeleteImplementedMap.hasOwnProperty(k8sResourceName)) {
|
||||
props.onDelete();
|
||||
return;
|
||||
}
|
||||
@@ -329,7 +324,6 @@ const DeleteResource = (props: DeleteResourceProps) => {
|
||||
setLoading(false);
|
||||
toast.error(
|
||||
'Could not check if resource is deployed on kubernetes, please reach out to Cloud-Platform team',
|
||||
resJson.statusText,
|
||||
);
|
||||
}
|
||||
})
|
||||
|
||||
@@ -4,7 +4,6 @@ import * as React from 'react';
|
||||
import AddIcon from '@material-ui/icons/Add';
|
||||
import DeleteIcon from '@material-ui/icons/Delete';
|
||||
import DeleteResource from './DeleteResource';
|
||||
import { path } from '@src/models/Manifest';
|
||||
|
||||
const useStyles = makeStyles({
|
||||
root: {
|
||||
@@ -58,7 +57,7 @@ export const FormikCardList = (props: FormikCardListProps) => {
|
||||
<Grid container justifyContent="space-between" direction={direction}>
|
||||
<DeleteResource
|
||||
name={name}
|
||||
fieldPath={`${path.loadBalancers}.${i}`}
|
||||
fieldPath={name}
|
||||
onDelete={deleteItem}
|
||||
disabled={removeCondition?.[i]}
|
||||
index={i}
|
||||
|
||||
Reference in New Issue
Block a user