mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-10-31 02:29:03 +00:00 
			
		
		
		
	ui: fix permission related bugs (#12160)
* fixed permissions related bugs for entity details pages * permission related bug fixes for version pages * changes to revert tab visibility for no permission * fixed console errors * fixed unit tests
This commit is contained in:
		
							parent
							
								
									d41c08df36
								
							
						
					
					
						commit
						9257065d69
					
				| @ -16,11 +16,13 @@ import classNames from 'classnames'; | ||||
| import { CustomPropertyTable } from 'components/common/CustomPropertyTable/CustomPropertyTable'; | ||||
| import { CustomPropertyProps } from 'components/common/CustomPropertyTable/CustomPropertyTable.interface'; | ||||
| import DescriptionV1 from 'components/common/description/DescriptionV1'; | ||||
| import ErrorPlaceHolder from 'components/common/error-with-placeholder/ErrorPlaceHolder'; | ||||
| import DataAssetsVersionHeader from 'components/DataAssets/DataAssetsVersionHeader/DataAssetsVersionHeader'; | ||||
| import TabsLabel from 'components/TabsLabel/TabsLabel.component'; | ||||
| import TagsContainerV1 from 'components/Tag/TagsContainerV1/TagsContainerV1'; | ||||
| import { getVersionPathWithTab } from 'constants/constants'; | ||||
| import { EntityField } from 'constants/Feeds.constants'; | ||||
| import { ERROR_PLACEHOLDER_TYPE } from 'enums/common.enum'; | ||||
| import { | ||||
|   ChangeDescription, | ||||
|   Column, | ||||
| @ -57,6 +59,7 @@ const ContainerVersion: React.FC<ContainerVersionProp> = ({ | ||||
|   deleted = false, | ||||
|   backHandler, | ||||
|   versionHandler, | ||||
|   entityPermissions, | ||||
| }: ContainerVersionProp) => { | ||||
|   const { t } = useTranslation(); | ||||
|   const history = useHistory(); | ||||
| @ -174,7 +177,9 @@ const ContainerVersion: React.FC<ContainerVersionProp> = ({ | ||||
|             name={t('label.custom-property-plural')} | ||||
|           /> | ||||
|         ), | ||||
|         children: ( | ||||
|         children: !entityPermissions.ViewAll ? ( | ||||
|           <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} /> | ||||
|         ) : ( | ||||
|           <CustomPropertyTable | ||||
|             isVersionView | ||||
|             entityDetails={ | ||||
| @ -186,9 +191,13 @@ const ContainerVersion: React.FC<ContainerVersionProp> = ({ | ||||
|         ), | ||||
|       }, | ||||
|     ], | ||||
|     [description, containerFQN, columns, currentVersionData] | ||||
|     [description, containerFQN, columns, currentVersionData, entityPermissions] | ||||
|   ); | ||||
| 
 | ||||
|   if (!(entityPermissions.ViewAll || entityPermissions.ViewBasic)) { | ||||
|     return <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} />; | ||||
|   } | ||||
| 
 | ||||
|   return ( | ||||
|     <> | ||||
|       {isVersionLoading ? ( | ||||
|  | ||||
| @ -10,6 +10,7 @@ | ||||
|  *  See the License for the specific language governing permissions and | ||||
|  *  limitations under the License. | ||||
|  */ | ||||
| import { OperationPermission } from 'components/PermissionProvider/PermissionProvider.interface'; | ||||
| import { Container } from 'generated/entity/data/container'; | ||||
| import { VersionData } from 'pages/EntityVersionPage/EntityVersionPage.component'; | ||||
| import { EntityHistory } from '../../generated/type/entityHistory'; | ||||
| @ -28,4 +29,5 @@ export interface ContainerVersionProp { | ||||
|   deleted?: boolean; | ||||
|   backHandler: () => void; | ||||
|   versionHandler: (v: string) => void; | ||||
|   entityPermissions: OperationPermission; | ||||
| } | ||||
|  | ||||
| @ -18,11 +18,13 @@ import classNames from 'classnames'; | ||||
| import { CustomPropertyTable } from 'components/common/CustomPropertyTable/CustomPropertyTable'; | ||||
| import { CustomPropertyProps } from 'components/common/CustomPropertyTable/CustomPropertyTable.interface'; | ||||
| import DescriptionV1 from 'components/common/description/DescriptionV1'; | ||||
| import ErrorPlaceHolder from 'components/common/error-with-placeholder/ErrorPlaceHolder'; | ||||
| import DataAssetsVersionHeader from 'components/DataAssets/DataAssetsVersionHeader/DataAssetsVersionHeader'; | ||||
| import TabsLabel from 'components/TabsLabel/TabsLabel.component'; | ||||
| import TagsContainerV1 from 'components/Tag/TagsContainerV1/TagsContainerV1'; | ||||
| import { getVersionPathWithTab } from 'constants/constants'; | ||||
| import { EntityField } from 'constants/Feeds.constants'; | ||||
| import { ERROR_PLACEHOLDER_TYPE } from 'enums/common.enum'; | ||||
| import { EntityTabs, EntityType } from 'enums/entity.enum'; | ||||
| import { TagSource } from 'generated/type/tagLabel'; | ||||
| import React, { FC, useEffect, useMemo, useState } from 'react'; | ||||
| @ -55,6 +57,7 @@ const DashboardVersion: FC<DashboardVersionProp> = ({ | ||||
|   deleted = false, | ||||
|   backHandler, | ||||
|   versionHandler, | ||||
|   entityPermissions, | ||||
| }: DashboardVersionProp) => { | ||||
|   const { t } = useTranslation(); | ||||
|   const history = useHistory(); | ||||
| @ -216,7 +219,9 @@ const DashboardVersion: FC<DashboardVersionProp> = ({ | ||||
|             name={t('label.custom-property-plural')} | ||||
|           /> | ||||
|         ), | ||||
|         children: ( | ||||
|         children: !entityPermissions.ViewAll ? ( | ||||
|           <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} /> | ||||
|         ) : ( | ||||
|           <CustomPropertyTable | ||||
|             isVersionView | ||||
|             entityDetails={ | ||||
| @ -228,9 +233,13 @@ const DashboardVersion: FC<DashboardVersionProp> = ({ | ||||
|         ), | ||||
|       }, | ||||
|     ], | ||||
|     [description, tableColumn, currentVersionData] | ||||
|     [description, tableColumn, currentVersionData, entityPermissions] | ||||
|   ); | ||||
| 
 | ||||
|   if (!(entityPermissions.ViewAll || entityPermissions.ViewBasic)) { | ||||
|     return <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} />; | ||||
|   } | ||||
| 
 | ||||
|   return ( | ||||
|     <> | ||||
|       <div data-testid="dashboard-version-container"> | ||||
|  | ||||
| @ -11,6 +11,7 @@ | ||||
|  *  limitations under the License. | ||||
|  */ | ||||
| 
 | ||||
| import { OperationPermission } from 'components/PermissionProvider/PermissionProvider.interface'; | ||||
| import { VersionData } from 'pages/EntityVersionPage/EntityVersionPage.component'; | ||||
| import { Dashboard } from '../../generated/entity/data/dashboard'; | ||||
| import { EntityHistory } from '../../generated/type/entityHistory'; | ||||
| @ -29,4 +30,5 @@ export interface DashboardVersionProp { | ||||
|   deleted?: boolean; | ||||
|   backHandler: () => void; | ||||
|   versionHandler: (v: string) => void; | ||||
|   entityPermissions: OperationPermission; | ||||
| } | ||||
|  | ||||
| @ -103,6 +103,7 @@ export const dashboardVersionProps = { | ||||
|     ], | ||||
|   }, | ||||
|   deleted: false, | ||||
|   entityPermissions: { ViewAll: true }, | ||||
| } as unknown as DashboardVersionProp; | ||||
| 
 | ||||
| export const mockTagChangeVersion = { | ||||
|  | ||||
| @ -33,7 +33,6 @@ import EntityHeaderTitle from 'components/Entity/EntityHeaderTitle/EntityHeaderT | ||||
| import { useTourProvider } from 'components/TourProvider/TourProvider'; | ||||
| import { FQN_SEPARATOR_CHAR } from 'constants/char.constants'; | ||||
| import { DE_ACTIVE_COLOR, getDashboardDetailsPath } from 'constants/constants'; | ||||
| import { NO_PERMISSION_FOR_ACTION } from 'constants/HelperTextUtil'; | ||||
| import { EntityTabs, EntityType } from 'enums/entity.enum'; | ||||
| import { Container } from 'generated/entity/data/container'; | ||||
| import { Dashboard } from 'generated/entity/data/dashboard'; | ||||
| @ -48,9 +47,9 @@ import { | ||||
|   ThreadType, | ||||
| } from 'generated/entity/feed/thread'; | ||||
| import { useClipboard } from 'hooks/useClipBoard'; | ||||
| import { t } from 'i18next'; | ||||
| import { isEmpty, isUndefined } from 'lodash'; | ||||
| import React, { useEffect, useMemo, useState } from 'react'; | ||||
| import { useTranslation } from 'react-i18next'; | ||||
| import { useHistory } from 'react-router-dom'; | ||||
| import { getActiveAnnouncement, getFeedCount } from 'rest/feedsAPI'; | ||||
| import { getCurrentUserId, getEntityDetailLink } from 'utils/CommonUtils'; | ||||
| @ -120,6 +119,7 @@ export const DataAssetsHeader = ({ | ||||
|   onDisplayNameUpdate, | ||||
| }: DataAssetsHeaderProps) => { | ||||
|   const USERId = getCurrentUserId(); | ||||
|   const { t } = useTranslation(); | ||||
|   const { isTourPage } = useTourProvider(); | ||||
|   const { onCopyToClipBoard } = useClipboard(window.location.href); | ||||
|   const [taskCount, setTaskCount] = useState(0); | ||||
| @ -182,7 +182,7 @@ export const DataAssetsHeader = ({ | ||||
|   }; | ||||
| 
 | ||||
|   useEffect(() => { | ||||
|     if (!isTourPage) { | ||||
|     if (dataAsset.fullyQualifiedName && !isTourPage) { | ||||
|       fetchActiveAnnouncement(); | ||||
|       fetchTaskCount(); | ||||
|     } | ||||
| @ -194,46 +194,6 @@ export const DataAssetsHeader = ({ | ||||
|       breadcrumbs: [], | ||||
|     }; | ||||
|     switch (entityType) { | ||||
|       default: | ||||
|       case EntityType.TABLE: | ||||
|         const tableDetails = dataAsset as Table; | ||||
| 
 | ||||
|         returnData.extraInfo = ( | ||||
|           <> | ||||
|             {tableDetails.tableType && ( | ||||
|               <ExtraInfoLabel | ||||
|                 label={t('label.type')} | ||||
|                 value={tableDetails.tableType} | ||||
|               /> | ||||
|             )} | ||||
|             {tableDetails?.usageSummary && ( | ||||
|               <ExtraInfoLabel | ||||
|                 label={t('label.usage')} | ||||
|                 value={getUsagePercentile( | ||||
|                   tableDetails.usageSummary?.weeklyStats?.percentileRank || 0, | ||||
|                   false | ||||
|                 )} | ||||
|               /> | ||||
|             )} | ||||
|             {tableDetails?.profile?.columnCount && ( | ||||
|               <ExtraInfoLabel | ||||
|                 label={t('label.column-plural')} | ||||
|                 value={tableDetails.profile?.columnCount} | ||||
|               /> | ||||
|             )} | ||||
|             {tableDetails?.profile?.rowCount && ( | ||||
|               <ExtraInfoLabel | ||||
|                 label={t('label.row-plural')} | ||||
|                 value={tableDetails.profile?.rowCount} | ||||
|               /> | ||||
|             )} | ||||
|           </> | ||||
|         ); | ||||
| 
 | ||||
|         returnData.breadcrumbs = getBreadcrumbForTable(tableDetails); | ||||
| 
 | ||||
|         break; | ||||
| 
 | ||||
|       case EntityType.TOPIC: | ||||
|         const topicDetails = dataAsset as Topic; | ||||
|         returnData.breadcrumbs = | ||||
| @ -402,6 +362,46 @@ export const DataAssetsHeader = ({ | ||||
|           getBreadcrumbForEntitiesWithServiceOnly(dataModelDetails); | ||||
| 
 | ||||
|         break; | ||||
| 
 | ||||
|       case EntityType.TABLE: | ||||
|       default: | ||||
|         const tableDetails = dataAsset as Table; | ||||
| 
 | ||||
|         returnData.extraInfo = ( | ||||
|           <> | ||||
|             {tableDetails.tableType && ( | ||||
|               <ExtraInfoLabel | ||||
|                 label={t('label.type')} | ||||
|                 value={tableDetails.tableType} | ||||
|               /> | ||||
|             )} | ||||
|             {tableDetails?.usageSummary && ( | ||||
|               <ExtraInfoLabel | ||||
|                 label={t('label.usage')} | ||||
|                 value={getUsagePercentile( | ||||
|                   tableDetails.usageSummary?.weeklyStats?.percentileRank || 0, | ||||
|                   false | ||||
|                 )} | ||||
|               /> | ||||
|             )} | ||||
|             {tableDetails?.profile?.columnCount && ( | ||||
|               <ExtraInfoLabel | ||||
|                 label={t('label.column-plural')} | ||||
|                 value={tableDetails.profile?.columnCount} | ||||
|               /> | ||||
|             )} | ||||
|             {tableDetails?.profile?.rowCount && ( | ||||
|               <ExtraInfoLabel | ||||
|                 label={t('label.row-plural')} | ||||
|                 value={tableDetails.profile?.rowCount} | ||||
|               /> | ||||
|             )} | ||||
|           </> | ||||
|         ); | ||||
| 
 | ||||
|         returnData.breadcrumbs = getBreadcrumbForTable(tableDetails); | ||||
| 
 | ||||
|         break; | ||||
|     } | ||||
| 
 | ||||
|     return returnData; | ||||
| @ -467,13 +467,8 @@ export const DataAssetsHeader = ({ | ||||
|                         })} | ||||
|                       </span> | ||||
|                     )} | ||||
|                     <Tooltip | ||||
|                       placement="topRight" | ||||
|                       title={ | ||||
|                         permissions.EditAll || permissions.EditTags | ||||
|                           ? '' | ||||
|                           : NO_PERMISSION_FOR_ACTION | ||||
|                       }> | ||||
| 
 | ||||
|                     {(permissions.EditAll || permissions.EditTags) && ( | ||||
|                       <Button | ||||
|                         className="flex-center p-0" | ||||
|                         data-testid="edit-tier" | ||||
| @ -484,7 +479,7 @@ export const DataAssetsHeader = ({ | ||||
|                         size="small" | ||||
|                         type="text" | ||||
|                       /> | ||||
|                     </Tooltip> | ||||
|                     )} | ||||
|                   </Space> | ||||
|                 </TierCard> | ||||
|                 {extraInfo} | ||||
| @ -565,8 +560,8 @@ export const DataAssetsHeader = ({ | ||||
|       {isAnnouncementDrawerOpen && ( | ||||
|         <AnnouncementDrawer | ||||
|           createPermission={permissions?.EditAll} | ||||
|           entityFQN={dataAsset.fullyQualifiedName || ''} | ||||
|           entityName={entityName || ''} | ||||
|           entityFQN={dataAsset.fullyQualifiedName ?? ''} | ||||
|           entityName={entityName ?? ''} | ||||
|           entityType={entityType} | ||||
|           open={isAnnouncementDrawerOpen} | ||||
|           onClose={() => setIsAnnouncementDrawer(false)} | ||||
|  | ||||
| @ -14,10 +14,12 @@ | ||||
| import { Col, Row, Space, Tabs, TabsProps } from 'antd'; | ||||
| import classNames from 'classnames'; | ||||
| import DescriptionV1 from 'components/common/description/DescriptionV1'; | ||||
| import ErrorPlaceHolder from 'components/common/error-with-placeholder/ErrorPlaceHolder'; | ||||
| import DataAssetsVersionHeader from 'components/DataAssets/DataAssetsVersionHeader/DataAssetsVersionHeader'; | ||||
| import TabsLabel from 'components/TabsLabel/TabsLabel.component'; | ||||
| import TagsContainerV1 from 'components/Tag/TagsContainerV1/TagsContainerV1'; | ||||
| import VersionTable from 'components/VersionTable/VersionTable.component'; | ||||
| import { ERROR_PLACEHOLDER_TYPE } from 'enums/common.enum'; | ||||
| import { EntityTabs, EntityType, FqnPart } from 'enums/entity.enum'; | ||||
| import { | ||||
|   ChangeDescription, | ||||
| @ -62,6 +64,7 @@ const DataModelVersion: FC<DataModelVersionProp> = ({ | ||||
|   backHandler, | ||||
|   versionHandler, | ||||
|   dataModelFQN, | ||||
|   entityPermissions, | ||||
| }: DataModelVersionProp) => { | ||||
|   const { t } = useTranslation(); | ||||
|   const [changeDescription, setChangeDescription] = useState<ChangeDescription>( | ||||
| @ -318,6 +321,10 @@ const DataModelVersion: FC<DataModelVersionProp> = ({ | ||||
|     [description, dataModelFQN, columns] | ||||
|   ); | ||||
| 
 | ||||
|   if (!(entityPermissions.ViewAll || entityPermissions.ViewBasic)) { | ||||
|     return <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} />; | ||||
|   } | ||||
| 
 | ||||
|   return ( | ||||
|     <> | ||||
|       <div data-testid="data-model-version-container"> | ||||
|  | ||||
| @ -11,6 +11,7 @@ | ||||
|  *  limitations under the License. | ||||
|  */ | ||||
| 
 | ||||
| import { OperationPermission } from 'components/PermissionProvider/PermissionProvider.interface'; | ||||
| import { DashboardDataModel } from 'generated/entity/data/dashboardDataModel'; | ||||
| import { VersionData } from 'pages/EntityVersionPage/EntityVersionPage.component'; | ||||
| import { EntityHistory } from '../../generated/type/entityHistory'; | ||||
| @ -30,4 +31,5 @@ export interface DataModelVersionProp { | ||||
|   deleted?: boolean; | ||||
|   backHandler: () => void; | ||||
|   versionHandler: (v: string) => void; | ||||
|   entityPermissions: OperationPermission; | ||||
| } | ||||
|  | ||||
| @ -16,11 +16,13 @@ import classNames from 'classnames'; | ||||
| import { CustomPropertyTable } from 'components/common/CustomPropertyTable/CustomPropertyTable'; | ||||
| import { CustomPropertyProps } from 'components/common/CustomPropertyTable/CustomPropertyTable.interface'; | ||||
| import DescriptionV1 from 'components/common/description/DescriptionV1'; | ||||
| import ErrorPlaceHolder from 'components/common/error-with-placeholder/ErrorPlaceHolder'; | ||||
| import DataAssetsVersionHeader from 'components/DataAssets/DataAssetsVersionHeader/DataAssetsVersionHeader'; | ||||
| import TabsLabel from 'components/TabsLabel/TabsLabel.component'; | ||||
| import TagsContainerV1 from 'components/Tag/TagsContainerV1/TagsContainerV1'; | ||||
| import { getVersionPathWithTab } from 'constants/constants'; | ||||
| import { EntityField } from 'constants/Feeds.constants'; | ||||
| import { ERROR_PLACEHOLDER_TYPE } from 'enums/common.enum'; | ||||
| import { TagSource } from 'generated/type/tagLabel'; | ||||
| import { cloneDeep, isUndefined, toString } from 'lodash'; | ||||
| import React, { useEffect, useMemo, useState } from 'react'; | ||||
| @ -59,6 +61,7 @@ const DatasetVersion: React.FC<DatasetVersionProp> = ({ | ||||
|   deleted = false, | ||||
|   backHandler, | ||||
|   versionHandler, | ||||
|   entityPermissions, | ||||
| }: DatasetVersionProp) => { | ||||
|   const { t } = useTranslation(); | ||||
|   const history = useHistory(); | ||||
| @ -194,7 +197,9 @@ const DatasetVersion: React.FC<DatasetVersionProp> = ({ | ||||
|             name={t('label.custom-property-plural')} | ||||
|           /> | ||||
|         ), | ||||
|         children: ( | ||||
|         children: !entityPermissions.ViewAll ? ( | ||||
|           <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} /> | ||||
|         ) : ( | ||||
|           <CustomPropertyTable | ||||
|             isVersionView | ||||
|             entityDetails={ | ||||
| @ -212,9 +217,14 @@ const DatasetVersion: React.FC<DatasetVersionProp> = ({ | ||||
|       columns, | ||||
|       constraintUpdatedColumns, | ||||
|       currentVersionData, | ||||
|       entityPermissions, | ||||
|     ] | ||||
|   ); | ||||
| 
 | ||||
|   if (!(entityPermissions.ViewAll || entityPermissions.ViewBasic)) { | ||||
|     return <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} />; | ||||
|   } | ||||
| 
 | ||||
|   return ( | ||||
|     <> | ||||
|       {isVersionLoading ? ( | ||||
|  | ||||
| @ -11,6 +11,7 @@ | ||||
|  *  limitations under the License. | ||||
|  */ | ||||
| 
 | ||||
| import { OperationPermission } from 'components/PermissionProvider/PermissionProvider.interface'; | ||||
| import { VersionData } from 'pages/EntityVersionPage/EntityVersionPage.component'; | ||||
| import { Table } from '../../generated/entity/data/table'; | ||||
| import { EntityHistory } from '../../generated/type/entityHistory'; | ||||
| @ -29,4 +30,5 @@ export interface DatasetVersionProp { | ||||
|   deleted?: boolean; | ||||
|   backHandler: () => void; | ||||
|   versionHandler: (v: string) => void; | ||||
|   entityPermissions: OperationPermission; | ||||
| } | ||||
|  | ||||
| @ -11,16 +11,7 @@ | ||||
|  *  limitations under the License. | ||||
|  */ | ||||
| 
 | ||||
| import { | ||||
|   Button, | ||||
|   Card, | ||||
|   Col, | ||||
|   Divider, | ||||
|   Row, | ||||
|   Space, | ||||
|   Tooltip, | ||||
|   Typography, | ||||
| } from 'antd'; | ||||
| import { Button, Card, Col, Divider, Row, Space, Typography } from 'antd'; | ||||
| import { ReactComponent as EditIcon } from 'assets/svg/edit-new.svg'; | ||||
| import TableTags from 'components/TableTags/TableTags.component'; | ||||
| import { TagSource } from 'generated/type/schema'; | ||||
| @ -103,7 +94,7 @@ const MlModelFeaturesList = ({ | ||||
|     } | ||||
|   }; | ||||
| 
 | ||||
|   if (mlFeatures && mlFeatures.length) { | ||||
|   if (!isEmpty(mlFeatures)) { | ||||
|     return ( | ||||
|       <Fragment> | ||||
|         <Row data-testid="feature-list"> | ||||
| @ -216,21 +207,10 @@ const MlModelFeaturesList = ({ | ||||
|                                 })} | ||||
|                               </Typography.Text> | ||||
|                             )} | ||||
|                             <Tooltip | ||||
|                               title={ | ||||
|                                 permissions.EditAll || | ||||
|                                 permissions.EditDescription | ||||
|                                   ? t('label.edit') | ||||
|                                   : t('message.no-permission-for-action') | ||||
|                               }> | ||||
|                             {(permissions.EditAll || | ||||
|                               permissions.EditDescription) && ( | ||||
|                               <Button | ||||
|                                 className="m-l-xxs no-border p-0 text-primary h-auto" | ||||
|                                 disabled={ | ||||
|                                   !( | ||||
|                                     permissions.EditAll || | ||||
|                                     permissions.EditDescription | ||||
|                                   ) | ||||
|                                 } | ||||
|                                 icon={<EditIcon width={16} />} | ||||
|                                 type="text" | ||||
|                                 onClick={() => { | ||||
| @ -238,7 +218,7 @@ const MlModelFeaturesList = ({ | ||||
|                                   setEditDescription(true); | ||||
|                                 }} | ||||
|                               /> | ||||
|                             </Tooltip> | ||||
|                             )} | ||||
|                           </Space> | ||||
|                         </Col> | ||||
|                       </Row> | ||||
|  | ||||
| @ -33,6 +33,7 @@ import TabsLabel from 'components/TabsLabel/TabsLabel.component'; | ||||
| import TagsContainerV1 from 'components/Tag/TagsContainerV1/TagsContainerV1'; | ||||
| import TagsViewer from 'components/Tag/TagsViewer/tags-viewer'; | ||||
| import { getVersionPathWithTab } from 'constants/constants'; | ||||
| import { ERROR_PLACEHOLDER_TYPE } from 'enums/common.enum'; | ||||
| import { EntityTabs, EntityType } from 'enums/entity.enum'; | ||||
| import { MlFeature, Mlmodel } from 'generated/entity/data/mlmodel'; | ||||
| import { TagSource } from 'generated/type/tagLabel'; | ||||
| @ -71,6 +72,7 @@ const MlModelVersion: FC<MlModelVersionProp> = ({ | ||||
|   deleted = false, | ||||
|   backHandler, | ||||
|   versionHandler, | ||||
|   entityPermissions, | ||||
| }: MlModelVersionProp) => { | ||||
|   const { t } = useTranslation(); | ||||
|   const history = useHistory(); | ||||
| @ -380,7 +382,9 @@ const MlModelVersion: FC<MlModelVersionProp> = ({ | ||||
|             name={t('label.custom-property-plural')} | ||||
|           /> | ||||
|         ), | ||||
|         children: ( | ||||
|         children: !entityPermissions.ViewAll ? ( | ||||
|           <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} /> | ||||
|         ) : ( | ||||
|           <CustomPropertyTable | ||||
|             isVersionView | ||||
|             entityDetails={ | ||||
| @ -392,9 +396,13 @@ const MlModelVersion: FC<MlModelVersionProp> = ({ | ||||
|         ), | ||||
|       }, | ||||
|     ], | ||||
|     [description, mlFeaturesData, currentVersionData] | ||||
|     [description, mlFeaturesData, currentVersionData, entityPermissions] | ||||
|   ); | ||||
| 
 | ||||
|   if (!(entityPermissions.ViewAll || entityPermissions.ViewBasic)) { | ||||
|     return <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} />; | ||||
|   } | ||||
| 
 | ||||
|   return ( | ||||
|     <> | ||||
|       {isVersionLoading ? ( | ||||
|  | ||||
| @ -11,6 +11,7 @@ | ||||
|  *  limitations under the License. | ||||
|  */ | ||||
| 
 | ||||
| import { OperationPermission } from 'components/PermissionProvider/PermissionProvider.interface'; | ||||
| import { Mlmodel } from 'generated/entity/data/mlmodel'; | ||||
| import { VersionData } from 'pages/EntityVersionPage/EntityVersionPage.component'; | ||||
| import { EntityHistory } from '../../generated/type/entityHistory'; | ||||
| @ -29,4 +30,5 @@ export interface MlModelVersionProp { | ||||
|   deleted?: boolean; | ||||
|   backHandler: () => void; | ||||
|   versionHandler: (v: string) => void; | ||||
|   entityPermissions: OperationPermission; | ||||
| } | ||||
|  | ||||
| @ -18,12 +18,14 @@ import classNames from 'classnames'; | ||||
| import { CustomPropertyTable } from 'components/common/CustomPropertyTable/CustomPropertyTable'; | ||||
| import { CustomPropertyProps } from 'components/common/CustomPropertyTable/CustomPropertyTable.interface'; | ||||
| import DescriptionV1 from 'components/common/description/DescriptionV1'; | ||||
| import ErrorPlaceHolder from 'components/common/error-with-placeholder/ErrorPlaceHolder'; | ||||
| import DataAssetsVersionHeader from 'components/DataAssets/DataAssetsVersionHeader/DataAssetsVersionHeader'; | ||||
| import TabsLabel from 'components/TabsLabel/TabsLabel.component'; | ||||
| import TagsContainerV1 from 'components/Tag/TagsContainerV1/TagsContainerV1'; | ||||
| import TagsViewer from 'components/Tag/TagsViewer/tags-viewer'; | ||||
| import { getVersionPathWithTab } from 'constants/constants'; | ||||
| import { TABLE_SCROLL_VALUE } from 'constants/Table.constants'; | ||||
| import { ERROR_PLACEHOLDER_TYPE } from 'enums/common.enum'; | ||||
| import { EntityTabs, EntityType } from 'enums/entity.enum'; | ||||
| import { TagSource } from 'generated/type/schema'; | ||||
| import { t } from 'i18next'; | ||||
| @ -69,6 +71,7 @@ const PipelineVersion: FC<PipelineVersionProp> = ({ | ||||
|   deleted = false, | ||||
|   backHandler, | ||||
|   versionHandler, | ||||
|   entityPermissions, | ||||
| }: PipelineVersionProp) => { | ||||
|   const history = useHistory(); | ||||
|   const { tab } = useParams<{ tab: EntityTabs }>(); | ||||
| @ -400,7 +403,9 @@ const PipelineVersion: FC<PipelineVersionProp> = ({ | ||||
|             name={t('label.custom-property-plural')} | ||||
|           /> | ||||
|         ), | ||||
|         children: ( | ||||
|         children: !entityPermissions.ViewAll ? ( | ||||
|           <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} /> | ||||
|         ) : ( | ||||
|           <CustomPropertyTable | ||||
|             isVersionView | ||||
|             entityDetails={ | ||||
| @ -412,9 +417,19 @@ const PipelineVersion: FC<PipelineVersionProp> = ({ | ||||
|         ), | ||||
|       }, | ||||
|     ], | ||||
|     [description, tableColumn, pipelineVersionTableData, currentVersionData] | ||||
|     [ | ||||
|       description, | ||||
|       tableColumn, | ||||
|       pipelineVersionTableData, | ||||
|       currentVersionData, | ||||
|       entityPermissions, | ||||
|     ] | ||||
|   ); | ||||
| 
 | ||||
|   if (!(entityPermissions.ViewAll || entityPermissions.ViewBasic)) { | ||||
|     return <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} />; | ||||
|   } | ||||
| 
 | ||||
|   return ( | ||||
|     <> | ||||
|       {isVersionLoading ? ( | ||||
|  | ||||
| @ -11,6 +11,7 @@ | ||||
|  *  limitations under the License. | ||||
|  */ | ||||
| 
 | ||||
| import { OperationPermission } from 'components/PermissionProvider/PermissionProvider.interface'; | ||||
| import { VersionData } from 'pages/EntityVersionPage/EntityVersionPage.component'; | ||||
| import { Pipeline } from '../../generated/entity/data/pipeline'; | ||||
| import { EntityHistory } from '../../generated/type/entityHistory'; | ||||
| @ -29,4 +30,5 @@ export interface PipelineVersionProp { | ||||
|   deleted?: boolean; | ||||
|   backHandler: () => void; | ||||
|   versionHandler: (v: string) => void; | ||||
|   entityPermissions: OperationPermission; | ||||
| } | ||||
|  | ||||
| @ -18,12 +18,14 @@ import ActivityFeedProvider, { | ||||
| } from 'components/ActivityFeed/ActivityFeedProvider/ActivityFeedProvider'; | ||||
| import { ActivityFeedTab } from 'components/ActivityFeed/ActivityFeedTab/ActivityFeedTab.component'; | ||||
| import DescriptionV1 from 'components/common/description/DescriptionV1'; | ||||
| import ErrorPlaceHolder from 'components/common/error-with-placeholder/ErrorPlaceHolder'; | ||||
| import PageLayoutV1 from 'components/containers/PageLayoutV1'; | ||||
| import { DataAssetsHeader } from 'components/DataAssets/DataAssetsHeader/DataAssetsHeader.component'; | ||||
| import { EntityName } from 'components/Modals/EntityNameModal/EntityNameModal.interface'; | ||||
| import TabsLabel from 'components/TabsLabel/TabsLabel.component'; | ||||
| import TagsContainerV2 from 'components/Tag/TagsContainerV2/TagsContainerV2'; | ||||
| import { getTopicDetailsPath } from 'constants/constants'; | ||||
| import { ERROR_PLACEHOLDER_TYPE } from 'enums/common.enum'; | ||||
| import { TagLabel } from 'generated/type/schema'; | ||||
| import { EntityFieldThreadCount } from 'interface/feed.interface'; | ||||
| import { EntityTags } from 'Models'; | ||||
| @ -43,18 +45,12 @@ import { | ||||
|   refreshPage, | ||||
| } from '../../utils/CommonUtils'; | ||||
| import { getEntityFieldThreadCounts } from '../../utils/FeedUtils'; | ||||
| import { DEFAULT_ENTITY_PERMISSION } from '../../utils/PermissionsUtils'; | ||||
| import { getTagsWithoutTier, getTierTags } from '../../utils/TableUtils'; | ||||
| import { showErrorToast, showSuccessToast } from '../../utils/ToastUtils'; | ||||
| import ActivityThreadPanel from '../ActivityFeed/ActivityThreadPanel/ActivityThreadPanel'; | ||||
| import { CustomPropertyTable } from '../common/CustomPropertyTable/CustomPropertyTable'; | ||||
| import { CustomPropertyProps } from '../common/CustomPropertyTable/CustomPropertyTable.interface'; | ||||
| import EntityLineageComponent from '../EntityLineage/EntityLineage.component'; | ||||
| import { usePermissionProvider } from '../PermissionProvider/PermissionProvider'; | ||||
| import { | ||||
|   OperationPermission, | ||||
|   ResourceEntity, | ||||
| } from '../PermissionProvider/PermissionProvider.interface'; | ||||
| import SampleDataTopic from '../SampleDataTopic/SampleDataTopic'; | ||||
| import SchemaEditor from '../schema-editor/SchemaEditor'; | ||||
| import { TopicDetailsProps } from './TopicDetails.interface'; | ||||
| @ -66,8 +62,8 @@ const TopicDetails: React.FC<TopicDetailsProps> = ({ | ||||
|   unFollowTopicHandler, | ||||
|   versionHandler, | ||||
|   createThread, | ||||
| 
 | ||||
|   onTopicUpdate, | ||||
|   topicPermissions, | ||||
| }: TopicDetailsProps) => { | ||||
|   const { t } = useTranslation(); | ||||
|   const { postFeed, deleteFeed, updateFeed } = useActivityFeedProvider(); | ||||
| @ -88,11 +84,6 @@ const TopicDetails: React.FC<TopicDetailsProps> = ({ | ||||
|     ThreadType.Conversation | ||||
|   ); | ||||
| 
 | ||||
|   const [topicPermissions, setTopicPermissions] = useState<OperationPermission>( | ||||
|     DEFAULT_ENTITY_PERMISSION | ||||
|   ); | ||||
| 
 | ||||
|   const { getEntityPermission } = usePermissionProvider(); | ||||
|   const { | ||||
|     owner, | ||||
|     description, | ||||
| @ -116,26 +107,6 @@ const TopicDetails: React.FC<TopicDetailsProps> = ({ | ||||
|     }; | ||||
|   }, [followers]); | ||||
| 
 | ||||
|   const fetchResourcePermission = useCallback(async () => { | ||||
|     try { | ||||
|       const permissions = await getEntityPermission( | ||||
|         ResourceEntity.TOPIC, | ||||
|         topicDetails.id | ||||
|       ); | ||||
|       setTopicPermissions(permissions); | ||||
|     } catch (error) { | ||||
|       showErrorToast( | ||||
|         t('server.fetch-entity-permissions-error', { entity: t('label.topic') }) | ||||
|       ); | ||||
|     } | ||||
|   }, [topicDetails.id, getEntityPermission, setTopicPermissions]); | ||||
| 
 | ||||
|   useEffect(() => { | ||||
|     if (topicDetails.id) { | ||||
|       fetchResourcePermission(); | ||||
|     } | ||||
|   }, [topicDetails.id]); | ||||
| 
 | ||||
|   const followTopic = async () => { | ||||
|     isFollowing ? await unFollowTopicHandler() : await followTopicHandler(); | ||||
|   }; | ||||
| @ -400,7 +371,13 @@ const TopicDetails: React.FC<TopicDetailsProps> = ({ | ||||
|           /> | ||||
|         ), | ||||
|         key: EntityTabs.SAMPLE_DATA, | ||||
|         children: <SampleDataTopic topicId={topicDetails.id} />, | ||||
|         children: !( | ||||
|           topicPermissions.ViewAll || topicPermissions.ViewSampleData | ||||
|         ) ? ( | ||||
|           <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} /> | ||||
|         ) : ( | ||||
|           <SampleDataTopic topicId={topicDetails.id} /> | ||||
|         ), | ||||
|       }, | ||||
|       { | ||||
|         label: <TabsLabel id={EntityTabs.CONFIG} name={t('label.config')} />, | ||||
| @ -452,6 +429,7 @@ const TopicDetails: React.FC<TopicDetailsProps> = ({ | ||||
|         ), | ||||
|       }, | ||||
|     ], | ||||
| 
 | ||||
|     [ | ||||
|       activeTab, | ||||
|       feedCount, | ||||
| @ -462,15 +440,10 @@ const TopicDetails: React.FC<TopicDetailsProps> = ({ | ||||
|       isEdit, | ||||
|       entityName, | ||||
|       topicFQN, | ||||
|       topicPermissions, | ||||
|     ] | ||||
|   ); | ||||
| 
 | ||||
|   useEffect(() => { | ||||
|     if (topicDetails.id) { | ||||
|       fetchResourcePermission(); | ||||
|     } | ||||
|   }, [topicDetails.id]); | ||||
| 
 | ||||
|   return ( | ||||
|     <PageLayoutV1 | ||||
|       className="bg-white" | ||||
|  | ||||
| @ -11,12 +11,14 @@ | ||||
|  *  limitations under the License. | ||||
|  */ | ||||
| 
 | ||||
| import { OperationPermission } from 'components/PermissionProvider/PermissionProvider.interface'; | ||||
| import { CreateThread } from '../../generated/api/feed/createThread'; | ||||
| import { CleanupPolicy, Topic } from '../../generated/entity/data/topic'; | ||||
| import { SchemaType } from '../../generated/type/schema'; | ||||
| 
 | ||||
| export interface TopicDetailsProps { | ||||
|   topicDetails: Topic; | ||||
|   topicPermissions: OperationPermission; | ||||
|   createThread: (data: CreateThread) => void; | ||||
|   followTopicHandler: () => Promise<void>; | ||||
|   unFollowTopicHandler: () => Promise<void>; | ||||
|  | ||||
| @ -20,6 +20,7 @@ import { | ||||
| import { EntityTabs } from 'enums/entity.enum'; | ||||
| import React from 'react'; | ||||
| import { MemoryRouter } from 'react-router-dom'; | ||||
| import { DEFAULT_ENTITY_PERMISSION } from 'utils/PermissionsUtils'; | ||||
| import TopicDetails from './TopicDetails.component'; | ||||
| import { TopicDetailsProps } from './TopicDetails.interface'; | ||||
| import { TOPIC_DETAILS } from './TopicDetails.mock'; | ||||
| @ -55,6 +56,7 @@ const topicDetailsProps: TopicDetailsProps = { | ||||
|   onTopicUpdate: jest.fn(), | ||||
|   versionHandler: jest.fn(), | ||||
|   createThread: jest.fn(), | ||||
|   topicPermissions: DEFAULT_ENTITY_PERMISSION, | ||||
| }; | ||||
| 
 | ||||
| const mockParams = { | ||||
|  | ||||
| @ -16,12 +16,14 @@ import classNames from 'classnames'; | ||||
| import { CustomPropertyTable } from 'components/common/CustomPropertyTable/CustomPropertyTable'; | ||||
| import { CustomPropertyProps } from 'components/common/CustomPropertyTable/CustomPropertyTable.interface'; | ||||
| import DescriptionV1 from 'components/common/description/DescriptionV1'; | ||||
| import ErrorPlaceHolder from 'components/common/error-with-placeholder/ErrorPlaceHolder'; | ||||
| import DataAssetsVersionHeader from 'components/DataAssets/DataAssetsVersionHeader/DataAssetsVersionHeader'; | ||||
| import TabsLabel from 'components/TabsLabel/TabsLabel.component'; | ||||
| import TagsContainerV1 from 'components/Tag/TagsContainerV1/TagsContainerV1'; | ||||
| import TopicSchemaFields from 'components/TopicDetails/TopicSchema/TopicSchema'; | ||||
| import { getVersionPathWithTab } from 'constants/constants'; | ||||
| import { EntityField } from 'constants/Feeds.constants'; | ||||
| import { ERROR_PLACEHOLDER_TYPE } from 'enums/common.enum'; | ||||
| import { EntityTabs, EntityType } from 'enums/entity.enum'; | ||||
| import { TagSource } from 'generated/type/tagLabel'; | ||||
| import React, { FC, useEffect, useMemo, useState } from 'react'; | ||||
| @ -49,6 +51,7 @@ const TopicVersion: FC<TopicVersionProp> = ({ | ||||
|   deleted = false, | ||||
|   backHandler, | ||||
|   versionHandler, | ||||
|   entityPermissions, | ||||
| }: TopicVersionProp) => { | ||||
|   const { t } = useTranslation(); | ||||
|   const history = useHistory(); | ||||
| @ -162,7 +165,9 @@ const TopicVersion: FC<TopicVersionProp> = ({ | ||||
|             name={t('label.custom-property-plural')} | ||||
|           /> | ||||
|         ), | ||||
|         children: ( | ||||
|         children: !entityPermissions.ViewAll ? ( | ||||
|           <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} /> | ||||
|         ) : ( | ||||
|           <CustomPropertyTable | ||||
|             isVersionView | ||||
|             entityDetails={ | ||||
| @ -174,9 +179,13 @@ const TopicVersion: FC<TopicVersionProp> = ({ | ||||
|         ), | ||||
|       }, | ||||
|     ], | ||||
|     [description, messageSchemaDiff, currentVersionData] | ||||
|     [description, messageSchemaDiff, currentVersionData, entityPermissions] | ||||
|   ); | ||||
| 
 | ||||
|   if (!(entityPermissions.ViewAll || entityPermissions.ViewBasic)) { | ||||
|     return <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} />; | ||||
|   } | ||||
| 
 | ||||
|   return ( | ||||
|     <> | ||||
|       {isVersionLoading ? ( | ||||
|  | ||||
| @ -11,6 +11,7 @@ | ||||
|  *  limitations under the License. | ||||
|  */ | ||||
| 
 | ||||
| import { OperationPermission } from 'components/PermissionProvider/PermissionProvider.interface'; | ||||
| import { VersionData } from 'pages/EntityVersionPage/EntityVersionPage.component'; | ||||
| import { Topic } from '../../generated/entity/data/topic'; | ||||
| import { EntityHistory } from '../../generated/type/entityHistory'; | ||||
| @ -29,4 +30,5 @@ export interface TopicVersionProp { | ||||
|   deleted?: boolean; | ||||
|   backHandler: () => void; | ||||
|   versionHandler: (v: string) => void; | ||||
|   entityPermissions: OperationPermission; | ||||
| } | ||||
|  | ||||
| @ -32,7 +32,7 @@ import { | ||||
| } from 'rest/dashboardAPI'; | ||||
| import { postThread } from 'rest/feedsAPI'; | ||||
| import { getVersionPath } from '../../constants/constants'; | ||||
| import { EntityType } from '../../enums/entity.enum'; | ||||
| import { EntityType, TabSpecificField } from '../../enums/entity.enum'; | ||||
| import { CreateThread } from '../../generated/api/feed/createThread'; | ||||
| import { Chart } from '../../generated/entity/data/chart'; | ||||
| import { Dashboard } from '../../generated/entity/data/dashboard'; | ||||
| @ -101,6 +101,24 @@ const DashboardDetailsPage = () => { | ||||
|     return patchDashboardDetails(dashboardId, jsonPatch); | ||||
|   }; | ||||
| 
 | ||||
|   const fetchUsageSummaryDetails = async (dashboardFQN: string) => { | ||||
|     setLoading(true); | ||||
| 
 | ||||
|     try { | ||||
|       const res = await getDashboardByFqn( | ||||
|         dashboardFQN, | ||||
|         TabSpecificField.USAGE_SUMMARY | ||||
|       ); | ||||
| 
 | ||||
|       const { usageSummary } = res; | ||||
|       setDashboardDetails((dashboard) => ({ ...dashboard, usageSummary })); | ||||
|     } catch (error) { | ||||
|       // Error here
 | ||||
|     } finally { | ||||
|       setLoading(false); | ||||
|     } | ||||
|   }; | ||||
| 
 | ||||
|   const fetchDashboardDetail = async (dashboardFQN: string) => { | ||||
|     setLoading(true); | ||||
| 
 | ||||
| @ -276,6 +294,9 @@ const DashboardDetailsPage = () => { | ||||
|     if (dashboardPermissions.ViewAll || dashboardPermissions.ViewBasic) { | ||||
|       fetchDashboardDetail(dashboardFQN); | ||||
|     } | ||||
|     if (dashboardPermissions.ViewUsage) { | ||||
|       fetchUsageSummaryDetails(dashboardFQN); | ||||
|     } | ||||
|   }, [dashboardFQN, dashboardPermissions]); | ||||
| 
 | ||||
|   useEffect(() => { | ||||
|  | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -51,36 +51,36 @@ jest.mock('components/DataModelVersion/DataModelVersion.component', () => { | ||||
| }); | ||||
| 
 | ||||
| jest.mock('rest/dashboardAPI', () => ({ | ||||
|   getDashboardByFqn: jest.fn().mockImplementation(() => Promise.resolve()), | ||||
|   getDashboardVersion: jest.fn().mockImplementation(() => Promise.resolve()), | ||||
|   getDashboardVersions: jest.fn().mockImplementation(() => Promise.resolve()), | ||||
|   getDashboardByFqn: jest.fn().mockImplementation(() => Promise.resolve({})), | ||||
|   getDashboardVersion: jest.fn().mockImplementation(() => Promise.resolve({})), | ||||
|   getDashboardVersions: jest.fn().mockImplementation(() => Promise.resolve({})), | ||||
| })); | ||||
| jest.mock('rest/pipelineAPI', () => ({ | ||||
|   getPipelineByFqn: jest.fn().mockImplementation(() => Promise.resolve()), | ||||
|   getPipelineVersion: jest.fn().mockImplementation(() => Promise.resolve()), | ||||
|   getPipelineVersions: jest.fn().mockImplementation(() => Promise.resolve()), | ||||
|   getPipelineByFqn: jest.fn().mockImplementation(() => Promise.resolve({})), | ||||
|   getPipelineVersion: jest.fn().mockImplementation(() => Promise.resolve({})), | ||||
|   getPipelineVersions: jest.fn().mockImplementation(() => Promise.resolve({})), | ||||
| })); | ||||
| jest.mock('rest/tableAPI', () => ({ | ||||
|   getTableDetailsByFQN: jest.fn().mockImplementation(() => Promise.resolve()), | ||||
|   getTableVersion: jest.fn().mockImplementation(() => Promise.resolve()), | ||||
|   getTableVersions: jest.fn().mockImplementation(() => Promise.resolve()), | ||||
|   getTableDetailsByFQN: jest.fn().mockImplementation(() => Promise.resolve({})), | ||||
|   getTableVersion: jest.fn().mockImplementation(() => Promise.resolve({})), | ||||
|   getTableVersions: jest.fn().mockImplementation(() => Promise.resolve({})), | ||||
| })); | ||||
| jest.mock('rest/topicsAPI', () => ({ | ||||
|   getTopicByFqn: jest.fn().mockImplementation(() => Promise.resolve()), | ||||
|   getTopicVersion: jest.fn().mockImplementation(() => Promise.resolve()), | ||||
|   getTopicVersions: jest.fn().mockImplementation(() => Promise.resolve()), | ||||
|   getTopicByFqn: jest.fn().mockImplementation(() => Promise.resolve({})), | ||||
|   getTopicVersion: jest.fn().mockImplementation(() => Promise.resolve({})), | ||||
|   getTopicVersions: jest.fn().mockImplementation(() => Promise.resolve({})), | ||||
| })); | ||||
| 
 | ||||
| jest.mock('rest/mlModelAPI', () => ({ | ||||
|   getMlModelByFQN: jest.fn().mockImplementation(() => Promise.resolve()), | ||||
|   getMlModelVersion: jest.fn().mockImplementation(() => Promise.resolve()), | ||||
|   getMlModelVersions: jest.fn().mockImplementation(() => Promise.resolve()), | ||||
|   getMlModelByFQN: jest.fn().mockImplementation(() => Promise.resolve({})), | ||||
|   getMlModelVersion: jest.fn().mockImplementation(() => Promise.resolve({})), | ||||
|   getMlModelVersions: jest.fn().mockImplementation(() => Promise.resolve({})), | ||||
| })); | ||||
| 
 | ||||
| jest.mock('rest/storageAPI', () => ({ | ||||
|   getContainerByName: jest.fn().mockImplementation(() => Promise.resolve()), | ||||
|   getContainerVersion: jest.fn().mockImplementation(() => Promise.resolve()), | ||||
|   getContainerVersions: jest.fn().mockImplementation(() => Promise.resolve()), | ||||
|   getContainerByName: jest.fn().mockImplementation(() => Promise.resolve({})), | ||||
|   getContainerVersion: jest.fn().mockImplementation(() => Promise.resolve({})), | ||||
|   getContainerVersions: jest.fn().mockImplementation(() => Promise.resolve({})), | ||||
| })); | ||||
| 
 | ||||
| jest.mock('components/containers/PageLayoutV1', () => | ||||
| @ -90,11 +90,11 @@ jest.mock('components/containers/PageLayoutV1', () => | ||||
| jest.mock('rest/dataModelsAPI', () => ({ | ||||
|   getDataModelDetailsByFQN: jest | ||||
|     .fn() | ||||
|     .mockImplementation(() => Promise.resolve()), | ||||
|   getDataModelVersion: jest.fn().mockImplementation(() => Promise.resolve()), | ||||
|     .mockImplementation(() => Promise.resolve({})), | ||||
|   getDataModelVersion: jest.fn().mockImplementation(() => Promise.resolve({})), | ||||
|   getDataModelVersionsList: jest | ||||
|     .fn() | ||||
|     .mockImplementation(() => Promise.resolve()), | ||||
|     .mockImplementation(() => Promise.resolve({})), | ||||
| })); | ||||
| 
 | ||||
| describe('Test EntityVersionPage component', () => { | ||||
|  | ||||
| @ -143,7 +143,7 @@ const MlModelPage = () => { | ||||
|       const { oldValue } = res.changeDescription.fieldsDeleted[0]; | ||||
|       setMlModelDetail((preVDetail) => ({ | ||||
|         ...preVDetail, | ||||
|         followers: (mlModelDetail.followers || []).filter( | ||||
|         followers: (mlModelDetail.followers ?? []).filter( | ||||
|           (follower) => follower.id !== oldValue[0].id | ||||
|         ), | ||||
|       })); | ||||
| @ -162,7 +162,7 @@ const MlModelPage = () => { | ||||
|       const res = await saveUpdatedMlModelData(updatedMlModel); | ||||
|       setMlModelDetail((preVDetail) => ({ | ||||
|         ...preVDetail, | ||||
|         tags: sortTagsCaseInsensitive(res.tags || []), | ||||
|         tags: sortTagsCaseInsensitive(res.tags ?? []), | ||||
|       })); | ||||
|       setCurrentVersion(res.version?.toString()); | ||||
|     } catch (error) { | ||||
|  | ||||
| @ -44,7 +44,13 @@ import { FQN_SEPARATOR_CHAR } from 'constants/char.constants'; | ||||
| import { getTableTabPath, getVersionPath } from 'constants/constants'; | ||||
| import { EntityField } from 'constants/Feeds.constants'; | ||||
| import { mockDatasetData } from 'constants/mockTourData.constants'; | ||||
| import { EntityTabs, EntityType, FqnPart } from 'enums/entity.enum'; | ||||
| import { ERROR_PLACEHOLDER_TYPE } from 'enums/common.enum'; | ||||
| import { | ||||
|   EntityTabs, | ||||
|   EntityType, | ||||
|   FqnPart, | ||||
|   TabSpecificField, | ||||
| } from 'enums/entity.enum'; | ||||
| import { compare } from 'fast-json-patch'; | ||||
| import { CreateThread } from 'generated/api/feed/createThread'; | ||||
| import { JoinedWith, Table } from 'generated/entity/data/table'; | ||||
| @ -120,6 +126,40 @@ const TableDetailsPageV1 = () => { | ||||
|     } | ||||
|   }; | ||||
| 
 | ||||
|   const fetchUsageDetails = async () => { | ||||
|     setLoading(true); | ||||
|     try { | ||||
|       const { usageSummary } = await getTableDetailsByFQN( | ||||
|         datasetFQN, | ||||
|         TabSpecificField.USAGE_SUMMARY | ||||
|       ); | ||||
| 
 | ||||
|       setTableDetails((table) => | ||||
|         table ? { ...table, usageSummary } : undefined | ||||
|       ); | ||||
|     } catch (error) { | ||||
|       // Error here
 | ||||
|     } finally { | ||||
|       setLoading(false); | ||||
|     } | ||||
|   }; | ||||
| 
 | ||||
|   const fetchTestSuiteDetails = async () => { | ||||
|     setLoading(true); | ||||
|     try { | ||||
|       const { testSuite } = await getTableDetailsByFQN( | ||||
|         datasetFQN, | ||||
|         TabSpecificField.TESTSUITE | ||||
|       ); | ||||
| 
 | ||||
|       setTableDetails((table) => (table ? { ...table, testSuite } : undefined)); | ||||
|     } catch (error) { | ||||
|       // Error here
 | ||||
|     } finally { | ||||
|       setLoading(false); | ||||
|     } | ||||
|   }; | ||||
| 
 | ||||
|   const fetchQueryCount = async () => { | ||||
|     if (!tableDetails?.id) { | ||||
|       return; | ||||
| @ -531,11 +571,13 @@ const TableDetailsPageV1 = () => { | ||||
|             name={t('label.sample-data')} | ||||
|           /> | ||||
|         ), | ||||
|         isHidden: !( | ||||
|           tablePermissions.ViewAll || tablePermissions.ViewSampleData | ||||
|         ), | ||||
| 
 | ||||
|         key: EntityTabs.SAMPLE_DATA, | ||||
|         children: ( | ||||
|         children: !( | ||||
|           tablePermissions.ViewAll || tablePermissions.ViewSampleData | ||||
|         ) ? ( | ||||
|           <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} /> | ||||
|         ) : ( | ||||
|           <SampleDataTableComponent | ||||
|             isTableDeleted={tableDetails?.deleted} | ||||
|             tableId={tableDetails?.id ?? ''} | ||||
| @ -551,13 +593,12 @@ const TableDetailsPageV1 = () => { | ||||
|             name={t('label.query-plural')} | ||||
|           /> | ||||
|         ), | ||||
|         isHidden: !( | ||||
|           tablePermissions.ViewAll || | ||||
|           tablePermissions.ViewBasic || | ||||
|           tablePermissions.ViewQueries | ||||
|         ), | ||||
|         key: EntityTabs.TABLE_QUERIES, | ||||
|         children: ( | ||||
|         children: !( | ||||
|           tablePermissions.ViewAll || tablePermissions.ViewQueries | ||||
|         ) ? ( | ||||
|           <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} /> | ||||
|         ) : ( | ||||
|           <TableQueries | ||||
|             isTableDeleted={tableDetails?.deleted} | ||||
|             tableId={tableDetails?.id ?? ''} | ||||
| @ -571,14 +612,14 @@ const TableDetailsPageV1 = () => { | ||||
|             name={t('label.profiler-amp-data-quality')} | ||||
|           /> | ||||
|         ), | ||||
|         isHidden: !( | ||||
|         key: EntityTabs.PROFILER, | ||||
|         children: !( | ||||
|           tablePermissions.ViewAll || | ||||
|           tablePermissions.ViewBasic || | ||||
|           tablePermissions.ViewDataProfile || | ||||
|           tablePermissions.ViewTests | ||||
|         ), | ||||
|         key: EntityTabs.PROFILER, | ||||
|         children: ( | ||||
|         ) ? ( | ||||
|           <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} /> | ||||
|         ) : ( | ||||
|           <TableProfilerV1 | ||||
|             isTableDeleted={tableDetails?.deleted} | ||||
|             permissions={tablePermissions} | ||||
| @ -651,7 +692,9 @@ const TableDetailsPageV1 = () => { | ||||
|           /> | ||||
|         ), | ||||
|         key: EntityTabs.CUSTOM_PROPERTIES, | ||||
|         children: ( | ||||
|         children: !tablePermissions.ViewAll ? ( | ||||
|           <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} /> | ||||
|         ) : ( | ||||
|           <CustomPropertyTable | ||||
|             entityDetails={tableDetails as CustomPropertyProps['entityDetails']} | ||||
|             entityType={EntityType.TABLE} | ||||
| @ -793,6 +836,12 @@ const TableDetailsPageV1 = () => { | ||||
|     } else { | ||||
|       fetchTableDetails(); | ||||
|       getEntityFeedCount(); | ||||
|       if (tablePermissions.ViewUsage) { | ||||
|         fetchUsageDetails(); | ||||
|       } | ||||
|       if (tablePermissions.ViewTests) { | ||||
|         fetchTestSuiteDetails(); | ||||
|       } | ||||
|     } | ||||
|   }, [datasetFQN, isTourOpen, isTourPage]); | ||||
| 
 | ||||
| @ -825,6 +874,10 @@ const TableDetailsPageV1 = () => { | ||||
|     return <Loader />; | ||||
|   } | ||||
| 
 | ||||
|   if (!(tablePermissions.ViewAll || tablePermissions.ViewBasic)) { | ||||
|     return <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} />; | ||||
|   } | ||||
| 
 | ||||
|   if (!tableDetails) { | ||||
|     return <ErrorPlaceHolder className="m-0" />; | ||||
|   } | ||||
|  | ||||
| @ -239,6 +239,7 @@ const TopicDetailsPage: FunctionComponent = () => { | ||||
|       createThread={createThread} | ||||
|       followTopicHandler={followTopic} | ||||
|       topicDetails={topicDetails} | ||||
|       topicPermissions={topicPermissions} | ||||
|       unFollowTopicHandler={unFollowTopic} | ||||
|       versionHandler={versionHandler} | ||||
|       onTopicUpdate={onTopicUpdate} | ||||
|  | ||||
| @ -18,8 +18,7 @@ import { TabSpecificField } from '../enums/entity.enum'; | ||||
| import { Dashboard } from '../generated/entity/data/dashboard'; | ||||
| import { sortTagsCaseInsensitive } from './CommonUtils'; | ||||
| 
 | ||||
| export const defaultFields = `${TabSpecificField.OWNER}, ${TabSpecificField.FOLLOWERS}, ${TabSpecificField.TAGS},
 | ||||
| ${TabSpecificField.USAGE_SUMMARY}, ${TabSpecificField.CHARTS},${TabSpecificField.EXTENSION}`;
 | ||||
| export const defaultFields = `${TabSpecificField.OWNER}, ${TabSpecificField.FOLLOWERS}, ${TabSpecificField.TAGS}, ${TabSpecificField.CHARTS},${TabSpecificField.EXTENSION}`; | ||||
| 
 | ||||
| export const sortTagsForCharts = (charts: ChartType[]) => { | ||||
|   return charts.map((chart) => ({ | ||||
|  | ||||
| @ -13,6 +13,6 @@ | ||||
| 
 | ||||
| import { TabSpecificField } from '../enums/entity.enum'; | ||||
| 
 | ||||
| export const defaultFields = `${TabSpecificField.COLUMNS}, ${TabSpecificField.USAGE_SUMMARY}, 
 | ||||
| export const defaultFields = `${TabSpecificField.COLUMNS}, 
 | ||||
| ${TabSpecificField.FOLLOWERS}, ${TabSpecificField.JOINS}, ${TabSpecificField.TAGS}, ${TabSpecificField.OWNER},  | ||||
| ${TabSpecificField.DATAMODEL},${TabSpecificField.TABLE_CONSTRAINTS},${TabSpecificField.EXTENSION},${TabSpecificField.TESTSUITE},${TabSpecificField.VIEW_DEFINITION}`;
 | ||||
| ${TabSpecificField.DATAMODEL},${TabSpecificField.TABLE_CONSTRAINTS},${TabSpecificField.EXTENSION},${TabSpecificField.VIEW_DEFINITION}`;
 | ||||
|  | ||||
| @ -13,5 +13,4 @@ | ||||
| 
 | ||||
| import { TabSpecificField } from '../enums/entity.enum'; | ||||
| 
 | ||||
| export const defaultFields = `${TabSpecificField.USAGE_SUMMARY}, 
 | ||||
| ${TabSpecificField.FOLLOWERS}, ${TabSpecificField.TAGS}, ${TabSpecificField.OWNER}, ${TabSpecificField.DASHBOARD} ,${TabSpecificField.EXTENSION}`;
 | ||||
| export const defaultFields = `${TabSpecificField.FOLLOWERS}, ${TabSpecificField.TAGS}, ${TabSpecificField.OWNER}, ${TabSpecificField.DASHBOARD} ,${TabSpecificField.EXTENSION}`; | ||||
|  | ||||
| @ -23,7 +23,7 @@ import { sortTagsCaseInsensitive } from './CommonUtils'; | ||||
| import { Icons } from './SvgUtils'; | ||||
| 
 | ||||
| export const defaultFields = `${TabSpecificField.FOLLOWERS}, ${TabSpecificField.TAGS}, ${TabSpecificField.OWNER},
 | ||||
| ${TabSpecificField.TASKS}, ${TabSpecificField.PIPELINE_STATUS},${TabSpecificField.EXTENSION}, ${TabSpecificField.SCHEDULE_INTERVAL}`;
 | ||||
| ${TabSpecificField.TASKS}, ${TabSpecificField.PIPELINE_STATUS},${TabSpecificField.EXTENSION}`;
 | ||||
| 
 | ||||
| export const pipelineDetailsTabs = [ | ||||
|   { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Aniket Katkar
						Aniket Katkar