Skip to content

Commit

Permalink
fix(ui): ui should show the same page number as in API (argoproj#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marvin9 authored and alexmt committed Oct 28, 2024
1 parent 13338bb commit c1cd823
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ export const ApplicationsList = (props: RouteComponentProps<{}>) => {
showHeader={healthBarPrefs.showHealthStatusBar}
preferencesKey='applications-list'
page={pref.page}
defaultPageSize={5}
emptyState={() => (
<EmptyState icon='fa fa-search'>
<h4>No matching applications found</h4>
Expand Down
5 changes: 3 additions & 2 deletions ui/src/app/shared/components/paginate/paginate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ export interface PaginateProps<T> {
header?: React.ReactNode;
showHeader?: boolean;
sortOptions?: SortOption<T>[];
defaultPageSize?: number;
}

export function Paginate<T>({page, onPageChange, children, data, emptyState, preferencesKey, header, showHeader, sortOptions, total}: PaginateProps<T>) {
export function Paginate<T>({page, onPageChange, children, data, emptyState, preferencesKey, header, showHeader, sortOptions, total, defaultPageSize}: PaginateProps<T>) {
const totalItems = total || data.length;
return (
<DataLoader load={() => services.viewPreferences.getPreferences()}>
{pref => {
preferencesKey = preferencesKey || 'default';
const pageSize = pref.pageSizes[preferencesKey] || 10;
const pageSize = pref.pageSizes[preferencesKey] || defaultPageSize || 10;
const sortOption = sortOptions ? (pref.sortOptions && pref.sortOptions[preferencesKey]) || sortOptions[0].title : '';
const pageCount = pageSize === -1 ? 1 : Math.ceil(totalItems / pageSize);
if (pageCount <= page) {
Expand Down

0 comments on commit c1cd823

Please sign in to comment.