Commit dfd9185d authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg

Merge branch '34102-online-view-of-artifacts-fe' of...

Merge branch '34102-online-view-of-artifacts-fe' of gitlab.com:gitlab-org/gitlab-ce into 34102-online-view-of-artifacts-fe
parents 8cbfe3ae 1bc5d24a
...@@ -90,7 +90,7 @@ w.gl.utils.refreshCurrentPage = () => gl.utils.visitUrl(document.location.href); ...@@ -90,7 +90,7 @@ w.gl.utils.refreshCurrentPage = () => gl.utils.visitUrl(document.location.href);
// eslint-disable-next-line import/prefer-default-export // eslint-disable-next-line import/prefer-default-export
export function visitUrl(url, external = false) { export function visitUrl(url, external = false) {
if (external) { if (external) {
// Simulate `target="blank" ref="noopener noreferrer"` // Simulate `target="blank" rel="noopener noreferrer"`
// See https://mathiasbynens.github.io/rel-noopener/ // See https://mathiasbynens.github.io/rel-noopener/
const otherWindow = window.open(); const otherWindow = window.open();
otherWindow.opener = null; otherWindow.opener = null;
......
...@@ -170,6 +170,8 @@ ...@@ -170,6 +170,8 @@
} }
.tree-item-file-external-link { .tree-item-file-external-link {
margin-right: 4px;
span { span {
text-decoration: inherit; text-decoration: inherit;
} }
......
...@@ -6,13 +6,12 @@ ...@@ -6,13 +6,12 @@
%td.tree-item-file-name %td.tree-item-file-name
= tree_icon('file', blob.mode, blob.name) = tree_icon('file', blob.mode, blob.name)
= link_to path_to_file, = link_to path_to_file,
class: 'tree-item-file-external-link js-artifact-tree-tooltip', class: ('tree-item-file-external-link js-artifact-tree-tooltip' if is_external_link),
target: ('_blank' if is_external_link), target: ('_blank' if is_external_link),
rel: ('noopener noreferrer' if is_external_link), rel: ('noopener noreferrer' if is_external_link),
title: ('Opens in a new window' if is_external_link) do title: ('Opens in a new window' if is_external_link) do
%span.str-truncated>= blob.name %span.str-truncated>= blob.name
- if is_external_link - if is_external_link
= ' ' = icon('external-link', class: 'js-artifact-tree-external-icon')
= icon('external-link')
%td %td
= number_to_human_size(blob.size, precision: 2) = number_to_human_size(blob.size, precision: 2)
---
title: Add online view of HTML artifacts for public projects
merge_request: 14399
author:
type: added
...@@ -50,6 +50,10 @@ For more examples on artifacts, follow the [artifacts reference in ...@@ -50,6 +50,10 @@ For more examples on artifacts, follow the [artifacts reference in
With GitLab 9.2, PDFs, images, videos and other formats can be previewed With GitLab 9.2, PDFs, images, videos and other formats can be previewed
directly in the job artifacts browser without the need to download them. directly in the job artifacts browser without the need to download them.
>**Note:**
With [GitLab 10.1][ce-14399], HTML files in a public project can be previewed
directly in a new tab without the need to download them.
After a job finishes, if you visit the job's specific page, there are three After a job finishes, if you visit the job's specific page, there are three
buttons. You can download the artifacts archive or browse its contents, whereas buttons. You can download the artifacts archive or browse its contents, whereas
the **Keep** button appears only if you have set an [expiry date] to the the **Keep** button appears only if you have set an [expiry date] to the
...@@ -64,7 +68,8 @@ archive. If your artifacts contained directories, then you are also able to ...@@ -64,7 +68,8 @@ archive. If your artifacts contained directories, then you are also able to
browse inside them. browse inside them.
Below you can see how browsing looks like. In this case we have browsed inside Below you can see how browsing looks like. In this case we have browsed inside
the archive and at this point there is one directory and one HTML file. the archive and at this point there is one directory, a couple files, and
one HTML file that you can view directly online (opens in a new tab).
![Job artifacts browser](img/job_artifacts_browser.png) ![Job artifacts browser](img/job_artifacts_browser.png)
...@@ -158,3 +163,4 @@ information in the UI. ...@@ -158,3 +163,4 @@ information in the UI.
[expiry date]: ../../../ci/yaml/README.md#artifacts-expire_in [expiry date]: ../../../ci/yaml/README.md#artifacts-expire_in
[ce-14399]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/14399
require 'spec_helper' require 'spec_helper'
feature 'Browse artifact', :js do feature 'Browse artifact', :js do
include ArtifactHelper
let(:project) { create(:project, :public) } let(:project) { create(:project, :public) }
let(:pipeline) { create(:ci_empty_pipeline, project: project) } let(:pipeline) { create(:ci_empty_pipeline, project: project) }
let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) } let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) }
let(:browse_url) do
browse_path('other_artifacts_0.1.2')
end
def browse_path(path) def browse_path(path)
browse_project_job_artifacts_path(project, job, path) browse_project_job_artifacts_path(project, job, path)
end end
context 'when visiting old URL' do context 'when visiting old URL' do
let(:browse_url) do
browse_path('other_artifacts_0.1.2')
end
before do before do
visit browse_url.sub('/-/jobs', '/builds') visit browse_url.sub('/-/jobs', '/builds')
end end
...@@ -22,4 +23,23 @@ feature 'Browse artifact', :js do ...@@ -22,4 +23,23 @@ feature 'Browse artifact', :js do
expect(page.current_path).to eq(browse_url) expect(page.current_path).to eq(browse_url)
end end
end end
context 'when browsing a directory with an HTML file' do
let(:html_entry) { job.artifacts_metadata_entry("other_artifacts_0.1.2/index.html") }
before do
allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
allow(Gitlab.config.pages).to receive(:artifacts_server).and_return(true)
visit browse_url
end
it "shows external link icon and styles" do
link = first('.tree-item-file-external-link')
expect(link).to have_content('index.html')
expect(link[:href]).to eq(html_artifact_url(project, job, html_entry.blob))
expect(page).to have_selector('.js-artifact-tree-external-icon')
end
end
end end
...@@ -470,7 +470,7 @@ describe API::Runner do ...@@ -470,7 +470,7 @@ describe API::Runner do
expect(json_response['dependencies'].count).to eq(1) expect(json_response['dependencies'].count).to eq(1)
expect(json_response['dependencies']).to include( expect(json_response['dependencies']).to include(
{ 'id' => job.id, 'name' => job.name, 'token' => job.token, { 'id' => job.id, 'name' => job.name, 'token' => job.token,
'artifacts_file' => { 'filename' => 'ci_build_artifacts.zip', 'size' => 106365 } }) 'artifacts_file' => { 'filename' => 'ci_build_artifacts.zip', 'size' => 106633 } })
end end
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