Commit 64fedd20 authored by Paul Slaughter's avatar Paul Slaughter

Merge branch 'migrate-pages-domains-edit-to-show' into 'master'

Migrate Pages Domain Settings from Edit to Show

See merge request gitlab-org/gitlab!20403
parents 45c51442 d7bdd603
...@@ -8,7 +8,6 @@ class Projects::PagesDomainsController < Projects::ApplicationController ...@@ -8,7 +8,6 @@ class Projects::PagesDomainsController < Projects::ApplicationController
before_action :domain, except: [:new, :create] before_action :domain, except: [:new, :create]
def show def show
redirect_to edit_project_pages_domain_path(@project, @domain)
end end
def new def new
...@@ -24,17 +23,18 @@ class Projects::PagesDomainsController < Projects::ApplicationController ...@@ -24,17 +23,18 @@ class Projects::PagesDomainsController < Projects::ApplicationController
flash[:alert] = 'Failed to verify domain ownership' flash[:alert] = 'Failed to verify domain ownership'
end end
redirect_to edit_project_pages_domain_path(@project, @domain) redirect_to project_pages_domain_path(@project, @domain)
end end
def edit def edit
redirect_to project_pages_domain_path(@project, @domain)
end end
def create def create
@domain = @project.pages_domains.create(create_params) @domain = @project.pages_domains.create(create_params)
if @domain.valid? if @domain.valid?
redirect_to edit_project_pages_domain_path(@project, @domain) redirect_to project_pages_domain_path(@project, @domain)
else else
render 'new' render 'new'
end end
...@@ -46,7 +46,7 @@ class Projects::PagesDomainsController < Projects::ApplicationController ...@@ -46,7 +46,7 @@ class Projects::PagesDomainsController < Projects::ApplicationController
status: :found, status: :found,
notice: 'Domain was updated' notice: 'Domain was updated'
else else
render 'edit' render 'show'
end end
end end
...@@ -68,7 +68,7 @@ class Projects::PagesDomainsController < Projects::ApplicationController ...@@ -68,7 +68,7 @@ class Projects::PagesDomainsController < Projects::ApplicationController
flash[:alert] = @domain.errors.full_messages.join(', ') flash[:alert] = @domain.errors.full_messages.join(', ')
end end
redirect_to edit_project_pages_domain_path(@project, @domain) redirect_to project_pages_domain_path(@project, @domain)
end end
private private
......
...@@ -21,11 +21,11 @@ ...@@ -21,11 +21,11 @@
%span.badge.badge-danger %span.badge.badge-danger
= s_('GitLabPages|Expired') = s_('GitLabPages|Expired')
%div %div
= link_to s_('GitLabPages|Edit'), edit_project_pages_domain_path(@project, domain), class: "btn btn-sm btn-grouped btn-success btn-inverted" = link_to s_('GitLabPages|Edit'), project_pages_domain_path(@project, domain), class: "btn btn-sm btn-grouped btn-success btn-inverted"
= link_to s_('GitLabPages|Remove'), project_pages_domain_path(@project, domain), data: { confirm: s_('GitLabPages|Are you sure?')}, method: :delete, class: "btn btn-remove btn-sm btn-grouped" = link_to s_('GitLabPages|Remove'), project_pages_domain_path(@project, domain), data: { confirm: s_('GitLabPages|Are you sure?')}, method: :delete, class: "btn btn-remove btn-sm btn-grouped"
- if verification_enabled && domain.unverified? - if verification_enabled && domain.unverified?
%li.list-group-item.bs-callout-warning %li.list-group-item.bs-callout-warning
- details_link_start = "<a href='#{edit_project_pages_domain_path(@project, domain)}'>".html_safe - details_link_start = "<a href='#{project_pages_domain_path(@project, domain)}'>".html_safe
- details_link_end = '</a>'.html_safe - details_link_end = '</a>'.html_safe
= s_('GitLabPages|%{domain} is not verified. To learn how to verify ownership, visit your %{link_start}domain details%{link_end}.').html_safe % { domain: domain.domain, = s_('GitLabPages|%{domain} is not verified. To learn how to verify ownership, visit your %{link_start}domain details%{link_end}.').html_safe % { domain: domain.domain,
link_start: details_link_start, link_start: details_link_start,
......
- add_to_breadcrumbs _("Pages"), project_pages_path(@project)
- breadcrumb_title @domain.domain
- page_title @domain.domain
- verification_enabled = Gitlab::CurrentSettings.pages_domain_verification_enabled?
- if verification_enabled && @domain.unverified?
= content_for :flash_message do
.alert.alert-warning
.container-fluid.container-limited
= _("This domain is not verified. You will need to verify ownership before access is enabled.")
%h3.page-title
= _('Pages Domain')
= render 'projects/pages_domains/helper_text'
%div
= form_for [@project.namespace.becomes(Namespace), @project, @domain], html: { class: 'fieldset-form' } do |f|
= render 'form', { f: f }
.form-actions.d-flex.justify-content-between
= f.submit _('Save Changes'), class: "btn btn-success"
= link_to _('Cancel'), project_pages_path(@project), class: 'btn btn-default btn-inverse'
- add_to_breadcrumbs _("Pages"), project_pages_path(@project) - add_to_breadcrumbs _("Pages"), project_pages_path(@project)
- breadcrumb_title @domain.domain - breadcrumb_title @domain.domain
- page_title "#{@domain.domain}", _('Pages Domains') - page_title @domain.domain
- dns_record = "#{@domain.domain} CNAME #{@domain.project.pages_subdomain}.#{Settings.pages.host}."
- verification_enabled = Gitlab::CurrentSettings.pages_domain_verification_enabled? - verification_enabled = Gitlab::CurrentSettings.pages_domain_verification_enabled?
...@@ -11,51 +10,12 @@ ...@@ -11,51 +10,12 @@
.container-fluid.container-limited .container-fluid.container-limited
= _("This domain is not verified. You will need to verify ownership before access is enabled.") = _("This domain is not verified. You will need to verify ownership before access is enabled.")
%h3.page-title.with-button %h3.page-title
= link_to _('Edit'), edit_project_pages_domain_path(@project, @domain), class: 'btn btn-success float-right' = _('Pages Domain')
= _("Pages Domain") = render 'projects/pages_domains/helper_text'
%div
.table-holder = form_for [@project.namespace.becomes(Namespace), @project, @domain], html: { class: 'fieldset-form' } do |f|
%table.table = render 'form', { f: f }
%tr .form-actions.d-flex.justify-content-between
%td = f.submit _('Save Changes'), class: "btn btn-success"
= _("Domain") = link_to _('Cancel'), project_pages_path(@project), class: 'btn btn-default btn-inverse'
%td
= external_link(@domain.url, @domain.url)
%tr
%td
= _("DNS")
%td
.input-group
= text_field_tag :domain_dns, dns_record , class: "monospace js-select-on-focus form-control", readonly: true
.input-group-append
= clipboard_button(target: '#domain_dns', class: 'btn-default input-group-text d-none d-sm-block')
%p.form-text.text-muted
= _("To access this domain create a new DNS record")
- if verification_enabled
- verification_record = "#{@domain.verification_domain} TXT #{@domain.keyed_verification_code}"
%tr
%td
= _("Verification status")
%td
= form_tag verify_project_pages_domain_path(@project, @domain) do
.status-badge
- text, status = @domain.unverified? ? [_('Unverified'), 'badge-danger'] : [_('Verified'), 'badge-success']
.badge{ class: status }
= text
%button.btn.has-tooltip{ type: "submit", data: { container: 'body' }, title: _("Retry verification") }
= sprite_icon('redo')
.input-group
= text_field_tag :domain_verification, verification_record, class: "monospace js-select-on-focus form-control", readonly: true
.input-group-append
= clipboard_button(target: '#domain_verification', class: 'btn-default d-none d-sm-block')
%p.form-text.text-muted
- link_to_help = link_to(_('verify ownership'), help_page_path('user/project/pages/custom_domains_ssl_tls_certification/index.md', anchor: '4-verify-the-domains-ownership'))
= _("To %{link_to_help} of your domain, add the above key to a TXT record within to your DNS configuration.").html_safe % { link_to_help: link_to_help }
%tr
%td
= _("Certificate")
%td
= render 'lets_encrypt_callout', auto_ssl_available_and_enabled: false
...@@ -12315,9 +12315,6 @@ msgstr "" ...@@ -12315,9 +12315,6 @@ msgstr ""
msgid "Pages Domain" msgid "Pages Domain"
msgstr "" msgstr ""
msgid "Pages Domains"
msgstr ""
msgid "Pages getting started guide" msgid "Pages getting started guide"
msgstr "" msgstr ""
......
...@@ -32,10 +32,11 @@ describe Projects::PagesDomainsController do ...@@ -32,10 +32,11 @@ describe Projects::PagesDomainsController do
get(:show, params: request_params.merge(id: pages_domain.domain)) get(:show, params: request_params.merge(id: pages_domain.domain))
end end
it "redirects to the 'edit' page" do it "displays to the 'show' page" do
make_request make_request
expect(response).to redirect_to(edit_project_pages_domain_path(project, pages_domain.domain)) expect(response).to have_gitlab_http_status(200)
expect(response).to render_template('show')
end end
context 'when user is developer' do context 'when user is developer' do
...@@ -69,16 +70,16 @@ describe Projects::PagesDomainsController do ...@@ -69,16 +70,16 @@ describe Projects::PagesDomainsController do
created_domain = PagesDomain.reorder(:id).last created_domain = PagesDomain.reorder(:id).last
expect(created_domain).to be_present expect(created_domain).to be_present
expect(response).to redirect_to(edit_project_pages_domain_path(project, created_domain)) expect(response).to redirect_to(project_pages_domain_path(project, created_domain))
end end
end end
describe 'GET edit' do describe 'GET show' do
it "displays the 'edit' page" do it "displays the 'show' page" do
get(:edit, params: request_params.merge(id: pages_domain.domain)) get(:show, params: request_params.merge(id: pages_domain.domain))
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(200)
expect(response).to render_template('edit') expect(response).to render_template('show')
end end
end end
...@@ -128,10 +129,10 @@ describe Projects::PagesDomainsController do ...@@ -128,10 +129,10 @@ describe Projects::PagesDomainsController do
context 'the domain is invalid' do context 'the domain is invalid' do
let(:pages_domain_params) { { user_provided_certificate: 'blabla' } } let(:pages_domain_params) { { user_provided_certificate: 'blabla' } }
it 'renders the edit action' do it 'renders the show action' do
patch(:update, params: params) patch(:update, params: params)
expect(response).to render_template('edit') expect(response).to render_template('show')
end end
end end
...@@ -160,7 +161,7 @@ describe Projects::PagesDomainsController do ...@@ -160,7 +161,7 @@ describe Projects::PagesDomainsController do
post :verify, params: params post :verify, params: params
expect(response).to redirect_to edit_project_pages_domain_path(project, pages_domain) expect(response).to redirect_to project_pages_domain_path(project, pages_domain)
expect(flash[:notice]).to eq('Successfully verified domain ownership') expect(flash[:notice]).to eq('Successfully verified domain ownership')
end end
...@@ -169,7 +170,7 @@ describe Projects::PagesDomainsController do ...@@ -169,7 +170,7 @@ describe Projects::PagesDomainsController do
post :verify, params: params post :verify, params: params
expect(response).to redirect_to edit_project_pages_domain_path(project, pages_domain) expect(response).to redirect_to project_pages_domain_path(project, pages_domain)
expect(flash[:alert]).to eq('Failed to verify domain ownership') expect(flash[:alert]).to eq('Failed to verify domain ownership')
end end
...@@ -195,10 +196,10 @@ describe Projects::PagesDomainsController do ...@@ -195,10 +196,10 @@ describe Projects::PagesDomainsController do
delete(:clean_certificate, params: request_params.merge(id: pages_domain.domain)) delete(:clean_certificate, params: request_params.merge(id: pages_domain.domain))
end end
it 'redirects to edit page' do it 'redirects to show page' do
subject subject
expect(response).to redirect_to(edit_project_pages_domain_path(project, pages_domain)) expect(response).to redirect_to(project_pages_domain_path(project, pages_domain))
end end
it 'removes certificate' do it 'removes certificate' do
...@@ -230,12 +231,12 @@ describe Projects::PagesDomainsController do ...@@ -230,12 +231,12 @@ describe Projects::PagesDomainsController do
expect(pages_domain.key).to be_present expect(pages_domain.key).to be_present
end end
it 'redirects to edit page with a flash message' do it 'redirects to show page with a flash message' do
subject subject
expect(flash[:alert]).to include('Certificate') expect(flash[:alert]).to include('Certificate')
expect(flash[:alert]).to include('Key') expect(flash[:alert]).to include('Key')
expect(response).to redirect_to(edit_project_pages_domain_path(project, pages_domain)) expect(response).to redirect_to(project_pages_domain_path(project, pages_domain))
end end
end end
end end
......
...@@ -41,7 +41,7 @@ describe "Pages with Let's Encrypt", :https_pages_enabled do ...@@ -41,7 +41,7 @@ describe "Pages with Let's Encrypt", :https_pages_enabled do
end end
it 'enables auto SSL and dynamically updates the form accordingly', :js do it 'enables auto SSL and dynamically updates the form accordingly', :js do
visit edit_project_pages_domain_path(project, domain) visit project_pages_domain_path(project, domain)
expect(domain.auto_ssl_enabled).to eq false expect(domain.auto_ssl_enabled).to eq false
...@@ -67,7 +67,7 @@ describe "Pages with Let's Encrypt", :https_pages_enabled do ...@@ -67,7 +67,7 @@ describe "Pages with Let's Encrypt", :https_pages_enabled do
end end
it 'disables auto SSL and dynamically updates the form accordingly', :js do it 'disables auto SSL and dynamically updates the form accordingly', :js do
visit edit_project_pages_domain_path(project, domain) visit project_pages_domain_path(project, domain)
expect(find("#pages_domain_auto_ssl_enabled", visible: false).value).to eq 'true' expect(find("#pages_domain_auto_ssl_enabled", visible: false).value).to eq 'true'
expect(page).not_to have_field 'Certificate (PEM)', type: 'textarea' expect(page).not_to have_field 'Certificate (PEM)', type: 'textarea'
...@@ -88,7 +88,7 @@ describe "Pages with Let's Encrypt", :https_pages_enabled do ...@@ -88,7 +88,7 @@ describe "Pages with Let's Encrypt", :https_pages_enabled do
shared_examples 'user sees private keys only for user provided certificate' do shared_examples 'user sees private keys only for user provided certificate' do
shared_examples 'user do not see private key' do shared_examples 'user do not see private key' do
it 'user do not see private key' do it 'user do not see private key' do
visit edit_project_pages_domain_path(project, domain) visit project_pages_domain_path(project, domain)
expect(page).not_to have_selector '.card-header', text: 'Certificate' expect(page).not_to have_selector '.card-header', text: 'Certificate'
expect(page).not_to have_text domain.subject expect(page).not_to have_text domain.subject
...@@ -111,14 +111,14 @@ describe "Pages with Let's Encrypt", :https_pages_enabled do ...@@ -111,14 +111,14 @@ describe "Pages with Let's Encrypt", :https_pages_enabled do
let(:domain) { create(:pages_domain, project: project, auto_ssl_enabled: false) } let(:domain) { create(:pages_domain, project: project, auto_ssl_enabled: false) }
it 'user sees certificate subject' do it 'user sees certificate subject' do
visit edit_project_pages_domain_path(project, domain) visit project_pages_domain_path(project, domain)
expect(page).to have_selector '.card-header', text: 'Certificate' expect(page).to have_selector '.card-header', text: 'Certificate'
expect(page).to have_text domain.subject expect(page).to have_text domain.subject
end end
it 'user can delete the certificate', :js do it 'user can delete the certificate', :js do
visit edit_project_pages_domain_path(project, domain) visit project_pages_domain_path(project, domain)
expect(page).to have_selector '.card-header', text: 'Certificate' expect(page).to have_selector '.card-header', text: 'Certificate'
expect(page).to have_text domain.subject expect(page).to have_text domain.subject
...@@ -139,7 +139,7 @@ describe "Pages with Let's Encrypt", :https_pages_enabled do ...@@ -139,7 +139,7 @@ describe "Pages with Let's Encrypt", :https_pages_enabled do
before do before do
stub_application_setting(lets_encrypt_terms_of_service_accepted: false) stub_application_setting(lets_encrypt_terms_of_service_accepted: false)
visit edit_project_pages_domain_path(project, domain) visit project_pages_domain_path(project, domain)
end end
it "does not render the Let's Encrypt field", :js do it "does not render the Let's Encrypt field", :js do
......
...@@ -8,6 +8,7 @@ describe 'projects/pages_domains/show' do ...@@ -8,6 +8,7 @@ describe 'projects/pages_domains/show' do
before do before do
assign(:project, project) assign(:project, project)
assign(:domain, domain) assign(:domain, domain)
stub_pages_setting(external_https: true)
end end
context 'when auto_ssl is enabled' do context 'when auto_ssl is enabled' 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