diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /app/controllers/whats_new_controller.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'app/controllers/whats_new_controller.rb')
-rw-r--r-- | app/controllers/whats_new_controller.rb | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/app/controllers/whats_new_controller.rb b/app/controllers/whats_new_controller.rb index 7156faa4e49..384c984089a 100644 --- a/app/controllers/whats_new_controller.rb +++ b/app/controllers/whats_new_controller.rb @@ -5,14 +5,14 @@ class WhatsNewController < ApplicationController skip_before_action :authenticate_user! - before_action :check_feature_flag + before_action :check_feature_flag, :check_valid_page_param, :set_pagination_headers feature_category :navigation def index respond_to do |format| format.js do - render json: whats_new_most_recent_release_items + render json: whats_new_release_items(page: current_page) end end end @@ -22,4 +22,23 @@ class WhatsNewController < ApplicationController def check_feature_flag render_404 unless Feature.enabled?(:whats_new_drawer, current_user) end + + def check_valid_page_param + render_404 if current_page < 1 + end + + def set_pagination_headers + response.set_header('X-Next-Page', next_page) + end + + def current_page + params[:page]&.to_i || 1 + end + + def next_page + next_page = current_page + 1 + next_index = next_page - 1 + + next_page if whats_new_file_paths[next_index] + end end |