Commit 4f9626e4 authored by Dan Davison's avatar Dan Davison

Merge branch 'calebcooper-improving-pipeline-subscriptions' into 'master'

Improving pipeline subscriptions screen

See merge request gitlab-org/gitlab!77332
parents 8cd0101b 3891ce09
...@@ -5,24 +5,10 @@ ...@@ -5,24 +5,10 @@
.form-group .form-group
= f.label :upstream_project_path do = f.label :upstream_project_path do
= _("Project path") = _("Project path")
= link_to sprite_icon('question-o'), help_page_path('ci/pipelines/multi_project_pipelines', anchor: 'trigger-a-pipeline-when-an-upstream-project-is-rebuilt'), target: '_blank', rel: 'noopener noreferrer'
= f.text_field :upstream_project_path, class: "form-control", data: { qa_selector: "upstream_project_path_field" } = f.text_field :upstream_project_path, class: "form-control", data: { qa_selector: "upstream_project_path_field" }
= f.submit _('Subscribe'), class: "gl-button btn btn-confirm", data: { qa_selector: "subscribe_button" } = f.submit _('Subscribe'), class: "gl-button btn btn-confirm", data: { qa_selector: "subscribe_button" }
.row.gl-mt-3.gl-mb-3 = render 'projects/settings/subscriptions/table', mode: 'upstream'
.col-lg-12
%h5
= _("Subscriptions")
- subscriptions_count = @project.upstream_projects_count + @project.downstream_projects_count
= gl_badge_tag subscriptions_count, variant: :pill
%table.table.gl-mt-3 = render 'projects/settings/subscriptions/table', mode: 'downstream'
%thead
%tr
%th= _("Project")
%th= _("Owner")
%th
%tbody
- @project.upstream_project_subscriptions.each do |subscription|
= render 'projects/settings/subscriptions/project', project: subscription.upstream_project, subscription: subscription
- @project.downstream_project_subscriptions.each do |subscription|
= render 'projects/settings/subscriptions/project', project: subscription.downstream_project, subscription: subscription
- is_upstream_mode = mode == "upstream"
- tooltip = _('Delete subscription') - tooltip = _('Delete subscription')
%tr %tr
%td %td
= project.name = link_to project.name, project_path(project)
%td %td
.gl-display-flex.gl-align-items-center .gl-display-flex.gl-align-items-center
= avatar_without_link(project.owner, size: 32) = avatar_without_link(project.owner, size: 32)
= project.owner.name = project.owner.name
%td.gl-text-right - if is_upstream_mode
= link_to project_subscription_path(@project, subscription.id), method: :delete, data: { toggle: 'tooltip', title: tooltip, container: 'body', testid: 'delete-subscription' }, class: "gl-button btn btn-danger" do %td.gl-text-right
= sprite_icon('close', size: 16, css_class: 'gl-icon') = link_to project_subscription_path(@project, subscription.id), method: :delete, data: { toggle: 'tooltip', title: tooltip, container: 'body', testid: 'delete-subscription' }, class: "gl-button btn btn-danger" do
= sprite_icon('close', size: 16, css_class: 'gl-icon')
- else
%td
- is_upstream_mode = mode == "upstream"
- title = is_upstream_mode ? _("Subscriptions") : _("Subscribed to this project")
- count = is_upstream_mode ? @project.upstream_projects_count : @project.downstream_projects_count
- subscriptions = is_upstream_mode ? @project.upstream_project_subscriptions : @project.downstream_project_subscriptions
- empty_text = is_upstream_mode ? _("This project is not subscribed to any project pipelines.") : _("No project subscribes to the pipelines in this project.")
.row.gl-mt-3.gl-mb-3{ data: { testid: "#{mode}-project-subscriptions" } }
.col-lg-12
%h5
= title
= gl_badge_tag count
%table.table.gl-mt-3
%thead
%tr
%th.gl-w-15.gl-md-w-50p= _("Project")
%th= _("Namespace")
%th
%tbody
- if count > 0
- subscriptions.each do |subscription|
- subscription_project = is_upstream_mode ? subscription.upstream_project : subscription.downstream_project
= render 'projects/settings/subscriptions/project', project: subscription_project, subscription: subscription, mode: mode
- else
%tr
%td.gl-text-center{ colspan: 3 }= empty_text
...@@ -5,11 +5,13 @@ require 'spec_helper' ...@@ -5,11 +5,13 @@ require 'spec_helper'
RSpec.describe 'Project Subscriptions', :js do RSpec.describe 'Project Subscriptions', :js do
let(:project) { create(:project, :public, :repository) } let(:project) { create(:project, :public, :repository) }
let(:upstream_project) { create(:project, :public, :repository) } let(:upstream_project) { create(:project, :public, :repository) }
let(:downstream_project) { create(:project, :public, :repository, upstream_projects: [project]) }
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
project.add_maintainer(user) project.add_maintainer(user)
upstream_project.add_maintainer(user) upstream_project.add_maintainer(user)
downstream_project.add_maintainer(user)
stub_licensed_features(ci_project_subscriptions: true) stub_licensed_features(ci_project_subscriptions: true)
...@@ -25,6 +27,21 @@ RSpec.describe 'Project Subscriptions', :js do ...@@ -25,6 +27,21 @@ RSpec.describe 'Project Subscriptions', :js do
end end
end end
it 'renders the list of downstream projects' do
within '[data-testid="downstream-project-subscriptions"]' do
expect(find('.badge-pill').text).to eq '1'
end
expect(page).to have_content(downstream_project.name)
expect(page).to have_content(downstream_project.owner.name)
end
it 'doesn\'t allow to delete downstream projects' do
within '[data-testid="downstream-project-subscriptions"]' do
expect(page).not_to have_content('[data-testid="delete-subscription"]')
end
end
it 'successfully creates new pipeline subscription' do it 'successfully creates new pipeline subscription' do
within '#pipeline-subscriptions' do within '#pipeline-subscriptions' do
within 'form' do within 'form' do
...@@ -33,7 +50,9 @@ RSpec.describe 'Project Subscriptions', :js do ...@@ -33,7 +50,9 @@ RSpec.describe 'Project Subscriptions', :js do
click_on 'Subscribe' click_on 'Subscribe'
end end
expect(find('.badge-pill').text).to eq '1' within '[data-testid="upstream-project-subscriptions"]' do
expect(find('.badge-pill').text).to eq '1'
end
expect(page).to have_content(upstream_project.name) expect(page).to have_content(upstream_project.name)
expect(page).to have_content(upstream_project.owner.name) expect(page).to have_content(upstream_project.owner.name)
...@@ -50,8 +69,10 @@ RSpec.describe 'Project Subscriptions', :js do ...@@ -50,8 +69,10 @@ RSpec.describe 'Project Subscriptions', :js do
click_on 'Subscribe' click_on 'Subscribe'
end end
expect(find('.badge-pill').text).to eq '0' within '[data-testid="upstream-project-subscriptions"]' do
expect(all('tbody tr').count).to eq(0) expect(find('.badge-pill').text).to eq '0'
expect(page).to have_content('This project is not subscribed to any project pipelines.')
end
end end
expect(page).to have_content('This project path either does not exist or you do not have access.') expect(page).to have_content('This project path either does not exist or you do not have access.')
......
...@@ -24092,6 +24092,9 @@ msgstr "" ...@@ -24092,6 +24092,9 @@ msgstr ""
msgid "No profiles found" msgid "No profiles found"
msgstr "" msgstr ""
msgid "No project subscribes to the pipelines in this project."
msgstr ""
msgid "No projects found" msgid "No projects found"
msgstr "" msgstr ""
...@@ -34264,6 +34267,9 @@ msgstr "" ...@@ -34264,6 +34267,9 @@ msgstr ""
msgid "Subscribed to this %{quick_action_target}." msgid "Subscribed to this %{quick_action_target}."
msgstr "" msgstr ""
msgid "Subscribed to this project"
msgstr ""
msgid "Subscribes to this %{quick_action_target}." msgid "Subscribes to this %{quick_action_target}."
msgstr "" msgstr ""
...@@ -36629,6 +36635,9 @@ msgstr "" ...@@ -36629,6 +36635,9 @@ msgstr ""
msgid "This project is licensed under the %{strong_start}%{license_name}%{strong_end}." msgid "This project is licensed under the %{strong_start}%{license_name}%{strong_end}."
msgstr "" msgstr ""
msgid "This project is not subscribed to any project pipelines."
msgstr ""
msgid "This project manages its dependencies using %{strong_start}%{manager_name}%{strong_end}" msgid "This project manages its dependencies using %{strong_start}%{manager_name}%{strong_end}"
msgstr "" msgstr ""
......
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