diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-15 15:49:40 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-15 15:49:40 +0000 |
commit | b04b1e12c5847f7d366e08af47115d985b73e185 (patch) | |
tree | 5077e33eedbf1e99b9ef9b87395f9acce844b234 /app | |
parent | a5b9fb9abc2b83304f45392642801b28f52b3f48 (diff) | |
download | gitlab-ce-b04b1e12c5847f7d366e08af47115d985b73e185.tar.gz |
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/projects/pages_domains_controller.rb | 10 | ||||
-rw-r--r-- | app/uploaders/file_uploader.rb | 2 | ||||
-rw-r--r-- | app/views/projects/pages_domains/_certificate.html.haml | 8 | ||||
-rw-r--r-- | app/views/projects/pages_domains/_dns.html.haml | 8 | ||||
-rw-r--r-- | app/views/projects/pages_domains/_form.html.haml | 10 | ||||
-rw-r--r-- | app/views/projects/pages_domains/_lets_encrypt_callout.html.haml | 10 | ||||
-rw-r--r-- | app/views/projects/pages_domains/new.html.haml | 2 | ||||
-rw-r--r-- | app/views/projects/pages_domains/show.html.haml | 8 |
8 files changed, 32 insertions, 26 deletions
diff --git a/app/controllers/projects/pages_domains_controller.rb b/app/controllers/projects/pages_domains_controller.rb index cdf6f5ce828..cccf8fe4358 100644 --- a/app/controllers/projects/pages_domains_controller.rb +++ b/app/controllers/projects/pages_domains_controller.rb @@ -7,6 +7,8 @@ class Projects::PagesDomainsController < Projects::ApplicationController before_action :authorize_update_pages! before_action :domain, except: [:new, :create] + helper_method :domain_presenter + def show end @@ -27,7 +29,7 @@ class Projects::PagesDomainsController < Projects::ApplicationController end def retry_auto_ssl - PagesDomains::RetryAcmeOrderService.new(@domain.pages_domain).execute + PagesDomains::RetryAcmeOrderService.new(@domain).execute redirect_to project_pages_domain_path(@project, @domain) end @@ -88,6 +90,10 @@ class Projects::PagesDomainsController < Projects::ApplicationController end def domain - @domain ||= @project.pages_domains.find_by_domain!(params[:id].to_s).present(current_user: current_user) + @domain ||= @project.pages_domains.find_by_domain!(params[:id].to_s) + end + + def domain_presenter + @domain_presenter ||= domain.present(current_user: current_user) end end diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb index 517c22e2334..20aab58243a 100644 --- a/app/uploaders/file_uploader.rb +++ b/app/uploaders/file_uploader.rb @@ -15,7 +15,7 @@ class FileUploader < GitlabUploader prepend ObjectStorage::Extension::RecordsUploads MARKDOWN_PATTERN = %r{\!?\[.*?\]\(/uploads/(?<secret>[0-9a-f]{32})/(?<file>.*?)\)}.freeze - DYNAMIC_PATH_PATTERN = %r{.*/(?<secret>\h{10,32})/(?<identifier>.*)}.freeze + DYNAMIC_PATH_PATTERN = %r{.*(?<secret>\b(\h{10}|\h{32}))\/(?<identifier>.*)}.freeze VALID_SECRET_PATTERN = %r{\A\h{10,32}\z}.freeze InvalidSecret = Class.new(StandardError) diff --git a/app/views/projects/pages_domains/_certificate.html.haml b/app/views/projects/pages_domains/_certificate.html.haml index e95841f2867..11c7e4a950b 100644 --- a/app/views/projects/pages_domains/_certificate.html.haml +++ b/app/views/projects/pages_domains/_certificate.html.haml @@ -1,7 +1,7 @@ - auto_ssl_available = ::Gitlab::LetsEncrypt.enabled? -- auto_ssl_enabled = @domain.auto_ssl_enabled? +- auto_ssl_enabled = domain_presenter.auto_ssl_enabled? - auto_ssl_available_and_enabled = auto_ssl_available && auto_ssl_enabled -- has_user_defined_certificate = @domain.certificate && @domain.certificate_user_provided? +- has_user_defined_certificate = domain_presenter.certificate && domain_presenter.certificate_user_provided? - if auto_ssl_available .form-group.border-section @@ -36,9 +36,9 @@ = _('Certificate') .d-flex.justify-content-between.align-items-center.p-3 %span - = @domain.pages_domain.subject || _('missing') + = domain_presenter.pages_domain.subject || _('missing') = link_to _('Remove'), - clean_certificate_project_pages_domain_path(@project, @domain), + clean_certificate_project_pages_domain_path(@project, domain_presenter), data: { confirm: _('Are you sure?') }, class: 'btn btn-remove btn-sm', method: :delete diff --git a/app/views/projects/pages_domains/_dns.html.haml b/app/views/projects/pages_domains/_dns.html.haml index e4e590f0a98..8e2a9c3bab4 100644 --- a/app/views/projects/pages_domains/_dns.html.haml +++ b/app/views/projects/pages_domains/_dns.html.haml @@ -1,5 +1,5 @@ - verification_enabled = Gitlab::CurrentSettings.pages_domain_verification_enabled? -- dns_record = "#{@domain.domain} CNAME #{@domain.project.pages_subdomain}.#{Settings.pages.host}." +- dns_record = "#{domain_presenter.domain} CNAME #{domain_presenter.project.pages_subdomain}.#{Settings.pages.host}." .form-group.border-section .row @@ -13,17 +13,17 @@ %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}" + - verification_record = "#{domain_presenter.verification_domain} TXT #{domain_presenter.keyed_verification_code}" .form-group.border-section .row .col-sm-2 = _("Verification status") .col-sm-10 .status-badge - - text, status = @domain.unverified? ? [_('Unverified'), 'badge-danger'] : [_('Verified'), 'badge-success'] + - text, status = domain_presenter.unverified? ? [_('Unverified'), 'badge-danger'] : [_('Verified'), 'badge-success'] .badge{ class: status } = text - = link_to sprite_icon("redo"), verify_project_pages_domain_path(@project, @domain), method: :post, class: "btn has-tooltip", title: _("Retry verification") + = link_to sprite_icon("redo"), verify_project_pages_domain_path(@project, domain_presenter), method: :post, class: "btn has-tooltip", title: _("Retry verification") .input-group = text_field_tag :domain_verification, verification_record, class: "monospace js-select-on-focus form-control", readonly: true .input-group-append diff --git a/app/views/projects/pages_domains/_form.html.haml b/app/views/projects/pages_domains/_form.html.haml index e06dab9be06..9e9f60a6f09 100644 --- a/app/views/projects/pages_domains/_form.html.haml +++ b/app/views/projects/pages_domains/_form.html.haml @@ -1,15 +1,15 @@ -- if @domain.errors.any? +- if domain_presenter.errors.any? .alert.alert-danger - - @domain.errors.full_messages.each do |msg| + - domain_presenter.errors.full_messages.each do |msg| = msg .form-group.border-section .row - - if @domain.persisted? + - if domain_presenter.persisted? .col-sm-2 = _("Domain") .col-sm-10 - = external_link(@domain.url, @domain.url) + = external_link(domain_presenter.url, domain_presenter.url) - else .col-sm-2 = f.label :domain, _("Domain") @@ -17,7 +17,7 @@ .input-group = f.text_field :domain, required: true, autocomplete: "off", class: "form-control" -- if @domain.persisted? +- if domain_presenter.persisted? = render 'dns' - if Gitlab.config.pages.external_https diff --git a/app/views/projects/pages_domains/_lets_encrypt_callout.html.haml b/app/views/projects/pages_domains/_lets_encrypt_callout.html.haml index f2de42b218c..a86637c36b3 100644 --- a/app/views/projects/pages_domains/_lets_encrypt_callout.html.haml +++ b/app/views/projects/pages_domains/_lets_encrypt_callout.html.haml @@ -1,6 +1,6 @@ -- if @domain.enabled? - - if @domain.auto_ssl_enabled - - if @domain.show_auto_ssl_failed_warning? +- if domain_presenter.enabled? + - if domain_presenter.auto_ssl_enabled + - if domain_presenter.show_auto_ssl_failed_warning? .form-group.border-section.js-shown-if-auto-ssl{ class: ("d-none" unless auto_ssl_available_and_enabled) } .row .col-sm-10.offset-sm-2 @@ -9,8 +9,8 @@ = icon('warning', class: 'mr-2') = _("Something went wrong while obtaining the Let's Encrypt certificate.") .row.mx-0.mt-3 - = link_to s_('GitLabPagesDomains|Retry'), retry_auto_ssl_project_pages_domain_path(@project, @domain), class: "btn btn-sm btn-grouped btn-warning", method: :post - - elsif !@domain.certificate_gitlab_provided? + = link_to s_('GitLabPagesDomains|Retry'), retry_auto_ssl_project_pages_domain_path(@project, domain_presenter), class: "btn btn-sm btn-grouped btn-warning", method: :post + - elsif !domain_presenter.certificate_gitlab_provided? .form-group.border-section.js-shown-if-auto-ssl{ class: ("d-none" unless auto_ssl_available_and_enabled) } .row .col-sm-10.offset-sm-2 diff --git a/app/views/projects/pages_domains/new.html.haml b/app/views/projects/pages_domains/new.html.haml index 3210bfe9231..f5dc3ccc60e 100644 --- a/app/views/projects/pages_domains/new.html.haml +++ b/app/views/projects/pages_domains/new.html.haml @@ -4,7 +4,7 @@ = _("New Pages Domain") = render 'projects/pages_domains/helper_text' %div - = form_for [@project.namespace.becomes(Namespace), @project, @domain], html: { class: 'fieldset-form' } do |f| + = form_for [@project.namespace.becomes(Namespace), @project, domain_presenter], html: { class: 'fieldset-form' } do |f| = render 'form', { f: f } .form-actions = f.submit _('Create New Domain'), class: "btn btn-success" diff --git a/app/views/projects/pages_domains/show.html.haml b/app/views/projects/pages_domains/show.html.haml index a08be65d7e4..e1be7335a3f 100644 --- a/app/views/projects/pages_domains/show.html.haml +++ b/app/views/projects/pages_domains/show.html.haml @@ -1,10 +1,10 @@ - add_to_breadcrumbs _("Pages"), project_pages_path(@project) -- breadcrumb_title @domain.domain -- page_title @domain.domain +- breadcrumb_title domain_presenter.domain +- page_title domain_presenter.domain - verification_enabled = Gitlab::CurrentSettings.pages_domain_verification_enabled? -- if verification_enabled && @domain.unverified? +- if verification_enabled && domain_presenter.unverified? = content_for :flash_message do .alert.alert-warning .container-fluid.container-limited @@ -14,7 +14,7 @@ = _('Pages Domain') = render 'projects/pages_domains/helper_text' %div - = form_for [@project.namespace.becomes(Namespace), @project, @domain], html: { class: 'fieldset-form' } do |f| + = form_for [@project.namespace.becomes(Namespace), @project, domain_presenter], 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" |