mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-27 16:55:06 +00:00
fix(ui): the tags issue with same column name in entities (#11921)
* fix the tags issue with same column name in entities * fix unit test
This commit is contained in:
parent
75d9826911
commit
8d3a8e0a37
@ -106,7 +106,7 @@ const ContainerDataModel: FC<ContainerDataModelProps> = ({
|
||||
|
||||
updateContainerColumnTags(
|
||||
containerDataModel?.columns,
|
||||
editColumnTag.name,
|
||||
editColumnTag.fullyQualifiedName ?? '',
|
||||
newSelectedTags
|
||||
);
|
||||
|
||||
@ -123,7 +123,7 @@ const ContainerDataModel: FC<ContainerDataModelProps> = ({
|
||||
const containerDataModel = cloneDeep(dataModel);
|
||||
updateContainerColumnDescription(
|
||||
containerDataModel?.columns,
|
||||
editContainerColumnDescription?.name,
|
||||
editContainerColumnDescription.fullyQualifiedName ?? '',
|
||||
updatedDescription
|
||||
);
|
||||
await onUpdate(containerDataModel);
|
||||
|
||||
@ -99,7 +99,7 @@ const ModelTab = ({
|
||||
|
||||
updateDataModelColumnTags(
|
||||
dataModelData,
|
||||
editColumnTag.name,
|
||||
editColumnTag.fullyQualifiedName ?? '',
|
||||
newSelectedTags
|
||||
);
|
||||
|
||||
@ -114,7 +114,7 @@ const ModelTab = ({
|
||||
const dataModelColumns = cloneDeep(data);
|
||||
updateDataModelColumnDescription(
|
||||
dataModelColumns,
|
||||
editColumnDescription?.name,
|
||||
editColumnDescription?.fullyQualifiedName ?? '',
|
||||
updatedDescription
|
||||
);
|
||||
await onUpdate(dataModelColumns);
|
||||
|
||||
@ -200,16 +200,16 @@ const EntityTable = ({
|
||||
|
||||
const updateColumnTags = (
|
||||
tableCols: Column[],
|
||||
changedColName: string,
|
||||
changedColFQN: string,
|
||||
newColumnTags: Array<TagOption>
|
||||
) => {
|
||||
tableCols?.forEach((col) => {
|
||||
if (col.name === changedColName) {
|
||||
if (col.fullyQualifiedName === changedColFQN) {
|
||||
col.tags = getUpdatedTags(col, newColumnTags);
|
||||
} else {
|
||||
updateColumnTags(
|
||||
col?.children as Column[],
|
||||
changedColName,
|
||||
changedColFQN,
|
||||
newColumnTags
|
||||
);
|
||||
}
|
||||
@ -242,7 +242,11 @@ const EntityTable = ({
|
||||
);
|
||||
if (newSelectedTags && editColumnTag) {
|
||||
const tableCols = cloneDeep(tableColumns);
|
||||
updateColumnTags(tableCols, editColumnTag.name, newSelectedTags);
|
||||
updateColumnTags(
|
||||
tableCols,
|
||||
editColumnTag.fullyQualifiedName ?? '',
|
||||
newSelectedTags
|
||||
);
|
||||
await onUpdate(tableCols);
|
||||
}
|
||||
};
|
||||
|
||||
@ -121,7 +121,7 @@ const TopicSchemaFields: FC<TopicSchemaFieldsProps> = ({
|
||||
const schema = cloneDeep(messageSchema);
|
||||
updateFieldTags(
|
||||
schema?.schemaFields,
|
||||
editColumnTag.name,
|
||||
editColumnTag.fullyQualifiedName ?? '',
|
||||
newSelectedTags
|
||||
);
|
||||
await onUpdate(schema);
|
||||
@ -133,7 +133,7 @@ const TopicSchemaFields: FC<TopicSchemaFieldsProps> = ({
|
||||
const schema = cloneDeep(messageSchema);
|
||||
updateFieldDescription(
|
||||
schema?.schemaFields,
|
||||
editFieldDescription.name,
|
||||
editFieldDescription.fullyQualifiedName ?? '',
|
||||
updatedDescription
|
||||
);
|
||||
await onUpdate(schema);
|
||||
|
||||
@ -53,11 +53,13 @@ const nestedColumn = {
|
||||
name: 'order_id',
|
||||
dataType: DataType.Int,
|
||||
description: 'order_id',
|
||||
fullyQualifiedName: 'sample_kafka.customer_events.Order.order_id',
|
||||
},
|
||||
{
|
||||
name: 'api_client_id',
|
||||
dataType: DataType.Int,
|
||||
description: 'api_client_id',
|
||||
fullyQualifiedName: 'sample_kafka.customer_events.Order.api_client_id',
|
||||
},
|
||||
],
|
||||
};
|
||||
@ -78,11 +80,13 @@ const updatedNestedColumn: Column = {
|
||||
name: 'order_id',
|
||||
dataType: DataType.Int,
|
||||
description: 'order_id',
|
||||
fullyQualifiedName: 'sample_kafka.customer_events.Order.order_id',
|
||||
},
|
||||
{
|
||||
name: 'api_client_id',
|
||||
dataType: DataType.Int,
|
||||
description: 'updated description',
|
||||
fullyQualifiedName: 'sample_kafka.customer_events.Order.api_client_id',
|
||||
},
|
||||
],
|
||||
};
|
||||
@ -105,12 +109,14 @@ const nestedColumnWithTags = {
|
||||
dataType: DataType.Int,
|
||||
description: 'order_id',
|
||||
tags: [],
|
||||
fullyQualifiedName: 'sample_kafka.customer_events.Order.order_id',
|
||||
},
|
||||
{
|
||||
name: 'api_client_id',
|
||||
dataType: DataType.Int,
|
||||
description: 'api_client_id',
|
||||
tags: [],
|
||||
fullyQualifiedName: 'sample_kafka.customer_events.Order.api_client_id',
|
||||
},
|
||||
],
|
||||
};
|
||||
@ -126,12 +132,14 @@ const updatedNestedColumnWithTags: Column = {
|
||||
dataType: DataType.Int,
|
||||
description: 'order_id',
|
||||
tags: mockTags as Column['tags'],
|
||||
fullyQualifiedName: 'sample_kafka.customer_events.Order.order_id',
|
||||
},
|
||||
{
|
||||
name: 'api_client_id',
|
||||
dataType: DataType.Int,
|
||||
description: 'api_client_id',
|
||||
tags: [],
|
||||
fullyQualifiedName: 'sample_kafka.customer_events.Order.api_client_id',
|
||||
},
|
||||
],
|
||||
};
|
||||
@ -158,14 +166,14 @@ describe('getContainerDetailPath', () => {
|
||||
// updated the single column
|
||||
updateContainerColumnDescription(
|
||||
containerColumns,
|
||||
'id',
|
||||
'sample_kafka.customer_events.id',
|
||||
'updated description'
|
||||
);
|
||||
|
||||
// updated the nested column
|
||||
updateContainerColumnDescription(
|
||||
containerColumns,
|
||||
'api_client_id',
|
||||
'sample_kafka.customer_events.Order.api_client_id',
|
||||
'updated description'
|
||||
);
|
||||
|
||||
@ -180,7 +188,11 @@ describe('getContainerDetailPath', () => {
|
||||
];
|
||||
|
||||
// updated the single column
|
||||
updateContainerColumnTags(containerColumns, 'id', mockTagOptions);
|
||||
updateContainerColumnTags(
|
||||
containerColumns,
|
||||
'sample_kafka.customer_events.id',
|
||||
mockTagOptions
|
||||
);
|
||||
|
||||
const updatedContainerColumns = [
|
||||
{ ...updatedSingleColumn, tags: mockTags },
|
||||
@ -193,7 +205,11 @@ describe('getContainerDetailPath', () => {
|
||||
const containerColumns = [nestedColumnWithTags];
|
||||
|
||||
// updated the single column
|
||||
updateContainerColumnTags(containerColumns, 'order_id', mockTagOptions);
|
||||
updateContainerColumnTags(
|
||||
containerColumns,
|
||||
'sample_kafka.customer_events.Order.order_id',
|
||||
mockTagOptions
|
||||
);
|
||||
|
||||
const updatedContainerColumns = [updatedNestedColumnWithTags];
|
||||
|
||||
|
||||
@ -64,11 +64,11 @@ const getUpdatedContainerColumnTags = (
|
||||
|
||||
export const updateContainerColumnTags = (
|
||||
containerColumns: ContainerDataModel['columns'] = [],
|
||||
changedColumnName: string,
|
||||
changedColumnFQN: string,
|
||||
newColumnTags: TagOption[] = []
|
||||
) => {
|
||||
containerColumns.forEach((containerColumn) => {
|
||||
if (containerColumn.name === changedColumnName) {
|
||||
if (containerColumn.fullyQualifiedName === changedColumnFQN) {
|
||||
containerColumn.tags = getUpdatedContainerColumnTags(
|
||||
containerColumn,
|
||||
newColumnTags
|
||||
@ -80,7 +80,7 @@ export const updateContainerColumnTags = (
|
||||
if (hasChildren) {
|
||||
updateContainerColumnTags(
|
||||
containerColumn.children,
|
||||
changedColumnName,
|
||||
changedColumnFQN,
|
||||
newColumnTags
|
||||
);
|
||||
}
|
||||
@ -90,11 +90,11 @@ export const updateContainerColumnTags = (
|
||||
|
||||
export const updateContainerColumnDescription = (
|
||||
containerColumns: ContainerDataModel['columns'] = [],
|
||||
changedColumnName: string,
|
||||
changedColumnFQN: string,
|
||||
description: string
|
||||
) => {
|
||||
containerColumns.forEach((containerColumn) => {
|
||||
if (containerColumn.name === changedColumnName) {
|
||||
if (containerColumn.fullyQualifiedName === changedColumnFQN) {
|
||||
containerColumn.description = description;
|
||||
} else {
|
||||
const hasChildren = !isEmpty(containerColumn.children);
|
||||
@ -103,7 +103,7 @@ export const updateContainerColumnDescription = (
|
||||
if (hasChildren) {
|
||||
updateContainerColumnDescription(
|
||||
containerColumn.children,
|
||||
changedColumnName,
|
||||
changedColumnFQN,
|
||||
description
|
||||
);
|
||||
}
|
||||
|
||||
@ -37,11 +37,11 @@ export const getDataModelsDetailPath = (dataModelFQN: string, tab?: string) => {
|
||||
|
||||
export const updateDataModelColumnDescription = (
|
||||
containerColumns: Column[] = [],
|
||||
changedColumnName: string,
|
||||
changedColumnFQN: string,
|
||||
description: string
|
||||
) => {
|
||||
containerColumns.forEach((containerColumn) => {
|
||||
if (containerColumn.name === changedColumnName) {
|
||||
if (containerColumn.fullyQualifiedName === changedColumnFQN) {
|
||||
containerColumn.description = description;
|
||||
} else {
|
||||
const hasChildren = !isEmpty(containerColumn.children);
|
||||
@ -50,7 +50,7 @@ export const updateDataModelColumnDescription = (
|
||||
if (hasChildren) {
|
||||
updateDataModelColumnDescription(
|
||||
containerColumn.children,
|
||||
changedColumnName,
|
||||
changedColumnFQN,
|
||||
description
|
||||
);
|
||||
}
|
||||
@ -91,11 +91,11 @@ const getUpdatedDataModelColumnTags = (
|
||||
|
||||
export const updateDataModelColumnTags = (
|
||||
containerColumns: Column[] = [],
|
||||
changedColumnName: string,
|
||||
changedColumnFQN: string,
|
||||
newColumnTags: TagOption[] = []
|
||||
) => {
|
||||
containerColumns.forEach((containerColumn) => {
|
||||
if (containerColumn.name === changedColumnName) {
|
||||
if (containerColumn.fullyQualifiedName === changedColumnFQN) {
|
||||
containerColumn.tags = getUpdatedDataModelColumnTags(
|
||||
containerColumn,
|
||||
newColumnTags
|
||||
@ -107,7 +107,7 @@ export const updateDataModelColumnTags = (
|
||||
if (hasChildren) {
|
||||
updateDataModelColumnTags(
|
||||
containerColumn.children,
|
||||
changedColumnName,
|
||||
changedColumnFQN,
|
||||
newColumnTags
|
||||
);
|
||||
}
|
||||
|
||||
@ -18,18 +18,18 @@ import { LabelType, State, TagLabel } from '../generated/type/tagLabel';
|
||||
|
||||
export const updateFieldDescription = (
|
||||
schemaFields: Field[] = [],
|
||||
changedFieldName: string,
|
||||
changedFieldFQN: string,
|
||||
description: string
|
||||
) => {
|
||||
schemaFields.forEach((field) => {
|
||||
if (field.name === changedFieldName) {
|
||||
if (field.fullyQualifiedName === changedFieldFQN) {
|
||||
field.description = description;
|
||||
} else {
|
||||
const hasChildren = !isEmpty(field.children);
|
||||
|
||||
// stop condition
|
||||
if (hasChildren) {
|
||||
updateFieldDescription(field.children, changedFieldName, description);
|
||||
updateFieldDescription(field.children, changedFieldFQN, description);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -65,18 +65,18 @@ const getUpdatedFieldTags = (field: Field, newFieldTags: TagOption[] = []) => {
|
||||
|
||||
export const updateFieldTags = (
|
||||
schemaFields: Field[] = [],
|
||||
changedFieldName: string,
|
||||
changedFieldFQN: string,
|
||||
newFieldTags: TagOption[] = []
|
||||
) => {
|
||||
schemaFields.forEach((field) => {
|
||||
if (field.name === changedFieldName) {
|
||||
if (field.fullyQualifiedName === changedFieldFQN) {
|
||||
field.tags = getUpdatedFieldTags(field, newFieldTags);
|
||||
} else {
|
||||
const hasChildren = !isEmpty(field.children);
|
||||
|
||||
// stop condition
|
||||
if (hasChildren) {
|
||||
updateFieldTags(field.children, changedFieldName, newFieldTags);
|
||||
updateFieldTags(field.children, changedFieldFQN, newFieldTags);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -49,11 +49,13 @@ const nestedField = {
|
||||
name: 'order_id',
|
||||
dataType: DataTypeTopic.Int,
|
||||
description: 'order_id',
|
||||
fullyQualifiedName: 'sample_kafka.customer_events.Order.order_id',
|
||||
},
|
||||
{
|
||||
name: 'api_client_id',
|
||||
dataType: DataTypeTopic.Int,
|
||||
description: 'api_client_id',
|
||||
fullyQualifiedName: 'sample_kafka.customer_events.Order.api_client_id',
|
||||
},
|
||||
],
|
||||
};
|
||||
@ -74,11 +76,13 @@ const updatedNestedField: Field = {
|
||||
name: 'order_id',
|
||||
dataType: DataTypeTopic.Int,
|
||||
description: 'order_id',
|
||||
fullyQualifiedName: 'sample_kafka.customer_events.Order.order_id',
|
||||
},
|
||||
{
|
||||
name: 'api_client_id',
|
||||
dataType: DataTypeTopic.Int,
|
||||
description: 'updated description',
|
||||
fullyQualifiedName: 'sample_kafka.customer_events.Order.api_client_id',
|
||||
},
|
||||
],
|
||||
};
|
||||
@ -101,12 +105,14 @@ const nestedFieldWithTags = {
|
||||
dataType: DataTypeTopic.Int,
|
||||
description: 'order_id',
|
||||
tags: [],
|
||||
fullyQualifiedName: 'sample_kafka.customer_events.Order.order_id',
|
||||
},
|
||||
{
|
||||
name: 'api_client_id',
|
||||
dataType: DataTypeTopic.Int,
|
||||
description: 'api_client_id',
|
||||
tags: [],
|
||||
fullyQualifiedName: 'sample_kafka.customer_events.Order.api_client_id',
|
||||
},
|
||||
],
|
||||
};
|
||||
@ -122,12 +128,14 @@ const updatedNestedFieldWithTags: Field = {
|
||||
dataType: DataTypeTopic.Int,
|
||||
description: 'order_id',
|
||||
tags: mockTags as Field['tags'],
|
||||
fullyQualifiedName: 'sample_kafka.customer_events.Order.order_id',
|
||||
},
|
||||
{
|
||||
name: 'api_client_id',
|
||||
dataType: DataTypeTopic.Int,
|
||||
description: 'api_client_id',
|
||||
tags: [],
|
||||
fullyQualifiedName: 'sample_kafka.customer_events.Order.api_client_id',
|
||||
},
|
||||
],
|
||||
};
|
||||
@ -137,12 +145,16 @@ describe('Topic schema field utils', () => {
|
||||
const schemaFields = [singleField, nestedField];
|
||||
|
||||
// updated the single field
|
||||
updateFieldDescription(schemaFields, 'id', 'updated description');
|
||||
updateFieldDescription(
|
||||
schemaFields,
|
||||
'sample_kafka.customer_events.id',
|
||||
'updated description'
|
||||
);
|
||||
|
||||
// updated the nested field
|
||||
updateFieldDescription(
|
||||
schemaFields,
|
||||
'api_client_id',
|
||||
'sample_kafka.customer_events.Order.api_client_id',
|
||||
'updated description'
|
||||
);
|
||||
|
||||
@ -157,7 +169,11 @@ describe('Topic schema field utils', () => {
|
||||
];
|
||||
|
||||
// updated the single field
|
||||
updateFieldTags(schemaFields, 'id', mockTagOptions);
|
||||
updateFieldTags(
|
||||
schemaFields,
|
||||
'sample_kafka.customer_events.id',
|
||||
mockTagOptions
|
||||
);
|
||||
|
||||
const updatedSchemaFields = [{ ...updatedSingleField, tags: mockTags }];
|
||||
|
||||
@ -168,7 +184,11 @@ describe('Topic schema field utils', () => {
|
||||
const schemaFields = [nestedFieldWithTags];
|
||||
|
||||
// updated the single field
|
||||
updateFieldTags(schemaFields, 'order_id', mockTagOptions);
|
||||
updateFieldTags(
|
||||
schemaFields,
|
||||
'sample_kafka.customer_events.Order.order_id',
|
||||
mockTagOptions
|
||||
);
|
||||
|
||||
const updatedSchemaFields = [updatedNestedFieldWithTags];
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user