mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-26 09:55:52 +00:00
fix(ui): pagination with search on service page (#18211)
This commit is contained in:
parent
3dc9abef45
commit
6b830f98bb
@ -23,6 +23,7 @@ import { Link, useHistory } from 'react-router-dom';
|
|||||||
import {
|
import {
|
||||||
DISABLED,
|
DISABLED,
|
||||||
getServiceDetailsPath,
|
getServiceDetailsPath,
|
||||||
|
INITIAL_PAGING_VALUE,
|
||||||
pagingObject,
|
pagingObject,
|
||||||
} from '../../../constants/constants';
|
} from '../../../constants/constants';
|
||||||
import { CONNECTORS_DOCS } from '../../../constants/docs.constants';
|
import { CONNECTORS_DOCS } from '../../../constants/docs.constants';
|
||||||
@ -194,15 +195,27 @@ const Services = ({ serviceName }: ServicesProps) => {
|
|||||||
[searchIndex, serviceName, deleted]
|
[searchIndex, serviceName, deleted]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleServicePageChange = ({
|
const handleServicePageChange = useCallback(
|
||||||
cursorType,
|
({ cursorType, currentPage }: PagingHandlerParams) => {
|
||||||
currentPage,
|
if (searchTerm) {
|
||||||
}: PagingHandlerParams) => {
|
handlePageChange(currentPage);
|
||||||
if (cursorType) {
|
getServiceDetails({
|
||||||
getServiceDetails({ [cursorType]: paging[cursorType] });
|
currentPage,
|
||||||
}
|
search: searchTerm,
|
||||||
handlePageChange(currentPage);
|
limit: pageSize,
|
||||||
};
|
filters: serviceTypeFilter?.length
|
||||||
|
? `(${serviceTypeFilter
|
||||||
|
.map((type) => `serviceType:${type}`)
|
||||||
|
.join(' ')})`
|
||||||
|
: undefined,
|
||||||
|
});
|
||||||
|
} else if (cursorType) {
|
||||||
|
handlePageChange(currentPage);
|
||||||
|
getServiceDetails({ [cursorType]: paging[cursorType] });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[getServiceDetails, searchTerm, serviceTypeFilter, paging, pageSize]
|
||||||
|
);
|
||||||
|
|
||||||
const addServicePermission = useMemo(
|
const addServicePermission = useMemo(
|
||||||
() =>
|
() =>
|
||||||
@ -414,6 +427,7 @@ const Services = ({ serviceName }: ServicesProps) => {
|
|||||||
|
|
||||||
const handleServiceSearch = useCallback(
|
const handleServiceSearch = useCallback(
|
||||||
async (search: string) => {
|
async (search: string) => {
|
||||||
|
handlePageChange(INITIAL_PAGING_VALUE);
|
||||||
setSearchTerm(search);
|
setSearchTerm(search);
|
||||||
},
|
},
|
||||||
[getServiceDetails]
|
[getServiceDetails]
|
||||||
@ -511,6 +525,7 @@ const Services = ({ serviceName }: ServicesProps) => {
|
|||||||
{showPagination && (
|
{showPagination && (
|
||||||
<NextPrevious
|
<NextPrevious
|
||||||
currentPage={currentPage}
|
currentPage={currentPage}
|
||||||
|
isNumberBased={!isEmpty(searchTerm)}
|
||||||
pageSize={pageSize}
|
pageSize={pageSize}
|
||||||
paging={paging}
|
paging={paging}
|
||||||
pagingHandler={handleServicePageChange}
|
pagingHandler={handleServicePageChange}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user