mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-27 10:26:09 +00:00
Fix UI :- Convert CustomProperty html table to antd table (#7583)
* Convert CustomProperty html table to antd table * fix cypress issue * fix cypress issue * fix cypress issue of not found @value
This commit is contained in:
parent
947cb4e99e
commit
10cecf1d56
@ -649,12 +649,12 @@ export const addCustomPropertiesForEntity = (entityType, customType, value) => {
|
|||||||
.should('exist')
|
.should('exist')
|
||||||
.should('be.visible')
|
.should('be.visible')
|
||||||
.click();
|
.click();
|
||||||
cy.get('[data-testid="table-body"]').should('contain', propertyName);
|
cy.get('tbody').should('contain', propertyName);
|
||||||
|
|
||||||
//Adding value for the custom property
|
//Adding value for the custom property
|
||||||
|
|
||||||
//Navigating through the created custom property for adding value
|
//Navigating through the created custom property for adding value
|
||||||
cy.get('[data-testid="data-row"]')
|
cy.get('tbody')
|
||||||
.contains(propertyName)
|
.contains(propertyName)
|
||||||
.scrollIntoView()
|
.scrollIntoView()
|
||||||
.next('td')
|
.next('td')
|
||||||
@ -684,13 +684,16 @@ export const addCustomPropertiesForEntity = (entityType, customType, value) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//Checking the added value to the property
|
//Checking the added value to the property
|
||||||
cy.get('[data-testid="data-row"]')
|
cy.get('tbody')
|
||||||
.contains(propertyName)
|
.contains(propertyName)
|
||||||
.scrollIntoView()
|
.scrollIntoView()
|
||||||
.next('td')
|
.next('td')
|
||||||
.as('value');
|
.as('value');
|
||||||
|
|
||||||
cy.get('@value').should('contain', value);
|
cy.get('tbody')
|
||||||
|
.contains(propertyName)
|
||||||
|
.scrollIntoView()
|
||||||
|
.next('td').should('contain', value);
|
||||||
|
|
||||||
//returning the property name since it needs to be deleted and updated
|
//returning the property name since it needs to be deleted and updated
|
||||||
return propertyName;
|
return propertyName;
|
||||||
@ -698,7 +701,7 @@ export const addCustomPropertiesForEntity = (entityType, customType, value) => {
|
|||||||
|
|
||||||
export const editCreatedProperty = (propertyName) => {
|
export const editCreatedProperty = (propertyName) => {
|
||||||
//Fetching for edit button
|
//Fetching for edit button
|
||||||
cy.get('[data-testid="table-body"]')
|
cy.get('tbody')
|
||||||
.children()
|
.children()
|
||||||
.contains(propertyName)
|
.contains(propertyName)
|
||||||
.scrollIntoView()
|
.scrollIntoView()
|
||||||
@ -731,7 +734,7 @@ export const editCreatedProperty = (propertyName) => {
|
|||||||
export const deleteCreatedProperty = (propertyName) => {
|
export const deleteCreatedProperty = (propertyName) => {
|
||||||
//Fetching for delete button
|
//Fetching for delete button
|
||||||
|
|
||||||
cy.get('[data-testid="table-body"]')
|
cy.get('tbody')
|
||||||
.children()
|
.children()
|
||||||
.contains(propertyName)
|
.contains(propertyName)
|
||||||
.nextUntil('button')
|
.nextUntil('button')
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { render } from '@testing-library/react';
|
import { render, screen } from '@testing-library/react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { getTypeByFQN } from '../../../axiosAPIs/metadataTypeAPI';
|
import { getTypeByFQN } from '../../../axiosAPIs/metadataTypeAPI';
|
||||||
import { EntityType } from '../../../enums/entity.enum';
|
import { EntityType } from '../../../enums/entity.enum';
|
||||||
@ -73,22 +73,18 @@ const mockProp = {
|
|||||||
|
|
||||||
describe('Test CustomProperty Table Component', () => {
|
describe('Test CustomProperty Table Component', () => {
|
||||||
it('Should render table component', async () => {
|
it('Should render table component', async () => {
|
||||||
const { findByTestId, findAllByTestId } = render(
|
render(<CustomPropertyTable {...mockProp} />);
|
||||||
<CustomPropertyTable {...mockProp} />
|
const table = await screen.findByTestId('custom-properties-table');
|
||||||
);
|
|
||||||
const table = await findByTestId('custom-properties-table');
|
|
||||||
|
|
||||||
expect(table).toBeInTheDocument();
|
expect(table).toBeInTheDocument();
|
||||||
|
|
||||||
const propertyName = await findByTestId('property-name');
|
const propertyName = await screen.findByText('Name');
|
||||||
const propertyValue = await findByTestId('property-value');
|
const propertyValue = await screen.findByText('Value');
|
||||||
|
const rows = await screen.findAllByRole('row');
|
||||||
|
|
||||||
expect(propertyName).toBeInTheDocument();
|
expect(propertyName).toBeInTheDocument();
|
||||||
expect(propertyValue).toBeInTheDocument();
|
expect(propertyValue).toBeInTheDocument();
|
||||||
|
expect(rows).toHaveLength(mockCustomProperties.length + 1);
|
||||||
const dataRows = await findAllByTestId('data-row');
|
|
||||||
|
|
||||||
expect(dataRows).toHaveLength(mockCustomProperties.length);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should render no data placeholder if custom properties list is empty', async () => {
|
it('Should render no data placeholder if custom properties list is empty', async () => {
|
||||||
|
@ -11,13 +11,13 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Table } from 'antd';
|
||||||
|
import { ColumnsType } from 'antd/lib/table';
|
||||||
import { AxiosError } from 'axios';
|
import { AxiosError } from 'axios';
|
||||||
import classNames from 'classnames';
|
import { isEmpty } from 'lodash';
|
||||||
import { isEmpty, uniqueId } from 'lodash';
|
import React, { FC, useEffect, useMemo, useState } from 'react';
|
||||||
import React, { FC, useEffect, useState } from 'react';
|
|
||||||
import { getTypeByFQN } from '../../../axiosAPIs/metadataTypeAPI';
|
import { getTypeByFQN } from '../../../axiosAPIs/metadataTypeAPI';
|
||||||
import { Type } from '../../../generated/entity/type';
|
import { CustomProperty, Type } from '../../../generated/entity/type';
|
||||||
import { isEven } from '../../../utils/CommonUtils';
|
|
||||||
import { showErrorToast } from '../../../utils/ToastUtils';
|
import { showErrorToast } from '../../../utils/ToastUtils';
|
||||||
import ErrorPlaceHolder from '../error-with-placeholder/ErrorPlaceHolder';
|
import ErrorPlaceHolder from '../error-with-placeholder/ErrorPlaceHolder';
|
||||||
import { CustomPropertyProps } from './CustomPropertyTable.interface';
|
import { CustomPropertyProps } from './CustomPropertyTable.interface';
|
||||||
@ -38,10 +38,6 @@ export const CustomPropertyTable: FC<CustomPropertyProps> = ({
|
|||||||
.catch((err: AxiosError) => showErrorToast(err));
|
.catch((err: AxiosError) => showErrorToast(err));
|
||||||
};
|
};
|
||||||
|
|
||||||
const customProperties = entityTypeDetail.customProperties || [];
|
|
||||||
|
|
||||||
const extension = entityDetails.extension;
|
|
||||||
|
|
||||||
const onExtensionUpdate = async (
|
const onExtensionUpdate = async (
|
||||||
updatedExtension: CustomPropertyProps['entityDetails']['extension']
|
updatedExtension: CustomPropertyProps['entityDetails']['extension']
|
||||||
) => {
|
) => {
|
||||||
@ -51,57 +47,47 @@ export const CustomPropertyTable: FC<CustomPropertyProps> = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const tableColumn: ColumnsType<CustomProperty> = useMemo(() => {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
title: 'Name',
|
||||||
|
dataIndex: 'name',
|
||||||
|
key: 'name',
|
||||||
|
width: '50%',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Value',
|
||||||
|
dataIndex: 'value',
|
||||||
|
key: 'value',
|
||||||
|
width: '50%',
|
||||||
|
render: (_, record) => (
|
||||||
|
<PropertyValue
|
||||||
|
extension={entityDetails.extension}
|
||||||
|
propertyName={record.name}
|
||||||
|
propertyType={record.propertyType}
|
||||||
|
onExtensionUpdate={onExtensionUpdate}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}, [entityDetails.extension]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchTypeDetail();
|
fetchTypeDetail();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{isEmpty(customProperties) ? (
|
{isEmpty(entityTypeDetail.customProperties) ? (
|
||||||
<ErrorPlaceHolder heading="Custom Properties" />
|
<ErrorPlaceHolder heading="Custom Properties" />
|
||||||
) : (
|
) : (
|
||||||
<div className="tw-table-container">
|
<Table
|
||||||
<table className="tw-w-full" data-testid="custom-properties-table">
|
columns={tableColumn}
|
||||||
<thead data-testid="table-header">
|
data-testid="custom-properties-table"
|
||||||
<tr className="tableHead-row">
|
dataSource={entityTypeDetail.customProperties || []}
|
||||||
<th
|
pagination={false}
|
||||||
className="tableHead-cell tw-w-2/4"
|
size="small"
|
||||||
data-testid="property-name">
|
/>
|
||||||
Name
|
|
||||||
</th>
|
|
||||||
<th
|
|
||||||
className="tableHead-cell tw-w-2/4"
|
|
||||||
data-testid="property-value">
|
|
||||||
Value
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody data-testid="table-body">
|
|
||||||
{customProperties.map((property, index) => (
|
|
||||||
<tr
|
|
||||||
className={classNames(
|
|
||||||
`tableBody-row ${!isEven(index + 1) && 'odd-row'}`,
|
|
||||||
{
|
|
||||||
'tw-border-b-0': index === customProperties.length - 1,
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
data-testid="data-row"
|
|
||||||
key={uniqueId()}>
|
|
||||||
<td className="tableBody-cell">{property.name}</td>
|
|
||||||
|
|
||||||
<td className="tableBody-cell">
|
|
||||||
<PropertyValue
|
|
||||||
extension={extension}
|
|
||||||
propertyName={property.name}
|
|
||||||
propertyType={property.propertyType}
|
|
||||||
onExtensionUpdate={onExtensionUpdate}
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -64,6 +64,7 @@ export const PropertyValue: FC<Props> = ({
|
|||||||
: updatedValue,
|
: updatedValue,
|
||||||
};
|
};
|
||||||
await onExtensionUpdate(updatedExtension);
|
await onExtensionUpdate(updatedExtension);
|
||||||
|
setShowInput(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getPropertyInput = () => {
|
const getPropertyInput = () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user