mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-28 19:05:53 +00:00
fix(ui): tabs flickers on permission api response (#9957)
This commit is contained in:
parent
134a5b2c54
commit
72912d75a4
@ -16,7 +16,13 @@ import { AxiosError } from 'axios';
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { isEqual, isNil, isUndefined } from 'lodash';
|
import { isEqual, isNil, isUndefined } from 'lodash';
|
||||||
import { EntityTags, ExtraInfo } from 'Models';
|
import { EntityTags, ExtraInfo } from 'Models';
|
||||||
import React, { RefObject, useCallback, useEffect, useState } from 'react';
|
import React, {
|
||||||
|
RefObject,
|
||||||
|
useCallback,
|
||||||
|
useEffect,
|
||||||
|
useMemo,
|
||||||
|
useState,
|
||||||
|
} from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { restoreTable } from 'rest/tableAPI';
|
import { restoreTable } from 'rest/tableAPI';
|
||||||
@ -137,6 +143,7 @@ const DatasetDetails: React.FC<DatasetDetailsProps> = ({
|
|||||||
const [isFollowing, setIsFollowing] = useState(false);
|
const [isFollowing, setIsFollowing] = useState(false);
|
||||||
const [usage, setUsage] = useState('');
|
const [usage, setUsage] = useState('');
|
||||||
const [weeklyUsageCount, setWeeklyUsageCount] = useState('');
|
const [weeklyUsageCount, setWeeklyUsageCount] = useState('');
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [tableJoinData, setTableJoinData] = useState<TableJoins>({
|
const [tableJoinData, setTableJoinData] = useState<TableJoins>({
|
||||||
startDate: new Date(),
|
startDate: new Date(),
|
||||||
dayCount: 0,
|
dayCount: 0,
|
||||||
@ -158,6 +165,7 @@ const DatasetDetails: React.FC<DatasetDetailsProps> = ({
|
|||||||
const { getEntityPermission } = usePermissionProvider();
|
const { getEntityPermission } = usePermissionProvider();
|
||||||
|
|
||||||
const fetchResourcePermission = useCallback(async () => {
|
const fetchResourcePermission = useCallback(async () => {
|
||||||
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
const tablePermission = await getEntityPermission(
|
const tablePermission = await getEntityPermission(
|
||||||
ResourceEntity.TABLE,
|
ResourceEntity.TABLE,
|
||||||
@ -169,6 +177,8 @@ const DatasetDetails: React.FC<DatasetDetailsProps> = ({
|
|||||||
showErrorToast(
|
showErrorToast(
|
||||||
jsonData['api-error-messages']['fetch-entity-permissions-error']
|
jsonData['api-error-messages']['fetch-entity-permissions-error']
|
||||||
);
|
);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
}, [tableDetails.id, getEntityPermission, setTablePermissions]);
|
}, [tableDetails.id, getEntityPermission, setTablePermissions]);
|
||||||
|
|
||||||
@ -201,108 +211,111 @@ const DatasetDetails: React.FC<DatasetDetailsProps> = ({
|
|||||||
);
|
);
|
||||||
setFollowersCount(followers?.length);
|
setFollowersCount(followers?.length);
|
||||||
};
|
};
|
||||||
const tabs = [
|
const tabs = useMemo(
|
||||||
{
|
() => [
|
||||||
name: t('label.schema'),
|
{
|
||||||
icon: {
|
name: t('label.schema'),
|
||||||
alt: 'schema',
|
icon: {
|
||||||
name: 'icon-schema',
|
alt: 'schema',
|
||||||
title: 'Schema',
|
name: 'icon-schema',
|
||||||
selectedName: 'icon-schemacolor',
|
title: 'Schema',
|
||||||
|
selectedName: 'icon-schemacolor',
|
||||||
|
},
|
||||||
|
isProtected: false,
|
||||||
|
position: 1,
|
||||||
},
|
},
|
||||||
isProtected: false,
|
{
|
||||||
position: 1,
|
name: t('label.activity-feed-and-task-plural'),
|
||||||
},
|
icon: {
|
||||||
{
|
alt: 'activity_feed',
|
||||||
name: t('label.activity-feed-and-task-plural'),
|
name: 'activity_feed',
|
||||||
icon: {
|
title: 'Activity Feed',
|
||||||
alt: 'activity_feed',
|
selectedName: 'activity-feed-color',
|
||||||
name: 'activity_feed',
|
},
|
||||||
title: 'Activity Feed',
|
isProtected: false,
|
||||||
selectedName: 'activity-feed-color',
|
position: 2,
|
||||||
|
count: feedCount,
|
||||||
},
|
},
|
||||||
isProtected: false,
|
{
|
||||||
position: 2,
|
name: t('label.sample-data'),
|
||||||
count: feedCount,
|
icon: {
|
||||||
},
|
alt: 'sample_data',
|
||||||
{
|
name: 'sample-data',
|
||||||
name: t('label.sample-data'),
|
title: 'Sample Data',
|
||||||
icon: {
|
selectedName: 'sample-data-color',
|
||||||
alt: 'sample_data',
|
},
|
||||||
name: 'sample-data',
|
isProtected: false,
|
||||||
title: 'Sample Data',
|
isHidden: !(
|
||||||
selectedName: 'sample-data-color',
|
tablePermissions.ViewAll ||
|
||||||
|
tablePermissions.ViewBasic ||
|
||||||
|
tablePermissions.ViewSampleData
|
||||||
|
),
|
||||||
|
position: 3,
|
||||||
},
|
},
|
||||||
isProtected: false,
|
{
|
||||||
isHidden: !(
|
name: t('label.query-plural'),
|
||||||
tablePermissions.ViewAll ||
|
icon: {
|
||||||
tablePermissions.ViewBasic ||
|
alt: 'table_queries',
|
||||||
tablePermissions.ViewSampleData
|
name: 'table_queries',
|
||||||
),
|
title: 'Table Queries',
|
||||||
position: 3,
|
selectedName: '',
|
||||||
},
|
},
|
||||||
{
|
isProtected: false,
|
||||||
name: t('label.query-plural'),
|
isHidden: !(
|
||||||
icon: {
|
tablePermissions.ViewAll ||
|
||||||
alt: 'table_queries',
|
tablePermissions.ViewBasic ||
|
||||||
name: 'table_queries',
|
tablePermissions.ViewQueries
|
||||||
title: 'Table Queries',
|
),
|
||||||
selectedName: '',
|
position: 4,
|
||||||
},
|
},
|
||||||
isProtected: false,
|
{
|
||||||
isHidden: !(
|
name: t('label.profiler-amp-data-quality'),
|
||||||
tablePermissions.ViewAll ||
|
icon: {
|
||||||
tablePermissions.ViewBasic ||
|
alt: 'profiler',
|
||||||
tablePermissions.ViewQueries
|
name: 'icon-profiler',
|
||||||
),
|
title: 'Profiler',
|
||||||
position: 4,
|
selectedName: 'icon-profilercolor',
|
||||||
},
|
},
|
||||||
{
|
isProtected: false,
|
||||||
name: t('label.profiler-amp-data-quality'),
|
isHidden: !(
|
||||||
icon: {
|
tablePermissions.ViewAll ||
|
||||||
alt: 'profiler',
|
tablePermissions.ViewBasic ||
|
||||||
name: 'icon-profiler',
|
tablePermissions.ViewDataProfile ||
|
||||||
title: 'Profiler',
|
tablePermissions.ViewTests
|
||||||
selectedName: 'icon-profilercolor',
|
),
|
||||||
|
position: 5,
|
||||||
},
|
},
|
||||||
isProtected: false,
|
{
|
||||||
isHidden: !(
|
name: t('label.lineage'),
|
||||||
tablePermissions.ViewAll ||
|
icon: {
|
||||||
tablePermissions.ViewBasic ||
|
alt: 'lineage',
|
||||||
tablePermissions.ViewDataProfile ||
|
name: 'icon-lineage',
|
||||||
tablePermissions.ViewTests
|
title: 'Lineage',
|
||||||
),
|
selectedName: 'icon-lineagecolor',
|
||||||
position: 5,
|
},
|
||||||
},
|
isProtected: false,
|
||||||
{
|
position: 7,
|
||||||
name: t('label.lineage'),
|
|
||||||
icon: {
|
|
||||||
alt: 'lineage',
|
|
||||||
name: 'icon-lineage',
|
|
||||||
title: 'Lineage',
|
|
||||||
selectedName: 'icon-lineagecolor',
|
|
||||||
},
|
},
|
||||||
isProtected: false,
|
{
|
||||||
position: 7,
|
name: t('label.dbt-uppercase'),
|
||||||
},
|
icon: {
|
||||||
{
|
alt: 'dbt-model',
|
||||||
name: t('label.dbt-uppercase'),
|
name: 'dbtmodel-light-grey',
|
||||||
icon: {
|
title: 'DBT',
|
||||||
alt: 'dbt-model',
|
selectedName: 'dbtmodel-primery',
|
||||||
name: 'dbtmodel-light-grey',
|
},
|
||||||
title: 'DBT',
|
isProtected: false,
|
||||||
selectedName: 'dbtmodel-primery',
|
isHidden: !dataModel?.sql,
|
||||||
|
position: 8,
|
||||||
},
|
},
|
||||||
isProtected: false,
|
{
|
||||||
isHidden: !dataModel?.sql,
|
name: t('label.custom-property-plural'),
|
||||||
position: 8,
|
isProtected: false,
|
||||||
},
|
position: 9,
|
||||||
{
|
},
|
||||||
name: t('label.custom-property-plural'),
|
],
|
||||||
isProtected: false,
|
[tablePermissions, dataModel, feedCount]
|
||||||
position: 9,
|
);
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const getFrequentlyJoinedWithTables = (): Array<
|
const getFrequentlyJoinedWithTables = (): Array<
|
||||||
JoinedWith & { name: string }
|
JoinedWith & { name: string }
|
||||||
@ -622,7 +635,9 @@ const DatasetDetails: React.FC<DatasetDetailsProps> = ({
|
|||||||
[paging]
|
[paging]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return isLoading ? (
|
||||||
|
<Loader />
|
||||||
|
) : (
|
||||||
<PageContainerV1>
|
<PageContainerV1>
|
||||||
<div className="entity-details-container">
|
<div className="entity-details-container">
|
||||||
<EntityPageInfo
|
<EntityPageInfo
|
||||||
|
@ -659,7 +659,7 @@
|
|||||||
"delete-team-message": "Any teams under \"{{teamName}}\" will be {{deleteType}} deleted as well.",
|
"delete-team-message": "Any teams under \"{{teamName}}\" will be {{deleteType}} deleted as well.",
|
||||||
"delete-webhook-permanently": "You want to delete webhook {{webhookName}} permanently? This action cannot be reverted.",
|
"delete-webhook-permanently": "You want to delete webhook {{webhookName}} permanently? This action cannot be reverted.",
|
||||||
"discover-your-data-and-unlock-the-value-of-data-assets": "Discover your data and unlock the value of data assets.",
|
"discover-your-data-and-unlock-the-value-of-data-assets": "Discover your data and unlock the value of data assets.",
|
||||||
"elastic-search-message": "Manage Elastisearch related works here. You can trigger re-create indexes or check the status of re-creating indexes",
|
"elastic-search-message": "Ensure that your Elasticsearch indexes are up-to-date by syncing, or recreating all indexes.",
|
||||||
"email-is-invalid": "Invalid Email.",
|
"email-is-invalid": "Invalid Email.",
|
||||||
"enable-column-profile": "Enable column profile",
|
"enable-column-profile": "Enable column profile",
|
||||||
"enable-debug-logging": "Enable debug logging",
|
"enable-debug-logging": "Enable debug logging",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user