2020-10-14 14:08:47 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class WhatsNewController < ApplicationController
|
2020-12-10 10:10:12 -05:00
|
|
|
include Gitlab::Utils::StrongMemoize
|
|
|
|
|
2020-10-14 14:08:47 -04:00
|
|
|
skip_before_action :authenticate_user!
|
|
|
|
|
2021-04-27 11:09:52 -04:00
|
|
|
before_action :check_whats_new_enabled
|
2021-04-12 17:11:12 -04:00
|
|
|
before_action :check_valid_page_param, :set_pagination_headers
|
2020-10-14 14:08:47 -04:00
|
|
|
|
|
|
|
feature_category :navigation
|
2022-05-20 17:08:53 -04:00
|
|
|
urgency :low
|
2020-10-14 14:08:47 -04:00
|
|
|
|
|
|
|
def index
|
|
|
|
respond_to do |format|
|
|
|
|
format.js do
|
2021-01-26 07:09:27 -05:00
|
|
|
render json: highlights.items
|
2020-10-14 14:08:47 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2021-04-27 11:09:52 -04:00
|
|
|
def check_whats_new_enabled
|
|
|
|
render_404 if Gitlab::CurrentSettings.current_application_settings.whats_new_variant_disabled?
|
|
|
|
end
|
|
|
|
|
2020-11-02 04:08:35 -05: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 10:10:12 -05:00
|
|
|
def highlights
|
|
|
|
strong_memoize(:highlights) do
|
2021-04-12 17:11:12 -04:00
|
|
|
ReleaseHighlight.paginated(page: current_page)
|
2020-12-10 10:10:12 -05:00
|
|
|
end
|
2020-11-24 13:09:14 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def set_pagination_headers
|
2020-12-10 10:10:12 -05:00
|
|
|
response.set_header('X-Next-Page', highlights.next_page)
|
|
|
|
end
|
2020-10-14 14:08:47 -04:00
|
|
|
end
|