LibraryPanels: Improves the Get All experience (#32028)

* 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
This commit is contained in:
Hugo Häggmark
2021-03-18 11:19:41 +01:00
committed by GitHub
parent 0fbe7f7f52
commit f508a16a43
14 changed files with 838 additions and 164 deletions

View File

@@ -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>