Skip to content

Commit be1fb84

Browse files
authored
ATLAS-5037: [React UI] Entity detail page not retained after term deletion via sidebar (#361)
1 parent f86f5d8 commit be1fb84

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

dashboard/src/views/Glossary/DeleteGlossary.tsx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ import { useAppDispatch } from "@hooks/reducerHook";
2424
import ErrorRoundedIcon from "@mui/icons-material/ErrorRounded";
2525
import { Typography } from "@mui/material";
2626
import { fetchGlossaryData } from "@redux/slice/glossarySlice";
27-
import { serverError } from "@utils/Utils";
27+
import { isEmpty, serverError } from "@utils/Utils";
2828
import { useRef } from "react";
29-
import { useNavigate } from "react-router-dom";
29+
import { useLocation, useNavigate, useParams } from "react-router-dom";
3030
import { toast } from "react-toastify";
3131

3232
const DeleteGlossary = (props: {
@@ -37,9 +37,14 @@ const DeleteGlossary = (props: {
3737
updatedData: any;
3838
}) => {
3939
const { open, onClose, setExpandNode, node, updatedData } = props;
40-
const { id, guid, cGuid, type } = node;
40+
const { id, guid, cGuid, types } = node;
4141
const gtype: string | undefined | null =
42-
type != "parents" ? "term" : "glossary";
42+
types != "parent" ? "term" : "glossary";
43+
const location = useLocation();
44+
const searchParams = new URLSearchParams(location.search);
45+
const glossaryType = searchParams.get("gtype");
46+
const { guid: glossaryGuid } = useParams();
47+
4348
const navigate = useNavigate();
4449
const dispatchApi = useAppDispatch();
4550
const toastId: any = useRef(null);
@@ -60,12 +65,14 @@ const DeleteGlossary = (props: {
6065
gtype == "term" ? "Term" : "Glossary"
6166
} ${id} was deleted successfully`
6267
);
63-
navigate(
64-
{
65-
pathname: "/"
66-
},
67-
{ replace: true }
68-
);
68+
if (!isEmpty(glossaryGuid) || !isEmpty(glossaryType)) {
69+
navigate(
70+
{
71+
pathname: "/"
72+
},
73+
{ replace: true }
74+
);
75+
}
6976
onClose();
7077
setExpandNode(null);
7178
} catch (error) {

0 commit comments

Comments
 (0)