diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /app/controllers/whats_new_controller.rb | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'app/controllers/whats_new_controller.rb')
-rw-r--r-- | app/controllers/whats_new_controller.rb | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/app/controllers/whats_new_controller.rb b/app/controllers/whats_new_controller.rb index 384c984089a..cba86c65848 100644 --- a/app/controllers/whats_new_controller.rb +++ b/app/controllers/whats_new_controller.rb @@ -1,18 +1,19 @@ # frozen_string_literal: true class WhatsNewController < ApplicationController - include Gitlab::WhatsNew + include Gitlab::Utils::StrongMemoize skip_before_action :authenticate_user! - before_action :check_feature_flag, :check_valid_page_param, :set_pagination_headers + before_action :check_feature_flag + before_action :check_valid_page_param, :set_pagination_headers, unless: -> { has_version_param? } feature_category :navigation def index respond_to do |format| format.js do - render json: whats_new_release_items(page: current_page) + render json: highlight_items end end end @@ -27,18 +28,29 @@ class WhatsNewController < ApplicationController 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 + def highlights + strong_memoize(:highlights) do + if has_version_param? + ReleaseHighlight.for_version(version: params[:version]) + else + ReleaseHighlight.paginated(page: current_page) + end + end + end + + def highlight_items + highlights.map {|item| Gitlab::WhatsNew::ItemPresenter.present(item) } + end + + def set_pagination_headers + response.set_header('X-Next-Page', highlights.next_page) + end - next_page if whats_new_file_paths[next_index] + def has_version_param? + params[:version].present? end end |