From c295cfb3876f59fee5e66e1fad95f66381252d2b Mon Sep 17 00:00:00 2001 From: Jeremy Lenz Date: Thu, 29 Aug 2024 16:51:44 -0400 Subject: [PATCH] Fixes #37587 - cast page and perPage to Number --- app/controllers/api/v2/base_controller.rb | 4 ++-- .../components/PF4/TableIndexPage/TableIndexPage.js | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/v2/base_controller.rb b/app/controllers/api/v2/base_controller.rb index 4f62ebff798..d4456333ba1 100644 --- a/app/controllers/api/v2/base_controller.rb +++ b/app/controllers/api/v2/base_controller.rb @@ -102,8 +102,8 @@ def metadata_page end def metadata_per_page - @per_page ||= Setting[:entries_per_page] if params[:per_page].blank? - @per_page ||= params[:per_page] == 'all' ? metadata_total : params[:per_page].to_i + @per_page ||= Setting[:entries_per_page].to_i if params[:per_page].blank? + @per_page ||= params[:per_page] == 'all' ? metadata_total.to_i : params[:per_page].to_i end # For the purpose of ADDING/REMOVING associations in CHILD node on POST/PUT payload diff --git a/webpack/assets/javascripts/react_app/components/PF4/TableIndexPage/TableIndexPage.js b/webpack/assets/javascripts/react_app/components/PF4/TableIndexPage/TableIndexPage.js index 0c6b2db8a1d..e379712c383 100644 --- a/webpack/assets/javascripts/react_app/components/PF4/TableIndexPage/TableIndexPage.js +++ b/webpack/assets/javascripts/react_app/components/PF4/TableIndexPage/TableIndexPage.js @@ -141,14 +141,16 @@ const TableIndexPage = ({ can_create: canCreate, results, total, - per_page: perPage, - page, + per_page: respPerPage, + page: respPage, subtotal, message: errorMessage, }, status = STATUS.PENDING, setAPIOptions, } = response; + const page = Number(respPage); + const perPage = Number(respPerPage); const memoDefaultSearchProps = useMemo( () => getControllerSearchProps(controller),