Skip to content

Commit f1677f7

Browse files
committed
ATLAS-5342: Atlas React UI: Entity modification functionalities (Add Classifications, Terms, Labels, Business Metadata) remain active for DELETED entities
1 parent 0fd03e3 commit f1677f7

13 files changed

Lines changed: 290 additions & 197 deletions

File tree

dashboard/src/components/ShowMore/DrawerBodyChipView.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import SearchIcon from "@mui/icons-material/Search";
3737
import ErrorRoundedIcon from "@mui/icons-material/ErrorRounded";
3838
import { Link as MuiLink } from "@mui/material";
3939
import { cloneDeep } from "@utils/Helper";
40+
import { EntityStatus } from "@utils/EntityStatus";
4041

4142
const CHIP_MAX_WIDTH = "200px";
4243

@@ -328,11 +329,11 @@ const DrawerBodyChipView = ({
328329
</EllipsisText>
329330
}
330331
onDelete={
331-
!isEmpty(removeApiMethod) && !isDeleteIcon
332+
currentEntity?.status !== EntityStatus.DELETED && !isEmpty(removeApiMethod) && !isDeleteIcon
332333
? () => {
333334
handleDelete(obj[displayKey] || obj);
334335
}
335-
: isDeleteIcon && obj.count > 1
336+
: currentEntity?.status !== EntityStatus.DELETED && isDeleteIcon && obj.count > 1
336337
? () => {
337338
const searchParams = new URLSearchParams();
338339
searchParams.set("tabActive", "classification");

dashboard/src/components/ShowMore/ShowMoreView.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Typography from "@mui/material/Typography";
1919
import Chip from "@mui/material/Chip";
2020
import MuiLink from "@mui/material/Link";
2121
import { LightTooltip } from "../muiComponents";
22-
import { useRef, useState } from "react";
22+
import { useEffect, useRef, useState } from "react";
2323
import { EllipsisText } from "../commonComponents";
2424
import { extractKeyValueFromEntity, isEmpty, serverError } from "@utils/Utils";
2525
import { useAppDispatch, useAppSelector } from "@hooks/reducerHook";
@@ -31,8 +31,9 @@ import ErrorRoundedIcon from "@mui/icons-material/ErrorRounded";
3131
import { fetchGlossaryData } from "@redux/slice/glossarySlice";
3232
import { fetchGlossaryDetails } from "@redux/slice/glossaryDetailsSlice";
3333
import ShowMoreDrawer from "./ShowMoreDrawer";
34-
import { openDrawer } from "@redux/slice/drawerSlice";
34+
import { openDrawer, closeDrawer } from "@redux/slice/drawerSlice";
3535
import { cloneDeep } from "@utils/Helper";
36+
import { EntityStatus } from "@utils/EntityStatus";
3637

3738
const CHIP_MAX_WIDTH = "200px";
3839

@@ -73,6 +74,12 @@ const ShowMoreView = ({
7374
const gType = searchParams.get("gtype");
7475
const dispatchApi = useAppDispatch();
7576

77+
useEffect(() => {
78+
return () => {
79+
dispatchApi(closeDrawer());
80+
};
81+
}, [dispatchApi]);
82+
7683
const { classificationData = {} }: any = useAppSelector(
7784
(state: any) => state.classification
7885
);
@@ -310,13 +317,13 @@ const ShowMoreView = ({
310317
}
311318
component="a"
312319
onDelete={
313-
!isEmpty(removeApiMethod) && !isDeleteIcon
320+
!isEmpty(removeApiMethod) && !isDeleteIcon && currentEntity?.status !== EntityStatus.DELETED
314321
? () => {
315322
// Handle undefined displayKey by extracting a string value
316323
const deleteValue = obj[displayKey] || obj.displayText || obj.text || obj.name || '';
317324
handleDelete(deleteValue);
318325
}
319-
: isDeleteIcon && obj.count > 1
326+
: isDeleteIcon && obj.count > 1 && currentEntity?.status !== EntityStatus.DELETED
320327
? () => {
321328
const searchParams = new URLSearchParams();
322329
searchParams.set("tabActive", "classification");

dashboard/src/components/ShowMore/__tests__/ShowMoreView.test.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ jest.mock('@redux/slice/drawerSlice', () => ({
151151
openDrawer: jest.fn((id: string) => ({
152152
type: 'drawer/openDrawer',
153153
payload: id
154+
})),
155+
closeDrawer: jest.fn(() => ({
156+
type: 'drawer/closeDrawer'
154157
}))
155158
}));
156159

@@ -739,6 +742,26 @@ describe('ShowMoreView', () => {
739742
});
740743

741744
describe('Delete Icon Functionality', () => {
745+
it('should not show delete button when currentEntity status is DELETED', () => {
746+
const dataWithCount = [
747+
{ typeName: 'Tag1' }
748+
];
749+
750+
render(
751+
<TestWrapper>
752+
<ShowMoreView
753+
{...defaultProps}
754+
data={dataWithCount}
755+
removeApiMethod={jest.fn()}
756+
currentEntity={{ guid: 'entity-guid-123', status: 'DELETED' }}
757+
/>
758+
</TestWrapper>
759+
);
760+
761+
expect(screen.queryByTestId('chip-ondelete-button')).not.toBeInTheDocument();
762+
});
763+
764+
742765
it('should show count when isDeleteIcon is true and count > 1', () => {
743766
const dataWithCount = [
744767
{ typeName: 'Tag1', count: 2 },
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
export enum EntityStatus {
19+
ACTIVE = "ACTIVE",
20+
DELETED = "DELETED"
21+
}

dashboard/src/views/DashboardOverview/ClassificationCoverage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ const ClassificationCoverage = memo(
289289
aria-label="Open classification search"
290290
>
291291
{numberFormatWithComma(typesInUse)} of{" "}
292-
{numberFormatWithComma(classificationTypeDefinitions)}
292+
{numberFormatWithComma(classificationTypeDefinitions)}{" "}
293293
classification types are in use (have at least one entity).
294294
</Typography>
295295
</Stack>

dashboard/src/views/DetailPage/DetailPageAttributes.tsx

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const getDescriptionForDisplay = (desc: unknown): string => {
4141
};
4242
import { useState } from "react";
4343
import { useAppSelector } from "@hooks/reducerHook";
44+
import { EntityStatus } from "@utils/EntityStatus";
4445
import { toast } from "react-toastify";
4546
import EditOutlinedIcon from "@mui/icons-material/EditOutlined";
4647
import { removeClassification } from "@api/apiMethods/classificationApiMethod";
@@ -147,7 +148,7 @@ const DetailPageAttribute = ({
147148
{name}{" "}
148149
</Typography>
149150
</LightTooltip>
150-
{isEmpty(bmguid) && (
151+
{isEmpty(bmguid) && !loading && data?.status !== EntityStatus.DELETED && (
151152
<LightTooltip title={"Edit Classification"}>
152153
<CustomButton
153154
variant="outlined"
@@ -315,23 +316,25 @@ const DetailPageAttribute = ({
315316
>
316317
Classifications
317318
</Typography>
318-
<LightTooltip title={"Add Classifications"}>
319-
<IconButton
320-
component="label"
321-
role={undefined}
322-
tabIndex={-1}
323-
size="small"
324-
color="primary"
325-
onClick={() => {
326-
setOpenAddTagModal(true);
327-
}}
328-
>
329-
<AddCircleOutlineIcon
330-
className="mr-0"
331-
fontSize="small"
332-
/>{" "}
333-
</IconButton>
334-
</LightTooltip>
319+
{!loading && data?.status !== EntityStatus.DELETED && (
320+
<LightTooltip title={"Add Classifications"}>
321+
<IconButton
322+
component="label"
323+
role={undefined}
324+
tabIndex={-1}
325+
size="small"
326+
color="primary"
327+
onClick={() => {
328+
setOpenAddTagModal(true);
329+
}}
330+
>
331+
<AddCircleOutlineIcon
332+
className="mr-0"
333+
fontSize="small"
334+
/>{" "}
335+
</IconButton>
336+
</LightTooltip>
337+
)}
335338
</Stack>
336339
<Stack
337340
data-cy="tagListTerm"
@@ -383,28 +386,30 @@ const DetailPageAttribute = ({
383386
>
384387
Terms
385388
</Typography>
386-
<LightTooltip title={"Add Term"}>
387-
<IconButton
388-
component="label"
389-
role={undefined}
390-
tabIndex={-1}
391-
size="small"
392-
color="primary"
393-
onClick={() => {
394-
if (!hasAnyGlossaryTerms) {
395-
toast.dismiss();
396-
toast.info("There are no available terms");
397-
return;
398-
}
399-
setOpenAddTermModal(true);
400-
}}
401-
>
402-
<AddCircleOutlineIcon
403-
className="mr-0"
404-
fontSize="small"
405-
/>{" "}
406-
</IconButton>
407-
</LightTooltip>
389+
{!loading && data?.status !== EntityStatus.DELETED && (
390+
<LightTooltip title={"Add Term"}>
391+
<IconButton
392+
component="label"
393+
role={undefined}
394+
tabIndex={-1}
395+
size="small"
396+
color="primary"
397+
onClick={() => {
398+
if (!hasAnyGlossaryTerms) {
399+
toast.dismiss();
400+
toast.info("There are no available terms");
401+
return;
402+
}
403+
setOpenAddTermModal(true);
404+
}}
405+
>
406+
<AddCircleOutlineIcon
407+
className="mr-0"
408+
fontSize="small"
409+
/>{" "}
410+
</IconButton>
411+
</LightTooltip>
412+
)}
408413
</Stack>
409414
<Stack
410415
data-cy="termList"

0 commit comments

Comments
 (0)