2020-10-14 18:08:47 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class WhatsNewController < ApplicationController
|
2020-12-10 15:10:12 +00:00
|
|
|
include Gitlab::Utils::StrongMemoize
|
|
|
|
|
2020-10-14 18:08:47 +00:00
|
|
|
skip_before_action :authenticate_user!
|
|
|
|
|
2021-04-27 15:09:52 +00:00
|
|
|
before_action :check_whats_new_enabled
|
2021-04-12 21:11:12 +00:00
|
|
|
before_action :check_valid_page_param, :set_pagination_headers
|
2020-10-14 18:08:47 +00:00
|
|
|
|
|
|
|
feature_category :navigation
|
|
|
|
|
|
|
|
def index
|
|
|
|
respond_to do |format|
|
|
|
|
format.js do
|
2021-01-26 12:09:27 +00:00
|
|
|
render json: highlights.items
|
2020-10-14 18:08:47 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2021-04-27 15:09:52 +00:00
|
|
|
def check_whats_new_enabled
|
|
|
|
render_404 if Gitlab::CurrentSettings.current_application_settings.whats_new_variant_disabled?
|
|
|
|
end
|
|
|
|
|
2020-11-02 09:08:35 +00:00
|
|
|
def check_valid_page_param
|
|
|
|
render_404 if current_page < 1
|
|
|
|
end
|
|
|
|
|
|
|
|
def current_page
|
|
|
|
params[:page]&.to_i || 1
|
|
|
|
end
|
|
|
|
|
2020-12-10 15:10:12 +00:00
|
|
|
def highlights
|
|
|
|
strong_memoize(:highlights) do
|
2021-04-12 21:11:12 +00:00
|
|
|
ReleaseHighlight.paginated(page: current_page)
|
2020-12-10 15:10:12 +00:00
|
|
|
end
|
2020-11-24 18:09:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def set_pagination_headers
|
2020-12-10 15:10:12 +00:00
|
|
|
response.set_header('X-Next-Page', highlights.next_page)
|
|
|
|
end
|
2020-10-14 18:08:47 +00:00
|
|
|
end
|