From be553eb017f2df3705b8bf1d9ebb4a19c64632b2 Mon Sep 17 00:00:00 2001 From: Sachin Chaurasiya Date: Tue, 6 Sep 2022 21:59:40 +0530 Subject: [PATCH] Fix #5091 Make "Data Quality" column on Table schema page optional to hide (#7260) * Fix #5091 Make "Data Quality" column on Table schema page optional to hide * Fix unit test * Improve checks --- .../BotListV1/BotListV1.component.tsx | 16 +++--- .../DatasetDetails.component.tsx | 12 +--- .../EntityTable/EntityTable.component.tsx | 14 ----- .../ProfilerDashboard/ProfilerDashboard.tsx | 19 +++++-- .../TableProfiler/TableProfiler.interface.ts | 3 +- .../TableProfiler/TableProfilerV1.test.tsx | 24 +++++++- .../TableProfiler/TableProfilerV1.tsx | 44 +++++++++------ .../ProfilerDashboardPage.tsx | 55 +++++++++++++++++-- 8 files changed, 128 insertions(+), 59 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/BotListV1/BotListV1.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/BotListV1/BotListV1.component.tsx index 174e94f232d..8117945e576 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/BotListV1/BotListV1.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/BotListV1/BotListV1.component.tsx @@ -176,13 +176,15 @@ const BotListV1 = ({ - + + + } doc={BOTS_DOCS} diff --git a/openmetadata-ui/src/main/resources/ui/src/components/DatasetDetails/DatasetDetails.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/DatasetDetails/DatasetDetails.component.tsx index bc9757067ca..d9f6e67bcd9 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/DatasetDetails/DatasetDetails.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/DatasetDetails/DatasetDetails.component.tsx @@ -48,11 +48,7 @@ import { getEntityFeedLink } from '../../utils/EntityUtils'; import { getDefaultValue } from '../../utils/FeedElementUtils'; import { getEntityFieldThreadCounts } from '../../utils/FeedUtils'; import { DEFAULT_ENTITY_PERMISSION } from '../../utils/PermissionsUtils'; -import { - getTableTestsValue, - getTagsWithoutTier, - getUsagePercentile, -} from '../../utils/TableUtils'; +import { getTagsWithoutTier, getUsagePercentile } from '../../utils/TableUtils'; import { showErrorToast } from '../../utils/ToastUtils'; import ActivityFeedList from '../ActivityFeed/ActivityFeedList/ActivityFeedList'; import ActivityThreadPanel from '../ActivityFeed/ActivityThreadPanel/ActivityThreadPanel'; @@ -125,7 +121,6 @@ const DatasetDetails: React.FC = ({ postFeedHandler, feedCount, entityFieldThreadCount, - tableTestCase, createThread, qualityTestFormHandler, deletePostHandler, @@ -408,7 +403,6 @@ const DatasetDetails: React.FC = ({ key: 'Rows', value: prepareTableRowInfo(), }, - { key: 'Tests', value: getTableTestsValue(tableTestCase) }, ]; const onDescriptionEdit = (): void => { @@ -745,9 +739,7 @@ const DatasetDetails: React.FC = ({ )} {activeTab === 5 && ( diff --git a/openmetadata-ui/src/main/resources/ui/src/components/EntityTable/EntityTable.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/EntityTable/EntityTable.component.tsx index 5a62e1d8baf..fc55c41b656 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/EntityTable/EntityTable.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/EntityTable/EntityTable.component.tsx @@ -833,20 +833,6 @@ const EntityTable = ({ return renderCell(TABLE_HEADERS_V1.dataTypeDisplay, record, index); }, }, - { - title: 'Data Quality', - dataIndex: 'columnTests', - key: 'columnTests', - accessor: 'columnTests', - width: 200, - render: ( - _: Array, - record: ModifiedTableColumn, - index: number - ) => { - return renderCell(TABLE_HEADERS_V1.columnTests, record, index); - }, - }, { title: 'Description', dataIndex: 'description', 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 753a8b1f24f..0d77477d597 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 @@ -10,7 +10,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Button, Col, Form, Radio, Row, Select, Space } from 'antd'; +import { Button, Col, Form, Radio, Row, Select, Space, Tooltip } from 'antd'; import { RadioChangeEvent } from 'antd/lib/radio'; import { AxiosError } from 'axios'; import { EntityTags, ExtraInfo } from 'Models'; @@ -25,6 +25,7 @@ import { getTableTabPath, getTeamAndUserDetailsPath, } from '../../constants/constants'; +import { NO_PERMISSION_FOR_ACTION } from '../../constants/HelperTextUtil'; import { PROFILER_FILTER_RANGE } from '../../constants/profiler.constant'; import { EntityType, FqnPart } from '../../enums/entity.enum'; import { ServiceCategory } from '../../enums/service.enum'; @@ -480,9 +481,19 @@ const ProfilerDashboard: React.FC = ({ onChange={handleTimeRangeChange} /> )} - + + + diff --git a/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfiler.interface.ts b/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfiler.interface.ts index cec0b205192..f00b1e90fee 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfiler.interface.ts +++ b/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfiler.interface.ts @@ -14,6 +14,7 @@ import { Column, Table } from '../../generated/entity/data/table'; import { TestCase } from '../../generated/tests/testCase'; import { DatasetTestModeType } from '../../interface/dataQuality.interface'; +import { OperationPermission } from '../PermissionProvider/PermissionProvider.interface'; export interface TableProfilerProps { onAddTestClick: ( @@ -22,7 +23,7 @@ export interface TableProfilerProps { columnName?: string ) => void; table: Table; - hasEditAccess: boolean; + permissions: OperationPermission; } export type TableTestsType = { diff --git a/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfilerV1.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfilerV1.test.tsx index 26ea3382345..40263d41f25 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfilerV1.test.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfilerV1.test.tsx @@ -21,6 +21,7 @@ import { } from '@testing-library/react'; import React from 'react'; import { MOCK_TABLE, TEST_CASE } from '../../mocks/TableData.mock'; +import { OperationPermission } from '../PermissionProvider/PermissionProvider.interface'; import { TableProfilerProps } from './TableProfiler.interface'; // internal imports import TableProfilerV1 from './TableProfilerV1'; @@ -60,7 +61,28 @@ jest.mock('../../axiosAPIs/testAPI', () => ({ const mockProps: TableProfilerProps = { table: MOCK_TABLE, - hasEditAccess: true, + permissions: { + Create: true, + Delete: true, + EditAll: true, + EditCustomFields: true, + EditDataProfile: true, + EditDescription: true, + EditDisplayName: true, + EditLineage: true, + EditOwner: true, + EditQueries: true, + EditSampleData: true, + EditTags: true, + EditTests: true, + EditTier: true, + ViewAll: true, + ViewDataProfile: true, + ViewQueries: true, + ViewSampleData: true, + ViewTests: true, + ViewUsage: true, + } as OperationPermission, onAddTestClick: jest.fn(), }; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfilerV1.tsx b/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfilerV1.tsx index 6ec3101a399..39bfe9f8042 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfilerV1.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/TableProfiler/TableProfilerV1.tsx @@ -57,9 +57,9 @@ import './tableProfiler.less'; const TableProfilerV1: FC = ({ table, onAddTestClick, - hasEditAccess, + permissions, }) => { - const { profile, columns } = table; + const { profile, columns = [] } = table; const history = useHistory(); const [settingModalVisible, setSettingModalVisible] = useState(false); const [columnTests, setColumnTests] = useState([]); @@ -71,6 +71,10 @@ const TableProfilerV1: FC = ({ ProfilerDashboardTab.SUMMARY ); + const viewTest = permissions.ViewAll || permissions.ViewTests; + const viewProfiler = permissions.ViewAll || permissions.ViewDataProfile; + const editTest = permissions.EditAll || permissions.EditTests; + const handleSettingModal = (value: boolean) => { setSettingModalVisible(value); }; @@ -106,11 +110,18 @@ const TableProfilerV1: FC = ({ ]; }, [profile, tableTests]); - const tabOptions = useMemo(() => { - return Object.values(ProfilerDashboardTab).filter( - (value) => value !== ProfilerDashboardTab.PROFILER - ); - }, []); + const tabOptions = [ + { + label: ProfilerDashboardTab.SUMMARY, + value: ProfilerDashboardTab.SUMMARY, + disabled: !viewProfiler, + }, + { + label: ProfilerDashboardTab.DATA_QUALITY, + value: ProfilerDashboardTab.DATA_QUALITY, + disabled: !viewTest, + }, + ]; const handleTabChange = (e: RadioChangeEvent) => { const value = e.target.value as ProfilerDashboardTab; @@ -158,8 +169,9 @@ const TableProfilerV1: FC = ({ }; useEffect(() => { - if (isEmpty(table)) return; - fetchAllTests(); + if (!isEmpty(table) && viewTest) { + fetchAllTests(); + } }, [table]); return ( @@ -177,11 +189,10 @@ const TableProfilerV1: FC = ({ /> - + = ({ - +