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
This commit is contained in:
Aniket Katkar 2023-07-31 21:15:32 +05:30 committed by GitHub
parent 43fdf78d73
commit f215a4424f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 138 additions and 139 deletions

View File

@ -40,7 +40,7 @@ import { compare, Operation } from 'fast-json-patch';
import { LabelType } from 'generated/entity/data/table'; import { LabelType } from 'generated/entity/data/table';
import { Include } from 'generated/type/include'; import { Include } from 'generated/type/include';
import { State, TagSource } from 'generated/type/tagLabel'; import { State, TagSource } from 'generated/type/tagLabel';
import { isNil, isUndefined } from 'lodash'; import { isEmpty, isNil, isUndefined } from 'lodash';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import { EntityTags } from 'Models'; import { EntityTags } from 'Models';
import React, { import React, {
@ -61,6 +61,7 @@ import {
} from 'rest/databaseAPI'; } from 'rest/databaseAPI';
import { getFeedCount, postThread } from 'rest/feedsAPI'; import { getFeedCount, postThread } from 'rest/feedsAPI';
import { handleDataAssetAfterDeleteAction } from 'utils/Assets/AssetsUtils'; import { handleDataAssetAfterDeleteAction } from 'utils/Assets/AssetsUtils';
import { getEntityMissingError } from 'utils/CommonUtils';
import { default as appState } from '../../AppState'; import { default as appState } from '../../AppState';
import { FQN_SEPARATOR_CHAR } from '../../constants/char.constants'; import { FQN_SEPARATOR_CHAR } from '../../constants/char.constants';
import { import {
@ -87,7 +88,6 @@ import {
} from '../../utils/EntityUtils'; } from '../../utils/EntityUtils';
import { getEntityFieldThreadCounts } from '../../utils/FeedUtils'; import { getEntityFieldThreadCounts } from '../../utils/FeedUtils';
import { DEFAULT_ENTITY_PERMISSION } from '../../utils/PermissionsUtils'; import { DEFAULT_ENTITY_PERMISSION } from '../../utils/PermissionsUtils';
import { getErrorText } from '../../utils/StringsUtils';
import { import {
getTagsWithoutTier, getTagsWithoutTier,
getTierTags, getTierTags,
@ -122,7 +122,6 @@ const DatabaseDetails: FunctionComponent = () => {
const [databaseSchemaInstanceCount, setSchemaInstanceCount] = const [databaseSchemaInstanceCount, setSchemaInstanceCount] =
useState<number>(0); useState<number>(0);
const [error, setError] = useState('');
const [feedCount, setFeedCount] = useState<number>(0); const [feedCount, setFeedCount] = useState<number>(0);
const [entityFieldThreadCount, setEntityFieldThreadCount] = useState< const [entityFieldThreadCount, setEntityFieldThreadCount] = useState<
EntityFieldThreadCount[] EntityFieldThreadCount[]
@ -149,7 +148,7 @@ const DatabaseDetails: FunctionComponent = () => {
); );
setDatabasePermission(response); setDatabasePermission(response);
} catch (error) { } catch (error) {
showErrorToast(error as AxiosError); // Error
} finally { } finally {
setIsLoading(false); setIsLoading(false);
} }
@ -177,13 +176,8 @@ const DatabaseDetails: FunctionComponent = () => {
} }
resolve(); resolve();
}) })
.catch((err: AxiosError) => { .catch(() => {
showErrorToast( // Error
err,
t('server.entity-fetch-error', {
entity: t('label.database schema'),
})
);
reject(); reject();
}) })
@ -218,8 +212,8 @@ const DatabaseDetails: FunctionComponent = () => {
throw t('server.unexpected-response'); throw t('server.unexpected-response');
} }
}) })
.catch((err: AxiosError) => { .catch(() => {
showErrorToast(err, t('server.entity-feed-fetch-error')); // Error
}); });
}; };
@ -236,19 +230,10 @@ const DatabaseDetails: FunctionComponent = () => {
setServiceType(serviceType); setServiceType(serviceType);
setShowDeletedSchemas(res.deleted ?? false); setShowDeletedSchemas(res.deleted ?? false);
fetchDatabaseSchemasAndDBTModels(); fetchDatabaseSchemasAndDBTModels();
} else {
throw t('server.unexpected-response');
} }
}) })
.catch((err: AxiosError) => { .catch(() => {
const errMsg = getErrorText( // Error
err,
t('server.entity-fetch-error', {
entity: t('label.database'),
})
);
setError(errMsg);
showErrorToast(errMsg);
}) })
.finally(() => { .finally(() => {
setIsLoading(false); setIsLoading(false);
@ -735,14 +720,6 @@ const DatabaseDetails: FunctionComponent = () => {
return <Loader />; return <Loader />;
} }
if (error) {
return (
<ErrorPlaceHolder>
<p data-testid="error-message">{error}</p>
</ErrorPlaceHolder>
);
}
if (!(databasePermission.ViewAll || databasePermission.ViewBasic)) { if (!(databasePermission.ViewAll || databasePermission.ViewBasic)) {
return <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} />; return <ErrorPlaceHolder type={ERROR_PLACEHOLDER_TYPE.PERMISSION} />;
} }
@ -753,6 +730,11 @@ const DatabaseDetails: FunctionComponent = () => {
pageTitle={t('label.entity-detail-plural', { pageTitle={t('label.entity-detail-plural', {
entity: getEntityName(database), entity: getEntityName(database),
})}> })}>
{isEmpty(database) ? (
<ErrorPlaceHolder className="m-0">
{getEntityMissingError(EntityType.DATABASE, databaseFQN)}
</ErrorPlaceHolder>
) : (
<Row gutter={[0, 12]}> <Row gutter={[0, 12]}>
<Col className="p-x-lg" span={24}> <Col className="p-x-lg" span={24}>
<DataAssetsHeader <DataAssetsHeader
@ -789,6 +771,7 @@ const DatabaseDetails: FunctionComponent = () => {
/> />
) : null} ) : null}
</Row> </Row>
)}
</PageLayoutV1> </PageLayoutV1>
); );
}; };

View File

@ -36,7 +36,7 @@ import { compare, Operation } from 'fast-json-patch';
import { ThreadType } from 'generated/entity/feed/thread'; import { ThreadType } from 'generated/entity/feed/thread';
import { Include } from 'generated/type/include'; import { Include } from 'generated/type/include';
import { LabelType, State, TagLabel, TagSource } from 'generated/type/tagLabel'; 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 { observer } from 'mobx-react';
import { EntityTags, PagingResponse } from 'Models'; import { EntityTags, PagingResponse } from 'Models';
import React, { import React, {
@ -57,6 +57,7 @@ import {
import { getFeedCount, postThread } from 'rest/feedsAPI'; import { getFeedCount, postThread } from 'rest/feedsAPI';
import { getTableList, TableListParams } from 'rest/tableAPI'; import { getTableList, TableListParams } from 'rest/tableAPI';
import { handleDataAssetAfterDeleteAction } from 'utils/Assets/AssetsUtils'; import { handleDataAssetAfterDeleteAction } from 'utils/Assets/AssetsUtils';
import { getEntityMissingError } from 'utils/CommonUtils';
import { default as appState } from '../../AppState'; import { default as appState } from '../../AppState';
import { import {
getDatabaseSchemaDetailsPath, getDatabaseSchemaDetailsPath,
@ -577,6 +578,11 @@ const DatabaseSchemaPage: FunctionComponent = () => {
pageTitle={t('label.entity-detail-plural', { pageTitle={t('label.entity-detail-plural', {
entity: getEntityName(databaseSchema), entity: getEntityName(databaseSchema),
})}> })}>
{isEmpty(databaseSchema) ? (
<ErrorPlaceHolder className="m-0">
{getEntityMissingError(EntityType.DATABASE_SCHEMA, databaseSchemaFQN)}
</ErrorPlaceHolder>
) : (
<Row gutter={[0, 12]}> <Row gutter={[0, 12]}>
<Col className="p-x-lg" span={24}> <Col className="p-x-lg" span={24}>
{isSchemaDetailsLoading ? ( {isSchemaDetailsLoading ? (
@ -625,6 +631,7 @@ const DatabaseSchemaPage: FunctionComponent = () => {
) : null} ) : null}
</Col> </Col>
</Row> </Row>
)}
</PageLayoutV1> </PageLayoutV1>
); );
}; };

View File

@ -97,6 +97,8 @@ import { getPipelines } from 'rest/pipelineAPI';
import { getServiceByFQN, patchService } from 'rest/serviceAPI'; import { getServiceByFQN, patchService } from 'rest/serviceAPI';
import { getContainers } from 'rest/storageAPI'; import { getContainers } from 'rest/storageAPI';
import { getTopics } from 'rest/topicsAPI'; import { getTopics } from 'rest/topicsAPI';
import { handleDataAssetAfterDeleteAction } from 'utils/Assets/AssetsUtils';
import { getEntityMissingError } from 'utils/CommonUtils';
import { getEntityName } from 'utils/EntityUtils'; import { getEntityName } from 'utils/EntityUtils';
import { DEFAULT_ENTITY_PERMISSION } from 'utils/PermissionsUtils'; import { DEFAULT_ENTITY_PERMISSION } from 'utils/PermissionsUtils';
import { getEditConnectionPath } from 'utils/RouterUtils'; import { getEditConnectionPath } from 'utils/RouterUtils';
@ -1008,10 +1010,16 @@ const ServiceDetailsPage: FunctionComponent = () => {
pageTitle={t('label.entity-detail-plural', { pageTitle={t('label.entity-detail-plural', {
entity: getEntityName(serviceDetails), entity: getEntityName(serviceDetails),
})}> })}>
{isEmpty(serviceDetails) ? (
<ErrorPlaceHolder className="m-0">
{getEntityMissingError(serviceCategory as string, serviceFQN)}
</ErrorPlaceHolder>
) : (
<Row data-testid="service-page" gutter={[0, 12]}> <Row data-testid="service-page" gutter={[0, 12]}>
<Col className="p-x-lg" span={24}> <Col className="p-x-lg" span={24}>
<DataAssetsHeader <DataAssetsHeader
isRecursiveDelete isRecursiveDelete
afterDeleteAction={handleDataAssetAfterDeleteAction}
allowSoftDelete={false} allowSoftDelete={false}
dataAsset={serviceDetails} dataAsset={serviceDetails}
entityType={entityType} entityType={entityType}
@ -1033,6 +1041,7 @@ const ServiceDetailsPage: FunctionComponent = () => {
/> />
</Col> </Col>
</Row> </Row>
)}
</PageLayoutV1> </PageLayoutV1>
); );
}; };