diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-30 12:08:55 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-30 12:08:55 +0300 |
commit | be37a0ee5e3e3dbb967266248f0f46f14a9931e2 (patch) | |
tree | 8fd575a36933fb847a6f92ff76d9c1ad908a3f7b /app | |
parent | 6305f1dc00870f6e0635e2e850538a00bbd00bda (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
6 files changed, 46 insertions, 7 deletions
diff --git a/app/assets/javascripts/pages/projects/pipelines/init_pipelines.js b/app/assets/javascripts/pages/projects/pipelines/init_pipelines.js index ba4ae04ab3d..ade6908c4a5 100644 --- a/app/assets/javascripts/pages/projects/pipelines/init_pipelines.js +++ b/app/assets/javascripts/pages/projects/pipelines/init_pipelines.js @@ -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') diff --git a/app/presenters/ci/pipeline_presenter.rb b/app/presenters/ci/pipeline_presenter.rb index f01ff56540a..b113c7043e7 100644 --- a/app/presenters/ci/pipeline_presenter.rb +++ b/app/presenters/ci/pipeline_presenter.rb @@ -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' diff --git a/app/services/metrics/dashboard/default_embed_service.rb b/app/services/metrics/dashboard/default_embed_service.rb index e1bd98bd5c2..39f7c3943dd 100644 --- a/app/services/metrics/dashboard/default_embed_service.rb +++ b/app/services/metrics/dashboard/default_embed_service.rb @@ -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] diff --git a/app/services/metrics/dashboard/predefined_dashboard_service.rb b/app/services/metrics/dashboard/predefined_dashboard_service.rb index 1be1a000854..297f00b1be9 100644 --- a/app/services/metrics/dashboard/predefined_dashboard_service.rb +++ b/app/services/metrics/dashboard/predefined_dashboard_service.rb @@ -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 diff --git a/app/services/metrics/dashboard/project_dashboard_service.rb b/app/services/metrics/dashboard/project_dashboard_service.rb index b0d54ee9347..fadbe0fae01 100644 --- a/app/services/metrics/dashboard/project_dashboard_service.rb +++ b/app/services/metrics/dashboard/project_dashboard_service.rb @@ -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) diff --git a/app/views/projects/pipelines/_info.html.haml b/app/views/projects/pipelines/_info.html.haml index ce6ae765de9..85902d51ab0 100644 --- a/app/views/projects/pipelines/_info.html.haml +++ b/app/views/projects/pipelines/_info.html.haml @@ -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 |