mirror of
				https://github.com/open-metadata/OpenMetadata.git
				synced 2025-11-04 04:29:13 +00:00 
			
		
		
		
	fix(ui): pagination with search on service page (#18211)
(cherry picked from commit 6b830f98bb9aab07dbadad0f250b92f1ada2585d)
This commit is contained in:
		
							parent
							
								
									b90e9b019b
								
							
						
					
					
						commit
						c9d1bdcdcd
					
				@ -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