Skip to content

Commit 0d4d022

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

7 files changed

Lines changed: 623 additions & 29 deletions

File tree

dashboard/src/styles/propertiesTab.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,7 @@
7878
.audit-attributes-item:nth-child(3) {
7979
flex: 0 0 100%;
8080
}
81+
82+
.text-underline {
83+
text-decoration: underline;
84+
}

dashboard/src/views/DetailPage/EntityDetailTabs/PropertiesTab/BMAttributes.tsx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,27 @@ const defaultField = {
6464
value: ""
6565
};
6666

67-
const BMAttributes = ({ loading, bmAttributes, entity }: any) => {
67+
type BMAttributesProps = {
68+
loading: boolean | undefined;
69+
bmAttributes: Record<string, any>;
70+
entity: any;
71+
};
72+
73+
const BMAttributes = ({ loading, bmAttributes, entity }: BMAttributesProps) => {
6874
const dispatchApi = useAppDispatch();
69-
const { guid }: any = useParams();
70-
const toastId: any = useRef(null);
71-
const { entityData }: any = useAppSelector((state: any) => state.entity);
75+
const { guid } = useParams();
76+
const toastId = useRef<number | string | null>(null);
77+
const { entityData } = useAppSelector((state: any) => state.entity);
7278
const { entityDefs } = entityData || {};
7379
let filterEntityData = cloneDeep(entityDefs);
74-
const { businessMetaData }: any = useAppSelector(
80+
const { businessMetaData } = useAppSelector(
7581
(state: any) => state.businessMetaData
7682
);
7783
const { businessMetadataDefs } = businessMetaData || {};
7884

7985
let businessAttributes = cloneDeep(bmAttributes);
8086
let bmAttributesData = Object.entries(businessAttributes).map(
81-
([key, value]: any) => {
87+
([key, value]: [string, any]) => {
8288
let foundBusinessMetadata = businessMetadataDefs.find(
8389
(obj: { name: any }) => obj.name == key
8490
);
@@ -212,7 +218,7 @@ const BMAttributes = ({ loading, bmAttributes, entity }: any) => {
212218
control
213219
});
214220

215-
const onSubmit = async (values: { businessMetadata: any }) => {
221+
const onSubmit = async (values: { businessMetadata: any[] }) => {
216222
let formData = { ...values };
217223
const { businessMetadata } = formData;
218224
let data: Record<string, any> = {};
@@ -301,7 +307,7 @@ const BMAttributes = ({ loading, bmAttributes, entity }: any) => {
301307
handleSubmit(onSubmit)();
302308
};
303309

304-
const renderValues = (values: any) => {
310+
const renderValues = (values: { value: any; typeName: string }) => {
305311
const { value, typeName } = values;
306312

307313
if (
@@ -480,7 +486,7 @@ const BMAttributes = ({ loading, bmAttributes, entity }: any) => {
480486
</Stack>
481487
</AccordionSummary>
482488

483-
{Object.entries(obj).map(([key, value]: any) => {
489+
{Object.entries(obj).map(([key, value]: [string, any]) => {
484490
return (
485491
<>
486492
{key !=
@@ -552,7 +558,7 @@ const BMAttributes = ({ loading, bmAttributes, entity }: any) => {
552558
e.stopPropagation();
553559
setAddLabel(false);
554560
}}
555-
style={{ textDecoration: "underline" }}
561+
className="text-color-green cursor-pointer text-underline"
556562
>
557563
here
558564
</Typography>
@@ -572,7 +578,7 @@ const BMAttributes = ({ loading, bmAttributes, entity }: any) => {
572578
}}
573579
variant="outlined"
574580
size="small"
575-
onClick={(e: any) => {
581+
onClick={(e: React.MouseEvent) => {
576582
e.stopPropagation();
577583
append(defaultField);
578584
}}

dashboard/src/views/DetailPage/EntityDetailTabs/PropertiesTab/Labels.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,18 @@ import { useAppDispatch } from "@hooks/reducerHook";
4545
import { fetchDetailPageData } from "@redux/slice/detailPageSlice";
4646
import { EntityStatus } from "@utils/EntityStatus";
4747

48-
const filter = createFilterOptions<any>();
48+
type LabelOption = string | { inputValue?: string; value?: string };
49+
const filter = createFilterOptions<LabelOption>();
4950

50-
const Labels = ({ loading, labels, entity }: any) => {
51-
const { guid }: any = useParams();
52-
const toastId: any = useRef(null);
51+
type LabelsProps = {
52+
loading: boolean | undefined;
53+
labels: string[];
54+
entity: any;
55+
};
56+
57+
const Labels = ({ loading, labels, entity }: LabelsProps) => {
58+
const { guid } = useParams();
59+
const toastId = useRef<number | string | null>(null);
5360
const dispatchApi = useAppDispatch();
5461
const [addLabel, setAddLabel] = useState<boolean>(true);
5562
const [expanded, setExpanded] = useState<string | false>(false);
@@ -101,7 +108,7 @@ const Labels = ({ loading, labels, entity }: any) => {
101108
setLoader(false);
102109
setOpen(false);
103110
};
104-
const onInputChange = (_event: any, value: string) => {
111+
const onInputChange = (_event: React.SyntheticEvent, value: string) => {
105112
if (value) {
106113
setOpen(true);
107114
setLoader(true);
@@ -136,7 +143,7 @@ const Labels = ({ loading, labels, entity }: any) => {
136143
return out;
137144
};
138145

139-
const onSubmit = async (values: any) => {
146+
const onSubmit = async (values: Record<string, any>) => {
140147
const formData = { ...values };
141148
const payload = normalizeLabelsPayload(formData.labels);
142149
if (payload.length === 0 && (!labels || labels.length === 0)) {
@@ -290,7 +297,7 @@ const Labels = ({ loading, labels, entity }: any) => {
290297
e.stopPropagation();
291298
setAddLabel(false);
292299
}}
293-
style={{ textDecoration: "underline" }}
300+
className="text-color-green cursor-pointer text-underline"
294301
>
295302
here
296303
</Typography>

dashboard/src/views/DetailPage/EntityDetailTabs/PropertiesTab/UserDefinedProperties.tsx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,16 @@ const defaultField = {
5757
value: ""
5858
};
5959

60-
const UserDefinedProperties = ({ loading, customAttributes, entity }: any) => {
60+
type UserDefinedPropertiesProps = {
61+
loading: boolean | undefined;
62+
customAttributes: Record<string, any>;
63+
entity: any;
64+
};
65+
66+
const UserDefinedProperties = ({ loading, customAttributes, entity }: UserDefinedPropertiesProps) => {
6167
const dispatchApi = useAppDispatch();
62-
const { guid }: any = useParams();
63-
const toastId: any = useRef(null);
68+
const { guid } = useParams();
69+
const toastId = useRef<number | string | null>(null);
6470
const [addLabel, setAddLabel] = useState<boolean>(true);
6571
const [expanded, setExpanded] = useState<string | false>(false);
6672
let attributes = cloneDeep(customAttributes);
@@ -102,7 +108,7 @@ const UserDefinedProperties = ({ loading, customAttributes, entity }: any) => {
102108
}
103109
};
104110

105-
const structureAttributes = (list: any) => {
111+
const structureAttributes = (list: { key: string; value: string }[]) => {
106112
const obj: Record<string, string> = {};
107113
if (!Array.isArray(list)) {
108114
return obj;
@@ -120,7 +126,7 @@ const UserDefinedProperties = ({ loading, customAttributes, entity }: any) => {
120126
return obj;
121127
};
122128

123-
const onSubmit = async (values: any) => {
129+
const onSubmit = async (values: Record<string, any>) => {
124130
let formData = { ...values };
125131
let entityObj = cloneDeep(entity);
126132
let properties = structureAttributes(formData.customAttributes);
@@ -153,10 +159,10 @@ const UserDefinedProperties = ({ loading, customAttributes, entity }: any) => {
153159
handleSubmit(onSubmit)();
154160
};
155161

156-
const validateKeyUnique = (value: any, index: number): any => {
162+
const validateKeyUnique = (value: string, index: number): string | boolean => {
157163
const items = getValues("customAttributes");
158164
const duplicate = items.some(
159-
(item: { key: any }, i: any) => item.key === value && i !== index
165+
(item: { key: string }, i: number) => item.key === value && i !== index
160166
);
161167
return duplicate ? "Key must be unique" : true;
162168
};
@@ -270,7 +276,7 @@ const UserDefinedProperties = ({ loading, customAttributes, entity }: any) => {
270276
{!isEmpty(customAttributes) ? (
271277
Object.entries(customAttributes)
272278
.sort()
273-
.map(([keys, value]: [string, any]) => {
279+
.map(([keys, value]: [string, string]) => {
274280
return (
275281
<>
276282
<Stack
@@ -319,7 +325,7 @@ const UserDefinedProperties = ({ loading, customAttributes, entity }: any) => {
319325
e.stopPropagation();
320326
setAddLabel(false);
321327
}}
322-
style={{ textDecoration: "underline" }}
328+
className="text-color-green cursor-pointer text-underline"
323329
>
324330
here
325331
</Typography>
@@ -332,7 +338,7 @@ const UserDefinedProperties = ({ loading, customAttributes, entity }: any) => {
332338
</>
333339
) : (
334340
<>
335-
{fields.map((item: any, index) => {
341+
{fields.map((item: Record<string, any>, index) => {
336342
return (
337343
<Stack
338344
gap="0.5rem"
@@ -411,7 +417,7 @@ const UserDefinedProperties = ({ loading, customAttributes, entity }: any) => {
411417
size="small"
412418
aria-label="add"
413419
className="cursor-pointer"
414-
onClick={(e: any) => {
420+
onClick={(e: React.MouseEvent) => {
415421
e.stopPropagation();
416422
append(defaultField);
417423
}}

0 commit comments

Comments
 (0)