Commit be37a0ee authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent 6305f1dc
import Pipelines from '~/pipelines'; import Pipelines from '~/pipelines';
export default () => { export default () => {
const mergeRequestListToggle = document.querySelector('.js-toggle-mr-list');
const truncatedMergeRequestList = document.querySelector('.js-truncated-mr-list');
const fullMergeRequestList = document.querySelector('.js-full-mr-list');
if (mergeRequestListToggle) {
mergeRequestListToggle.addEventListener('click', e => {
e.preventDefault();
truncatedMergeRequestList.classList.toggle('hide');
fullMergeRequestList.classList.toggle('hide');
});
}
const { controllerAction } = document.querySelector('.js-pipeline-container').dataset; const { controllerAction } = document.querySelector('.js-pipeline-container').dataset;
const pipelineStatusUrl = `${document const pipelineStatusUrl = `${document
.querySelector('.js-pipeline-tab-link a') .querySelector('.js-pipeline-tab-link a')
......
...@@ -70,18 +70,22 @@ module Ci ...@@ -70,18 +70,22 @@ module Ci
end end
end end
def all_related_merge_request_text def all_related_merge_request_text(limit: nil)
if all_related_merge_requests.none? if all_related_merge_requests.none?
'No related merge requests found.' _("No related merge requests found.")
else else
_("%{count} related %{pluralized_subject}: %{links}" % { _("%{count} related %{pluralized_subject}: %{links}" % {
count: all_related_merge_requests.count, count: all_related_merge_requests.count,
pluralized_subject: 'merge request'.pluralize(all_related_merge_requests.count), pluralized_subject: n_('merge request', 'merge requests', all_related_merge_requests.count),
links: all_related_merge_request_links.join(', ') links: all_related_merge_request_links(limit: limit).join(', ')
}).html_safe }).html_safe
end end
end end
def has_many_merge_requests?
all_related_merge_requests.count > 1
end
def link_to_pipeline_ref def link_to_pipeline_ref
link_to(pipeline.ref, link_to(pipeline.ref,
project_commits_path(pipeline.project, pipeline.ref), project_commits_path(pipeline.project, pipeline.ref),
...@@ -118,8 +122,10 @@ module Ci ...@@ -118,8 +122,10 @@ module Ci
end end
end end
def all_related_merge_request_links def all_related_merge_request_links(limit: nil)
all_related_merge_requests.map do |merge_request| limit ||= all_related_merge_requests.count
all_related_merge_requests.first(limit).map do |merge_request|
mr_path = project_merge_request_path(merge_request.project, merge_request) mr_path = project_merge_request_path(merge_request.project, merge_request)
link_to "#{merge_request.to_reference} #{merge_request.title}", mr_path, class: 'mr-iid' link_to "#{merge_request.to_reference} #{merge_request.title}", mr_path, class: 'mr-iid'
......
...@@ -20,6 +20,12 @@ module Metrics ...@@ -20,6 +20,12 @@ module Metrics
system_metrics_kubernetes_container_cores_total system_metrics_kubernetes_container_cores_total
).freeze ).freeze
class << self
def valid_params?(params)
params[:embedded].present?
end
end
# Returns a new dashboard with only the matching # Returns a new dashboard with only the matching
# metrics from the system dashboard, stripped of groups. # metrics from the system dashboard, stripped of groups.
# @return [Hash] # @return [Hash]
......
...@@ -15,6 +15,10 @@ module Metrics ...@@ -15,6 +15,10 @@ module Metrics
].freeze ].freeze
class << self class << self
def valid_params?(params)
matching_dashboard?(params[:dashboard_path])
end
def matching_dashboard?(filepath) def matching_dashboard?(filepath)
filepath == self::DASHBOARD_PATH filepath == self::DASHBOARD_PATH
end end
......
...@@ -9,6 +9,10 @@ module Metrics ...@@ -9,6 +9,10 @@ module Metrics
DASHBOARD_ROOT = ".gitlab/dashboards" DASHBOARD_ROOT = ".gitlab/dashboards"
class << self class << self
def valid_params?(params)
params[:dashboard_path].present?
end
def all_dashboard_paths(project) def all_dashboard_paths(project)
file_finder(project) file_finder(project)
.list_files_for(DASHBOARD_ROOT) .list_files_for(DASHBOARD_ROOT)
......
...@@ -69,4 +69,11 @@ ...@@ -69,4 +69,11 @@
.icon-container .icon-container
= sprite_icon("git-merge") = sprite_icon("git-merge")
%span.related-merge-requests %span.related-merge-requests
= @pipeline.all_related_merge_request_text %span.js-truncated-mr-list
= @pipeline.all_related_merge_request_text(limit: 1)
- if @pipeline.has_many_merge_requests?
= link_to("#", class: "js-toggle-mr-list") do
%span.text-expander
= sprite_icon('ellipsis_h', size: 12)
%span.js-full-mr-list.hide
= @pipeline.all_related_merge_request_text
---
title: update service desk project to use GlLoadingIcon over font awesome spinner
merge_request:
author: Oregand
type: changed
---
title: Update styles for pipeline status badge to be correctly vertically centered
in project pipeline card
merge_request:
author: Oregand
type: fixed
---
title: Truncate related merge requests list in pipeline view
merge_request: 19404
author:
type: changed
...@@ -8,50 +8,39 @@ module Gitlab ...@@ -8,50 +8,39 @@ module Gitlab
module Metrics module Metrics
module Dashboard module Dashboard
class ServiceSelector class ServiceSelector
SERVICES = ::Metrics::Dashboard
class << self class << self
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
SERVICES = [
::Metrics::Dashboard::CustomMetricEmbedService,
::Metrics::Dashboard::GrafanaMetricEmbedService,
::Metrics::Dashboard::DynamicEmbedService,
::Metrics::Dashboard::DefaultEmbedService,
::Metrics::Dashboard::SystemDashboardService,
::Metrics::Dashboard::PodDashboardService,
::Metrics::Dashboard::ProjectDashboardService
].freeze
# Returns a class which inherits from the BaseService # Returns a class which inherits from the BaseService
# class that can be used to obtain a dashboard. # class that can be used to obtain a dashboard for
# the provided params.
# @return [Gitlab::Metrics::Dashboard::Services::BaseService] # @return [Gitlab::Metrics::Dashboard::Services::BaseService]
def call(params) def call(params)
return SERVICES::CustomMetricEmbedService if custom_metric_embed?(params) service = services.find do |service_class|
return SERVICES::GrafanaMetricEmbedService if grafana_metric_embed?(params) service_class.valid_params?(params)
return SERVICES::DynamicEmbedService if dynamic_embed?(params) end
return SERVICES::DefaultEmbedService if params[:embedded]
return SERVICES::SystemDashboardService if system_dashboard?(params[:dashboard_path])
return SERVICES::PodDashboardService if pod_dashboard?(params[:dashboard_path])
return SERVICES::ProjectDashboardService if params[:dashboard_path]
default_service
end
private service || default_service
def default_service
SERVICES::SystemDashboardService
end end
def system_dashboard?(filepath) private
SERVICES::SystemDashboardService.matching_dashboard?(filepath)
end
def pod_dashboard?(filepath)
SERVICES::PodDashboardService.matching_dashboard?(filepath)
end
def custom_metric_embed?(params)
SERVICES::CustomMetricEmbedService.valid_params?(params)
end
def grafana_metric_embed?(params) def services
SERVICES::GrafanaMetricEmbedService.valid_params?(params) SERVICES
end end
def dynamic_embed?(params) def default_service
SERVICES::DynamicEmbedService.valid_params?(params) ::Metrics::Dashboard::SystemDashboardService
end end
end end
end end
......
...@@ -7164,6 +7164,9 @@ msgstr "" ...@@ -7164,6 +7164,9 @@ msgstr ""
msgid "Enter new AWS Secret Access Key" msgid "Enter new AWS Secret Access Key"
msgstr "" msgstr ""
msgid "Enter number of issues"
msgstr ""
msgid "Enter the issue description" msgid "Enter the issue description"
msgstr "" msgstr ""
...@@ -11292,9 +11295,6 @@ msgstr "" ...@@ -11292,9 +11295,6 @@ msgstr ""
msgid "List" msgid "List"
msgstr "" msgstr ""
msgid "List Settings"
msgstr ""
msgid "List Your Gitea Repositories" msgid "List Your Gitea Repositories"
msgstr "" msgstr ""
...@@ -11304,6 +11304,9 @@ msgstr "" ...@@ -11304,6 +11304,9 @@ msgstr ""
msgid "List of IPs and CIDRs of allowed secondary nodes. Comma-separated, e.g. \"1.1.1.1, 2.2.2.0/24\"" msgid "List of IPs and CIDRs of allowed secondary nodes. Comma-separated, e.g. \"1.1.1.1, 2.2.2.0/24\""
msgstr "" msgstr ""
msgid "List settings"
msgstr ""
msgid "List the merge requests that must be merged before this one." msgid "List the merge requests that must be merged before this one."
msgstr "" msgstr ""
...@@ -12604,6 +12607,9 @@ msgstr "" ...@@ -12604,6 +12607,9 @@ msgstr ""
msgid "No public groups" msgid "No public groups"
msgstr "" msgstr ""
msgid "No related merge requests found."
msgstr ""
msgid "No repository" msgid "No repository"
msgstr "" msgstr ""
...@@ -15607,6 +15613,9 @@ msgstr "" ...@@ -15607,6 +15613,9 @@ msgstr ""
msgid "Remove group" msgid "Remove group"
msgstr "" msgstr ""
msgid "Remove limit"
msgstr ""
msgid "Remove milestone" msgid "Remove milestone"
msgstr "" msgstr ""
...@@ -21436,7 +21445,7 @@ msgstr "" ...@@ -21436,7 +21445,7 @@ msgstr ""
msgid "Withdraw Access Request" msgid "Withdraw Access Request"
msgstr "" msgstr ""
msgid "Work in Progress Limit" msgid "Work in progress Limit"
msgstr "" msgstr ""
msgid "Workflow Help" msgid "Workflow Help"
......
...@@ -99,12 +99,74 @@ describe 'Pipeline', :js do ...@@ -99,12 +99,74 @@ describe 'Pipeline', :js do
end end
end end
it 'shows links to the related merge requests' do describe 'related merge requests' do
visit_pipeline context 'when there are no related merge requests' do
it 'shows a "no related merge requests" message' do
visit_pipeline
within '.related-merge-request-info' do
expect(page).to have_content('No related merge requests found.')
end
end
end
context 'when there is one related merge request' do
before do
create(:merge_request,
source_project: project,
source_branch: pipeline.ref)
end
it 'shows a link to the merge request' do
visit_pipeline
within '.related-merge-requests' do
expect(page).to have_content('1 related merge request: ')
expect(page).to have_selector('.js-truncated-mr-list')
expect(page).to have_link('!1 My title 1')
expect(page).not_to have_selector('.js-full-mr-list')
expect(page).not_to have_selector('.text-expander')
end
end
end
context 'when there are two related merge requests' do
before do
create(:merge_request,
source_project: project,
source_branch: pipeline.ref,
target_branch: 'feature-1')
create(:merge_request,
source_project: project,
source_branch: pipeline.ref,
target_branch: 'feature-2')
end
within '.related-merge-request-info' do it 'links to the most recent related merge request' do
pipeline.all_merge_requests.map do |merge_request| visit_pipeline
expect(page).to have_link(project_merge_request_path(project, merge_request))
within '.related-merge-requests' do
expect(page).to have_content('2 related merge requests: ')
expect(page).to have_link('!2 My title 3')
expect(page).to have_selector('.text-expander')
expect(page).to have_selector('.js-full-mr-list', visible: false)
end
end
it 'expands to show links to all related merge requests' do
visit_pipeline
within '.related-merge-requests' do
find('.text-expander').click
expect(page).to have_selector('.js-full-mr-list', visible: true)
pipeline.all_merge_requests.map do |merge_request|
expect(page).to have_link(href: project_merge_request_path(project, merge_request))
end
end
end end
end end
end end
......
...@@ -209,6 +209,15 @@ describe Ci::PipelinePresenter do ...@@ -209,6 +209,15 @@ describe Ci::PipelinePresenter do
"<a class=\"mr-iid\" href=\"#{merge_request_path(mr_2)}\">#{mr_2.to_reference} #{mr_2.title}</a>, " \ "<a class=\"mr-iid\" href=\"#{merge_request_path(mr_2)}\">#{mr_2.to_reference} #{mr_2.title}</a>, " \
"<a class=\"mr-iid\" href=\"#{merge_request_path(mr_1)}\">#{mr_1.to_reference} #{mr_1.title}</a>") "<a class=\"mr-iid\" href=\"#{merge_request_path(mr_1)}\">#{mr_1.to_reference} #{mr_1.title}</a>")
} }
context 'with a limit passed' do
subject { presenter.all_related_merge_request_text(limit: 1) }
it {
is_expected.to eq("2 related merge requests: " \
"<a class=\"mr-iid\" href=\"#{merge_request_path(mr_2)}\">#{mr_2.to_reference} #{mr_2.title}</a>")
}
end
end end
end end
......
...@@ -13,6 +13,26 @@ describe Metrics::Dashboard::DefaultEmbedService, :use_clean_rails_memory_store_ ...@@ -13,6 +13,26 @@ describe Metrics::Dashboard::DefaultEmbedService, :use_clean_rails_memory_store_
project.add_maintainer(user) project.add_maintainer(user)
end end
describe '.valid_params?' do
let(:params) { { embedded: true } }
subject { described_class.valid_params?(params) }
it { is_expected.to be_truthy }
context 'missing embedded' do
let(:params) { {} }
it { is_expected.to be_falsey }
end
context 'not embedded' do
let(:params) { { embedded: false } }
it { is_expected.to be_falsey }
end
end
describe '#get_dashboard' do describe '#get_dashboard' do
let(:service_params) { [project, user, { environment: environment }] } let(:service_params) { [project, user, { environment: environment }] }
let(:service_call) { described_class.new(*service_params).get_dashboard } let(:service_call) { described_class.new(*service_params).get_dashboard }
......
...@@ -13,7 +13,27 @@ describe Metrics::Dashboard::PodDashboardService, :use_clean_rails_memory_store_ ...@@ -13,7 +13,27 @@ describe Metrics::Dashboard::PodDashboardService, :use_clean_rails_memory_store_
project.add_maintainer(user) project.add_maintainer(user)
end end
describe 'get_dashboard' do describe '.valid_params?' do
let(:params) { { dashboard_path: described_class::DASHBOARD_PATH } }
subject { described_class.valid_params?(params) }
it { is_expected.to be_truthy }
context 'missing dashboard_path' do
let(:params) { {} }
it { is_expected.to be_falsey }
end
context 'non-matching dashboard_path' do
let(:params) { { dashboard_path: 'path/to/bunk.yml' } }
it { is_expected.to be_falsey }
end
end
describe '#get_dashboard' do
let(:dashboard_path) { described_class::DASHBOARD_PATH } let(:dashboard_path) { described_class::DASHBOARD_PATH }
let(:service_params) { [project, user, { environment: environment, dashboard_path: dashboard_path }] } let(:service_params) { [project, user, { environment: environment, dashboard_path: dashboard_path }] }
let(:service_call) { described_class.new(*service_params).get_dashboard } let(:service_call) { described_class.new(*service_params).get_dashboard }
......
...@@ -13,7 +13,7 @@ describe Metrics::Dashboard::ProjectDashboardService, :use_clean_rails_memory_st ...@@ -13,7 +13,7 @@ describe Metrics::Dashboard::ProjectDashboardService, :use_clean_rails_memory_st
project.add_maintainer(user) project.add_maintainer(user)
end end
describe 'get_dashboard' do describe '#get_dashboard' do
let(:dashboard_path) { '.gitlab/dashboards/test.yml' } let(:dashboard_path) { '.gitlab/dashboards/test.yml' }
let(:service_params) { [project, user, { environment: environment, dashboard_path: dashboard_path }] } let(:service_params) { [project, user, { environment: environment, dashboard_path: dashboard_path }] }
let(:service_call) { described_class.new(*service_params).get_dashboard } let(:service_call) { described_class.new(*service_params).get_dashboard }
...@@ -62,7 +62,7 @@ describe Metrics::Dashboard::ProjectDashboardService, :use_clean_rails_memory_st ...@@ -62,7 +62,7 @@ describe Metrics::Dashboard::ProjectDashboardService, :use_clean_rails_memory_st
end end
end end
describe '::all_dashboard_paths' do describe '.all_dashboard_paths' do
let(:all_dashboards) { described_class.all_dashboard_paths(project) } let(:all_dashboards) { described_class.all_dashboard_paths(project) }
context 'when there are no project dashboards' do context 'when there are no project dashboards' do
...@@ -87,4 +87,24 @@ describe Metrics::Dashboard::ProjectDashboardService, :use_clean_rails_memory_st ...@@ -87,4 +87,24 @@ describe Metrics::Dashboard::ProjectDashboardService, :use_clean_rails_memory_st
end end
end end
end end
describe '.valid_params?' do
let(:params) { { dashboard_path: '.gitlab/dashboard/test.yml' } }
subject { described_class.valid_params?(params) }
it { is_expected.to be_truthy }
context 'missing dashboard_path' do
let(:params) { {} }
it { is_expected.to be_falsey }
end
context 'empty dashboard_path' do
let(:params) { { dashboard_path: '' } }
it { is_expected.to be_falsey }
end
end
end end
...@@ -13,7 +13,7 @@ describe Metrics::Dashboard::SystemDashboardService, :use_clean_rails_memory_sto ...@@ -13,7 +13,7 @@ describe Metrics::Dashboard::SystemDashboardService, :use_clean_rails_memory_sto
project.add_maintainer(user) project.add_maintainer(user)
end end
describe 'get_dashboard' do describe '#get_dashboard' do
let(:dashboard_path) { described_class::DASHBOARD_PATH } let(:dashboard_path) { described_class::DASHBOARD_PATH }
let(:service_params) { [project, user, { environment: environment, dashboard_path: dashboard_path }] } let(:service_params) { [project, user, { environment: environment, dashboard_path: dashboard_path }] }
let(:service_call) { described_class.new(*service_params).get_dashboard } let(:service_call) { described_class.new(*service_params).get_dashboard }
...@@ -30,7 +30,7 @@ describe Metrics::Dashboard::SystemDashboardService, :use_clean_rails_memory_sto ...@@ -30,7 +30,7 @@ describe Metrics::Dashboard::SystemDashboardService, :use_clean_rails_memory_sto
end end
end end
describe '::all_dashboard_paths' do describe '.all_dashboard_paths' do
it 'returns the dashboard attributes' do it 'returns the dashboard attributes' do
all_dashboards = described_class.all_dashboard_paths(project) all_dashboards = described_class.all_dashboard_paths(project)
...@@ -44,4 +44,24 @@ describe Metrics::Dashboard::SystemDashboardService, :use_clean_rails_memory_sto ...@@ -44,4 +44,24 @@ describe Metrics::Dashboard::SystemDashboardService, :use_clean_rails_memory_sto
) )
end end
end end
describe '.valid_params?' do
let(:params) { { dashboard_path: described_class::DASHBOARD_PATH } }
subject { described_class.valid_params?(params) }
it { is_expected.to be_truthy }
context 'missing dashboard_path' do
let(:params) { {} }
it { is_expected.to be_falsey }
end
context 'non-matching dashboard_path' do
let(:params) { { dashboard_path: 'path/to/bunk.yml' } }
it { is_expected.to be_falsey }
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