diff --git a/openmetadata-ui/src/main/resources/ui/src/components/DataAssetSummaryPanel/DataAssetSummaryPanel.tsx b/openmetadata-ui/src/main/resources/ui/src/components/DataAssetSummaryPanel/DataAssetSummaryPanel.tsx
index 0928cb430e9..0154dc03e94 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/DataAssetSummaryPanel/DataAssetSummaryPanel.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/DataAssetSummaryPanel/DataAssetSummaryPanel.tsx
@@ -144,7 +144,6 @@ export const DataAssetSummaryPanel = ({
dataAsset.id
);
setEntityPermissions(permissions);
- fetchEntityBasedDetails();
} else {
setEntityPermissions(null);
}
@@ -220,7 +219,10 @@ export const DataAssetSummaryPanel = ({
{entityType === EntityType.TABLE && (
-
+
)}
) {
const { t } = useTranslation();
const location = useCustomLocation();
const history = useHistory();
const isTourPage = location.pathname.includes(ROUTES.TOUR);
- const { getEntityPermission } = usePermissionProvider();
const [testSuiteSummary, setTestSuiteSummary] = useState();
const [tablePermissions, setTablePermissions] = useState(
DEFAULT_ENTITY_PERMISSION
);
-
+ useEffect(() => {
+ setTablePermissions(permissions as OperationPermission);
+ }, [permissions]);
// Since we are showing test cases summary in the table summary panel, we are using ViewTests permission
const viewTestCasesPermission = useMemo(
- () => tablePermissions.ViewAll || tablePermissions.ViewTests,
+ () => tablePermissions?.ViewAll || tablePermissions?.ViewTests,
[tablePermissions]
);
@@ -154,33 +154,21 @@ function TableSummary({ entityDetails: tableDetails }: TableSummaryProps) {
const init = useCallback(async () => {
if (tableDetails.id && !isTourPage) {
- const tablePermission = await getEntityPermission(
- ResourceEntity.TABLE,
- tableDetails.id
- );
- setTablePermissions(tablePermission);
const shouldFetchTestCaseData =
!isTableDeleted &&
tableDetails.service?.type === 'databaseService' &&
- (tablePermission.ViewAll || tablePermission.ViewTests);
-
+ (permissions?.ViewAll || permissions?.ViewTests);
if (shouldFetchTestCaseData) {
fetchAllTests();
}
} else {
setTablePermissions(mockTablePermission as OperationPermission);
}
- }, [
- tableDetails,
- isTourPage,
- isTableDeleted,
- fetchAllTests,
- getEntityPermission,
- ]);
+ }, [tableDetails, isTourPage, isTableDeleted, fetchAllTests, permissions]);
useEffect(() => {
init();
- }, [tableDetails.id]);
+ }, [tableDetails.id, permissions]);
return (
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/TableSummary/TableSummary.interface.ts b/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/TableSummary/TableSummary.interface.ts
index bb657152b25..18abb6bbe20 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/TableSummary/TableSummary.interface.ts
+++ b/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/TableSummary/TableSummary.interface.ts
@@ -11,10 +11,12 @@
* limitations under the License.
*/
+import { OperationPermission } from '../../../../context/PermissionProvider/PermissionProvider.interface';
import { Table } from '../../../../generated/entity/data/table';
export interface TableSummaryProps {
entityDetails: Table;
+ permissions: OperationPermission | null;
}
export interface TableProfileDetails {
diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/TableSummary/TableSummary.test.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/TableSummary/TableSummary.test.tsx
index 4bd732439a5..4e6d912d747 100644
--- a/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/TableSummary/TableSummary.test.tsx
+++ b/openmetadata-ui/src/main/resources/ui/src/components/Explore/EntitySummaryPanel/TableSummary/TableSummary.test.tsx
@@ -14,6 +14,7 @@
import { act, render, screen } from '@testing-library/react';
import React from 'react';
import { MemoryRouter } from 'react-router-dom';
+import { OperationPermission } from '../../../../context/PermissionProvider/PermissionProvider.interface';
import { getTestCaseExecutionSummary } from '../../../../rest/testAPI';
import { mockTableEntityDetails } from '../mocks/TableSummary.mock';
import TableSummary from './TableSummary.component';
@@ -69,9 +70,15 @@ jest.mock('../../../../context/PermissionProvider/PermissionProvider', () => ({
describe('TableSummary component tests', () => {
it('Component should render properly, when loaded in the Explore page.', async () => {
await act(async () => {
- render(, {
- wrapper: MemoryRouter,
- });
+ render(
+ ,
+ {
+ wrapper: MemoryRouter,
+ }
+ );
});
const profilerHeader = screen.getByTestId('profiler-header');
@@ -89,9 +96,15 @@ describe('TableSummary component tests', () => {
it('Component should render properly, when loaded in the Lineage page.', async () => {
await act(async () => {
- render(, {
- wrapper: MemoryRouter,
- });
+ render(
+ ,
+ {
+ wrapper: MemoryRouter,
+ }
+ );
});
const profilerHeader = screen.getByTestId('profiler-header');
@@ -117,9 +130,15 @@ describe('TableSummary component tests', () => {
);
await act(async () => {
- render(, {
- wrapper: MemoryRouter,
- });
+ render(
+ ,
+ {
+ wrapper: MemoryRouter,
+ }
+ );
});
const testsPassedLabel = screen.getByTestId('test-passed');
@@ -146,9 +165,15 @@ describe('TableSummary component tests', () => {
})
);
await act(async () => {
- render(, {
- wrapper: MemoryRouter,
- });
+ render(
+ ,
+ {
+ wrapper: MemoryRouter,
+ }
+ );
});
const testsPassedValue = screen.getByTestId('test-passed-value');
const testsAbortedValue = screen.getByTestId('test-aborted-value');