Merge branch '66067-pages-domain-doesnt-set-target-blank' into 'master'
Makes custom Pages domain open as external link in new tab Closes #66067 See merge request gitlab-org/gitlab-ce!32130
This commit is contained in:
commit
2ead328abc
6 changed files with 37 additions and 8 deletions
9
app/helpers/external_link_helper.rb
Normal file
9
app/helpers/external_link_helper.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module ExternalLinkHelper
|
||||
def external_link(body, url, options = {})
|
||||
link_to url, { target: '_blank', rel: 'noopener noreferrer' }.merge(options) do
|
||||
"#{body} #{icon('external-link')}".html_safe
|
||||
end
|
||||
end
|
||||
end
|
|
@ -7,9 +7,11 @@
|
|||
%strong
|
||||
= _("Your pages are served under:")
|
||||
|
||||
%p= link_to @project.pages_url, @project.pages_url
|
||||
%p
|
||||
= external_link(@project.pages_url, @project.pages_url)
|
||||
|
||||
- @project.pages_domains.each do |domain|
|
||||
%p= link_to domain.url, domain.url
|
||||
%p
|
||||
= external_link(domain.url, domain.url)
|
||||
.card-footer.alert-primary
|
||||
= _("It may take up to 30 minutes before the site is available after the first deployment.")
|
||||
|
|
|
@ -12,9 +12,7 @@
|
|||
.domain-status.ci-status-icon.has-tooltip{ class: "ci-status-icon-#{status}", title: tooltip }
|
||||
= sprite_icon("status_#{status}", size: 16 )
|
||||
.domain-name
|
||||
= link_to domain.url do
|
||||
= domain.url
|
||||
= icon('external-link')
|
||||
= external_link(domain.url, domain.url)
|
||||
- if domain.subject
|
||||
%div
|
||||
%span.badge.badge-gray Certificate: #{domain.subject}
|
||||
|
|
|
@ -21,9 +21,7 @@
|
|||
%td
|
||||
= _("Domain")
|
||||
%td
|
||||
= link_to @domain.url do
|
||||
= @domain.url
|
||||
= icon('external-link')
|
||||
= external_link(@domain.url, @domain.url)
|
||||
%tr
|
||||
%td
|
||||
= _("DNS")
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Makes custom Pages domain open as external link in new tab
|
||||
merge_request: 32130
|
||||
author: jakeburden
|
||||
type: fixed
|
17
spec/helpers/external_link_helper_spec.rb
Normal file
17
spec/helpers/external_link_helper_spec.rb
Normal file
|
@ -0,0 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe ExternalLinkHelper do
|
||||
include IconsHelper
|
||||
|
||||
it 'returns external link with icon' do
|
||||
expect(external_link('https://gitlab.com', 'https://gitlab.com').to_s)
|
||||
.to eq('<a target="_blank" rel="noopener noreferrer" href="https://gitlab.com">https://gitlab.com <i aria-hidden="true" data-hidden="true" class="fa fa-external-link"></i></a>')
|
||||
end
|
||||
|
||||
it 'allows options when creating external link with icon' do
|
||||
expect(external_link('https://gitlab.com', 'https://gitlab.com', { "data-foo": "bar", class: "externalLink" }).to_s)
|
||||
.to eq('<a target="_blank" rel="noopener noreferrer" data-foo="bar" class="externalLink" href="https://gitlab.com">https://gitlab.com <i aria-hidden="true" data-hidden="true" class="fa fa-external-link"></i></a>')
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue