diff --git a/CHANGELOG.md b/CHANGELOG.md index fbf41bcaa9..ae7741dcea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ - [#1917](https://github.com/poanetwork/blockscout/pull/1917) - Force block refetch if transaction is re-collated in a different block - [#1992](https://github.com/poanetwork/blockscout/pull/1992) - fix: support https for wobserver polling - [#1966](https://github.com/poanetwork/blockscout/pull/1966) - fix: add fields for contract filter performance +- [#2009](https://github.com/poanetwork/blockscout/pull/2009) - addresses page improvements ### Chore diff --git a/apps/block_scout_web/assets/js/lib/async_listing_load.js b/apps/block_scout_web/assets/js/lib/async_listing_load.js index 0d7f427fd3..e22f6e399d 100644 --- a/apps/block_scout_web/assets/js/lib/async_listing_load.js +++ b/apps/block_scout_web/assets/js/lib/async_listing_load.js @@ -48,6 +48,8 @@ export const asyncInitialState = { loading: false, /* if there was an error fetching items */ requestError: false, + /* if response has no items */ + emptyResponse: false, /* if it is loading the first page */ loadingFirstPage: true, /* link to the next page */ @@ -90,6 +92,7 @@ export function asyncReducer (state = asyncInitialState, action) { return Object.assign({}, state, { requestError: false, + emptyResponse: action.items.length === 0, items: action.items, nextPagePath: action.nextPagePath, prevPagePath: prevPagePath @@ -169,6 +172,10 @@ export const elements = { }, '[data-async-listing] [data-next-page-button]': { render ($el, state) { + if (state.emptyResponse) { + return $el.hide() + } + if (state.requestError || !state.nextPagePath || state.loading) { return $el.attr('disabled', 'disabled') } @@ -179,6 +186,10 @@ export const elements = { }, '[data-async-listing] [data-prev-page-button]': { render ($el, state) { + if (state.emptyResponse) { + return $el.hide() + } + if (state.requestError || !state.prevPagePath || state.loading) { return $el.attr('disabled', 'disabled') } @@ -189,6 +200,10 @@ export const elements = { }, '[data-async-listing] [data-page-number]': { render ($el, state) { + if (state.emptyResponse) { + return $el.hide() + } + if (state.pagesStack.length === 0) { return $el.text('Page 1') } diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex index d8b1fbbf60..6ce33a2773 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex @@ -26,7 +26,7 @@ defmodule BlockScoutWeb.AddressController do address_path( conn, :index, - next_page_params + Map.delete(next_page_params, "type") ) end diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex index e3140a0efc..47d7f2457b 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex @@ -3,11 +3,11 @@

<%= gettext "Addresses" %>

- <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "top", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true %> + <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "top", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true, data_prev_page_button: true %>
- <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "bottom", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true %> + <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "bottom", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true, data_prev_page_button: true %>