Commit 2ead328a authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

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
parents 273ba34c e6090e71
# 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 @@ ...@@ -7,9 +7,11 @@
%strong %strong
= _("Your pages are served under:") = _("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| - @project.pages_domains.each do |domain|
%p= link_to domain.url, domain.url %p
= external_link(domain.url, domain.url)
.card-footer.alert-primary .card-footer.alert-primary
= _("It may take up to 30 minutes before the site is available after the first deployment.") = _("It may take up to 30 minutes before the site is available after the first deployment.")
...@@ -12,9 +12,7 @@ ...@@ -12,9 +12,7 @@
.domain-status.ci-status-icon.has-tooltip{ class: "ci-status-icon-#{status}", title: tooltip } .domain-status.ci-status-icon.has-tooltip{ class: "ci-status-icon-#{status}", title: tooltip }
= sprite_icon("status_#{status}", size: 16 ) = sprite_icon("status_#{status}", size: 16 )
.domain-name .domain-name
= link_to domain.url do = external_link(domain.url, domain.url)
= domain.url
= icon('external-link')
- if domain.subject - if domain.subject
%div %div
%span.badge.badge-gray Certificate: #{domain.subject} %span.badge.badge-gray Certificate: #{domain.subject}
......
...@@ -21,9 +21,7 @@ ...@@ -21,9 +21,7 @@
%td %td
= _("Domain") = _("Domain")
%td %td
= link_to @domain.url do = external_link(@domain.url, @domain.url)
= @domain.url
= icon('external-link')
%tr %tr
%td %td
= _("DNS") = _("DNS")
......
---
title: Makes custom Pages domain open as external link in new tab
merge_request: 32130
author: jakeburden
type: fixed
# 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
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