Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dashboard/src/components/ShowMore/DrawerBodyChipView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import SearchIcon from "@mui/icons-material/Search";
import ErrorRoundedIcon from "@mui/icons-material/ErrorRounded";
import { Link as MuiLink } from "@mui/material";
import { cloneDeep } from "@utils/Helper";
import { EntityStatus } from "@utils/EntityStatus";

const CHIP_MAX_WIDTH = "200px";

Expand Down Expand Up @@ -328,11 +329,11 @@ const DrawerBodyChipView = ({
</EllipsisText>
}
onDelete={
!isEmpty(removeApiMethod) && !isDeleteIcon
currentEntity?.status !== EntityStatus.DELETED && !isEmpty(removeApiMethod) && !isDeleteIcon
? () => {
handleDelete(obj[displayKey] || obj);
}
: isDeleteIcon && obj.count > 1
: currentEntity?.status !== EntityStatus.DELETED && isDeleteIcon && obj.count > 1
? () => {
const searchParams = new URLSearchParams();
searchParams.set("tabActive", "classification");
Expand Down
15 changes: 11 additions & 4 deletions dashboard/src/components/ShowMore/ShowMoreView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Typography from "@mui/material/Typography";
import Chip from "@mui/material/Chip";
import MuiLink from "@mui/material/Link";
import { LightTooltip } from "../muiComponents";
import { useRef, useState } from "react";
import { useEffect, useRef, useState } from "react";
import { EllipsisText } from "../commonComponents";
import { extractKeyValueFromEntity, isEmpty, serverError } from "@utils/Utils";
import { useAppDispatch, useAppSelector } from "@hooks/reducerHook";
Expand All @@ -31,8 +31,9 @@ import ErrorRoundedIcon from "@mui/icons-material/ErrorRounded";
import { fetchGlossaryData } from "@redux/slice/glossarySlice";
import { fetchGlossaryDetails } from "@redux/slice/glossaryDetailsSlice";
import ShowMoreDrawer from "./ShowMoreDrawer";
import { openDrawer } from "@redux/slice/drawerSlice";
import { openDrawer, closeDrawer } from "@redux/slice/drawerSlice";
import { cloneDeep } from "@utils/Helper";
import { EntityStatus } from "@utils/EntityStatus";

const CHIP_MAX_WIDTH = "200px";

Expand Down Expand Up @@ -73,6 +74,12 @@ const ShowMoreView = ({
const gType = searchParams.get("gtype");
const dispatchApi = useAppDispatch();

useEffect(() => {
return () => {
dispatchApi(closeDrawer());
};
}, [dispatchApi]);

const { classificationData = {} }: any = useAppSelector(
(state: any) => state.classification
);
Expand Down Expand Up @@ -310,13 +317,13 @@ const ShowMoreView = ({
}
component="a"
onDelete={
!isEmpty(removeApiMethod) && !isDeleteIcon
!isEmpty(removeApiMethod) && !isDeleteIcon && currentEntity?.status !== EntityStatus.DELETED
? () => {
// Handle undefined displayKey by extracting a string value
const deleteValue = obj[displayKey] || obj.displayText || obj.text || obj.name || '';
handleDelete(deleteValue);
}
: isDeleteIcon && obj.count > 1
: isDeleteIcon && obj.count > 1 && currentEntity?.status !== EntityStatus.DELETED
? () => {
const searchParams = new URLSearchParams();
searchParams.set("tabActive", "classification");
Expand Down
23 changes: 23 additions & 0 deletions dashboard/src/components/ShowMore/__tests__/ShowMoreView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ jest.mock('@redux/slice/drawerSlice', () => ({
openDrawer: jest.fn((id: string) => ({
type: 'drawer/openDrawer',
payload: id
})),
closeDrawer: jest.fn(() => ({
type: 'drawer/closeDrawer'
}))
}));

Expand Down Expand Up @@ -739,6 +742,26 @@ describe('ShowMoreView', () => {
});

describe('Delete Icon Functionality', () => {
it('should not show delete button when currentEntity status is DELETED', () => {
const dataWithCount = [
{ typeName: 'Tag1' }
];

render(
<TestWrapper>
<ShowMoreView
{...defaultProps}
data={dataWithCount}
removeApiMethod={jest.fn()}
currentEntity={{ guid: 'entity-guid-123', status: 'DELETED' }}
/>
</TestWrapper>
);

expect(screen.queryByTestId('chip-ondelete-button')).not.toBeInTheDocument();
});


it('should show count when isDeleteIcon is true and count > 1', () => {
const dataWithCount = [
{ typeName: 'Tag1', count: 2 },
Expand Down
21 changes: 21 additions & 0 deletions dashboard/src/utils/EntityStatus.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export enum EntityStatus {
ACTIVE = "ACTIVE",
DELETED = "DELETED"
}
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ const ClassificationCoverage = memo(
aria-label="Open classification search"
>
{numberFormatWithComma(typesInUse)} of{" "}
{numberFormatWithComma(classificationTypeDefinitions)}
{numberFormatWithComma(classificationTypeDefinitions)}{" "}
classification types are in use (have at least one entity).
</Typography>
</Stack>
Expand Down
85 changes: 45 additions & 40 deletions dashboard/src/views/DetailPage/DetailPageAttributes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const getDescriptionForDisplay = (desc: unknown): string => {
};
import { useState } from "react";
import { useAppSelector } from "@hooks/reducerHook";
import { EntityStatus } from "@utils/EntityStatus";
import { toast } from "react-toastify";
import EditOutlinedIcon from "@mui/icons-material/EditOutlined";
import { removeClassification } from "@api/apiMethods/classificationApiMethod";
Expand Down Expand Up @@ -147,7 +148,7 @@ const DetailPageAttribute = ({
{name}{" "}
</Typography>
</LightTooltip>
{isEmpty(bmguid) && (
{isEmpty(bmguid) && !loading && data?.status !== EntityStatus.DELETED && (
<LightTooltip title={"Edit Classification"}>
<CustomButton
variant="outlined"
Expand Down Expand Up @@ -315,23 +316,25 @@ const DetailPageAttribute = ({
>
Classifications
</Typography>
<LightTooltip title={"Add Classifications"}>
<IconButton
component="label"
role={undefined}
tabIndex={-1}
size="small"
color="primary"
onClick={() => {
setOpenAddTagModal(true);
}}
>
<AddCircleOutlineIcon
className="mr-0"
fontSize="small"
/>{" "}
</IconButton>
</LightTooltip>
{!loading && data?.status !== EntityStatus.DELETED && (
<LightTooltip title={"Add Classifications"}>
<IconButton
component="label"
role={undefined}
tabIndex={-1}
size="small"
color="primary"
onClick={() => {
setOpenAddTagModal(true);
}}
>
<AddCircleOutlineIcon
className="mr-0"
fontSize="small"
/>{" "}
</IconButton>
</LightTooltip>
)}
</Stack>
<Stack
data-cy="tagListTerm"
Expand Down Expand Up @@ -383,28 +386,30 @@ const DetailPageAttribute = ({
>
Terms
</Typography>
<LightTooltip title={"Add Term"}>
<IconButton
component="label"
role={undefined}
tabIndex={-1}
size="small"
color="primary"
onClick={() => {
if (!hasAnyGlossaryTerms) {
toast.dismiss();
toast.info("There are no available terms");
return;
}
setOpenAddTermModal(true);
}}
>
<AddCircleOutlineIcon
className="mr-0"
fontSize="small"
/>{" "}
</IconButton>
</LightTooltip>
{!loading && data?.status !== EntityStatus.DELETED && (
<LightTooltip title={"Add Term"}>
<IconButton
component="label"
role={undefined}
tabIndex={-1}
size="small"
color="primary"
onClick={() => {
if (!hasAnyGlossaryTerms) {
toast.dismiss();
toast.info("There are no available terms");
return;
}
setOpenAddTermModal(true);
}}
>
<AddCircleOutlineIcon
className="mr-0"
fontSize="small"
/>{" "}
</IconButton>
</LightTooltip>
)}
</Stack>
<Stack
data-cy="termList"
Expand Down
Loading
Loading