Commit 8c1bf02c authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'mo-dont-expose-artifacts-on-pipeline-index' into 'master'

Do not expose artifacts on pipeline index

See merge request gitlab-org/gitlab!60126
parents 8538989a 3d24f8bc
...@@ -41,7 +41,7 @@ export default { ...@@ -41,7 +41,7 @@ export default {
this.pipeline.flags.retryable || this.pipeline.flags.retryable ||
this.pipeline.flags.cancelable || this.pipeline.flags.cancelable ||
this.pipeline.details.manual_actions.length || this.pipeline.details.manual_actions.length ||
this.pipeline.details.artifacts.length this.pipeline.details.has_downloadable_artifacts
); );
}, },
actions() { actions() {
...@@ -55,9 +55,7 @@ export default { ...@@ -55,9 +55,7 @@ export default {
return this.cancelingPipeline === this.pipeline.id; return this.cancelingPipeline === this.pipeline.id;
}, },
showArtifacts() { showArtifacts() {
return ( return this.pipeline.details.has_downloadable_artifacts;
this.pipeline.details.artifacts?.length || this.pipeline.details.has_downloadable_artifacts
);
}, },
}, },
watch: { watch: {
......
...@@ -218,7 +218,7 @@ class Projects::PipelinesController < Projects::ApplicationController ...@@ -218,7 +218,7 @@ class Projects::PipelinesController < Projects::ApplicationController
PipelineSerializer PipelineSerializer
.new(project: @project, current_user: @current_user) .new(project: @project, current_user: @current_user)
.with_pagination(request, response) .with_pagination(request, response)
.represent(@pipelines, disable_coverage: true, preload: true) .represent(@pipelines, disable_coverage: true, preload: true, disable_artifacts: true)
end end
def render_show def render_show
......
...@@ -1076,6 +1076,14 @@ module Ci ...@@ -1076,6 +1076,14 @@ module Ci
complete? && builds.latest.with_exposed_artifacts.exists? complete? && builds.latest.with_exposed_artifacts.exists?
end end
def has_downloadable_artifacts?
if downloadable_artifacts.loaded?
downloadable_artifacts.any?
else
downloadable_artifacts.exists?
end
end
def branch_updated? def branch_updated?
strong_memoize(:branch_updated) do strong_memoize(:branch_updated) do
push_details.branch_updated? push_details.branch_updated?
......
...@@ -8,7 +8,8 @@ class PipelineDetailsEntity < Ci::PipelineEntity ...@@ -8,7 +8,8 @@ class PipelineDetailsEntity < Ci::PipelineEntity
end end
expose :details do expose :details do
expose :artifacts do |pipeline, options| expose :has_downloadable_artifacts?, as: :has_downloadable_artifacts
expose :artifacts, unless: proc { options[:disable_artifacts] } do |pipeline, options|
rel = pipeline.downloadable_artifacts rel = pipeline.downloadable_artifacts
if Feature.enabled?(:non_public_artifacts, type: :development) if Feature.enabled?(:non_public_artifacts, type: :development)
......
---
title: Stop exposing artifacts on pipelines.json
merge_request: 60126
author:
type: performance
...@@ -460,20 +460,6 @@ RSpec.describe 'Pipelines', :js do ...@@ -460,20 +460,6 @@ RSpec.describe 'Pipelines', :js do
it 'has artifacts dropdown' do it 'has artifacts dropdown' do
expect(page).to have_selector('[data-testid="pipeline-multi-actions-dropdown"]') expect(page).to have_selector('[data-testid="pipeline-multi-actions-dropdown"]')
end end
it 'has artifacts download dropdown' do
find('[data-testid="pipeline-multi-actions-dropdown"]').click
expect(page).to have_link(with_artifacts.file_type)
end
it 'has download attribute on download links' do
find('[data-testid="pipeline-multi-actions-dropdown"]').click
expect(page).to have_selector('a', text: 'Download')
page.all('[data-testid="artifact-item"]', text: 'Download').each do |link|
expect(link[:download]).to eq ''
end
end
end end
context 'with artifacts expired' do context 'with artifacts expired' do
......
...@@ -4437,4 +4437,18 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do ...@@ -4437,4 +4437,18 @@ RSpec.describe Ci::Pipeline, :mailer, factory_default: :keep do
.not_to exceed_query_limit(control_count) .not_to exceed_query_limit(control_count)
end end
end end
describe '#has_downloadable_artifacts?' do
it 'returns false when when pipeline does not have downloadable artifacts' do
pipeline = create(:ci_pipeline, :success)
expect(pipeline.has_downloadable_artifacts?). to eq(false)
end
it 'returns false when when pipeline does not have downloadable artifacts' do
pipeline = create(:ci_pipeline, :with_codequality_reports)
expect(pipeline.has_downloadable_artifacts?). to eq(true)
end
end
end end
...@@ -32,7 +32,7 @@ RSpec.describe PipelineDetailsEntity do ...@@ -32,7 +32,7 @@ RSpec.describe PipelineDetailsEntity do
expect(subject[:details]) expect(subject[:details])
.to include :duration, :finished_at .to include :duration, :finished_at
expect(subject[:details]) expect(subject[:details])
.to include :stages, :artifacts, :manual_actions, :scheduled_actions .to include :stages, :artifacts, :has_downloadable_artifacts, :manual_actions, :scheduled_actions
expect(subject[:details][:status]).to include :icon, :favicon, :text, :label expect(subject[:details][:status]).to include :icon, :favicon, :text, :label
end end
...@@ -186,5 +186,35 @@ RSpec.describe PipelineDetailsEntity do ...@@ -186,5 +186,35 @@ RSpec.describe PipelineDetailsEntity do
end end
it_behaves_like 'public artifacts' it_behaves_like 'public artifacts'
context 'when pipeline has downloadable artifacts' do
subject(:entity) { described_class.represent(pipeline, request: request, disable_artifacts: disable_artifacts).as_json }
let_it_be(:pipeline) { create(:ci_pipeline, :with_codequality_reports) }
context 'when disable_artifacts is true' do
subject(:entity) { described_class.represent(pipeline, request: request, disable_artifacts: true).as_json }
it 'excludes artifacts data' do
expect(entity[:details]).not_to include(:artifacts)
end
it 'returns true for has_downloadable_artifacts' do
expect(entity[:details][:has_downloadable_artifacts]).to eq(true)
end
end
context 'when disable_artifacts is false' do
subject(:entity) { described_class.represent(pipeline, request: request, disable_artifacts: false).as_json }
it 'includes artifacts data' do
expect(entity[:details]).to include(:artifacts)
end
it 'returns true for has_downloadable_artifacts' do
expect(entity[:details][:has_downloadable_artifacts]).to eq(true)
end
end
end
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