Skip to content

Commit

Permalink
Fix issues around 'Show more'
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzhaoyuan committed May 9, 2024
1 parent 399651d commit f029412
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/shared/components/lazyMobXTable/LazyMobXTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
action,
computed,
IReactionDisposer,
makeObservable,
observable,
reaction,
makeObservable,
} from 'mobx';
import { observer, Observer } from 'mobx-react';
import './styles.scss';
Expand Down Expand Up @@ -1129,6 +1129,8 @@ export default class LazyMobXTable<T> extends React.Component<
textBeforeButtons: this.store.paginationStatusText,
groupButtons: false,
bsStyle: 'primary',
isResultLimitedAtMaxPage:
this.props.isResultLimited && this.isAtMaxPage(),
};
// override with given paginationProps if they exist
if (this.props.paginationProps) {
Expand Down Expand Up @@ -1322,14 +1324,17 @@ export default class LazyMobXTable<T> extends React.Component<
);
}

private isAtMaxPage() {
return this.store.maxPage > 0 && this.store.page === this.store.maxPage;
}

render() {
return (
<div className="lazy-mobx-table" data-test="LazyMobXTable">
<Observer>{this.getTopToolbar}</Observer>
<Observer>{this.getTable}</Observer>
{this.props.isResultLimited &&
this.store.maxPage > 0 &&
this.store.page === this.store.maxPage && (
(this.store.showingAllRows || this.isAtMaxPage()) && (
<div className={'text-center alert alert-info'}>
<strong>
You've reached the maximum viewable records.{' '}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface IPaginationControlsProps {
groupButtons?: boolean;
hidePaginationIfOnePage?: boolean;
bsStyle?: 'default' | 'primary' | 'success' | 'info' | 'warning';
isResultLimitedAtMaxPage?: boolean;
}

@observer
Expand Down Expand Up @@ -142,6 +143,7 @@ export class PaginationControls extends React.Component<
id="showMoreButton"
bsSize="sm"
disabled={
this.props.isResultLimitedAtMaxPage ||
!this.props.itemsPerPageOptions ||
!this.props.itemsPerPage ||
!this.props.totalItems ||
Expand Down

0 comments on commit f029412

Please sign in to comment.