debian-mirror-gitlab/app/controllers/projects/pages_controller.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

85 lines
2.1 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
class Projects::PagesController < Projects::ApplicationController
2023-03-17 16:20:25 +05:30
layout :resolve_layout
2017-08-17 22:00:37 +05:30
before_action :require_pages_enabled!
before_action :authorize_read_pages!, only: [:show]
2019-07-07 11:18:12 +05:30
before_action :authorize_update_pages!, except: [:show, :destroy]
before_action :authorize_remove_pages!, only: [:destroy]
2017-08-17 22:00:37 +05:30
2021-01-03 14:25:43 +05:30
feature_category :pages
2023-03-17 16:20:25 +05:30
before_action do
push_frontend_feature_flag(:show_pages_in_deployments_menu, current_user, type: :experiment)
end
2022-08-27 11:52:29 +05:30
def new
@pipeline_wizard_data = {
project_path: @project.full_path,
default_branch: @project.repository.root_ref,
redirect_to_when_done: project_pages_path(@project)
}
end
2017-08-17 22:00:37 +05:30
def show
2022-08-27 11:52:29 +05:30
unless @project.pages_enabled?
render :disabled
return
end
if @project.pages_show_onboarding?
redirect_to action: 'new'
return
end
# rubocop: disable CodeReuse/ActiveRecord
2020-04-22 19:07:51 +05:30
@domains = @project.pages_domains.order(:domain).present(current_user: current_user)
2022-08-27 11:52:29 +05:30
# rubocop: enable CodeReuse/ActiveRecord
2017-08-17 22:00:37 +05:30
end
def destroy
2020-01-01 13:55:28 +05:30
::Pages::DeleteService.new(@project, current_user).execute
2017-08-17 22:00:37 +05:30
respond_to do |format|
2019-03-02 22:35:43 +05:30
format.html do
2017-09-10 17:25:29 +05:30
redirect_to project_pages_path(@project),
2019-12-26 22:10:19 +05:30
status: :found,
2020-11-24 15:15:51 +05:30
notice: 'Pages were scheduled for removal'
2017-08-17 22:00:37 +05:30
end
end
end
2018-05-09 12:01:36 +05:30
def update
result = Projects::UpdateService.new(@project, current_user, project_params).execute
respond_to do |format|
format.html do
if result[:status] == :success
flash[:notice] = 'Your changes have been saved'
else
2020-03-13 15:44:24 +05:30
flash[:alert] = result[:message]
2018-05-09 12:01:36 +05:30
end
redirect_to project_pages_path(@project)
end
end
end
private
2023-03-17 16:20:25 +05:30
def resolve_layout
'project_settings' unless Feature.enabled?(:show_pages_in_deployments_menu, current_user, type: :experiment)
end
2018-05-09 12:01:36 +05:30
def project_params
2020-03-13 15:44:24 +05:30
params.require(:project).permit(project_params_attributes)
end
def project_params_attributes
%i[pages_https_only]
2018-05-09 12:01:36 +05:30
end
2017-08-17 22:00:37 +05:30
end
2020-03-13 15:44:24 +05:30
2021-06-08 01:23:25 +05:30
Projects::PagesController.prepend_mod_with('Projects::PagesController')