1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# frozen_string_literal: true
class Projects::PagesController < Projects::ApplicationController
layout :resolve_layout
before_action :require_pages_enabled!
before_action :authorize_read_pages!, only: [:show]
before_action :authorize_update_pages!, except: [:show, :destroy]
before_action :authorize_remove_pages!, only: [:destroy]
feature_category :pages
before_action do
push_frontend_feature_flag(:show_pages_in_deployments_menu, current_user, type: :experiment)
end
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
def show
unless @project.pages_enabled?
render :disabled
return
end
if @project.pages_show_onboarding?
redirect_to action: 'new'
return
end
# rubocop: disable CodeReuse/ActiveRecord
@domains = @project.pages_domains.order(:domain).present(current_user: current_user)
# rubocop: enable CodeReuse/ActiveRecord
end
def destroy
::Pages::DeleteService.new(@project, current_user).execute
respond_to do |format|
format.html do
redirect_to project_pages_path(@project), status: :found, notice: 'Pages were scheduled for removal'
end
end
end
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
flash[:alert] = result[:message]
end
redirect_to project_pages_path(@project)
end
end
end
private
def resolve_layout
'project_settings' unless Feature.enabled?(:show_pages_in_deployments_menu, current_user, type: :experiment)
end
def project_params
params.require(:project).permit(project_params_attributes)
end
def project_params_attributes
attributes = %i[pages_https_only]
return attributes unless Feature.enabled?(:pages_unique_domain, @project)
attributes + [
project_setting_attributes: [
:pages_unique_domain_enabled
]
]
end
end
Projects::PagesController.prepend_mod_with('Projects::PagesController')
|