From 9dc93a4519d9d5d7be48ff274127136236a3adb3 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Tue, 20 Apr 2021 23:50:22 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-11-stable-ee --- app/controllers/projects/blame_controller.rb | 2 +- app/controllers/projects/blob_controller.rb | 2 +- app/controllers/projects/boards_controller.rb | 3 +- app/controllers/projects/branches_controller.rb | 2 +- .../projects/ci/pipeline_editor_controller.rb | 1 + .../projects/clusters/integrations_controller.rb | 15 +++++++ app/controllers/projects/commit_controller.rb | 39 ++++++++++-------- app/controllers/projects/commits_controller.rb | 8 +--- app/controllers/projects/compare_controller.rb | 2 +- app/controllers/projects/forks_controller.rb | 16 ++++++-- app/controllers/projects/issues_controller.rb | 34 +++++++-------- app/controllers/projects/jobs_controller.rb | 5 +++ app/controllers/projects/labels_controller.rb | 11 +++-- app/controllers/projects/logs_controller.rb | 2 +- .../projects/merge_requests/content_controller.rb | 11 ++++- .../merge_requests/creations_controller.rb | 17 ++++---- .../projects/merge_requests_controller.rb | 48 +++++++++++++++------- app/controllers/projects/network_controller.rb | 5 --- app/controllers/projects/notes_controller.rb | 6 +-- .../packages/infrastructure_registry_controller.rb | 9 ++++ app/controllers/projects/pipelines_controller.rb | 43 +++++++++---------- .../projects/registry/repositories_controller.rb | 15 +------ app/controllers/projects/releases_controller.rb | 1 - app/controllers/projects/services_controller.rb | 2 +- .../projects/settings/access_tokens_controller.rb | 9 ++-- .../projects/settings/ci_cd_controller.rb | 3 +- .../projects/settings/operations_controller.rb | 1 + .../projects/settings/repository_controller.rb | 1 + app/controllers/projects/tags_controller.rb | 3 ++ 29 files changed, 188 insertions(+), 128 deletions(-) create mode 100644 app/controllers/projects/clusters/integrations_controller.rb create mode 100644 app/controllers/projects/packages/infrastructure_registry_controller.rb (limited to 'app/controllers/projects') diff --git a/app/controllers/projects/blame_controller.rb b/app/controllers/projects/blame_controller.rb index d5de0d38152..2c7c49b4250 100644 --- a/app/controllers/projects/blame_controller.rb +++ b/app/controllers/projects/blame_controller.rb @@ -20,7 +20,7 @@ class Projects::BlameController < Projects::ApplicationController environment_params = @repository.branch_exists?(@ref) ? { ref: @ref } : { commit: @commit } environment_params[:find_latest] = true - @environment = EnvironmentsFinder.new(@project, current_user, environment_params).execute.last + @environment = EnvironmentsByDeploymentsFinder.new(@project, current_user, environment_params).execute.last @blame = Gitlab::Blame.new(@blob, @commit) @blame = Gitlab::View::Presenter::Factory.new(@blame, project: @project, path: @path).fabricate! diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index 0080ae1a5be..a398fc56a35 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -214,7 +214,7 @@ class Projects::BlobController < Projects::ApplicationController def show_html environment_params = @repository.branch_exists?(@ref) ? { ref: @ref } : { commit: @commit } environment_params[:find_latest] = true - @environment = EnvironmentsFinder.new(@project, current_user, environment_params).execute.last + @environment = EnvironmentsByDeploymentsFinder.new(@project, current_user, environment_params).execute.last @last_commit = @repository.last_commit_for_path(@commit.id, @blob.path, literal_pathspec: true) @code_navigation_path = Gitlab::CodeNavigationPath.new(@project, @blob.commit_id).full_json_path_for(@blob.path) diff --git a/app/controllers/projects/boards_controller.rb b/app/controllers/projects/boards_controller.rb index 418f2ee1592..349649c7b35 100644 --- a/app/controllers/projects/boards_controller.rb +++ b/app/controllers/projects/boards_controller.rb @@ -8,7 +8,8 @@ class Projects::BoardsController < Projects::ApplicationController before_action :authorize_read_board!, only: [:index, :show] before_action :assign_endpoint_vars before_action do - push_frontend_feature_flag(:add_issues_button) + push_frontend_feature_flag(:swimlanes_buffered_rendering, project, default_enabled: :yaml) + push_frontend_feature_flag(:graphql_board_lists, project, default_enabled: :yaml) end feature_category :boards diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index 6f3c96fa654..f522dffdf3e 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -49,7 +49,7 @@ class Projects::BranchesController < Projects::ApplicationController branches = BranchesFinder.new(repository, params.permit(names: [])).execute Gitlab::GitalyClient.allow_n_plus_1_calls do - render json: branches.map { |branch| [branch.name, service.call(branch)] }.to_h + render json: branches.to_h { |branch| [branch.name, service.call(branch)] } end end end diff --git a/app/controllers/projects/ci/pipeline_editor_controller.rb b/app/controllers/projects/ci/pipeline_editor_controller.rb index 4d491b33aa0..754e2ccf4f9 100644 --- a/app/controllers/projects/ci/pipeline_editor_controller.rb +++ b/app/controllers/projects/ci/pipeline_editor_controller.rb @@ -7,6 +7,7 @@ class Projects::Ci::PipelineEditorController < Projects::ApplicationController push_frontend_feature_flag(:ci_config_merged_tab, @project, default_enabled: :yaml) push_frontend_feature_flag(:pipeline_status_for_pipeline_editor, @project, default_enabled: :yaml) push_frontend_feature_flag(:pipeline_editor_empty_state_action, @project, default_enabled: :yaml) + push_frontend_feature_flag(:pipeline_editor_branch_switcher, @project, default_enabled: :yaml) end feature_category :pipeline_authoring diff --git a/app/controllers/projects/clusters/integrations_controller.rb b/app/controllers/projects/clusters/integrations_controller.rb new file mode 100644 index 00000000000..94b8dd653e6 --- /dev/null +++ b/app/controllers/projects/clusters/integrations_controller.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class Projects::Clusters::IntegrationsController < ::Clusters::IntegrationsController + prepend_before_action :project + + private + + def clusterable + @clusterable ||= ClusterablePresenter.fabricate(project, current_user: current_user) + end + + def project + @project ||= find_routable!(Project, File.join(params[:namespace_id], params[:project_id])) + end +end diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index 8154128da29..0c3ff07bc76 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -19,13 +19,8 @@ class Projects::CommitController < Projects::ApplicationController before_action :define_commit_box_vars, only: [:show, :pipelines] before_action :define_note_vars, only: [:show, :diff_for_path, :diff_files] before_action :authorize_edit_tree!, only: [:revert, :cherry_pick] - - before_action only: [:show, :pipelines] do - push_frontend_feature_flag(:ci_commit_pipeline_mini_graph_vue, @project, default_enabled: :yaml) - end - before_action do - push_frontend_feature_flag(:pick_into_project) + push_frontend_feature_flag(:pick_into_project, @project, default_enabled: :yaml) end BRANCH_SEARCH_LIMIT = 1000 @@ -59,8 +54,6 @@ class Projects::CommitController < Projects::ApplicationController # rubocop: disable CodeReuse/ActiveRecord def pipelines - set_pipeline_feature_flag - @pipelines = @commit.pipelines.order(id: :desc) @pipelines = @pipelines.where(ref: params[:ref]).page(params[:page]).per(30) if params[:ref] @@ -119,7 +112,7 @@ class Projects::CommitController < Projects::ApplicationController @branch_name = create_new_branch? ? @commit.revert_branch_name : @start_branch create_commit(Commits::RevertService, success_notice: "The #{@commit.change_type_title(current_user)} has been successfully reverted.", - success_path: -> { successful_change_path }, failure_path: failed_change_path) + success_path: -> { successful_change_path(@project) }, failure_path: failed_change_path) end def cherry_pick @@ -127,24 +120,25 @@ class Projects::CommitController < Projects::ApplicationController return render_404 if @start_branch.blank? + target_project = find_cherry_pick_target_project + return render_404 unless target_project + @branch_name = create_new_branch? ? @commit.cherry_pick_branch_name : @start_branch create_commit(Commits::CherryPickService, success_notice: "The #{@commit.change_type_title(current_user)} has been successfully cherry-picked into #{@branch_name}.", - success_path: -> { successful_change_path }, failure_path: failed_change_path) + success_path: -> { successful_change_path(target_project) }, + failure_path: failed_change_path, + target_project: target_project) end private - def set_pipeline_feature_flag - push_frontend_feature_flag(:new_pipelines_table, @project, default_enabled: :yaml) - end - def create_new_branch? params[:create_merge_request].present? || !can?(current_user, :push_code, @project) end - def successful_change_path - referenced_merge_request_url || project_commits_url(@project, @branch_name) + def successful_change_path(target_project) + referenced_merge_request_url || project_commits_url(target_project, @branch_name) end def failed_change_path @@ -173,7 +167,7 @@ class Projects::CommitController < Projects::ApplicationController @diffs = commit.diffs(opts) @notes_count = commit.notes.count - @environment = EnvironmentsFinder.new(@project, current_user, commit: @commit, find_latest: true).execute.last + @environment = EnvironmentsByDeploymentsFinder.new(@project, current_user, commit: @commit, find_latest: true).execute.last end # rubocop: disable CodeReuse/ActiveRecord @@ -214,7 +208,6 @@ class Projects::CommitController < Projects::ApplicationController def define_commit_box_vars @last_pipeline = @commit.last_pipeline - return unless ::Gitlab::Ci::Features.ci_commit_pipeline_mini_graph_vue_enabled?(@project) return unless @commit.last_pipeline @last_pipeline_stages = StageSerializer.new(project: @project, current_user: @current_user).represent(@last_pipeline.stages) @@ -224,4 +217,14 @@ class Projects::CommitController < Projects::ApplicationController @start_branch = params[:start_branch] @commit_params = { commit: @commit } end + + def find_cherry_pick_target_project + return @project if params[:target_project_id].blank? + return @project unless Feature.enabled?(:pick_into_project, @project, default_enabled: :yaml) + + MergeRequestTargetProjectFinder + .new(current_user: current_user, source_project: @project, project_feature: :repository) + .execute + .find_by_id(params[:target_project_id]) + end end diff --git a/app/controllers/projects/commits_controller.rb b/app/controllers/projects/commits_controller.rb index d267ab732f9..9ca917841e9 100644 --- a/app/controllers/projects/commits_controller.rb +++ b/app/controllers/projects/commits_controller.rb @@ -8,7 +8,6 @@ class Projects::CommitsController < Projects::ApplicationController prepend_before_action(only: [:show]) { authenticate_sessionless_user!(:rss) } around_action :allow_gitaly_ref_name_caching - before_action :whitelist_query_limiting, except: :commits_root before_action :require_non_empty_project before_action :assign_ref_vars, except: :commits_root before_action :authorize_download_code! @@ -64,7 +63,8 @@ class Projects::CommitsController < Projects::ApplicationController def set_commits render_404 unless @path.empty? || request.format == :atom || @repository.blob_at(@commit.id, @path) || @repository.tree(@commit.id, @path).entries.present? - @limit, @offset = (params[:limit] || 40).to_i, (params[:offset] || 0).to_i + @limit = (params[:limit] || 40).to_i + @offset = (params[:offset] || 0).to_i search = params[:search] author = params[:author] @@ -82,8 +82,4 @@ class Projects::CommitsController < Projects::ApplicationController @commits = @commits.with_latest_pipeline(@ref) @commits = set_commits_for_rendering(@commits) end - - def whitelist_query_limiting - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42330') - end end diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb index 81f80d37662..221bc16e256 100644 --- a/app/controllers/projects/compare_controller.rb +++ b/app/controllers/projects/compare_controller.rb @@ -132,7 +132,7 @@ class Projects::CompareController < Projects::ApplicationController if compare environment_params = source_project.repository.branch_exists?(head_ref) ? { ref: head_ref } : { commit: compare.commit } environment_params[:find_latest] = true - @environment = EnvironmentsFinder.new(source_project, current_user, environment_params).execute.last + @environment = EnvironmentsByDeploymentsFinder.new(source_project, current_user, environment_params).execute.last end end diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb index 33f046f414f..9fc8e8c063b 100644 --- a/app/controllers/projects/forks_controller.rb +++ b/app/controllers/projects/forks_controller.rb @@ -7,7 +7,7 @@ class Projects::ForksController < Projects::ApplicationController include Gitlab::Utils::StrongMemoize # Authorize - before_action :whitelist_query_limiting, only: [:create] + before_action :disable_query_limiting, only: [:create] before_action :require_non_empty_project before_action :authorize_download_code! before_action :authenticate_user!, only: [:new, :create] @@ -44,13 +44,17 @@ class Projects::ForksController < Projects::ApplicationController def new respond_to do |format| format.html do - @own_namespace = current_user.namespace if fork_service.valid_fork_targets.include?(current_user.namespace) + @own_namespace = current_user.namespace if can_fork_to?(current_user.namespace) @project = project end format.json do namespaces = load_namespaces_with_associations - [project.namespace] + namespaces = [current_user.namespace] + namespaces if + Feature.enabled?(:fork_project_form, project, default_enabled: :yaml) && + can_fork_to?(current_user.namespace) + render json: { namespaces: ForkNamespaceSerializer.new.represent(namespaces, project: project, current_user: current_user, memberships: memberships_hash) } @@ -78,6 +82,10 @@ class Projects::ForksController < Projects::ApplicationController private + def can_fork_to?(namespace) + ForkTargetsFinder.new(@project, current_user).execute.id_in(current_user.namespace).any? + end + def load_forks forks = ForkProjectsFinder.new( project, @@ -110,8 +118,8 @@ class Projects::ForksController < Projects::ApplicationController access_denied! unless fork_namespace && fork_service.valid_fork_target? end - def whitelist_query_limiting - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42335') + def disable_query_limiting + Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/20783') end def load_namespaces_with_associations diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index c454ae6eaf4..cae5cc411bc 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -18,7 +18,7 @@ class Projects::IssuesController < Projects::ApplicationController prepend_before_action :authenticate_user!, only: [:new, :export_csv] prepend_before_action :store_uri, only: [:new, :show, :designs] - before_action :whitelist_query_limiting, only: [:create, :create_merge_request, :move, :bulk_update] + before_action :disable_query_limiting, only: [:create_merge_request, :move, :bulk_update] before_action :check_issues_available! before_action :issue, unless: ->(c) { ISSUES_EXCEPT_ACTIONS.include?(c.action_name.to_sym) } after_action :log_issue_show, unless: ->(c) { ISSUES_EXCEPT_ACTIONS.include?(c.action_name.to_sym) } @@ -45,6 +45,7 @@ class Projects::IssuesController < Projects::ApplicationController push_frontend_feature_flag(:vue_issuables_list, project) push_frontend_feature_flag(:usage_data_design_action, project, default_enabled: true) push_frontend_feature_flag(:improved_emoji_picker, project, default_enabled: :yaml) + push_frontend_feature_flag(:vue_issues_list, project) end before_action only: :show do @@ -53,15 +54,22 @@ class Projects::IssuesController < Projects::ApplicationController push_to_gon_attributes(:features, real_time_feature_flag, real_time_enabled) push_frontend_feature_flag(:confidential_notes, @project, default_enabled: :yaml) + push_frontend_feature_flag(:issue_assignees_widget, @project, default_enabled: :yaml) record_experiment_user(:invite_members_version_b) + + experiment(:invite_members_in_comment, namespace: @project.root_ancestor) do |experiment_instance| + experiment_instance.exclude! unless helpers.can_import_members? + + experiment_instance.use {} + experiment_instance.try(:invite_member_link) {} + + experiment_instance.track(:view, property: @project.root_ancestor.id.to_s) + end end around_action :allow_gitaly_ref_name_caching, only: [:discussions] - before_action :run_null_hypothesis_experiment, - only: [:index, :new, :create] - respond_to :html alias_method :designs, :show @@ -344,13 +352,13 @@ class Projects::IssuesController < Projects::ApplicationController IssuesFinder end - def whitelist_query_limiting + def disable_query_limiting # Also see the following issues: # - # 1. https://gitlab.com/gitlab-org/gitlab-foss/issues/42423 - # 2. https://gitlab.com/gitlab-org/gitlab-foss/issues/42424 - # 3. https://gitlab.com/gitlab-org/gitlab-foss/issues/42426 - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42422') + # 1. https://gitlab.com/gitlab-org/gitlab/-/issues/20815 + # 2. https://gitlab.com/gitlab-org/gitlab/-/issues/20816 + # 3. https://gitlab.com/gitlab-org/gitlab/-/issues/21068 + Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/20814') end private @@ -390,14 +398,6 @@ class Projects::IssuesController < Projects::ApplicationController action_name == 'service_desk' end - def run_null_hypothesis_experiment - experiment(:null_hypothesis, project: project) do |e| - e.use { } # define the control - e.try { } # define the candidate - e.track(action_name) # track the action so we can build a funnel - end - end - # Overridden in EE def create_vulnerability_issue_feedback(issue); end end diff --git a/app/controllers/projects/jobs_controller.rb b/app/controllers/projects/jobs_controller.rb index f19a86209fc..92442fd4e28 100644 --- a/app/controllers/projects/jobs_controller.rb +++ b/app/controllers/projects/jobs_controller.rb @@ -15,6 +15,7 @@ class Projects::JobsController < Projects::ApplicationController before_action :verify_api_request!, only: :terminal_websocket_authorize before_action :authorize_create_proxy_build!, only: :proxy_websocket_authorize before_action :verify_proxy_request!, only: :proxy_websocket_authorize + before_action :push_jobs_table_vue, only: [:index] layout 'project' @@ -256,4 +257,8 @@ class Projects::JobsController < Projects::ApplicationController ::Gitlab::Workhorse.channel_websocket(service) end + + def push_jobs_table_vue + push_frontend_feature_flag(:jobs_table_vue, @project, default_enabled: :yaml) + end end diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index 3992165d07c..6bf3885fb7a 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -17,11 +17,14 @@ class Projects::LabelsController < Projects::ApplicationController feature_category :issue_tracking def index - @prioritized_labels = @available_labels.prioritized(@project) - @labels = @available_labels.unprioritized(@project).page(params[:page]) - respond_to do |format| - format.html + format.html do + @prioritized_labels = @available_labels.prioritized(@project) + @labels = @available_labels.unprioritized(@project).page(params[:page]) + # preload group, project, and subscription data + Preloaders::LabelsPreloader.new(@prioritized_labels, current_user, @project).preload_all + Preloaders::LabelsPreloader.new(@labels, current_user, @project).preload_all + end format.json do render json: LabelSerializer.new.represent_appearance(@available_labels) end diff --git a/app/controllers/projects/logs_controller.rb b/app/controllers/projects/logs_controller.rb index b9aa9bfc947..f9b8091a419 100644 --- a/app/controllers/projects/logs_controller.rb +++ b/app/controllers/projects/logs_controller.rb @@ -58,7 +58,7 @@ module Projects def environment strong_memoize(:environment) do if cluster_params.key?(:environment_name) - EnvironmentsFinder.new(project, current_user, name: cluster_params[:environment_name]).find.first + EnvironmentsFinder.new(project, current_user, name: cluster_params[:environment_name]).execute.first else project.default_environment end diff --git a/app/controllers/projects/merge_requests/content_controller.rb b/app/controllers/projects/merge_requests/content_controller.rb index 399745151b1..dfc060c9204 100644 --- a/app/controllers/projects/merge_requests/content_controller.rb +++ b/app/controllers/projects/merge_requests/content_controller.rb @@ -14,6 +14,8 @@ class Projects::MergeRequests::ContentController < Projects::MergeRequests::Appl SLOW_POLLING_INTERVAL = 5.minutes.in_milliseconds def widget + check_mergeability_async! + respond_to do |format| format.json do render json: serializer(MergeRequestPollWidgetEntity) @@ -38,6 +40,13 @@ class Projects::MergeRequests::ContentController < Projects::MergeRequests::Appl def serializer(entity) serializer = MergeRequestSerializer.new(current_user: current_user, project: merge_request.project) - serializer.represent(merge_request, {}, entity) + serializer.represent(merge_request, { async_mergeability_check: params[:async_mergeability_check] }, entity) + end + + def check_mergeability_async! + return unless Feature.enabled?(:check_mergeability_async_in_widget, merge_request.project, default_enabled: :yaml) + return if params[:async_mergeability_check].blank? + + merge_request.check_mergeability(async: true) end end diff --git a/app/controllers/projects/merge_requests/creations_controller.rb b/app/controllers/projects/merge_requests/creations_controller.rb index e79c19c3b67..dc77b5e09c8 100644 --- a/app/controllers/projects/merge_requests/creations_controller.rb +++ b/app/controllers/projects/merge_requests/creations_controller.rb @@ -6,7 +6,6 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap include RendersCommits skip_before_action :merge_request - before_action :whitelist_query_limiting, only: [:create] before_action :authorize_create_merge_request_from! before_action :apply_diff_view_cookie!, only: [:diffs, :diff_for_path] before_action :build_merge_request, except: [:create] @@ -122,24 +121,24 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap # rubocop: disable CodeReuse/ActiveRecord def selected_target_project - if @project.id.to_s == params[:target_project_id] || !@project.forked? - @project - elsif params[:target_project_id].present? + return @project unless @project.forked? + + if params[:target_project_id].present? + return @project if @project.id.to_s == params[:target_project_id] + MergeRequestTargetProjectFinder.new(current_user: current_user, source_project: @project) .find_by(id: params[:target_project_id]) else - @project.forked_from_project + @project.default_merge_request_target end end # rubocop: enable CodeReuse/ActiveRecord - def whitelist_query_limiting - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42384') - end - def incr_count_webide_merge_request return if params[:nav_source] != 'webide' Gitlab::UsageDataCounters::WebIdeCounter.increment_merge_requests_count end end + +Projects::MergeRequests::CreationsController.prepend_ee_mod diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 2c6d5f62b4e..4e409b5f28f 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -14,7 +14,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo skip_before_action :merge_request, only: [:index, :bulk_update, :export_csv] before_action :apply_diff_view_cookie!, only: [:show] - before_action :whitelist_query_limiting, only: [:assign_related_issues, :update] + before_action :disable_query_limiting, only: [:assign_related_issues, :update] before_action :authorize_update_issuable!, only: [:close, :edit, :update, :remove_wip, :sort] before_action :authorize_read_actual_head_pipeline!, only: [ :test_reports, @@ -30,21 +30,32 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo before_action :check_user_can_push_to_source_branch!, only: [:rebase] before_action only: [:show] do push_frontend_feature_flag(:file_identifier_hash) - push_frontend_feature_flag(:batch_suggestions, @project, default_enabled: true) push_frontend_feature_flag(:approvals_commented_by, @project, default_enabled: true) push_frontend_feature_flag(:merge_request_widget_graphql, @project, default_enabled: :yaml) push_frontend_feature_flag(:drag_comment_selection, @project, default_enabled: true) push_frontend_feature_flag(:unified_diff_components, @project, default_enabled: true) push_frontend_feature_flag(:default_merge_ref_for_diffs, @project, default_enabled: :yaml) push_frontend_feature_flag(:core_security_mr_widget_counts, @project) - push_frontend_feature_flag(:remove_resolve_note, @project, default_enabled: true) push_frontend_feature_flag(:diffs_gradual_load, @project, default_enabled: true) - push_frontend_feature_flag(:codequality_backend_comparison, @project, default_enabled: :yaml) push_frontend_feature_flag(:local_file_reviews, default_enabled: :yaml) push_frontend_feature_flag(:paginated_notes, @project, default_enabled: :yaml) - push_frontend_feature_flag(:new_pipelines_table, @project, default_enabled: :yaml) + push_frontend_feature_flag(:confidential_notes, @project, default_enabled: :yaml) + push_frontend_feature_flag(:usage_data_i_testing_summary_widget_total, @project, default_enabled: :yaml) + push_frontend_feature_flag(:improved_emoji_picker, project, default_enabled: :yaml) + + # Usage data feature flags + push_frontend_feature_flag(:users_expanding_widgets_usage_data, @project, default_enabled: :yaml) record_experiment_user(:invite_members_version_b) + + experiment(:invite_members_in_comment, namespace: @project.root_ancestor) do |experiment_instance| + experiment_instance.exclude! unless helpers.can_import_members? + + experiment_instance.use {} + experiment_instance.try(:invite_member_link) {} + + experiment_instance.track(:view, property: @project.root_ancestor.id.to_s) + end end before_action do @@ -57,16 +68,19 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo feature_category :code_review, [ :assign_related_issues, :bulk_update, :cancel_auto_merge, - :ci_environments_status, :commit_change_content, :commits, - :context_commits, :destroy, :diff_for_path, :discussions, - :edit, :exposed_artifacts, :index, :merge, - :pipeline_status, :pipelines, :rebase, :remove_wip, :show, - :toggle_award_emoji, :toggle_subscription, :update + :commit_change_content, :commits, :context_commits, :destroy, + :discussions, :edit, :index, :merge, :rebase, :remove_wip, + :show, :toggle_award_emoji, :toggle_subscription, :update + ] + + feature_category :code_testing, [ + :test_reports, :coverage_reports, :codequality_reports, + :codequality_mr_diff_reports ] - feature_category :code_testing, [:test_reports, :coverage_reports, :codequality_mr_diff_reports] feature_category :accessibility_testing, [:accessibility_reports] feature_category :infrastructure_as_code, [:terraform_reports] + feature_category :continuous_integration, [:pipeline_status, :pipelines, :exposed_artifacts] def index @merge_requests = @issuables @@ -83,7 +97,10 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo def show close_merge_request_if_no_source_project - @merge_request.check_mergeability(async: true) + + if Feature.disabled?(:check_mergeability_async_in_widget, @project, default_enabled: :yaml) + @merge_request.check_mergeability(async: true) + end respond_to do |format| format.html do @@ -102,6 +119,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo @show_whitespace_default = current_user.nil? || current_user.show_whitespace_in_diffs @file_by_file_default = current_user&.view_diffs_file_by_file @coverage_path = coverage_reports_project_merge_request_path(@project, @merge_request, format: :json) if @merge_request.has_coverage_reports? + @update_current_user_path = expose_path(api_v4_user_preferences_path) @endpoint_metadata_url = endpoint_metadata_url(@project, @merge_request) set_pipeline_variables @@ -459,9 +477,9 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo access_denied! unless @merge_request.can_be_merged_by?(current_user) end - def whitelist_query_limiting - # Also see https://gitlab.com/gitlab-org/gitlab-foss/issues/42441 - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42438') + def disable_query_limiting + # Also see https://gitlab.com/gitlab-org/gitlab/-/issues/20827 + Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/20824') end def reports_response(report_comparison, pipeline = nil) diff --git a/app/controllers/projects/network_controller.rb b/app/controllers/projects/network_controller.rb index 89b679fc033..f3a7bc7913e 100644 --- a/app/controllers/projects/network_controller.rb +++ b/app/controllers/projects/network_controller.rb @@ -4,7 +4,6 @@ class Projects::NetworkController < Projects::ApplicationController include ExtractsPath include ApplicationHelper - before_action :whitelist_query_limiting before_action :require_non_empty_project before_action :assign_ref_vars before_action :authorize_download_code! @@ -41,8 +40,4 @@ class Projects::NetworkController < Projects::ApplicationController @commit = @repo.commit(@options[:extended_sha1]) end - - def whitelist_query_limiting - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42333') - end end diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb index 77fd7688caf..e7e6aed8ec8 100644 --- a/app/controllers/projects/notes_controller.rb +++ b/app/controllers/projects/notes_controller.rb @@ -6,7 +6,7 @@ class Projects::NotesController < Projects::ApplicationController include NotesHelper include ToggleAwardEmoji - before_action :whitelist_query_limiting, only: [:create, :update] + before_action :disable_query_limiting, only: [:create, :update] before_action :authorize_read_note! before_action :authorize_create_note!, only: [:create] before_action :authorize_resolve_note!, only: [:resolve, :unresolve] @@ -87,7 +87,7 @@ class Projects::NotesController < Projects::ApplicationController access_denied! unless can?(current_user, :create_note, noteable) end - def whitelist_query_limiting - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42383') + def disable_query_limiting + Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/20800') end end diff --git a/app/controllers/projects/packages/infrastructure_registry_controller.rb b/app/controllers/projects/packages/infrastructure_registry_controller.rb new file mode 100644 index 00000000000..22ae1d65013 --- /dev/null +++ b/app/controllers/projects/packages/infrastructure_registry_controller.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Projects + module Packages + class InfrastructureRegistryController < Projects::ApplicationController + feature_category :infrastructure_as_code + end + end +end diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index 9b5f5871c41..ee1e10221ec 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -4,7 +4,7 @@ class Projects::PipelinesController < Projects::ApplicationController include ::Gitlab::Utils::StrongMemoize include Analytics::UniqueVisitsHelper - before_action :whitelist_query_limiting, only: [:create, :retry] + before_action :disable_query_limiting, only: [:create, :retry] before_action :pipeline, except: [:index, :new, :create, :charts, :config_variables] before_action :set_pipeline_path, only: [:show] before_action :authorize_read_pipeline! @@ -14,10 +14,11 @@ class Projects::PipelinesController < Projects::ApplicationController before_action :authorize_update_pipeline!, only: [:retry, :cancel] before_action do push_frontend_feature_flag(:new_pipeline_form, project, default_enabled: :yaml) + push_frontend_feature_flag(:pipeline_graph_layers_view, project, type: :development, default_enabled: :yaml) + push_frontend_feature_flag(:pipeline_filter_jobs, project, default_enabled: :yaml) push_frontend_feature_flag(:graphql_pipeline_details, project, type: :development, default_enabled: :yaml) push_frontend_feature_flag(:graphql_pipeline_details_users, current_user, type: :development, default_enabled: :yaml) push_frontend_feature_flag(:jira_for_vulnerabilities, project, type: :development, default_enabled: :yaml) - push_frontend_feature_flag(:new_pipelines_table, project, default_enabled: :yaml) end before_action :ensure_pipeline, only: [:show] @@ -44,7 +45,17 @@ class Projects::PipelinesController < Projects::ApplicationController @pipelines_count = limited_pipelines_count(project) respond_to do |format| - format.html + format.html do + experiment(:pipeline_empty_state_templates, actor: current_user) do |e| + e.exclude! unless current_user + e.exclude! if @pipelines_count.to_i > 0 + e.exclude! if helpers.has_gitlab_ci?(project) + + e.use {} + e.try {} + e.track(:view, value: project.namespace_id) + end + end format.json do Gitlab::PollingInterval.set_header(response, interval: POLLING_INTERVAL) @@ -92,10 +103,10 @@ class Projects::PipelinesController < Projects::ApplicationController end def show - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab/-/issues/26657') + Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/26657') respond_to do |format| - format.html + format.html { render_show } format.json do Gitlab::PollingInterval.set_header(response, interval: POLLING_INTERVAL) @@ -150,15 +161,6 @@ class Projects::PipelinesController < Projects::ApplicationController .represent(@stage, details: true, retried: params[:retried]) end - # TODO: This endpoint is used by mini-pipeline-graph - # TODO: This endpoint should be migrated to `stage.json` - def stage_ajax - @stage = pipeline.legacy_stage(params[:stage]) - return not_found unless @stage - - render json: { html: view_to_html_string('projects/pipelines/_stage') } - end - def retry pipeline.retry_failed(current_user) @@ -185,10 +187,7 @@ class Projects::PipelinesController < Projects::ApplicationController def test_report respond_to do |format| - format.html do - render 'show' - end - + format.html { render_show } format.json do render json: TestReportSerializer .new(current_user: @current_user) @@ -217,6 +216,8 @@ class Projects::PipelinesController < Projects::ApplicationController end def render_show + @stages = @pipeline.stages.with_latest_and_retried_statuses + respond_to do |format| format.html do render 'show' @@ -269,9 +270,9 @@ class Projects::PipelinesController < Projects::ApplicationController &.present(current_user: current_user) end - def whitelist_query_limiting - # Also see https://gitlab.com/gitlab-org/gitlab-foss/issues/42343 - Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42339') + def disable_query_limiting + # Also see https://gitlab.com/gitlab-org/gitlab/-/issues/20785 + Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/20784') end def authorize_update_pipeline! diff --git a/app/controllers/projects/registry/repositories_controller.rb b/app/controllers/projects/registry/repositories_controller.rb index 28a86ecc9f0..8acebd89033 100644 --- a/app/controllers/projects/registry/repositories_controller.rb +++ b/app/controllers/projects/registry/repositories_controller.rb @@ -6,22 +6,11 @@ module Projects include PackagesHelper before_action :authorize_update_container_image!, only: [:destroy] - before_action :ensure_root_container_repository!, only: [:index] def index respond_to do |format| - format.html - format.json do - @images = ContainerRepositoriesFinder.new(user: current_user, subject: project, params: params.slice(:name)) - .execute - - track_package_event(:list_repositories, :container) - - serializer = ContainerRepositoriesSerializer - .new(project: project, current_user: current_user) - - render json: serializer.with_pagination(request, response).represent(@images) - end + format.html { ensure_root_container_repository! } + format.json { render_404 } end end diff --git a/app/controllers/projects/releases_controller.rb b/app/controllers/projects/releases_controller.rb index 614bada09ed..26382856761 100644 --- a/app/controllers/projects/releases_controller.rb +++ b/app/controllers/projects/releases_controller.rb @@ -12,7 +12,6 @@ class Projects::ReleasesController < Projects::ApplicationController push_frontend_feature_flag(:graphql_release_data, project, default_enabled: true) push_frontend_feature_flag(:graphql_milestone_stats, project, default_enabled: true) push_frontend_feature_flag(:graphql_releases_page, project, default_enabled: true) - push_frontend_feature_flag(:graphql_individual_release_page, project, default_enabled: true) end before_action :authorize_update_release!, only: %i[edit update] before_action :authorize_create_release!, only: :new diff --git a/app/controllers/projects/services_controller.rb b/app/controllers/projects/services_controller.rb index 554eb01defe..ccb8b393bfe 100644 --- a/app/controllers/projects/services_controller.rb +++ b/app/controllers/projects/services_controller.rb @@ -71,7 +71,7 @@ class Projects::ServicesController < Projects::ApplicationController end result[:data].presence || {} - rescue Gitlab::HTTP::BlockedUrlError => e + rescue *Gitlab::HTTP::HTTP_ERRORS => e { error: true, message: s_('Integrations|Connection failed. Please check your settings.'), service_response: e.message, test_failed: true } end diff --git a/app/controllers/projects/settings/access_tokens_controller.rb b/app/controllers/projects/settings/access_tokens_controller.rb index 74350147825..e3bb8c616df 100644 --- a/app/controllers/projects/settings/access_tokens_controller.rb +++ b/app/controllers/projects/settings/access_tokens_controller.rb @@ -5,7 +5,10 @@ module Projects class AccessTokensController < Projects::ApplicationController include ProjectsHelper - before_action :check_feature_availability + layout 'project_settings' + before_action -> { check_permission(:read_resource_access_tokens) }, only: [:index] + before_action -> { check_permission(:destroy_resource_access_tokens) }, only: [:revoke] + before_action -> { check_permission(:create_resource_access_tokens) }, only: [:create] feature_category :authentication_and_authorization @@ -42,8 +45,8 @@ module Projects private - def check_feature_availability - render_404 unless project_access_token_available?(@project) + def check_permission(action) + render_404 unless can?(current_user, action, @project) end def create_params diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb index 34b11c456b9..1a465406660 100644 --- a/app/controllers/projects/settings/ci_cd_controller.rb +++ b/app/controllers/projects/settings/ci_cd_controller.rb @@ -7,6 +7,7 @@ module Projects NUMBER_OF_RUNNERS_PER_PAGE = 20 + layout 'project_settings' before_action :authorize_admin_pipeline! before_action :define_variables before_action do @@ -61,7 +62,7 @@ module Projects end def runner_setup_scripts - private_runner_setup_scripts(project: @project) + private_runner_setup_scripts end private diff --git a/app/controllers/projects/settings/operations_controller.rb b/app/controllers/projects/settings/operations_controller.rb index c407b15e29f..a05793a0283 100644 --- a/app/controllers/projects/settings/operations_controller.rb +++ b/app/controllers/projects/settings/operations_controller.rb @@ -3,6 +3,7 @@ module Projects module Settings class OperationsController < Projects::ApplicationController + layout 'project_settings' before_action :authorize_admin_operations! before_action :authorize_read_prometheus_alerts!, only: [:reset_alerting_token] diff --git a/app/controllers/projects/settings/repository_controller.rb b/app/controllers/projects/settings/repository_controller.rb index 821560e32ba..bb5ad8e9aea 100644 --- a/app/controllers/projects/settings/repository_controller.rb +++ b/app/controllers/projects/settings/repository_controller.rb @@ -3,6 +3,7 @@ module Projects module Settings class RepositoryController < Projects::ApplicationController + layout 'project_settings' before_action :authorize_admin_project! before_action :define_variables, only: [:create_deploy_token] before_action do diff --git a/app/controllers/projects/tags_controller.rb b/app/controllers/projects/tags_controller.rb index 94b0473e1f3..3bf9988ca22 100644 --- a/app/controllers/projects/tags_controller.rb +++ b/app/controllers/projects/tags_controller.rb @@ -9,6 +9,9 @@ class Projects::TagsController < Projects::ApplicationController before_action :require_non_empty_project before_action :authorize_download_code! before_action :authorize_admin_tag!, only: [:new, :create, :destroy] + before_action do + push_frontend_feature_flag(:gldropdown_tags, default_enabled: :yaml) + end feature_category :source_code_management, [:index, :show, :new, :destroy] feature_category :release_evidence, [:create] -- cgit v1.2.3