From a0b1a4e9255a935733e5bf57a40f85abeb321f04 Mon Sep 17 00:00:00 2001 From: Pranita Fulsundar Date: Fri, 6 Dec 2024 21:32:14 +0530 Subject: [PATCH] fix: reset current page to initial value on limit change in pagination (#18940) * fix: reset current page to initial value on limit change in pagination * fix: reset current page for APICollectionVersion page --------- Co-authored-by: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> --- .../TeamDetails/UserTab/UserTab.component.tsx | 1 + .../APICollectionPage/APICollectionPage.tsx | 16 ++++++++++------ .../APICollectionVersionPage.tsx | 18 ++++++++++-------- .../DatabaseSchemaPage.component.tsx | 18 +++++++++++------- .../DatabaseSchemaVersionPage.tsx | 12 ++++++++---- .../ServiceDetailsPage/ServiceDetailsPage.tsx | 2 +- 6 files changed, 41 insertions(+), 26 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Settings/Team/TeamDetails/UserTab/UserTab.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Settings/Team/TeamDetails/UserTab/UserTab.component.tsx index 6a14ba5647e..b4a4b0d1645 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Settings/Team/TeamDetails/UserTab/UserTab.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Settings/Team/TeamDetails/UserTab/UserTab.component.tsx @@ -188,6 +188,7 @@ export const UserTab = ({ useEffect(() => { getCurrentTeamUsers(currentTeam.name); + handlePageChange(INITIAL_PAGING_VALUE); }, [currentTeam, pageSize]); const isTeamDeleted = useMemo( diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/APICollectionPage/APICollectionPage.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/APICollectionPage/APICollectionPage.tsx index aaaf573e4db..04476b83ece 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/APICollectionPage/APICollectionPage.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/APICollectionPage/APICollectionPage.tsx @@ -103,7 +103,13 @@ const APICollectionPage: FunctionComponent = () => { const { getEntityPermissionByFqn } = usePermissionProvider(); const pagingInfo = usePaging(PAGE_SIZE); - const { paging, pageSize, handlePagingChange } = pagingInfo; + const { + paging, + pageSize, + handlePagingChange, + handlePageChange, + currentPage, + } = pagingInfo; const { tab: activeTab = EntityTabs.API_ENDPOINT } = useParams<{ tab: EntityTabs }>(); @@ -130,8 +136,6 @@ const APICollectionPage: FunctionComponent = () => { useState(DEFAULT_ENTITY_PERMISSION); const [showDeletedEndpoints, setShowDeletedEndpoints] = useState(false); - const [currentEndpointsPage, setCurrentEndpointsPage] = - useState(INITIAL_PAGING_VALUE); const extraDropdownContent = useMemo( () => @@ -145,7 +149,7 @@ const APICollectionPage: FunctionComponent = () => { const handleShowDeletedEndPoints = (value: boolean) => { setShowDeletedEndpoints(value); - setCurrentEndpointsPage(INITIAL_PAGING_VALUE); + handlePageChange(INITIAL_PAGING_VALUE); }; const { currentVersion, tags, tier, apiCollectionId } = useMemo( @@ -459,7 +463,7 @@ const APICollectionPage: FunctionComponent = () => { }, }); } - setCurrentEndpointsPage(currentPage); + handlePageChange(currentPage); }, [paging, getAPICollectionEndpoints] ); @@ -584,7 +588,7 @@ const APICollectionPage: FunctionComponent = () => { apiCollectionDetails={apiCollection} apiEndpoints={apiEndpoints} apiEndpointsLoading={apiEndpointsLoading} - currentEndpointsPage={currentEndpointsPage} + currentEndpointsPage={currentPage} description={apiCollection?.description ?? ''} editDescriptionPermission={editDescriptionPermission} endpointPaginationHandler={endpointPaginationHandler} diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/APICollectionPage/APICollectionVersionPage.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/APICollectionPage/APICollectionVersionPage.tsx index bca74edd2c0..f56e226c406 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/APICollectionPage/APICollectionVersionPage.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/APICollectionPage/APICollectionVersionPage.tsx @@ -32,7 +32,6 @@ import { DisplayType } from '../../components/Tag/TagsViewer/TagsViewer.interfac import { getEntityDetailsPath, getVersionPath, - INITIAL_PAGING_VALUE, PAGE_SIZE, } from '../../constants/constants'; import { usePermissionProvider } from '../../context/PermissionProvider/PermissionProvider'; @@ -86,7 +85,13 @@ const APICollectionVersionPage = () => { const pagingInfo = usePaging(PAGE_SIZE); - const { paging, pageSize, handlePagingChange } = pagingInfo; + const { + paging, + pageSize, + handlePagingChange, + handlePageChange, + currentPage, + } = pagingInfo; const [collectionPermissions, setCollectionPermissions] = useState(DEFAULT_ENTITY_PERMISSION); @@ -106,9 +111,6 @@ const APICollectionVersionPage = () => { const [apiEndpoints, setAPIEndpoints] = useState>([]); - const [currentEndpointsPage, setCurrentEndpointsPage] = - useState(INITIAL_PAGING_VALUE); - const { tier, owners, breadcrumbLinks, changeDescription, deleted, domain } = useMemo( () => @@ -235,7 +237,7 @@ const APICollectionVersionPage = () => { }, }); } - setCurrentEndpointsPage(currentPage); + handlePageChange(currentPage); }, [paging, getAPICollectionEndpoints] ); @@ -286,7 +288,7 @@ const APICollectionVersionPage = () => { apiCollectionDetails={currentVersionData} apiEndpoints={apiEndpoints} apiEndpointsLoading={apiEndpointsLoading} - currentEndpointsPage={currentEndpointsPage} + currentEndpointsPage={currentPage} description={description} endpointPaginationHandler={endpointPaginationHandler} pagingInfo={pagingInfo} @@ -348,7 +350,7 @@ const APICollectionVersionPage = () => { currentVersionData, apiEndpoints, apiEndpointsLoading, - currentEndpointsPage, + currentPage, endpointPaginationHandler, viewVersionPermission, ] 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 2a1bf7852f3..00e7e11781e 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 @@ -94,7 +94,13 @@ const DatabaseSchemaPage: FunctionComponent = () => { const { getEntityPermissionByFqn } = usePermissionProvider(); const pagingInfo = usePaging(PAGE_SIZE); - const { paging, pageSize, handlePagingChange } = pagingInfo; + const { + paging, + pageSize, + handlePagingChange, + currentPage, + handlePageChange, + } = pagingInfo; const { tab: activeTab = EntityTabs.TABLE } = useParams<{ tab: EntityTabs }>(); @@ -121,8 +127,6 @@ const DatabaseSchemaPage: FunctionComponent = () => { const [databaseSchemaPermission, setDatabaseSchemaPermission] = useState(DEFAULT_ENTITY_PERMISSION); const [showDeletedTables, setShowDeletedTables] = useState(false); - const [currentTablesPage, setCurrentTablesPage] = - useState(INITIAL_PAGING_VALUE); const [storedProcedureCount, setStoredProcedureCount] = useState(0); const [updateProfilerSetting, setUpdateProfilerSetting] = @@ -140,7 +144,7 @@ const DatabaseSchemaPage: FunctionComponent = () => { const handleShowDeletedTables = (value: boolean) => { setShowDeletedTables(value); - setCurrentTablesPage(INITIAL_PAGING_VALUE); + handlePageChange(INITIAL_PAGING_VALUE); }; const { version: currentVersion, deleted } = useMemo( @@ -458,7 +462,7 @@ const DatabaseSchemaPage: FunctionComponent = () => { if (cursorType) { getSchemaTables({ [cursorType]: paging[cursorType] }); } - setCurrentTablesPage(currentPage); + handlePageChange(currentPage); }, [paging, getSchemaTables] ); @@ -579,7 +583,7 @@ const DatabaseSchemaPage: FunctionComponent = () => { feedCount, tableData, activeTab, - currentTablesPage, + currentTablesPage: currentPage, databaseSchema, description, editDescriptionPermission, @@ -611,7 +615,7 @@ const DatabaseSchemaPage: FunctionComponent = () => { feedCount, tableData, activeTab, - currentTablesPage, + currentPage, databaseSchema, description, editDescriptionPermission, diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/DatabaseSchemaVersionPage/DatabaseSchemaVersionPage.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/DatabaseSchemaVersionPage/DatabaseSchemaVersionPage.tsx index 63aab9c61e5..88dedb72cd1 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/DatabaseSchemaVersionPage/DatabaseSchemaVersionPage.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/DatabaseSchemaVersionPage/DatabaseSchemaVersionPage.tsx @@ -31,7 +31,6 @@ import { DisplayType } from '../../components/Tag/TagsViewer/TagsViewer.interfac import { getEntityDetailsPath, getVersionPath, - INITIAL_PAGING_VALUE, PAGE_SIZE, } from '../../constants/constants'; import { usePermissionProvider } from '../../context/PermissionProvider/PermissionProvider'; @@ -76,9 +75,14 @@ function DatabaseSchemaVersionPage() { const pagingInfo = usePaging(PAGE_SIZE); - const { paging, pageSize, handlePagingChange } = pagingInfo; + const { + paging, + pageSize, + handlePagingChange, + handlePageChange, + currentPage, + } = pagingInfo; - const [currentPage, setCurrentPage] = useState(INITIAL_PAGING_VALUE); const [tableData, setTableData] = useState>([]); const [servicePermissions, setServicePermissions] = useState(DEFAULT_ENTITY_PERMISSION); @@ -195,7 +199,7 @@ function DatabaseSchemaVersionPage() { if (cursorType) { getSchemaTables({ [cursorType]: paging[cursorType] }); } - setCurrentPage(currentPage); + handlePageChange(currentPage); }, [paging, getSchemaTables] ); 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 5d3dac7d379..38526a1083c 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 @@ -780,8 +780,8 @@ const ServiceDetailsPage: FunctionComponent = () => { getOtherDetails({ [cursorType]: paging[cursorType], }); - handlePageChange(currentPage); } + handlePageChange(currentPage); }, [paging, getOtherDetails, handlePageChange] );