diff --git a/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/IncidentManager/FailedTestCaseSampleData/FailedTestCaseSampleData.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/IncidentManager/FailedTestCaseSampleData/FailedTestCaseSampleData.component.tsx index 7e97e80cdecf..a85a770756d2 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/IncidentManager/FailedTestCaseSampleData/FailedTestCaseSampleData.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/DataQuality/IncidentManager/FailedTestCaseSampleData/FailedTestCaseSampleData.component.tsx @@ -11,7 +11,8 @@ * limitations under the License. */ -import { Button, Dropdown, Space, Table, Tooltip, Typography } from 'antd'; +import { Table, Typography } from '@openmetadata/ui-core-components'; +import { Button, Dropdown, Space, Tooltip } from 'antd'; import { ItemType } from 'antd/lib/menu/hooks/useItems'; import { AxiosError } from 'axios'; import classNames from 'classnames'; @@ -40,33 +41,41 @@ import { showErrorToast } from '../../../../utils/ToastUtils'; import Loader from '../../../common/Loader/Loader'; import { ManageButtonItemLabel } from '../../../common/ManageButtonContentItem/ManageButtonContentItem.component'; import { RowData } from '../../../Database/SampleDataTable/RowData'; -import { - SampleData, - SampleDataType, -} from '../../../Database/SampleDataTable/SampleData.interface'; +import { SampleDataType } from '../../../Database/SampleDataTable/SampleData.interface'; import EntityDeleteModal from '../../../Modals/EntityDeleteModal/EntityDeleteModal'; -import './failed-test-case-sample-data.less'; import { FailedTestCaseSampleDataProps } from './FailedTestCaseSampleData.interface'; const DIFF_TYPE = 'diffType'; const ROW_KEY = '__rowKey'; + const DIFF_TYPE_VALUES = { ADD: '+', REMOVE: '-', NOT_EQUAL: '!=', }; +type SampleDataColumn = { + id: string; + label: string; +}; + +type LocalSampleData = { + columns: SampleDataColumn[]; + rows: Record[]; +}; + const FailedTestCaseSampleData = ({ testCaseData, }: FailedTestCaseSampleDataProps) => { const { t } = useTranslation(); - const [sampleData, setSampleData] = useState(); + const [sampleData, setSampleData] = useState(); const [isLoading, setIsLoading] = useState(false); const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false); const [showActions, setShowActions] = useState(false); const { permissions } = usePermissionProvider(); const { version } = useParams<{ version: string }>(); const isVersionPage = !isUndefined(version); + const columnName = useMemo( () => testCaseData?.entityLink @@ -74,6 +83,7 @@ const FailedTestCaseSampleData = ({ : undefined, [testCaseData] ); + const hasViewSampleDataPermission = useMemo(() => { return checkPermission( Operation.ViewSampleData, @@ -116,48 +126,26 @@ const FailedTestCaseSampleData = ({ }, }, ]; - const getSampleDataWithType = (sampleData: TableData) => { - const updatedColumns = sampleData?.columns?.map((column) => { - return { - name: column, - title: - column === DIFF_TYPE ? ( - '' - ) : ( -
- {column} -
- ), - dataIndex: column, - key: column, - accessor: column, - width: column === DIFF_TYPE ? undefined : 210, - render: (data: SampleDataType) => ({ - props: { - className: classNames({ - 'failed-sample-data-column': column === columnName, - 'diff-type-sample-data-column': column === DIFF_TYPE, - }), - }, - children: , - }), - }; - }); - const data = (sampleData?.rows ?? []).map((item, index) => { + const getSampleDataWithType = (tableData: TableData): LocalSampleData => { + const columns: SampleDataColumn[] = (tableData?.columns ?? []).map( + (column) => ({ + id: column, + label: column === DIFF_TYPE ? '' : column, + }) + ); + + const rows = (tableData?.rows ?? []).map((item, index) => { const dataObject: Record = {}; - (sampleData?.columns ?? []).forEach((col, index) => { - dataObject[col] = item[index]; + (tableData?.columns ?? []).forEach((col, colIndex) => { + dataObject[col] = item[colIndex]; }); dataObject[ROW_KEY] = index; return dataObject; }); - return { - columns: updatedColumns, - rows: data, - }; + return { columns, rows }; }; const fetchFailedTestCaseSampleData = async () => { @@ -216,9 +204,9 @@ const FailedTestCaseSampleData = ({ return (
- + {t('label.sample-data')} - +
{testCaseData?.inspectionQuery && !isVersionPage && ( - { - const type = record?.diffType; +
+
+ + {(col) => ( + + )} + + + {(record) => { + const diffType = record[DIFF_TYPE]; + + return ( + + {(col) => { + const isDiffCol = col.id === DIFF_TYPE; + const isFailedCol = col.id === columnName; - return classNames({ - 'remove-sample-data': type === DIFF_TYPE_VALUES.REMOVE, - 'add-sample-data': type === DIFF_TYPE_VALUES.ADD, - 'not-equal-sample-data': type === DIFF_TYPE_VALUES.NOT_EQUAL, - }); - }} - rowKey={ROW_KEY} - scroll={{ x: 'max-content' }} - size="small" - /> + return ( + + {isDiffCol ? ( + + {record[col.id] as string} + + ) : ( + + + + )} + + ); + }} + + ); + }} + +
+
{isDeleteModalOpen && ( table - tbody - > tr - td.ant-table-cell.diff-type-sample-data-column { - border-right: 1px solid rgba(0, 0, 0, 0.06); - padding-right: 16px; -} - -.add-sample-data { - background: fade(@green-3, 5%); - - .diff-type-sample-data-column { - .ant-typography { - color: @green-3; - } - } -} -.remove-sample-data { - background: fade(@red-3, 5%); - - .diff-type-sample-data-column { - .ant-typography { - color: @red-3; - } - } -} -.not-equal-sample-data { - background: #f8f8f8; - - .diff-type-sample-data-column { - .ant-typography { - color: @grey-4; - } - } -}