Split PagesController into PagesController and PagesDomainsController
1. PagesController is used to show all domains and general overview of Pages 2. PagesDomainsController is used to manage pages domains
This commit is contained in:
parent
84edc9a22f
commit
7f12cb0eed
11 changed files with 104 additions and 107 deletions
|
@ -1,49 +1,13 @@
|
|||
class Projects::PagesController < Projects::ApplicationController
|
||||
layout 'project_settings'
|
||||
|
||||
before_action :authorize_update_pages!, except: [:show]
|
||||
before_action :authorize_remove_pages!, only: [:remove_pages]
|
||||
before_action :label, only: [:destroy]
|
||||
before_action :domain, only: [:show]
|
||||
before_action :authorize_update_pages!
|
||||
|
||||
helper_method :valid_certificate?, :valid_certificate_key?
|
||||
helper_method :valid_key_for_certificiate?, :valid_certificate_intermediates?
|
||||
helper_method :certificate, :certificate_key
|
||||
|
||||
def index
|
||||
def show
|
||||
@domains = @project.pages_domains.order(:domain)
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def new
|
||||
@domain = @project.pages_domains.new
|
||||
end
|
||||
|
||||
def create
|
||||
@domain = @project.pages_domains.create(pages_domain_params)
|
||||
|
||||
if @domain.valid?
|
||||
redirect_to namespace_project_pages_path(@project.namespace, @project)
|
||||
else
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@domain.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
redirect_to(namespace_project_pages_path(@project.namespace, @project),
|
||||
notice: 'Domain was removed')
|
||||
end
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def remove_pages
|
||||
project.remove_pages
|
||||
project.pages_domains.destroy_all
|
||||
|
||||
|
@ -54,18 +18,4 @@ class Projects::PagesController < Projects::ApplicationController
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def pages_domain_params
|
||||
params.require(:pages_domain).permit(
|
||||
:certificate,
|
||||
:key,
|
||||
:domain
|
||||
)
|
||||
end
|
||||
|
||||
def domain
|
||||
@domain ||= @project.pages_domains.find_by(domain: params[:id].to_s)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
class Projects::PagesDomainsController < Projects::ApplicationController
|
||||
layout 'project_settings'
|
||||
|
||||
before_action :authorize_update_pages!, except: [:show]
|
||||
before_action :domain, only: [:show, :destroy]
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def new
|
||||
@domain = @project.pages_domains.new
|
||||
end
|
||||
|
||||
def create
|
||||
@domain = @project.pages_domains.create(pages_domain_params)
|
||||
|
||||
if @domain.valid?
|
||||
redirect_to namespace_project_pages_path(@project.namespace, @project)
|
||||
else
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@domain.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
redirect_to(namespace_project_pages_path(@project.namespace, @project),
|
||||
notice: 'Domain was removed')
|
||||
end
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def pages_domain_params
|
||||
params.require(:pages_domain).permit(
|
||||
:certificate,
|
||||
:key,
|
||||
:domain
|
||||
)
|
||||
end
|
||||
|
||||
def domain
|
||||
@domain ||= @project.pages_domains.find_by(domain: params[:id].to_s)
|
||||
end
|
||||
end
|
|
@ -6,4 +6,4 @@
|
|||
%p
|
||||
Removing the pages will prevent from exposing them to outside world.
|
||||
.form-actions
|
||||
= link_to 'Remove', remove_pages_namespace_project_pages_path(@project.namespace, @project), data: { confirm: 'Are you sure?'}, method: :delete, class: "btn btn-remove"
|
||||
= link_to 'Remove pages', namespace_project_pages_path(@project.namespace, @project), data: { confirm: 'Are you sure?'}, method: :delete, class: "btn btn-remove"
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
- @domains.each do |domain|
|
||||
%li
|
||||
.pull-right
|
||||
= link_to 'Details', namespace_project_page_path(@project.namespace, @project, domain), class: "btn btn-sm btn-grouped"
|
||||
= link_to 'Remove', namespace_project_page_path(@project.namespace, @project, domain), data: { confirm: 'Are you sure?'}, method: :delete, class: "btn btn-remove btn-sm btn-grouped"
|
||||
= link_to 'Details', namespace_project_pages_domain_path(@project.namespace, @project, domain), class: "btn btn-sm btn-grouped"
|
||||
= link_to 'Remove', namespace_project_pages_domain_path(@project.namespace, @project, domain), data: { confirm: 'Are you sure?'}, method: :delete, class: "btn btn-remove btn-sm btn-grouped"
|
||||
.clearfix
|
||||
%span= link_to domain.domain, domain.url
|
||||
%p
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
- page_title "Pages"
|
||||
%h3.page_title
|
||||
Pages
|
||||
|
||||
- if Gitlab.config.pages.external_http || Gitlab.config.pages.external_https
|
||||
= link_to new_namespace_project_page_path(@project.namespace, @project), class: "btn btn-new pull-right", title: "New Domain" do
|
||||
%i.fa.fa-plus
|
||||
New Domain
|
||||
|
||||
%p.light
|
||||
With GitLab Pages you can host for free your static websites on GitLab.
|
||||
Combined with the power of GitLab CI and the help of GitLab Runner
|
||||
you can deploy static pages for your individual projects, your user or your group.
|
||||
|
||||
%hr.clearfix
|
||||
|
||||
- if Gitlab.config.pages.enabled
|
||||
= render 'access'
|
||||
= render 'use'
|
||||
- if Gitlab.config.pages.external_http || Gitlab.config.pages.external_https
|
||||
= render 'list'
|
||||
- else
|
||||
= render 'no_domains'
|
||||
= render 'destroy'
|
||||
- else
|
||||
= render 'disabled'
|
|
@ -1,22 +1,26 @@
|
|||
- page_title "#{@domain.domain}", "Pages Domain"
|
||||
- page_title "Pages"
|
||||
%h3.page_title
|
||||
Pages
|
||||
|
||||
%h3.page-title
|
||||
Pages Domain
|
||||
- if Gitlab.config.pages.external_http || Gitlab.config.pages.external_https
|
||||
= link_to new_namespace_project_pages_domain_path(@project.namespace, @project), class: "btn btn-new pull-right", title: "New Domain" do
|
||||
%i.fa.fa-plus
|
||||
New Domain
|
||||
|
||||
.table-holder
|
||||
%table.table
|
||||
%tr
|
||||
%td
|
||||
Domain
|
||||
%td
|
||||
= link_to @domain.domain, @domain.url
|
||||
%tr
|
||||
%td
|
||||
Certificate
|
||||
%td
|
||||
- if @domain.certificate_text
|
||||
%pre
|
||||
= @domain.certificate_text
|
||||
- else
|
||||
.light
|
||||
missing
|
||||
%p.light
|
||||
With GitLab Pages you can host for free your static websites on GitLab.
|
||||
Combined with the power of GitLab CI and the help of GitLab Runner
|
||||
you can deploy static pages for your individual projects, your user or your group.
|
||||
|
||||
%hr.clearfix
|
||||
|
||||
- if Gitlab.config.pages.enabled
|
||||
= render 'access'
|
||||
= render 'use'
|
||||
- if Gitlab.config.pages.external_http || Gitlab.config.pages.external_https
|
||||
= render 'list'
|
||||
- else
|
||||
= render 'no_domains'
|
||||
= render 'destroy'
|
||||
- else
|
||||
= render 'disabled'
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
= form_for [@domain], url: namespace_project_pages_path(@project.namespace, @project), html: { class: 'form-horizontal fieldset-form' } do |f|
|
||||
= form_for [@project.namespace, @project, @domain], html: { class: 'form-horizontal fieldset-form' } do |f|
|
||||
- if @domain.errors.any?
|
||||
#error_explanation
|
||||
.alert.alert-danger
|
22
app/views/projects/pages_domains/show.html.haml
Normal file
22
app/views/projects/pages_domains/show.html.haml
Normal file
|
@ -0,0 +1,22 @@
|
|||
- page_title "#{@domain.domain}", "Pages Domain"
|
||||
|
||||
%h3.page-title
|
||||
Pages Domain
|
||||
|
||||
.table-holder
|
||||
%table.table
|
||||
%tr
|
||||
%td
|
||||
Domain
|
||||
%td
|
||||
= link_to @domain.domain, @domain.url
|
||||
%tr
|
||||
%td
|
||||
Certificate
|
||||
%td
|
||||
- if @domain.certificate_text
|
||||
%pre
|
||||
= @domain.certificate_text
|
||||
- else
|
||||
.light
|
||||
missing
|
|
@ -39,10 +39,8 @@ constraints(ProjectUrlConstrainer.new) do
|
|||
end
|
||||
end
|
||||
|
||||
resources :pages, except: [:edit, :update] do
|
||||
collection do
|
||||
delete :remove_pages
|
||||
end
|
||||
resource :pages, only: [:show, :destroy] do
|
||||
resources :domains, only: [:show, :new, :create, :destroy], controller: 'pages_domains'
|
||||
end
|
||||
|
||||
resources :compare, only: [:index, :create] do
|
||||
|
|
|
@ -67,7 +67,7 @@ class Spinach::Features::ProjectPages < Spinach::FeatureSteps
|
|||
end
|
||||
|
||||
step 'I visit add a new Pages Domain' do
|
||||
visit new_namespace_project_page_path(@project.namespace, @project)
|
||||
visit new_namespace_project_pages_domain_path(@project.namespace, @project)
|
||||
end
|
||||
|
||||
step 'I fill the domain' do
|
||||
|
|
Loading…
Reference in a new issue