ATLAS-5105: [REACT UI] Incorrect errors being displayed when assigning blank term to entity.
diff --git a/dashboard/src/components/Forms/FormTreeView.tsx b/dashboard/src/components/Forms/FormTreeView.tsx
index 1b1cd7b..896fe64 100644
--- a/dashboard/src/components/Forms/FormTreeView.tsx
+++ b/dashboard/src/components/Forms/FormTreeView.tsx
@@ -222,10 +222,21 @@
node?.id && (
<CustomTreeItem
key={node.id}
- itemId={node.types != "parent" ? `${node.id}@${node?.parent}` : node.id}
+ itemId={
+ node.types != "parent"
+ ? node.id === "No Records Found"
+ ? node.id
+ : `${node.id}@${node?.parent}`
+ : node.id
+ }
label={
<div
onClick={(_event: React.MouseEvent<HTMLElement>) => {
+ if (node.id === "No Records Found") {
+ toast.dismiss(toastId.current);
+ toastId.current = toast.info("No terms present");
+ return;
+ }
if (node.types == "parent" && isEmpty(node.children)) {
toast.dismiss(toastId.current);
toastId.current = toast.warning(`No ${treeName}`);
diff --git a/dashboard/src/views/DetailPage/DetailPageAttributes.tsx b/dashboard/src/views/DetailPage/DetailPageAttributes.tsx
index 4fbe50e..4031508 100644
--- a/dashboard/src/views/DetailPage/DetailPageAttributes.tsx
+++ b/dashboard/src/views/DetailPage/DetailPageAttributes.tsx
@@ -31,6 +31,8 @@
sanitizeHtmlContent
} from "@utils/Utils";
import { useState } from "react";
+import { useAppSelector } from "@hooks/reducerHook";
+import { toast } from "react-toastify";
import EditOutlinedIcon from "@mui/icons-material/EditOutlined";
import { removeClassification } from "@api/apiMethods/classificationApiMethod";
import { useParams, useSearchParams } from "react-router-dom";
@@ -104,6 +106,11 @@
const { name }: { name: string; found: boolean; key: any } =
extractKeyValueFromEntity(data);
+ const { glossaryData }: any = useAppSelector((state: any) => state.glossary);
+ const hasAnyGlossaryTerms = Array.isArray(glossaryData)
+ ? glossaryData.some((g: any) => Array.isArray(g?.terms) && g.terms.length > 0)
+ : false;
+
return (
<>
<Stack
@@ -373,6 +380,11 @@
size="small"
color="primary"
onClick={() => {
+ if (!hasAnyGlossaryTerms) {
+ toast.dismiss();
+ toast.info("There are no available terms");
+ return;
+ }
setOpenAddTermModal(true);
}}
>
diff --git a/dashboard/src/views/DetailPage/EntityDetailPage.tsx b/dashboard/src/views/DetailPage/EntityDetailPage.tsx
index 6d88d31..dfec7b4 100644
--- a/dashboard/src/views/DetailPage/EntityDetailPage.tsx
+++ b/dashboard/src/views/DetailPage/EntityDetailPage.tsx
@@ -33,6 +33,7 @@
import RelationshipsTab from "./EntityDetailTabs/RelationshipsTab";
import ClassificationsTab from "./EntityDetailTabs/ClassificationsTab";
import { CustomButton, LightTooltip, LinkTab } from "@components/muiComponents";
+import { toast } from "react-toastify";
import AuditsTab from "./EntityDetailTabs/AuditsTab";
import { EntityState } from "@models/relationshipSearchType";
import { useSelector } from "react-redux";
@@ -82,6 +83,10 @@
const { entity, referredEntities }: any = detailPageData || {};
const { classifications = {}, relationshipAttributes = {} } = entity || {};
const { meanings = [] } = relationshipAttributes || {};
+ const { glossaryData }: any = useAppSelector((state: any) => state.glossary);
+ const hasAnyGlossaryTerms = Array.isArray(glossaryData)
+ ? glossaryData.some((g: any) => Array.isArray(g?.terms) && g.terms.length > 0)
+ : false;
const { name }: { name: string; found: boolean; key: any } =
extractKeyValueFromEntity(entity);
@@ -417,7 +422,14 @@
tabIndex={-1}
size="small"
color="primary"
- onClick={() => setOpenAddTermModal(true)}
+ onClick={() => {
+ if (!hasAnyGlossaryTerms) {
+ toast.dismiss();
+ toast.info("There are no available terms");
+ return;
+ }
+ setOpenAddTermModal(true);
+ }}
>
<AddCircleOutlineIcon
className="mr-0"
diff --git a/dashboard/src/views/Glossary/AssignTerm.tsx b/dashboard/src/views/Glossary/AssignTerm.tsx
index e7525a1..61f66d1 100644
--- a/dashboard/src/views/Glossary/AssignTerm.tsx
+++ b/dashboard/src/views/Glossary/AssignTerm.tsx
@@ -294,6 +294,11 @@
}, []);
const handleNodeSelect = (nodeId: any) => {
+ if (nodeId === "No Records Found") {
+ toast.dismiss(toastId.current);
+ toastId.current = toast.info("No terms present");
+ return;
+ }
setSelectedNode(nodeId);
};
@@ -445,6 +450,7 @@
maxWidth="sm"
button2Handler={relatedTerm ? handleSubmit(onSubmit) : assignTerm}
disableButton2={isSubmitting}
+ isDirty={!isEmpty(selectedNode)}
>
{relatedTerm ? (
<Stack gap="16px" sx={{ width: "100%" }}>