diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-31 15:06:41 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-31 15:06:41 +0000 |
commit | 083d64c6468a070ae7b0b406ead8d87da27d1d22 (patch) | |
tree | ba92a9b5b6418f805ede9ef05b371d82d2c1d27d /app | |
parent | 0be510a49f6e4f8e27b19b707fd1dac61571f78f (diff) | |
download | gitlab-ce-083d64c6468a070ae7b0b406ead8d87da27d1d22.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/concerns/metrics_dashboard.rb | 11 | ||||
-rw-r--r-- | app/controllers/projects/environments_controller.rb | 3 | ||||
-rw-r--r-- | app/controllers/projects/grafana_api_controller.rb | 11 | ||||
-rw-r--r-- | app/helpers/search_helper.rb | 4 | ||||
-rw-r--r-- | app/helpers/tree_helper.rb | 4 | ||||
-rw-r--r-- | app/models/releases/source.rb | 4 | ||||
-rw-r--r-- | app/services/groups/transfer_service.rb | 4 | ||||
-rw-r--r-- | app/services/projects/transfer_service.rb | 2 | ||||
-rw-r--r-- | app/views/projects/buttons/_download_links.html.haml | 6 | ||||
-rw-r--r-- | app/views/search/_results.html.haml | 1 |
10 files changed, 32 insertions, 18 deletions
diff --git a/app/controllers/concerns/metrics_dashboard.rb b/app/controllers/concerns/metrics_dashboard.rb index 62efdacb710..b06b5d5a30c 100644 --- a/app/controllers/concerns/metrics_dashboard.rb +++ b/app/controllers/concerns/metrics_dashboard.rb @@ -3,21 +3,24 @@ # Provides an action which fetches a metrics dashboard according # to the parameters specified by the controller. module MetricsDashboard + include RenderServiceResults extend ActiveSupport::Concern def metrics_dashboard result = dashboard_finder.find( project_for_dashboard, current_user, - metrics_dashboard_params + metrics_dashboard_params.to_h.symbolize_keys ) - if include_all_dashboards? + if include_all_dashboards? && result result[:all_dashboards] = dashboard_finder.find_all_paths(project_for_dashboard) end respond_to do |format| - if result[:status] == :success + if result.nil? + format.json { continue_polling_response } + elsif result[:status] == :success format.json { render dashboard_success_response(result) } else format.json { render dashboard_error_response(result) } @@ -56,7 +59,7 @@ module MetricsDashboard def dashboard_error_response(result) { - status: result[:http_status], + status: result[:http_status] || :bad_request, json: result.slice(:all_dashboards, :message, :status) } end diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index c053ca19a94..5fd475f5499 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -199,8 +199,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController def metrics_dashboard_params params - .permit(:embedded, :group, :title, :y_label) - .to_h.symbolize_keys + .permit(:embedded, :group, :title, :y_label, :dashboard_path, :environment) .merge(dashboard_path: params[:dashboard], environment: environment) end diff --git a/app/controllers/projects/grafana_api_controller.rb b/app/controllers/projects/grafana_api_controller.rb index 4bdf4c12cac..85f47b92e58 100644 --- a/app/controllers/projects/grafana_api_controller.rb +++ b/app/controllers/projects/grafana_api_controller.rb @@ -2,6 +2,9 @@ class Projects::GrafanaApiController < Projects::ApplicationController include RenderServiceResults + include MetricsDashboard + + before_action :validate_feature_enabled!, only: [:metrics_dashboard] def proxy result = ::Grafana::ProxyService.new( @@ -19,6 +22,14 @@ class Projects::GrafanaApiController < Projects::ApplicationController private + def metrics_dashboard_params + params.permit(:embedded, :grafana_url) + end + + def validate_feature_enabled! + render_403 unless Feature.enabled?(:gfm_grafana_integration) + end + def query_params params.permit(:query, :start, :end, :step) end diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index 099609c29ca..777fe82e4c0 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true module SearchHelper + SEARCH_PERMITTED_PARAMS = [:search, :scope, :project_id, :group_id, :repository_ref, :snippets].freeze + def search_autocomplete_opts(term) return unless current_user @@ -200,7 +202,7 @@ module SearchHelper search_params = params .merge(search) .merge({ scope: scope }) - .permit(:search, :scope, :project_id, :group_id, :repository_ref, :snippets) + .permit(SEARCH_PERMITTED_PARAMS) if @scope == scope li_class = 'active' diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb index 28adc7ccbdb..fc25b78da93 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -197,9 +197,7 @@ module TreeHelper end def directory_download_links(project, ref, archive_prefix) - formats = ['zip', 'tar.gz', 'tar.bz2', 'tar'] - - formats.map do |fmt| + Gitlab::Workhorse::ARCHIVE_FORMATS.map do |fmt| { text: fmt, path: project_archive_path(project, id: tree_join(ref, archive_prefix), format: fmt) diff --git a/app/models/releases/source.rb b/app/models/releases/source.rb index 4d3d54457af..2f00d25d768 100644 --- a/app/models/releases/source.rb +++ b/app/models/releases/source.rb @@ -6,11 +6,9 @@ module Releases attr_accessor :project, :tag_name, :format - FORMATS = %w(zip tar.gz tar.bz2 tar).freeze - class << self def all(project, tag_name) - Releases::Source::FORMATS.map do |format| + Gitlab::Workhorse::ARCHIVE_FORMATS.map do |format| Releases::Source.new(project: project, tag_name: tag_name, format: format) diff --git a/app/services/groups/transfer_service.rb b/app/services/groups/transfer_service.rb index 6902b7bd529..14f5a605633 100644 --- a/app/services/groups/transfer_service.rb +++ b/app/services/groups/transfer_service.rb @@ -13,7 +13,7 @@ module Groups TransferError = Class.new(StandardError) - attr_reader :error + attr_reader :error, :new_parent_group def initialize(group, user, params = {}) super @@ -115,3 +115,5 @@ module Groups end end end + +Groups::TransferService.prepend_if_ee('EE::Groups::TransferService') diff --git a/app/services/projects/transfer_service.rb b/app/services/projects/transfer_service.rb index 525fc18b312..718416a03d4 100644 --- a/app/services/projects/transfer_service.rb +++ b/app/services/projects/transfer_service.rb @@ -13,6 +13,8 @@ module Projects include Gitlab::ShellAdapter TransferError = Class.new(StandardError) + attr_reader :new_namespace + def execute(new_namespace) @new_namespace = new_namespace diff --git a/app/views/projects/buttons/_download_links.html.haml b/app/views/projects/buttons/_download_links.html.haml index b256d94065b..990f3ff526b 100644 --- a/app/views/projects/buttons/_download_links.html.haml +++ b/app/views/projects/buttons/_download_links.html.haml @@ -1,6 +1,4 @@ -- formats = [['zip', 'btn-primary'], ['tar.gz'], ['tar.bz2'], ['tar']] - .btn-group.ml-0.w-100 - - formats.each do |(fmt, extra_class)| + - Gitlab::Workhorse::ARCHIVE_FORMATS.each_with_index do |fmt, index| - archive_path = project_archive_path(project, id: tree_join(ref, archive_prefix), path: path, format: fmt) - = link_to fmt, external_storage_url_or_path(archive_path), rel: 'nofollow', download: '', class: "btn btn-xs #{extra_class}" + = link_to fmt, external_storage_url_or_path(archive_path), rel: 'nofollow', download: '', class: "btn btn-xs #{"btn-primary" if index == 0}" diff --git a/app/views/search/_results.html.haml b/app/views/search/_results.html.haml index de9947528cf..629a5a045b1 100644 --- a/app/views/search/_results.html.haml +++ b/app/views/search/_results.html.haml @@ -1,6 +1,7 @@ - if @search_objects.to_a.empty? = render partial: "search/results/empty" = render_if_exists 'shared/promotions/promote_advanced_search' + = render_if_exists 'search/form_revert_to_basic' - else .row-content-block.d-md-flex.text-left.align-items-center - unless @search_objects.is_a?(Kaminari::PaginatableWithoutCount) |