debian-mirror-gitlab/app/controllers/whats_new_controller.rb

45 lines
885 B
Ruby
Raw Normal View History

2021-01-03 14:25:43 +05:30
# frozen_string_literal: true
class WhatsNewController < ApplicationController
include Gitlab::WhatsNew
skip_before_action :authenticate_user!
2021-01-29 00:20:46 +05:30
before_action :check_feature_flag, :check_valid_page_param, :set_pagination_headers
2021-01-03 14:25:43 +05:30
feature_category :navigation
def index
respond_to do |format|
format.js do
2021-01-29 00:20:46 +05:30
render json: whats_new_release_items(page: current_page)
2021-01-03 14:25:43 +05:30
end
end
end
private
def check_feature_flag
render_404 unless Feature.enabled?(:whats_new_drawer, current_user)
end
2021-01-29 00:20:46 +05:30
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
2021-01-03 14:25:43 +05:30
end