Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
6305f1dc00
commit
be37a0ee5e
17 changed files with 257 additions and 53 deletions
|
@ -1,6 +1,18 @@
|
|||
import Pipelines from '~/pipelines';
|
||||
|
||||
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 pipelineStatusUrl = `${document
|
||||
.querySelector('.js-pipeline-tab-link a')
|
||||
|
|
|
@ -70,18 +70,22 @@ module Ci
|
|||
end
|
||||
end
|
||||
|
||||
def all_related_merge_request_text
|
||||
def all_related_merge_request_text(limit: nil)
|
||||
if all_related_merge_requests.none?
|
||||
'No related merge requests found.'
|
||||
_("No related merge requests found.")
|
||||
else
|
||||
_("%{count} related %{pluralized_subject}: %{links}" % {
|
||||
count: all_related_merge_requests.count,
|
||||
pluralized_subject: 'merge request'.pluralize(all_related_merge_requests.count),
|
||||
links: all_related_merge_request_links.join(', ')
|
||||
pluralized_subject: n_('merge request', 'merge requests', all_related_merge_requests.count),
|
||||
links: all_related_merge_request_links(limit: limit).join(', ')
|
||||
}).html_safe
|
||||
end
|
||||
end
|
||||
|
||||
def has_many_merge_requests?
|
||||
all_related_merge_requests.count > 1
|
||||
end
|
||||
|
||||
def link_to_pipeline_ref
|
||||
link_to(pipeline.ref,
|
||||
project_commits_path(pipeline.project, pipeline.ref),
|
||||
|
@ -118,8 +122,10 @@ module Ci
|
|||
end
|
||||
end
|
||||
|
||||
def all_related_merge_request_links
|
||||
all_related_merge_requests.map do |merge_request|
|
||||
def all_related_merge_request_links(limit: nil)
|
||||
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)
|
||||
|
||||
link_to "#{merge_request.to_reference} #{merge_request.title}", mr_path, class: 'mr-iid'
|
||||
|
|
|
@ -20,6 +20,12 @@ module Metrics
|
|||
system_metrics_kubernetes_container_cores_total
|
||||
).freeze
|
||||
|
||||
class << self
|
||||
def valid_params?(params)
|
||||
params[:embedded].present?
|
||||
end
|
||||
end
|
||||
|
||||
# Returns a new dashboard with only the matching
|
||||
# metrics from the system dashboard, stripped of groups.
|
||||
# @return [Hash]
|
||||
|
|
|
@ -15,6 +15,10 @@ module Metrics
|
|||
].freeze
|
||||
|
||||
class << self
|
||||
def valid_params?(params)
|
||||
matching_dashboard?(params[:dashboard_path])
|
||||
end
|
||||
|
||||
def matching_dashboard?(filepath)
|
||||
filepath == self::DASHBOARD_PATH
|
||||
end
|
||||
|
|
|
@ -9,6 +9,10 @@ module Metrics
|
|||
DASHBOARD_ROOT = ".gitlab/dashboards"
|
||||
|
||||
class << self
|
||||
def valid_params?(params)
|
||||
params[:dashboard_path].present?
|
||||
end
|
||||
|
||||
def all_dashboard_paths(project)
|
||||
file_finder(project)
|
||||
.list_files_for(DASHBOARD_ROOT)
|
||||
|
|
|
@ -69,4 +69,11 @@
|
|||
.icon-container
|
||||
= sprite_icon("git-merge")
|
||||
%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
|
||||
|
|
5
changelogs/unreleased/198466.yml
Normal file
5
changelogs/unreleased/198466.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: update service desk project to use GlLoadingIcon over font awesome spinner
|
||||
merge_request:
|
||||
author: Oregand
|
||||
type: changed
|
6
changelogs/unreleased/39531.yml
Normal file
6
changelogs/unreleased/39531.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
title: Update styles for pipeline status badge to be correctly vertically centered
|
||||
in project pipeline card
|
||||
merge_request:
|
||||
author: Oregand
|
||||
type: fixed
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Truncate related merge requests list in pipeline view
|
||||
merge_request: 19404
|
||||
author:
|
||||
type: changed
|
|
@ -8,50 +8,39 @@ module Gitlab
|
|||
module Metrics
|
||||
module Dashboard
|
||||
class ServiceSelector
|
||||
SERVICES = ::Metrics::Dashboard
|
||||
|
||||
class << self
|
||||
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
|
||||
# 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]
|
||||
def call(params)
|
||||
return SERVICES::CustomMetricEmbedService if custom_metric_embed?(params)
|
||||
return SERVICES::GrafanaMetricEmbedService if grafana_metric_embed?(params)
|
||||
return SERVICES::DynamicEmbedService if dynamic_embed?(params)
|
||||
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]
|
||||
service = services.find do |service_class|
|
||||
service_class.valid_params?(params)
|
||||
end
|
||||
|
||||
default_service
|
||||
service || default_service
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def services
|
||||
SERVICES
|
||||
end
|
||||
|
||||
def default_service
|
||||
SERVICES::SystemDashboardService
|
||||
end
|
||||
|
||||
def system_dashboard?(filepath)
|
||||
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)
|
||||
SERVICES::GrafanaMetricEmbedService.valid_params?(params)
|
||||
end
|
||||
|
||||
def dynamic_embed?(params)
|
||||
SERVICES::DynamicEmbedService.valid_params?(params)
|
||||
::Metrics::Dashboard::SystemDashboardService
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -7164,6 +7164,9 @@ msgstr ""
|
|||
msgid "Enter new AWS Secret Access Key"
|
||||
msgstr ""
|
||||
|
||||
msgid "Enter number of issues"
|
||||
msgstr ""
|
||||
|
||||
msgid "Enter the issue description"
|
||||
msgstr ""
|
||||
|
||||
|
@ -11292,9 +11295,6 @@ msgstr ""
|
|||
msgid "List"
|
||||
msgstr ""
|
||||
|
||||
msgid "List Settings"
|
||||
msgstr ""
|
||||
|
||||
msgid "List Your Gitea Repositories"
|
||||
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\""
|
||||
msgstr ""
|
||||
|
||||
msgid "List settings"
|
||||
msgstr ""
|
||||
|
||||
msgid "List the merge requests that must be merged before this one."
|
||||
msgstr ""
|
||||
|
||||
|
@ -12604,6 +12607,9 @@ msgstr ""
|
|||
msgid "No public groups"
|
||||
msgstr ""
|
||||
|
||||
msgid "No related merge requests found."
|
||||
msgstr ""
|
||||
|
||||
msgid "No repository"
|
||||
msgstr ""
|
||||
|
||||
|
@ -15607,6 +15613,9 @@ msgstr ""
|
|||
msgid "Remove group"
|
||||
msgstr ""
|
||||
|
||||
msgid "Remove limit"
|
||||
msgstr ""
|
||||
|
||||
msgid "Remove milestone"
|
||||
msgstr ""
|
||||
|
||||
|
@ -21436,7 +21445,7 @@ msgstr ""
|
|||
msgid "Withdraw Access Request"
|
||||
msgstr ""
|
||||
|
||||
msgid "Work in Progress Limit"
|
||||
msgid "Work in progress Limit"
|
||||
msgstr ""
|
||||
|
||||
msgid "Workflow Help"
|
||||
|
|
|
@ -99,12 +99,74 @@ describe 'Pipeline', :js do
|
|||
end
|
||||
end
|
||||
|
||||
it 'shows links to the related merge requests' do
|
||||
visit_pipeline
|
||||
describe 'related merge requests' do
|
||||
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
|
||||
pipeline.all_merge_requests.map do |merge_request|
|
||||
expect(page).to have_link(project_merge_request_path(project, merge_request))
|
||||
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
|
||||
|
||||
it 'links to the most recent related merge request' do
|
||||
visit_pipeline
|
||||
|
||||
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
|
||||
|
|
|
@ -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_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
|
||||
|
||||
|
|
|
@ -13,6 +13,26 @@ describe Metrics::Dashboard::DefaultEmbedService, :use_clean_rails_memory_store_
|
|||
project.add_maintainer(user)
|
||||
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
|
||||
let(:service_params) { [project, user, { environment: environment }] }
|
||||
let(:service_call) { described_class.new(*service_params).get_dashboard }
|
||||
|
|
|
@ -13,7 +13,27 @@ describe Metrics::Dashboard::PodDashboardService, :use_clean_rails_memory_store_
|
|||
project.add_maintainer(user)
|
||||
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(:service_params) { [project, user, { environment: environment, dashboard_path: dashboard_path }] }
|
||||
let(:service_call) { described_class.new(*service_params).get_dashboard }
|
||||
|
|
|
@ -13,7 +13,7 @@ describe Metrics::Dashboard::ProjectDashboardService, :use_clean_rails_memory_st
|
|||
project.add_maintainer(user)
|
||||
end
|
||||
|
||||
describe 'get_dashboard' do
|
||||
describe '#get_dashboard' do
|
||||
let(:dashboard_path) { '.gitlab/dashboards/test.yml' }
|
||||
let(:service_params) { [project, user, { environment: environment, dashboard_path: dashboard_path }] }
|
||||
let(:service_call) { described_class.new(*service_params).get_dashboard }
|
||||
|
@ -62,7 +62,7 @@ describe Metrics::Dashboard::ProjectDashboardService, :use_clean_rails_memory_st
|
|||
end
|
||||
end
|
||||
|
||||
describe '::all_dashboard_paths' do
|
||||
describe '.all_dashboard_paths' do
|
||||
let(:all_dashboards) { described_class.all_dashboard_paths(project) }
|
||||
|
||||
context 'when there are no project dashboards' do
|
||||
|
@ -87,4 +87,24 @@ describe Metrics::Dashboard::ProjectDashboardService, :use_clean_rails_memory_st
|
|||
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
|
||||
|
|
|
@ -13,7 +13,7 @@ describe Metrics::Dashboard::SystemDashboardService, :use_clean_rails_memory_sto
|
|||
project.add_maintainer(user)
|
||||
end
|
||||
|
||||
describe 'get_dashboard' do
|
||||
describe '#get_dashboard' do
|
||||
let(:dashboard_path) { described_class::DASHBOARD_PATH }
|
||||
let(:service_params) { [project, user, { environment: environment, dashboard_path: dashboard_path }] }
|
||||
let(:service_call) { described_class.new(*service_params).get_dashboard }
|
||||
|
@ -30,7 +30,7 @@ describe Metrics::Dashboard::SystemDashboardService, :use_clean_rails_memory_sto
|
|||
end
|
||||
end
|
||||
|
||||
describe '::all_dashboard_paths' do
|
||||
describe '.all_dashboard_paths' do
|
||||
it 'returns the dashboard attributes' do
|
||||
all_dashboards = described_class.all_dashboard_paths(project)
|
||||
|
||||
|
@ -44,4 +44,24 @@ describe Metrics::Dashboard::SystemDashboardService, :use_clean_rails_memory_sto
|
|||
)
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue