From b8fd072e487a924aff478eaf767f2a354d383704 Mon Sep 17 00:00:00 2001 From: Shailesh Parmar Date: Tue, 13 Sep 2022 21:00:46 +0530 Subject: [PATCH] UI: Fixed Clicking "profiler & data quality" and "data quality" tab making the main tabs disappear #7351 (#7417) * UI: Fixed Clicking "profiler & data quality" and "data quality" tab making the main tabs disappear #7351 * miner fix * addressing comment --- .../ProfilerDashboard/ProfilerDashboard.tsx | 44 +---- .../component/DataQualityTab.tsx | 1 + .../TableProfiler/TableProfilerV1.tsx | 180 +++++++++++++----- .../TableProfiler/tableProfiler.less | 6 - .../src/main/resources/ui/src/styles/app.less | 8 + .../ui/src/styles/components/size.less | 16 ++ .../src/main/resources/ui/src/styles/index.js | 1 + 7 files changed, 161 insertions(+), 95 deletions(-) create mode 100644 openmetadata-ui/src/main/resources/ui/src/styles/components/size.less diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ProfilerDashboard/ProfilerDashboard.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ProfilerDashboard/ProfilerDashboard.tsx index 289d8997103..cd53a081632 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ProfilerDashboard/ProfilerDashboard.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ProfilerDashboard/ProfilerDashboard.tsx @@ -36,7 +36,6 @@ import { Table, TestCaseStatus, } from '../../generated/entity/data/table'; -import { EntityType as TestType } from '../../generated/tests/testDefinition'; import { EntityReference } from '../../generated/type/entityReference'; import { LabelType, State } from '../../generated/type/tagLabel'; import jsonData from '../../jsons/en'; @@ -100,7 +99,6 @@ const ProfilerDashboard: React.FC = ({ ); const [selectedTestCaseStatus, setSelectedTestCaseStatus] = useState(''); - const [selectedTestType, setSelectedTestType] = useState(''); const [selectedTimeRange, setSelectedTimeRange] = useState('last3days'); const [activeColumnDetails, setActiveColumnDetails] = useState( @@ -156,21 +154,6 @@ const ProfilerDashboard: React.FC = ({ return testCaseStatus; }, []); - const testCaseTypeOption = useMemo(() => { - const testCaseStatus: Record[] = Object.entries( - TestType - ).map(([key, value]) => ({ - label: key, - value: value, - })); - testCaseStatus.unshift({ - label: 'All', - value: '', - }); - - return testCaseStatus; - }, []); - const tier = useMemo(() => getTierTags(table.tags ?? []), [table]); const breadcrumb = useMemo(() => { const serviceName = getEntityName(table.service); @@ -395,12 +378,6 @@ const ProfilerDashboard: React.FC = ({ } }; - const handleTestCaseTypeChange = (value: string) => { - if (value !== selectedTestType) { - setSelectedTestType(value); - } - }; - const getFilterTestCase = () => { const dataByStatus = testCases.filter( (data) => @@ -408,16 +385,7 @@ const ProfilerDashboard: React.FC = ({ data.testCaseResult?.testCaseStatus === selectedTestCaseStatus ); - return isColumnView - ? dataByStatus - : dataByStatus.filter( - (data) => - selectedTestType === '' || - (selectedTestType === TestType.Table && - entityTypeFQN === data.entityFQN) || - (selectedTestType === TestType.Column && - entityTypeFQN !== data.entityFQN) - ); + return dataByStatus; }; useEffect(() => { @@ -482,16 +450,6 @@ const ProfilerDashboard: React.FC = ({ /> - {activeTab === ProfilerDashboardTab.DATA_QUALITY && - !isColumnView && ( - - = ({ /> = ({ permissions, }) => { const { profile, columns = [] } = table; - const history = useHistory(); const [settingModalVisible, setSettingModalVisible] = useState(false); const [columnTests, setColumnTests] = useState([]); const [tableTests, setTableTests] = useState({ tests: [], results: INITIAL_TEST_RESULT_SUMMARY, }); - const [activeTab] = useState( + const [activeTab, setActiveTab] = useState( ProfilerDashboardTab.SUMMARY ); + const [selectedTestCaseStatus, setSelectedTestCaseStatus] = + useState(''); + const [selectedTestType, setSelectedTestType] = useState(''); + const isSummary = activeTab === ProfilerDashboardTab.SUMMARY; + const isDataQuality = activeTab === ProfilerDashboardTab.DATA_QUALITY; + + const testCaseStatusOption = useMemo(() => { + const testCaseStatus: SelectableOption[] = Object.values( + TestCaseStatus + ).map((value) => ({ + label: value, + value: value, + })); + testCaseStatus.unshift({ + label: 'All', + value: '', + }); + + return testCaseStatus; + }, []); + + const testCaseTypeOption = useMemo(() => { + const testCaseStatus: SelectableOption[] = Object.entries(TestType).map( + ([key, value]) => ({ + label: key, + value: value, + }) + ); + testCaseStatus.unshift({ + label: 'All', + value: '', + }); + + return testCaseStatus; + }, []); const viewTest = permissions.ViewAll || permissions.ViewTests; const viewProfiler = permissions.ViewAll || permissions.ViewDataProfile; @@ -125,21 +162,13 @@ const TableProfilerV1: FC = ({ const handleTabChange = (e: RadioChangeEvent) => { const value = e.target.value as ProfilerDashboardTab; - if (ProfilerDashboardTab.DATA_QUALITY === value) { - history.push( - getProfilerDashboardWithFqnPath( - ProfilerDashboardType.TABLE, - table.fullyQualifiedName || '', - ProfilerDashboardTab.DATA_QUALITY - ) - ); - } + setActiveTab(value); }; const fetchAllTests = async () => { try { const { data } = await getListTestCase({ - fields: 'testCaseResult', + fields: 'testCaseResult,entityLink,testDefinition,testSuite', entityLink: generateEntityLink(table.fullyQualifiedName || ''), includeAllTests: true, limit: API_RES_MAX_SIZE, @@ -169,6 +198,35 @@ const TableProfilerV1: FC = ({ } }; + const handleTestCaseStatusChange = (value: string) => { + if (value !== selectedTestCaseStatus) { + setSelectedTestCaseStatus(value); + } + }; + + const handleTestCaseTypeChange = (value: string) => { + if (value !== selectedTestType) { + setSelectedTestType(value); + } + }; + + const getFilterTestCase = () => { + let tests: TestCase[] = []; + if (selectedTestType === TestType.Table) { + tests = tableTests.tests; + } else if (selectedTestType === TestType.Column) { + tests = columnTests; + } else { + tests = [...tableTests.tests, ...columnTests]; + } + + return tests.filter( + (data) => + selectedTestCaseStatus === '' || + data.testCaseResult?.testCaseStatus === selectedTestCaseStatus + ); + }; + useEffect(() => { if (!isEmpty(table) && viewTest) { fetchAllTests(); @@ -191,6 +249,25 @@ const TableProfilerV1: FC = ({ /> + {isDataQuality && ( + <> + + + + + )} + = ({ - - - + {isSummary && ( + + + + )} @@ -273,15 +351,25 @@ const TableProfilerV1: FC = ({ ))} - ({ - ...col, - key: col.name, - }))} - hasEditAccess={editTest} - onAddTestClick={onAddTestClick} - /> + {isSummary && ( + ({ + ...col, + key: col.name, + }))} + hasEditAccess={editTest} + onAddTestClick={onAddTestClick} + /> + )} + + {isDataQuality && ( + + )} {settingModalVisible && (