Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/whats_new_controller.rb')
-rw-r--r--app/controllers/whats_new_controller.rb34
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