-
Notifications
You must be signed in to change notification settings - Fork 844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hide paginationBar in EuiBasicTable when there is no data #2598
Changes from 8 commits
dbc0655
a005546
b55ef3f
243a566
2bbd44d
4e6fdd8
664bf2b
d63690f
d98a56f
0bc2686
60286e2
3d195a2
3616b1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -384,7 +384,7 @@ export class EuiBasicTable extends Component { | |||||
); | ||||||
|
||||||
const table = this.renderTable(); | ||||||
const paginationBar = this.renderPaginationBar(); | ||||||
const paginationBar = this.renderPaginationBar(items); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A better thing to pass here would be the length of items so that there's an understanding of what the
Suggested change
|
||||||
|
||||||
return ( | ||||||
<div className={classes} {...rest}> | ||||||
|
@@ -1049,9 +1049,9 @@ export class EuiBasicTable extends Component { | |||||
return profile.align; | ||||||
} | ||||||
|
||||||
renderPaginationBar() { | ||||||
renderPaginationBar(items) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then here, you can change the name to something like
Suggested change
|
||||||
const { error, pagination, onChange } = this.props; | ||||||
if (!error && pagination) { | ||||||
if (!error && pagination && items.length > 0) { | ||||||
if (!onChange) { | ||||||
throw new Error(`The Basic Table is configured with pagination but [onChange] is | ||||||
not configured. This callback must be implemented to handle pagination changes`); | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,59 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`EuiPagination is rendered 1`] = `<span />`; | ||
exports[`EuiPagination is rendered 1`] = ` | ||
<div | ||
aria-label="aria-label" | ||
class="euiPagination testClass1 testClass2" | ||
data-test-subj="test subject string" | ||
role="group" | ||
> | ||
<button | ||
aria-label="Previous page" | ||
class="euiButtonIcon euiButtonIcon--text" | ||
data-test-subj="pagination-button-previous" | ||
type="button" | ||
> | ||
<svg | ||
aria-hidden="true" | ||
class="euiIcon euiIcon--medium euiIcon-isLoading euiButtonIcon__icon" | ||
focusable="false" | ||
height="16" | ||
viewBox="0 0 16 16" | ||
width="16" | ||
xmlns="http://www.w3.org/2000/svg" | ||
/> | ||
</button> | ||
<button | ||
aria-label="Page 1 of 1" | ||
class="euiButtonEmpty euiButtonEmpty--text euiButtonEmpty--xSmall euiPaginationButton euiPaginationButton--hideOnMobile" | ||
data-test-subj="pagination-button-0" | ||
type="button" | ||
> | ||
<span | ||
class="euiButtonEmpty__content" | ||
> | ||
<span | ||
class="euiButtonEmpty__text" | ||
> | ||
1 | ||
</span> | ||
</span> | ||
</button> | ||
<button | ||
aria-label="Next page" | ||
class="euiButtonIcon euiButtonIcon--text" | ||
data-test-subj="pagination-button-next" | ||
type="button" | ||
> | ||
<svg | ||
aria-hidden="true" | ||
class="euiIcon euiIcon--medium euiIcon-isLoading euiButtonIcon__icon" | ||
focusable="false" | ||
height="16" | ||
viewBox="0 0 16 16" | ||
width="16" | ||
xmlns="http://www.w3.org/2000/svg" | ||
/> | ||
</button> | ||
</div> | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,7 +173,7 @@ export const EuiPagination: FunctionComponent<Props> = ({ | |
</EuiI18n> | ||
); | ||
|
||
if (pages.length > 1) { | ||
if (pages.length > 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const selectablePages = pages; | ||
if (compressed) { | ||
return ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These entries can be rolled into one because they both are affecting EuiBasicTable pagination options