From 7c99e8cad04e2d7baa352581f5c773a70aa18a10 Mon Sep 17 00:00:00 2001 From: Peter Petrov Date: Wed, 20 Sep 2023 14:44:25 +0300 Subject: [PATCH] Boost: Remove global state from Pagination component (#33110) * Remove global state from Pagination component * add changelog * Update next/previous pagination buttons behavior * Update next/previous buttons to use a separate component * Make it easier to change the contents of PaginationArrow --- .../RecommendationsPage.svelte | 6 ++- .../recommendations/Pagination.svelte | 36 +++++------------ .../components/PaginationArrow.svelte | 40 +++++++++++++++++++ .../remove-state-pagination-component | 5 +++ 4 files changed, 61 insertions(+), 26 deletions(-) create mode 100644 projects/plugins/boost/app/assets/src/js/modules/image-size-analysis/recommendations/components/PaginationArrow.svelte create mode 100644 projects/plugins/boost/changelog/remove-state-pagination-component diff --git a/projects/plugins/boost/app/assets/src/js/modules/image-size-analysis/RecommendationsPage.svelte b/projects/plugins/boost/app/assets/src/js/modules/image-size-analysis/RecommendationsPage.svelte index 5e53270a1d3b0..717f5a1523711 100644 --- a/projects/plugins/boost/app/assets/src/js/modules/image-size-analysis/RecommendationsPage.svelte +++ b/projects/plugins/boost/app/assets/src/js/modules/image-size-analysis/RecommendationsPage.svelte @@ -46,7 +46,11 @@
- +
diff --git a/projects/plugins/boost/app/assets/src/js/modules/image-size-analysis/recommendations/Pagination.svelte b/projects/plugins/boost/app/assets/src/js/modules/image-size-analysis/recommendations/Pagination.svelte index e1bfc4aa1b603..1bad147693dba 100644 --- a/projects/plugins/boost/app/assets/src/js/modules/image-size-analysis/recommendations/Pagination.svelte +++ b/projects/plugins/boost/app/assets/src/js/modules/image-size-analysis/recommendations/Pagination.svelte @@ -2,7 +2,12 @@ import ChevronLeft from '../../../svg/chevron-left.svg'; import ChevronRight from '../../../svg/chevron-right.svg'; import { Link } from '../../../utils/router'; - import { isaData } from '../store/isa-data'; + import PaginationArrow from './components/PaginationArrow.svelte'; + + export let group: string; + export let current: number; + export let total: number; + // "-1" is replaced by "..." when rendering the pagination const MORE_ICON = -1; @@ -41,28 +46,14 @@ return pagination; } - function nextPage() { - if ( current < total ) { - $isaData.query.page += 1; - } - } - - function previousPage() { - if ( current > 1 ) { - $isaData.query.page -= 1; - } - } - - $: current = $isaData.query.page; - $: total = $isaData.data.total_pages; $: pages = generatePagination( current, total );
{#if total > 1} - + - + {/if}
@@ -106,7 +93,6 @@ margin: 0; } - button, .jb-pagination__page, .jb-pagination :global( a ) { background-color: transparent; diff --git a/projects/plugins/boost/app/assets/src/js/modules/image-size-analysis/recommendations/components/PaginationArrow.svelte b/projects/plugins/boost/app/assets/src/js/modules/image-size-analysis/recommendations/components/PaginationArrow.svelte new file mode 100644 index 0000000000000..1950a5a47bab0 --- /dev/null +++ b/projects/plugins/boost/app/assets/src/js/modules/image-size-analysis/recommendations/components/PaginationArrow.svelte @@ -0,0 +1,40 @@ + + +{#if inactive} + + + +{:else} + + + +{/if} + + diff --git a/projects/plugins/boost/changelog/remove-state-pagination-component b/projects/plugins/boost/changelog/remove-state-pagination-component new file mode 100644 index 0000000000000..a1a7dde3072cd --- /dev/null +++ b/projects/plugins/boost/changelog/remove-state-pagination-component @@ -0,0 +1,5 @@ +Significance: patch +Type: removed +Comment: Removed global state from pagination component. + +