From f215a4424ff4f15acbfead9bdbcb9204d1cc12ca Mon Sep 17 00:00:00 2001 From: Aniket Katkar Date: Mon, 31 Jul 2023 21:15:32 +0530 Subject: [PATCH] fix(ui): service, database and database schema page bugs (#12673) * fixed bugs on service details page * fixed bugs on database details page refactored database details page code * fixed bugs on database schema page * reverted the changes for code refactoring on dataset details page --- .../DatabaseDetailsPage.tsx | 117 ++++++++---------- .../DatabaseSchemaPage.component.tsx | 103 ++++++++------- .../ServiceDetailsPage/ServiceDetailsPage.tsx | 57 +++++---- 3 files changed, 138 insertions(+), 139 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/DatabaseDetailsPage/DatabaseDetailsPage.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/DatabaseDetailsPage/DatabaseDetailsPage.tsx index 88340f313b6..f59bd58b4ad 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/DatabaseDetailsPage/DatabaseDetailsPage.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/DatabaseDetailsPage/DatabaseDetailsPage.tsx @@ -40,7 +40,7 @@ import { compare, Operation } from 'fast-json-patch'; import { LabelType } from 'generated/entity/data/table'; import { Include } from 'generated/type/include'; import { State, TagSource } from 'generated/type/tagLabel'; -import { isNil, isUndefined } from 'lodash'; +import { isEmpty, isNil, isUndefined } from 'lodash'; import { observer } from 'mobx-react'; import { EntityTags } from 'Models'; import React, { @@ -61,6 +61,7 @@ import { } from 'rest/databaseAPI'; import { getFeedCount, postThread } from 'rest/feedsAPI'; import { handleDataAssetAfterDeleteAction } from 'utils/Assets/AssetsUtils'; +import { getEntityMissingError } from 'utils/CommonUtils'; import { default as appState } from '../../AppState'; import { FQN_SEPARATOR_CHAR } from '../../constants/char.constants'; import { @@ -87,7 +88,6 @@ import { } from '../../utils/EntityUtils'; import { getEntityFieldThreadCounts } from '../../utils/FeedUtils'; import { DEFAULT_ENTITY_PERMISSION } from '../../utils/PermissionsUtils'; -import { getErrorText } from '../../utils/StringsUtils'; import { getTagsWithoutTier, getTierTags, @@ -122,7 +122,6 @@ const DatabaseDetails: FunctionComponent = () => { const [databaseSchemaInstanceCount, setSchemaInstanceCount] = useState(0); - const [error, setError] = useState(''); const [feedCount, setFeedCount] = useState(0); const [entityFieldThreadCount, setEntityFieldThreadCount] = useState< EntityFieldThreadCount[] @@ -149,7 +148,7 @@ const DatabaseDetails: FunctionComponent = () => { ); setDatabasePermission(response); } catch (error) { - showErrorToast(error as AxiosError); + // Error } finally { setIsLoading(false); } @@ -177,13 +176,8 @@ const DatabaseDetails: FunctionComponent = () => { } resolve(); }) - .catch((err: AxiosError) => { - showErrorToast( - err, - t('server.entity-fetch-error', { - entity: t('label.database schema'), - }) - ); + .catch(() => { + // Error reject(); }) @@ -218,8 +212,8 @@ const DatabaseDetails: FunctionComponent = () => { throw t('server.unexpected-response'); } }) - .catch((err: AxiosError) => { - showErrorToast(err, t('server.entity-feed-fetch-error')); + .catch(() => { + // Error }); }; @@ -236,19 +230,10 @@ const DatabaseDetails: FunctionComponent = () => { setServiceType(serviceType); setShowDeletedSchemas(res.deleted ?? false); fetchDatabaseSchemasAndDBTModels(); - } else { - throw t('server.unexpected-response'); } }) - .catch((err: AxiosError) => { - const errMsg = getErrorText( - err, - t('server.entity-fetch-error', { - entity: t('label.database'), - }) - ); - setError(errMsg); - showErrorToast(errMsg); + .catch(() => { + // Error }) .finally(() => { setIsLoading(false); @@ -735,14 +720,6 @@ const DatabaseDetails: FunctionComponent = () => { return ; } - if (error) { - return ( - -

{error}

-
- ); - } - if (!(databasePermission.ViewAll || databasePermission.ViewBasic)) { return ; } @@ -753,42 +730,48 @@ const DatabaseDetails: FunctionComponent = () => { pageTitle={t('label.entity-detail-plural', { entity: getEntityName(database), })}> - - - - - - - + {isEmpty(database) ? ( + + {getEntityMissingError(EntityType.DATABASE, databaseFQN)} + + ) : ( + + + + + + + - {threadLink ? ( - - ) : null} - + {threadLink ? ( + + ) : null} + + )} ); }; diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/DatabaseSchemaPage/DatabaseSchemaPage.component.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/DatabaseSchemaPage/DatabaseSchemaPage.component.tsx index e25f11bdb06..39ecd7b75f4 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/DatabaseSchemaPage/DatabaseSchemaPage.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/DatabaseSchemaPage/DatabaseSchemaPage.component.tsx @@ -36,7 +36,7 @@ import { compare, Operation } from 'fast-json-patch'; import { ThreadType } from 'generated/entity/feed/thread'; import { Include } from 'generated/type/include'; import { LabelType, State, TagLabel, TagSource } from 'generated/type/tagLabel'; -import { isString, isUndefined } from 'lodash'; +import { isEmpty, isString, isUndefined } from 'lodash'; import { observer } from 'mobx-react'; import { EntityTags, PagingResponse } from 'Models'; import React, { @@ -57,6 +57,7 @@ import { import { getFeedCount, postThread } from 'rest/feedsAPI'; import { getTableList, TableListParams } from 'rest/tableAPI'; import { handleDataAssetAfterDeleteAction } from 'utils/Assets/AssetsUtils'; +import { getEntityMissingError } from 'utils/CommonUtils'; import { default as appState } from '../../AppState'; import { getDatabaseSchemaDetailsPath, @@ -577,54 +578,60 @@ const DatabaseSchemaPage: FunctionComponent = () => { pageTitle={t('label.entity-detail-plural', { entity: getEntityName(databaseSchema), })}> - - - {isSchemaDetailsLoading ? ( - + {getEntityMissingError(EntityType.DATABASE_SCHEMA, databaseSchemaFQN)} + + ) : ( + + + {isSchemaDetailsLoading ? ( + + ) : ( + + )} + + + - ) : ( - - )} - - - - - - {threadLink ? ( - - ) : null} - - + + + {threadLink ? ( + + ) : null} + + + )} ); }; diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/ServiceDetailsPage/ServiceDetailsPage.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/ServiceDetailsPage/ServiceDetailsPage.tsx index 420ebb30f82..f3f29049dc8 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/ServiceDetailsPage/ServiceDetailsPage.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/ServiceDetailsPage/ServiceDetailsPage.tsx @@ -97,6 +97,8 @@ import { getPipelines } from 'rest/pipelineAPI'; import { getServiceByFQN, patchService } from 'rest/serviceAPI'; import { getContainers } from 'rest/storageAPI'; import { getTopics } from 'rest/topicsAPI'; +import { handleDataAssetAfterDeleteAction } from 'utils/Assets/AssetsUtils'; +import { getEntityMissingError } from 'utils/CommonUtils'; import { getEntityName } from 'utils/EntityUtils'; import { DEFAULT_ENTITY_PERMISSION } from 'utils/PermissionsUtils'; import { getEditConnectionPath } from 'utils/RouterUtils'; @@ -1008,31 +1010,38 @@ const ServiceDetailsPage: FunctionComponent = () => { pageTitle={t('label.entity-detail-plural', { entity: getEntityName(serviceDetails), })}> - - - Promise.resolve()} - onTierUpdate={handleUpdateTier} - /> - + {isEmpty(serviceDetails) ? ( + + {getEntityMissingError(serviceCategory as string, serviceFQN)} + + ) : ( + + + Promise.resolve()} + onTierUpdate={handleUpdateTier} + /> + - - - - + + + + + )} ); };