Skip to content

Commit 14b8a53

Browse files
committed
ATLAS-5044: [React UI] Fix node expand/collapse and selection issues in TreeView component within sidebar
1 parent 02065d0 commit 14b8a53

File tree

18 files changed

+1297
-1758
lines changed

18 files changed

+1297
-1758
lines changed

dashboard/src/components/DialogShowMoreLess.tsx

Lines changed: 74 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,17 @@ import AddCircleOutlineIcon from "@mui/icons-material/AddCircleOutline";
3030
import MoreHorizIcon from "@mui/icons-material/MoreHoriz";
3131
import AddTag from "@views/Classification/AddTag";
3232
import { useAppDispatch, useAppSelector } from "@hooks/reducerHook";
33-
import AssignTerm from "@views/Glossary/AssignTerm";
34-
import AssignCategory from "@views/Glossary/AssignCategory";
3533
import AddTagAttributes from "@views/Classification/AddTagAttributes";
3634
import { fetchGlossaryDetails } from "@redux/slice/glossaryDetailsSlice";
3735
import { fetchDetailPageData } from "@redux/slice/detailPageSlice";
3836
import { fetchGlossaryData } from "@redux/slice/glossarySlice";
37+
import AssignGlossaryItem from "@views/Glossary/AssignGlossaryItem";
38+
import {
39+
assignGlossaryType,
40+
assignTermstoEntites
41+
} from "@api/apiMethods/glossaryApiMethod";
3942

4043
const CHIP_MAX_WIDTH = "200px";
41-
const ITEM_HEIGHT = 48;
4244

4345
const DialogShowMoreLess = ({
4446
value,
@@ -81,14 +83,12 @@ const DialogShowMoreLess = ({
8183
const toastId: any = useRef(null);
8284
const { guid }: any = useParams();
8385
const dispatchApi = useAppDispatch();
84-
// const navigate = useNavigate();
8586
const location = useLocation();
8687
const searchParams = new URLSearchParams(location.search);
8788
const gType = searchParams.get("gtype");
8889
const [openModal, setOpenModal] = useState<boolean>(false);
8990
const [tagModal, setTagModal] = useState<boolean>(false);
9091
const [termModal, setTermModal] = useState<boolean>(false);
91-
const [categoryModal, setCategoryModal] = useState<boolean>(false);
9292
const [attributeModal, setAttributeModal] = useState<boolean>(false);
9393
const [removeLoader, setRemoveLoader] = useState(false);
9494

@@ -99,9 +99,7 @@ const DialogShowMoreLess = ({
9999
const handleCloseTermModal = () => {
100100
setTermModal(false);
101101
};
102-
const handleCloseCategoryModal = () => {
103-
setCategoryModal(false);
104-
};
102+
105103
const handleCloseAttributeModal = () => {
106104
setAttributeModal(false);
107105
};
@@ -131,7 +129,7 @@ const DialogShowMoreLess = ({
131129
setRemoveLoader(true);
132130
if (colName == "Classification") {
133131
await removeApiMethod(
134-
detailPage ? entity.guid : value.guid,
132+
entity?.guid || value.guid,
135133
currentValue.selectedValue
136134
);
137135
} else if (colName == "Term" || colName == "Category") {
@@ -149,28 +147,30 @@ const DialogShowMoreLess = ({
149147
}
150148
}
151149
);
152-
if (isEmpty(guid) || detailPage) {
150+
if ((isEmpty(guid) || detailPage) && !relatedTerm) {
153151
await removeApiMethod(
154-
detailPage ? selectedTerm.guid : selectedTerm.termGuid,
152+
selectedTerm?.guid || selectedTerm.termGuid,
155153

156154
{
157-
guid: detailPage ? entity.guid : value.guid,
158-
relationshipGuid: detailPage
159-
? selectedTerm.relationshipGuid
160-
: selectedTerm.relationGuid
155+
guid: entity?.guid || value.guid,
156+
relationshipGuid:
157+
selectedTerm?.relationshipGuid || selectedTerm.relationGuid
161158
}
162159
);
163-
} else if (!detailPage && !isShowMoreLess) {
160+
} else if ((!detailPage && !isShowMoreLess) || relatedTerm) {
164161
let values = { ...value };
165162
let data;
166163
if (colName == "Term") {
167164
data = values?.[columnVal].filter(
168-
(obj: { displayText: string }) => {
169-
return obj.displayText != currentValue.selectedValue;
165+
(obj: { qualifiedName: string }) => {
166+
return obj.qualifiedName != currentValue.selectedValue;
170167
}
171168
);
172-
173-
values["terms"] = data;
169+
if (relatedTerm) {
170+
values[columnVal] = data;
171+
} else {
172+
values["terms"] = data;
173+
}
174174
} else {
175175
data = values?.[columnVal].filter(
176176
(obj: { displayText: string }) => {
@@ -180,11 +180,7 @@ const DialogShowMoreLess = ({
180180
values["categories"] = data;
181181
}
182182

183-
await removeApiMethod(
184-
guid,
185-
colName == "Term" ? "category" : "term",
186-
values
187-
);
183+
await removeApiMethod(guid, values);
188184
}
189185
}
190186
setOpenModal(false);
@@ -238,9 +234,7 @@ const DialogShowMoreLess = ({
238234
if (colName == "Classification" || colName == "Propagated Classification") {
239235
let keys = Array.from(searchParams.keys());
240236
for (let i = 0; i < keys.length; i++) {
241-
// if (keys[i] != "searchType") {
242237
searchParams.delete(keys[i]);
243-
// }
244238
}
245239
searchParams.set("tag", values);
246240

@@ -285,20 +279,26 @@ const DialogShowMoreLess = ({
285279
};
286280

287281
const assignTitle = () => {
288-
if (colName == "Classification") {
289-
return "Add Classification";
290-
} else if (colName == "Term") {
291-
return "Add Term";
282+
switch (colName) {
283+
case "Classification":
284+
return "Add Classification";
285+
case "Term":
286+
return "Add Term";
287+
default:
288+
return "";
292289
}
293290
};
294291

295292
const removeTitle = () => {
296-
if (colName == "Classification") {
297-
return "Remove Classification Assignment";
298-
} else if (colName == "Term") {
299-
return "Remove Term Assignment";
300-
} else if (colName == "Category") {
301-
return "Remove Category Assignment";
293+
switch (colName) {
294+
case "Classification":
295+
return "Remove Classification Assignment";
296+
case "Term":
297+
return "Remove Term Assignment";
298+
case "Category":
299+
return "Remove Category Assignment";
300+
default:
301+
return "";
302302
}
303303
};
304304

@@ -425,14 +425,18 @@ const DialogShowMoreLess = ({
425425
color="primary"
426426
size="small"
427427
onClick={() => {
428-
if (colName == "Classification") {
429-
setTagModal(true);
430-
} else if (colName == "Term") {
431-
setTermModal(true);
432-
} else if (colName == "Category") {
433-
setCategoryModal(true);
434-
} else if (colName == "Attribute") {
435-
setAttributeModal(true);
428+
switch (colName) {
429+
case "Classification":
430+
setTagModal(true);
431+
break;
432+
case "Term":
433+
setTermModal(true);
434+
break;
435+
case "Attribute":
436+
setAttributeModal(true);
437+
break;
438+
default:
439+
break;
436440
}
437441
}}
438442
>
@@ -449,11 +453,6 @@ const DialogShowMoreLess = ({
449453
anchorEl={openMenu}
450454
open={open}
451455
onClose={handleClose}
452-
PaperProps={{
453-
style: {
454-
maxHeight: ITEM_HEIGHT * 4.5
455-
}
456-
}}
457456
>
458457
{value?.[columnVal].map((obj: any, index: number) => {
459458
if (index > 0) {
@@ -513,14 +512,18 @@ const DialogShowMoreLess = ({
513512
color="primary"
514513
size="small"
515514
onClick={() => {
516-
if (colName == "Classification") {
517-
setTagModal(true);
518-
} else if (colName == "Term") {
519-
setTermModal(true);
520-
} else if (colName == "Category") {
521-
setCategoryModal(true);
522-
} else if (colName == "Attribute") {
523-
setAttributeModal(true);
515+
switch (colName) {
516+
case "Classification":
517+
setTagModal(true);
518+
break;
519+
case "Term":
520+
setTermModal(true);
521+
break;
522+
case "Attribute":
523+
setAttributeModal(true);
524+
break;
525+
default:
526+
break;
524527
}
525528
}}
526529
>
@@ -564,35 +567,33 @@ const DialogShowMoreLess = ({
564567
setRowSelection={undefined}
565568
/>
566569
)}
570+
567571
{termModal && colName == "Term" && !relatedTerm && (
568-
<AssignTerm
572+
<AssignGlossaryItem
569573
open={termModal}
570-
// glossaryType={colName}
571574
onClose={handleCloseTermModal}
572575
data={value}
573-
relatedTerm={relatedTerm}
576+
relatedItem={relatedTerm}
574577
updateTable={setUpdateTable}
578+
itemType="term"
579+
dataKey="terms"
580+
assignApiMethod={assignTermstoEntites}
581+
treeLabel="Term"
575582
/>
576583
)}
577584

578585
{termModal && colName == "Term" && relatedTerm && (
579-
<AssignTerm
586+
<AssignGlossaryItem
580587
open={termModal}
581-
// glossaryType={colName}
582588
onClose={handleCloseTermModal}
583589
data={value}
584-
relatedTerm={relatedTerm}
590+
relatedItem={relatedTerm}
585591
updateTable={setUpdateTable}
586592
columnVal={columnVal}
587-
/>
588-
)}
589-
590-
{categoryModal && colName == "Category" && (
591-
<AssignCategory
592-
open={categoryModal}
593-
onClose={handleCloseCategoryModal}
594-
data={value}
595-
updateTable={setUpdateTable}
593+
itemType="term"
594+
dataKey="terms"
595+
assignApiMethod={assignGlossaryType}
596+
treeLabel="Term"
596597
/>
597598
)}
598599

dashboard/src/components/Table/TableFilters.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ import Filters from "@components/QueryBuilder/Filters";
4646
import { attributeFilter } from "@utils/CommonViewFunction";
4747
import { toast } from "react-toastify";
4848
import { downloadSearchResultsCSV } from "@api/apiMethods/downloadApiMethod";
49-
import AssignTerm from "@views/Glossary/AssignTerm";
49+
import AssignGlossaryItem from "@views/Glossary/AssignGlossaryItem";
50+
import { assignTermstoEntites } from "@api/apiMethods/glossaryApiMethod";
5051

5152
export const StyledMenu = styled((props: MenuProps) => (
5253
<div style={{ position: "relative" }}>
@@ -497,14 +498,17 @@ export const TableFilter = ({
497498
)}
498499

499500
{termModal && (
500-
<AssignTerm
501+
<AssignGlossaryItem
501502
open={termModal}
502-
columnVal={"terms"}
503503
onClose={handleCloseTermModal}
504504
data={selectedRow}
505-
relatedTerm={undefined}
505+
relatedItem={undefined}
506506
updateTable={setUpdateTable}
507507
setRowSelection={setRowSelection}
508+
itemType="term"
509+
dataKey="terms"
510+
treeLabel="Term"
511+
assignApiMethod={assignTermstoEntites}
508512
/>
509513
)}
510514

0 commit comments

Comments
 (0)