* LibraryPanels: Improves Get All Api
* Refactor: using useReducer instead of useState
* Refactor: adds Pagination to UI
* Tests: adds reducer tests
* Refactor: using Observable instead to avoid flickering
* Refactor: moves exclusion to backend instead
* Chore: changing back the perPage default value
(cherry picked from commit f508a16a43)
Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
This commit is contained in:
co-authored by
Hugo Häggmark
parent
da11a67c4e
commit
ca31570dcc
@@ -13,9 +13,11 @@ interface Props {
|
||||
numberOfPages: number;
|
||||
/** Callback function for fetching the selected page */
|
||||
onNavigate: (toPage: number) => void;
|
||||
/** When set to true and the pagination result is only one page it will not render the pagination at all */
|
||||
hideWhenSinglePage?: boolean;
|
||||
}
|
||||
|
||||
export const Pagination: React.FC<Props> = ({ currentPage, numberOfPages, onNavigate }) => {
|
||||
export const Pagination: React.FC<Props> = ({ currentPage, numberOfPages, onNavigate, hideWhenSinglePage }) => {
|
||||
const styles = getStyles();
|
||||
const pages = [...new Array(numberOfPages).keys()];
|
||||
|
||||
@@ -71,6 +73,10 @@ export const Pagination: React.FC<Props> = ({ currentPage, numberOfPages, onNavi
|
||||
return pagesToRender;
|
||||
}, []);
|
||||
|
||||
if (hideWhenSinglePage && numberOfPages <= 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<ol>
|
||||
|
||||
Reference in New Issue
Block a user