Commit 7f12cb0e authored by Kamil Trzcinski's avatar Kamil Trzcinski Committed by James Edwards-Jones

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
parent 84edc9a2
class Projects::PagesController < Projects::ApplicationController class Projects::PagesController < Projects::ApplicationController
layout 'project_settings' layout 'project_settings'
before_action :authorize_update_pages!, except: [:show] before_action :authorize_update_pages!
before_action :authorize_remove_pages!, only: [:remove_pages]
before_action :label, only: [:destroy]
before_action :domain, only: [:show]
helper_method :valid_certificate?, :valid_certificate_key?
helper_method :valid_key_for_certificiate?, :valid_certificate_intermediates?
helper_method :certificate, :certificate_key
def index
@domains = @project.pages_domains.order(:domain)
end
def show def show
end @domains = @project.pages_domains.order(:domain)
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 end
def destroy 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.remove_pages
project.pages_domains.destroy_all project.pages_domains.destroy_all
...@@ -54,18 +18,4 @@ class Projects::PagesController < Projects::ApplicationController ...@@ -54,18 +18,4 @@ class Projects::PagesController < Projects::ApplicationController
end end
end 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 end
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 @@ ...@@ -6,4 +6,4 @@
%p %p
Removing the pages will prevent from exposing them to outside world. Removing the pages will prevent from exposing them to outside world.
.form-actions .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 @@ ...@@ -6,8 +6,8 @@
- @domains.each do |domain| - @domains.each do |domain|
%li %li
.pull-right .pull-right
= link_to 'Details', namespace_project_page_path(@project.namespace, @project, domain), class: "btn 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_page_path(@project.namespace, @project, domain), data: { confirm: 'Are you sure?'}, method: :delete, class: "btn btn-remove 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 .clearfix
%span= link_to domain.domain, domain.url %span= link_to domain.domain, domain.url
%p %p
......
- 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'
- page_title "#{@domain.domain}", "Pages Domain" - page_title "Pages"
%h3.page_title
Pages
%h3.page-title - if Gitlab.config.pages.external_http || Gitlab.config.pages.external_https
Pages Domain = 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 %p.light
%table.table With GitLab Pages you can host for free your static websites on GitLab.
%tr Combined with the power of GitLab CI and the help of GitLab Runner
%td you can deploy static pages for your individual projects, your user or your group.
Domain
%td %hr.clearfix
= link_to @domain.domain, @domain.url
%tr - if Gitlab.config.pages.enabled
%td = render 'access'
Certificate = render 'use'
%td - if Gitlab.config.pages.external_http || Gitlab.config.pages.external_https
- if @domain.certificate_text = render 'list'
%pre
= @domain.certificate_text
- else - else
.light = render 'no_domains'
missing = render 'destroy'
- else
= render 'disabled'
= 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? - if @domain.errors.any?
#error_explanation #error_explanation
.alert.alert-danger .alert.alert-danger
......
- 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 ...@@ -39,10 +39,8 @@ constraints(ProjectUrlConstrainer.new) do
end end
end end
resources :pages, except: [:edit, :update] do resource :pages, only: [:show, :destroy] do
collection do resources :domains, only: [:show, :new, :create, :destroy], controller: 'pages_domains'
delete :remove_pages
end
end end
resources :compare, only: [:index, :create] do resources :compare, only: [:index, :create] do
......
...@@ -67,7 +67,7 @@ class Spinach::Features::ProjectPages < Spinach::FeatureSteps ...@@ -67,7 +67,7 @@ class Spinach::Features::ProjectPages < Spinach::FeatureSteps
end end
step 'I visit add a new Pages Domain' do 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 end
step 'I fill the domain' do step 'I fill the domain' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment