diff options
Diffstat (limited to 'app/controllers/projects')
41 files changed, 256 insertions, 177 deletions
diff --git a/app/controllers/projects/autocomplete_sources_controller.rb b/app/controllers/projects/autocomplete_sources_controller.rb index 7755effe1da..ef20c71cd77 100644 --- a/app/controllers/projects/autocomplete_sources_controller.rb +++ b/app/controllers/projects/autocomplete_sources_controller.rb @@ -7,7 +7,7 @@ class Projects::AutocompleteSourcesController < Projects::ApplicationController feature_category :team_planning, [:issues, :labels, :milestones, :commands, :contacts] feature_category :code_review, [:merge_requests] feature_category :users, [:members] - feature_category :snippets, [:snippets] + feature_category :source_code_management, [:snippets] urgency :low, [:merge_requests, :members] urgency :low, [:issues, :labels, :milestones, :commands, :contacts] diff --git a/app/controllers/projects/badges_controller.rb b/app/controllers/projects/badges_controller.rb index 42bd87e1c01..dbbffc4c283 100644 --- a/app/controllers/projects/badges_controller.rb +++ b/app/controllers/projects/badges_controller.rb @@ -13,10 +13,10 @@ class Projects::BadgesController < Projects::ApplicationController def pipeline pipeline_status = Gitlab::Ci::Badge::Pipeline::Status .new(project, params[:ref], opts: { - ignore_skipped: params[:ignore_skipped], - key_text: params[:key_text], - key_width: params[:key_width] - }) + ignore_skipped: params[:ignore_skipped], + key_text: params[:key_text], + key_width: params[:key_width] + }) render_badge pipeline_status end @@ -24,13 +24,13 @@ class Projects::BadgesController < Projects::ApplicationController def coverage coverage_report = Gitlab::Ci::Badge::Coverage::Report .new(project, params[:ref], opts: { - job: params[:job], - key_text: params[:key_text], - key_width: params[:key_width], - min_good: params[:min_good], - min_acceptable: params[:min_acceptable], - min_medium: params[:min_medium] - }) + job: params[:job], + key_text: params[:key_text], + key_width: params[:key_width], + min_good: params[:min_good], + min_acceptable: params[:min_acceptable], + min_medium: params[:min_medium] + }) render_badge coverage_report end @@ -38,10 +38,10 @@ class Projects::BadgesController < Projects::ApplicationController def release latest_release = Gitlab::Ci::Badge::Release::LatestRelease .new(project, current_user, opts: { - key_text: params[:key_text], - key_width: params[:key_width], - order_by: params[:order_by] - }) + key_text: params[:key_text], + key_width: params[:key_width], + order_by: params[:order_by] + }) render_badge latest_release end diff --git a/app/controllers/projects/blame_controller.rb b/app/controllers/projects/blame_controller.rb index 01ed5473b41..cfff281604e 100644 --- a/app/controllers/projects/blame_controller.rb +++ b/app/controllers/projects/blame_controller.rb @@ -7,7 +7,7 @@ class Projects::BlameController < Projects::ApplicationController before_action :require_non_empty_project before_action :assign_ref_vars - before_action :authorize_download_code! + before_action :authorize_read_code! feature_category :source_code_management urgency :low, [:show] diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index f5188e28b81..4eda76f4f21 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -18,7 +18,8 @@ class Projects::BlobController < Projects::ApplicationController around_action :allow_gitaly_ref_name_caching, only: [:show] before_action :require_non_empty_project, except: [:new, :create] - before_action :authorize_download_code! + before_action :authorize_download_code!, except: [:show] + before_action :authorize_read_code!, only: [:show] # We need to assign the blob vars before `authorize_edit_tree!` so we can # validate access to a specific ref. diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index 27969cb1a75..7b01e4db42a 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -6,7 +6,7 @@ class Projects::BranchesController < Projects::ApplicationController # Authorize before_action :require_non_empty_project, except: :create - before_action :authorize_download_code! + before_action :authorize_read_code! before_action :authorize_push_code!, only: [:new, :create, :destroy, :destroy_all_merged] # Support legacy URLs diff --git a/app/controllers/projects/ci/daily_build_group_report_results_controller.rb b/app/controllers/projects/ci/daily_build_group_report_results_controller.rb index b2b5e096105..37138afc719 100644 --- a/app/controllers/projects/ci/daily_build_group_report_results_controller.rb +++ b/app/controllers/projects/ci/daily_build_group_report_results_controller.rb @@ -25,7 +25,7 @@ class Projects::Ci::DailyBuildGroupReportResultsController < Projects::Applicati { date: 'date', group_name: 'group_name', - param_type => -> (record) { record.data[param_type] } + param_type => ->(record) { record.data[param_type] } } ).render end diff --git a/app/controllers/projects/clusters_controller.rb b/app/controllers/projects/clusters_controller.rb index 30d001d0ac5..b781365b3c3 100644 --- a/app/controllers/projects/clusters_controller.rb +++ b/app/controllers/projects/clusters_controller.rb @@ -5,7 +5,6 @@ class Projects::ClustersController < Clusters::ClustersController before_action :repository before_action do - push_frontend_feature_flag(:prometheus_computed_alerts) push_frontend_feature_flag(:show_gitlab_agent_feedback, type: :ops) end diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index 870320a79d9..583b572d4b1 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -12,7 +12,7 @@ class Projects::CommitController < Projects::ApplicationController # Authorize before_action :require_non_empty_project - before_action :authorize_download_code! + before_action :authorize_read_code! before_action :authorize_read_pipeline!, only: [:pipelines] before_action :commit before_action :define_commit_vars, only: [:show, :diff_for_path, :diff_files, :pipelines, :merge_requests] diff --git a/app/controllers/projects/commits_controller.rb b/app/controllers/projects/commits_controller.rb index f4125fd0a15..c006d56ae81 100644 --- a/app/controllers/projects/commits_controller.rb +++ b/app/controllers/projects/commits_controller.rb @@ -12,7 +12,7 @@ class Projects::CommitsController < Projects::ApplicationController around_action :allow_gitaly_ref_name_caching before_action :require_non_empty_project before_action :assign_ref_vars, except: :commits_root - before_action :authorize_download_code! + before_action :authorize_read_code! before_action :validate_ref!, except: :commits_root before_action :set_commits, except: :commits_root @@ -28,6 +28,8 @@ class Projects::CommitsController < Projects::ApplicationController @merge_request = MergeRequestsFinder.new(current_user, project_id: @project.id).execute.opened .find_by(source_project: @project, source_branch: @ref, target_branch: @repository.root_ref) + @ref_type = ref_type + respond_to do |format| format.html format.atom { render layout: 'xml' } @@ -73,18 +75,20 @@ class Projects::CommitsController < Projects::ApplicationController search = permitted_params[:search] author = permitted_params[:author] + # fully_qualified_ref is available in some situations when the use_ref_type_parameter FF is enabled + ref = @fully_qualified_ref || @ref @commits = if search.present? - @repository.find_commits_by_message(search, @ref, @path, @limit, @offset) + @repository.find_commits_by_message(search, ref, @path, @limit, @offset) elsif author.present? - @repository.commits(@ref, author: author, path: @path, limit: @limit, offset: @offset) + @repository.commits(ref, author: author, path: @path, limit: @limit, offset: @offset) else - @repository.commits(@ref, path: @path, limit: @limit, offset: @offset) + @repository.commits(ref, path: @path, limit: @limit, offset: @offset) end @commits.each(&:lazy_author) # preload authors - @commits = @commits.with_markdown_cache.with_latest_pipeline(@ref) + @commits = @commits.with_markdown_cache.with_latest_pipeline(ref) @commits = set_commits_for_rendering(@commits) end diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb index 61308f24412..266edd506d5 100644 --- a/app/controllers/projects/compare_controller.rb +++ b/app/controllers/projects/compare_controller.rb @@ -10,7 +10,7 @@ class Projects::CompareController < Projects::ApplicationController # Authorize before_action :require_non_empty_project - before_action :authorize_download_code! + before_action :authorize_read_code! # Defining ivars before_action :define_diffs, only: [:show, :diff_for_path] before_action :define_environment, only: [:show] @@ -95,7 +95,7 @@ class Projects::CompareController < Projects::ApplicationController target_project = target_projects(source_project).find_by_id(compare_params[:from_project_id]) # Just ignore the field if it points at a non-existent or hidden project - next source_project unless target_project && can?(current_user, :download_code, target_project) + next source_project unless target_project && can?(current_user, :read_code, target_project) target_project end diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index 67f2f85ce65..537fd3854c4 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -14,11 +14,11 @@ class Projects::EnvironmentsController < Projects::ApplicationController before_action only: [:metrics, :additional_metrics, :metrics_dashboard] do authorize_metrics_dashboard! - - push_frontend_feature_flag(:prometheus_computed_alerts) - push_frontend_feature_flag(:disable_metric_dashboard_refresh_rate) end + before_action only: [:show] do + push_frontend_feature_flag(:environment_details_vue, @project) + end before_action :authorize_read_environment!, except: [:metrics, :additional_metrics, :metrics_dashboard, :metrics_redirect] before_action :authorize_create_environment!, only: [:new, :create] before_action :authorize_stop_environment!, only: [:stop] diff --git a/app/controllers/projects/find_file_controller.rb b/app/controllers/projects/find_file_controller.rb index c6bc115e737..b5099d555ae 100644 --- a/app/controllers/projects/find_file_controller.rb +++ b/app/controllers/projects/find_file_controller.rb @@ -8,7 +8,7 @@ class Projects::FindFileController < Projects::ApplicationController before_action :require_non_empty_project before_action :assign_ref_vars - before_action :authorize_download_code! + before_action :authorize_read_code! feature_category :source_code_management urgency :low, [:show, :list] diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb index 3208a5076e7..ff3dc71b6cc 100644 --- a/app/controllers/projects/forks_controller.rb +++ b/app/controllers/projects/forks_controller.rb @@ -9,9 +9,9 @@ class Projects::ForksController < Projects::ApplicationController # Authorize before_action :disable_query_limiting, only: [:create] before_action :require_non_empty_project - before_action :authorize_download_code! + before_action :authorize_read_code! before_action :authenticate_user!, only: [:new, :create] - before_action :authorize_fork_project!, only: [:new, :create] + before_action :authorize_fork_project!, except: [:index] before_action :authorize_fork_namespace!, only: [:create] feature_category :source_code_management diff --git a/app/controllers/projects/graphs_controller.rb b/app/controllers/projects/graphs_controller.rb index 6da70b5e157..d072381933a 100644 --- a/app/controllers/projects/graphs_controller.rb +++ b/app/controllers/projects/graphs_controller.rb @@ -21,11 +21,24 @@ class Projects::GraphsController < Projects::ApplicationController feature_category :continuous_integration, [:ci] urgency :low, [:ci] + MAX_COMMITS = 6000 + def show + @ref_type = ref_type + respond_to do |format| format.html format.json do - fetch_graph + commits = @project.repository.commits(ref, limit: MAX_COMMITS, skip_merges: true) + log = commits.map do |commit| + { + author_name: commit.author_name, + author_email: commit.author_email, + date: commit.committed_date.strftime("%Y-%m-%d") + } + end + + render json: Gitlab::Json.dump(log) end end end @@ -50,9 +63,13 @@ class Projects::GraphsController < Projects::ApplicationController private + def ref + @fully_qualified_ref || @ref + end + def get_commits @commits_limit = 2000 - @commits = @project.repository.commits(@ref, limit: @commits_limit, skip_merges: true) + @commits = @project.repository.commits(ref, limit: @commits_limit, skip_merges: true) @commits_graph = Gitlab::Graphs::Commits.new(@commits) @commits_per_week_days = @commits_graph.commits_per_week_days @commits_per_time = @commits_graph.commits_per_time @@ -76,7 +93,7 @@ class Projects::GraphsController < Projects::ApplicationController base_params: { start_date: date_today - report_window, end_date: date_today, - ref_path: @project.repository.expand_ref(@ref), + ref_path: @project.repository.expand_ref(ref), param_type: 'coverage' }, download_path: namespace_project_ci_daily_build_group_report_results_path( @@ -92,21 +109,6 @@ class Projects::GraphsController < Projects::ApplicationController } end - def fetch_graph - @commits = @project.repository.commits(@ref, limit: 6000, skip_merges: true) - @log = [] - - @commits.each do |commit| - @log << { - author_name: commit.author_name, - author_email: commit.author_email, - date: commit.committed_date.strftime("%Y-%m-%d") - } - end - - render json: Gitlab::Json.dump(@log) - end - def tracking_namespace_source project.namespace end diff --git a/app/controllers/projects/incidents_controller.rb b/app/controllers/projects/incidents_controller.rb index 599505dcb6d..3842a88d15b 100644 --- a/app/controllers/projects/incidents_controller.rb +++ b/app/controllers/projects/incidents_controller.rb @@ -8,6 +8,7 @@ class Projects::IncidentsController < Projects::ApplicationController before_action :load_incident, only: [:show] before_action do push_force_frontend_feature_flag(:work_items, @project&.work_items_feature_flag_enabled?) + push_force_frontend_feature_flag(:work_items_mvc, @project&.work_items_mvc_feature_flag_enabled?) push_force_frontend_feature_flag(:work_items_mvc_2, @project&.work_items_mvc_2_feature_flag_enabled?) end diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index ee845cd001e..631e697dd2f 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -7,6 +7,7 @@ class Projects::IssuesController < Projects::ApplicationController include IssuableCollections include IssuesCalendar include RecordUserLastActivity + include ::Observability::ContentSecurityPolicy ISSUES_EXCEPT_ACTIONS = %i[index calendar new create bulk_update import_csv export_csv service_desk].freeze SET_ISSUABLES_INDEX_ONLY_ACTIONS = %i[index calendar service_desk].freeze @@ -19,7 +20,7 @@ class Projects::IssuesController < Projects::ApplicationController 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) } - before_action :redirect_if_task, unless: ->(c) { ISSUES_EXCEPT_ACTIONS.include?(c.action_name.to_sym) } + before_action :redirect_if_work_item, unless: ->(c) { ISSUES_EXCEPT_ACTIONS.include?(c.action_name.to_sym) } after_action :log_issue_show, only: :show @@ -37,7 +38,7 @@ class Projects::IssuesController < Projects::ApplicationController before_action :authorize_create_merge_request_from!, only: [:create_merge_request] before_action :authorize_import_issues!, only: [:import_csv] - before_action :authorize_download_code!, only: [:related_branches] + before_action :authorize_read_code!, only: [:related_branches] before_action do push_frontend_feature_flag(:preserve_unchanged_markdown, project) @@ -55,8 +56,10 @@ class Projects::IssuesController < Projects::ApplicationController before_action only: :show do push_frontend_feature_flag(:issue_assignees_widget, project) push_frontend_feature_flag(:work_items_mvc, project&.group) + push_force_frontend_feature_flag(:work_items_mvc, project&.work_items_mvc_feature_flag_enabled?) push_force_frontend_feature_flag(:work_items_mvc_2, project&.work_items_mvc_2_feature_flag_enabled?) push_frontend_feature_flag(:epic_widget_edit_confirmation, project) + push_frontend_feature_flag(:use_iid_in_work_items_path, project) push_force_frontend_feature_flag(:work_items_create_from_markdown, project&.work_items_create_from_markdown_feature_flag_enabled?) end @@ -432,8 +435,8 @@ class Projects::IssuesController < Projects::ApplicationController # Overridden in EE def create_vulnerability_issue_feedback(issue); end - def redirect_if_task - return unless issue.task? + def redirect_if_work_item + return unless allowed_work_item? if Feature.enabled?(:use_iid_in_work_items_path, project.group) redirect_to project_work_items_path(project, issue.iid, params: request.query_parameters.merge(iid_path: true)) @@ -441,6 +444,10 @@ class Projects::IssuesController < Projects::ApplicationController redirect_to project_work_items_path(project, issue.id, params: request.query_parameters) end end + + def allowed_work_item? + issue.task? + end end Projects::IssuesController.prepend_mod_with('Projects::IssuesController') diff --git a/app/controllers/projects/jobs_controller.rb b/app/controllers/projects/jobs_controller.rb index 557ac566733..c6d442a6f27 100644 --- a/app/controllers/projects/jobs_controller.rb +++ b/app/controllers/projects/jobs_controller.rb @@ -20,9 +20,6 @@ class Projects::JobsController < Projects::ApplicationController before_action :verify_proxy_request!, only: :proxy_websocket_authorize before_action :push_job_log_jump_to_failures, only: [:show] before_action :reject_if_build_artifacts_size_refreshing!, only: [:erase] - before_action do - push_frontend_feature_flag(:graphql_job_app, project, type: :development) - end layout 'project' diff --git a/app/controllers/projects/merge_requests/creations_controller.rb b/app/controllers/projects/merge_requests/creations_controller.rb index 93e2298ca98..cba0056ccd5 100644 --- a/app/controllers/projects/merge_requests/creations_controller.rb +++ b/app/controllers/projects/merge_requests/creations_controller.rb @@ -4,6 +4,7 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap include DiffForPath include DiffHelper include RendersCommits + include ::Observability::ContentSecurityPolicy skip_before_action :merge_request before_action :authorize_create_merge_request_from! @@ -19,6 +20,10 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap :branch_to ] + before_action do + push_frontend_feature_flag(:mr_compare_dropdowns, project) + end + def new define_new_vars end @@ -89,6 +94,14 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap render layout: false end + def target_projects + projects = MergeRequestTargetProjectFinder + .new(current_user: current_user, source_project: @project, project_feature: :repository) + .execute(include_routes: true).limit(20).search(params[:search]) + + render json: ProjectSerializer.new.represent(projects) + end + private def build_merge_request diff --git a/app/controllers/projects/merge_requests/diffs_controller.rb b/app/controllers/projects/merge_requests/diffs_controller.rb index c88dbc70ed5..83377f67723 100644 --- a/app/controllers/projects/merge_requests/diffs_controller.rb +++ b/app/controllers/projects/merge_requests/diffs_controller.rb @@ -60,17 +60,11 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic options[:merge_conflicts_in_diff] ] - if Feature.enabled?(:check_etags_diffs_batch_before_write_cache, merge_request.project) && !stale?(etag: [cache_context + diff_options_hash.fetch(:paths, []), diffs]) - return - end + return unless stale?(etag: [cache_context + diff_options_hash.fetch(:paths, []), diffs]) diffs.unfold_diff_files(unfoldable_positions) diffs.write_cache - if Feature.disabled?(:check_etags_diffs_batch_before_write_cache, merge_request.project) && !stale?(etag: [cache_context + diff_options_hash.fetch(:paths, []), diffs]) - return - end - render json: PaginatedDiffSerializer.new(current_user: current_user).represent(diffs, options) end # rubocop: enable Metrics/AbcSize diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 4ba79d43f27..3ab1f7d1d32 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -11,10 +11,11 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo include SourcegraphDecorator include DiffHelper include Gitlab::Cache::Helpers + include ::Observability::ContentSecurityPolicy prepend_before_action(only: [:index]) { authenticate_sessionless_user!(:rss) } skip_before_action :merge_request, only: [:index, :bulk_update, :export_csv] - before_action :apply_diff_view_cookie!, only: [:show] + before_action :apply_diff_view_cookie!, only: [:show, :diffs] 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: [ @@ -30,7 +31,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo before_action :authenticate_user!, only: [:assign_related_issues] before_action :check_user_can_push_to_source_branch!, only: [:rebase] - before_action only: [:show] do + before_action only: [:show, :diffs] do push_frontend_feature_flag(:core_security_mr_widget_counts, project) push_frontend_feature_flag(:issue_assignees_widget, @project) push_frontend_feature_flag(:refactor_security_extension, @project) @@ -40,21 +41,22 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo push_frontend_feature_flag(:mr_review_submit_comment, project) push_frontend_feature_flag(:mr_experience_survey, project) push_frontend_feature_flag(:realtime_reviewers, project) + push_frontend_feature_flag(:realtime_mr_status_change, project) end before_action do push_frontend_feature_flag(:permit_all_shared_groups_for_approval, @project) end - around_action :allow_gitaly_ref_name_caching, only: [:index, :show, :discussions] + around_action :allow_gitaly_ref_name_caching, only: [:index, :show, :diffs, :discussions] - after_action :log_merge_request_show, only: [:show] + after_action :log_merge_request_show, only: [:show, :diffs] feature_category :code_review, [ :assign_related_issues, :bulk_update, :cancel_auto_merge, :commit_change_content, :commits, :context_commits, :destroy, :discussions, :edit, :index, :merge, :rebase, :remove_wip, - :show, :toggle_award_emoji, :toggle_subscription, :update + :show, :diffs, :toggle_award_emoji, :toggle_subscription, :update ] feature_category :code_testing, [:test_reports, :coverage_reports] @@ -67,6 +69,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo urgency :low, [ :index, :show, + :diffs, :commits, :bulk_update, :edit, @@ -100,74 +103,13 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo end end - # rubocop:disable Metrics/AbcSize def show - close_merge_request_if_no_source_project - @merge_request.check_mergeability(async: true) - - respond_to do |format| - format.html do - # use next to appease Rubocop - next render('invalid') if target_branch_missing? - - preload_assignees_for_render(@merge_request) - - # Build a note object for comment form - @note = @project.notes.new(noteable: @merge_request) - - @noteable = @merge_request - @commits_count = @merge_request.commits_count + @merge_request.context_commits_count - @diffs_count = get_diffs_count - @issuable_sidebar = serializer.represent(@merge_request, serializer: 'sidebar') - @current_user_data = Gitlab::Json.dump(UserSerializer.new(project: @project).represent(current_user, {}, MergeRequestCurrentUserEntity)) - @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) - @endpoint_diff_batch_url = endpoint_diff_batch_url(@project, @merge_request) - - set_pipeline_variables - - @number_of_pipelines = @pipelines.size - - render - end - - format.json do - Gitlab::PollingInterval.set_header(response, interval: 10_000) - - if params[:serializer] == 'sidebar_extras' - cache_context = [ - params[:serializer], - current_user&.cache_key, - @merge_request.merge_request_assignees.map(&:cache_key), - @merge_request.merge_request_reviewers.map(&:cache_key) - ] - - render_cached(@merge_request, - with: serializer, - cache_context: -> (_) { [Digest::SHA256.hexdigest(cache_context.to_s)] }, - serializer: params[:serializer]) - else - render json: serializer.represent(@merge_request, serializer: params[:serializer]) - end - end - - format.patch do - break render_404 unless @merge_request.diff_refs - - send_git_patch @project.repository, @merge_request.diff_refs - end - - format.diff do - break render_404 unless @merge_request.diff_refs + show_merge_request + end - send_git_diff @project.repository, @merge_request.diff_refs - end - end + def diffs + show_merge_request end - # rubocop:enable Metrics/AbcSize def commits # Get context commits from repository @@ -412,6 +354,77 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo private + def show_merge_request + close_merge_request_if_no_source_project + @merge_request.check_mergeability(async: true) + + respond_to do |format| + format.html do + # use next to appease Rubocop + next render('invalid') if target_branch_missing? + + render_html_page + end + + format.json do + Gitlab::PollingInterval.set_header(response, interval: 10_000) + + if params[:serializer] == 'sidebar_extras' + cache_context = [ + params[:serializer], + current_user&.cache_key, + @merge_request.merge_request_assignees.map(&:cache_key), + @merge_request.merge_request_reviewers.map(&:cache_key) + ] + + render_cached(@merge_request, + with: serializer, + cache_context: ->(_) { [Digest::SHA256.hexdigest(cache_context.to_s)] }, + serializer: params[:serializer]) + else + render json: serializer.represent(@merge_request, serializer: params[:serializer]) + end + end + + format.patch do + break render_404 unless @merge_request.diff_refs + + send_git_patch @project.repository, @merge_request.diff_refs + end + + format.diff do + break render_404 unless @merge_request.diff_refs + + send_git_diff @project.repository, @merge_request.diff_refs + end + end + end + + def render_html_page + preload_assignees_for_render(@merge_request) + + # Build a note object for comment form + @note = @project.notes.new(noteable: @merge_request) + + @noteable = @merge_request + @commits_count = @merge_request.commits_count + @merge_request.context_commits_count + @diffs_count = get_diffs_count + @issuable_sidebar = serializer.represent(@merge_request, serializer: 'sidebar') + @current_user_data = Gitlab::Json.dump(UserSerializer.new(project: @project).represent(current_user, {}, MergeRequestCurrentUserEntity)) + @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) + @endpoint_diff_batch_url = endpoint_diff_batch_url(@project, @merge_request) + + set_pipeline_variables + + @number_of_pipelines = @pipelines.size + + render + end + def get_diffs_count if show_only_context_commits? @merge_request.context_commits_diff.raw_diffs.size diff --git a/app/controllers/projects/metrics_dashboard_controller.rb b/app/controllers/projects/metrics_dashboard_controller.rb index b78ee6ca917..08757d11912 100644 --- a/app/controllers/projects/metrics_dashboard_controller.rb +++ b/app/controllers/projects/metrics_dashboard_controller.rb @@ -9,10 +9,6 @@ module Projects include Gitlab::Utils::StrongMemoize before_action :authorize_metrics_dashboard! - before_action do - push_frontend_feature_flag(:prometheus_computed_alerts) - push_frontend_feature_flag(:disable_metric_dashboard_refresh_rate) - end feature_category :metrics urgency :low diff --git a/app/controllers/projects/ml/candidates_controller.rb b/app/controllers/projects/ml/candidates_controller.rb new file mode 100644 index 00000000000..b702edb858e --- /dev/null +++ b/app/controllers/projects/ml/candidates_controller.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Projects + module Ml + class CandidatesController < ApplicationController + before_action :check_feature_flag + + feature_category :mlops + + def show + @candidate = ::Ml::Candidate.with_project_id_and_iid(@project.id, params['iid']) + + render_404 unless @candidate.present? + end + + private + + def check_feature_flag + render_404 unless Feature.enabled?(:ml_experiment_tracking, @project) + end + end + end +end diff --git a/app/controllers/projects/ml/experiments_controller.rb b/app/controllers/projects/ml/experiments_controller.rb index 749586791ac..c82a959d612 100644 --- a/app/controllers/projects/ml/experiments_controller.rb +++ b/app/controllers/projects/ml/experiments_controller.rb @@ -3,7 +3,6 @@ module Projects module Ml class ExperimentsController < ::Projects::ApplicationController - include Projects::Ml::ExperimentsHelper before_action :check_feature_flag feature_category :mlops diff --git a/app/controllers/projects/network_controller.rb b/app/controllers/projects/network_controller.rb index 84ac9fb01fd..aa0838752e2 100644 --- a/app/controllers/projects/network_controller.rb +++ b/app/controllers/projects/network_controller.rb @@ -6,7 +6,7 @@ class Projects::NetworkController < Projects::ApplicationController before_action :require_non_empty_project before_action :assign_ref_vars - before_action :authorize_download_code! + before_action :authorize_read_code! before_action :assign_options before_action :assign_commit @@ -14,7 +14,13 @@ class Projects::NetworkController < Projects::ApplicationController urgency :low, [:show] def show - @url = project_network_path(@project, @ref, @options.merge(format: :json)) + @url = if Feature.enabled?(:use_ref_type_parameter, @project) + project_network_path(@project, @ref, @options.merge(format: :json, ref_type: ref_type)) + else + project_network_path(@project, @ref, @options.merge(format: :json)) + end + + @ref_type = ref_type @commit_url = project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s") respond_to do |format| diff --git a/app/controllers/projects/performance_monitoring/dashboards_controller.rb b/app/controllers/projects/performance_monitoring/dashboards_controller.rb index 8acbc17aef3..d043f8d0b9f 100644 --- a/app/controllers/projects/performance_monitoring/dashboards_controller.rb +++ b/app/controllers/projects/performance_monitoring/dashboards_controller.rb @@ -70,7 +70,7 @@ module Projects end def validate_required_params! - params.require(%i(branch file_name dashboard commit_message)) + params.require(%i[branch file_name dashboard commit_message]) end def redirect_safe_branch_name @@ -78,7 +78,7 @@ module Projects end def dashboard_params - params.permit(%i(branch file_name dashboard commit_message)).to_h + params.permit(%i[branch file_name dashboard commit_message]).to_h end def file_content_params diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index 7d1a75ae449..db77127cb0a 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -24,11 +24,6 @@ class Projects::PipelinesController < Projects::ApplicationController before_action :ensure_pipeline, only: [:show, :downloadable_artifacts] before_action :reject_if_build_artifacts_size_refreshing!, only: [:destroy] - before_action do - push_frontend_feature_flag(:pipeline_tabs_vue, @project) - push_frontend_feature_flag(:run_pipeline_graphql, @project) - end - # Will be removed with https://gitlab.com/gitlab-org/gitlab/-/issues/225596 before_action :redirect_for_legacy_scope_filter, only: [:index], if: -> { request.format.html? } diff --git a/app/controllers/projects/protected_branches_controller.rb b/app/controllers/projects/protected_branches_controller.rb index 8c70ef446a2..baa4607dcb6 100644 --- a/app/controllers/projects/protected_branches_controller.rb +++ b/app/controllers/projects/protected_branches_controller.rb @@ -1,6 +1,12 @@ # frozen_string_literal: true class Projects::ProtectedBranchesController < Projects::ProtectedRefsController + def show + super + + render 'protected_branches/show' + end + protected def project_refs diff --git a/app/controllers/projects/raw_controller.rb b/app/controllers/projects/raw_controller.rb index 9707b70f26f..924de0ee7ea 100644 --- a/app/controllers/projects/raw_controller.rb +++ b/app/controllers/projects/raw_controller.rb @@ -12,7 +12,7 @@ class Projects::RawController < Projects::ApplicationController before_action :set_ref_and_path before_action :require_non_empty_project - before_action :authorize_download_code! + before_action :authorize_read_code! before_action :check_show_rate_limit!, only: [:show], unless: :external_storage_request? before_action :redirect_to_external_storage, only: :show, if: :static_objects_external_storage_enabled? @@ -21,7 +21,7 @@ class Projects::RawController < Projects::ApplicationController def show @blob = @repository.blob_at(@ref, @path, limit: Gitlab::Git::Blob::LFS_POINTER_MAX_SIZE) - send_blob(@repository, @blob, inline: (params[:inline] != 'false'), allow_caching: Guest.can?(:download_code, @project)) + send_blob(@repository, @blob, inline: (params[:inline] != 'false'), allow_caching: Guest.can?(:read_code, @project)) end private diff --git a/app/controllers/projects/refs_controller.rb b/app/controllers/projects/refs_controller.rb index 72af3280a39..8ac6d872aae 100644 --- a/app/controllers/projects/refs_controller.rb +++ b/app/controllers/projects/refs_controller.rb @@ -9,7 +9,7 @@ class Projects::RefsController < Projects::ApplicationController before_action :require_non_empty_project before_action :validate_ref_id before_action :assign_ref_vars - before_action :authorize_download_code! + before_action :authorize_read_code! feature_category :source_code_management urgency :low, [:switch, :logs_tree] @@ -24,9 +24,17 @@ class Projects::RefsController < Projects::ApplicationController when "blob" project_blob_path(@project, @id) when "graph" - project_network_path(@project, @id, @options) + if Feature.enabled?(:use_ref_type_parameter, @project) + project_network_path(@project, @id, ref_type: ref_type) + else + project_network_path(@project, @id, @options) + end when "graphs" - project_graph_path(@project, @id) + if Feature.enabled?(:use_ref_type_parameter, @project) + project_graph_path(@project, @id, ref_type: ref_type) + else + project_graph_path(@project, @id) + end when "find_file" project_find_file_path(@project, @id) when "graphs_commits" @@ -34,7 +42,11 @@ class Projects::RefsController < Projects::ApplicationController when "badges" project_settings_ci_cd_path(@project, ref: @id) else - project_commits_path(@project, @id) + if Feature.enabled?(:use_ref_type_parameter, @project) + project_commits_path(@project, @id, ref_type: ref_type) + else + project_commits_path(@project, @id) + end end redirect_to new_path diff --git a/app/controllers/projects/registry/repositories_controller.rb b/app/controllers/projects/registry/repositories_controller.rb index ffe95bf4fee..6c663c4694a 100644 --- a/app/controllers/projects/registry/repositories_controller.rb +++ b/app/controllers/projects/registry/repositories_controller.rb @@ -23,10 +23,6 @@ module Projects def destroy image.delete_scheduled! - unless Feature.enabled?(:container_registry_delete_repository_with_cron_worker) - DeleteContainerRepositoryWorker.perform_async(current_user.id, image.id) # rubocop:disable CodeReuse/Worker - end - track_package_event(:delete_repository, :container) respond_to do |format| diff --git a/app/controllers/projects/runner_projects_controller.rb b/app/controllers/projects/runner_projects_controller.rb index 5946c43b134..6f896244acb 100644 --- a/app/controllers/projects/runner_projects_controller.rb +++ b/app/controllers/projects/runner_projects_controller.rb @@ -11,7 +11,7 @@ class Projects::RunnerProjectsController < Projects::ApplicationController def create @runner = Ci::Runner.find(params[:runner_project][:runner_id]) - return head(403) unless can?(current_user, :assign_runner, @runner) + return head(:forbidden) unless can?(current_user, :assign_runner, @runner) path = project_runners_path(project) diff --git a/app/controllers/projects/service_desk_controller.rb b/app/controllers/projects/service_desk_controller.rb index aa0e70121df..8f576b8d72b 100644 --- a/app/controllers/projects/service_desk_controller.rb +++ b/app/controllers/projects/service_desk_controller.rb @@ -29,7 +29,7 @@ class Projects::ServiceDeskController < Projects::ApplicationController end def allowed_update_attributes - %i(issue_template_key outgoing_name project_key) + %i[issue_template_key outgoing_name project_key] end def service_desk_attributes diff --git a/app/controllers/projects/service_ping_controller.rb b/app/controllers/projects/service_ping_controller.rb index 43c249afd8e..cfc322b47e7 100644 --- a/app/controllers/projects/service_ping_controller.rb +++ b/app/controllers/projects/service_ping_controller.rb @@ -10,7 +10,7 @@ class Projects::ServicePingController < Projects::ApplicationController Gitlab::UsageDataCounters::WebIdeCounter.increment_previews_count - head(200) + head(:ok) end def web_ide_clientside_preview_success @@ -20,12 +20,12 @@ class Projects::ServicePingController < Projects::ApplicationController Gitlab::UsageDataCounters::EditorUniqueCounter.track_live_preview_edit_action(author: current_user, project: project) - head(200) + head(:ok) end def web_ide_pipelines_count Gitlab::UsageDataCounters::WebIdeCounter.increment_pipelines_count - head(200) + head(:ok) end end diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb index 8aef1c3d24d..cf07de4dc29 100644 --- a/app/controllers/projects/settings/ci_cd_controller.rb +++ b/app/controllers/projects/settings/ci_cd_controller.rb @@ -18,6 +18,9 @@ module Projects urgency :low def show + @entity = :project + @variable_limit = ::Plan.default.actual_limits.project_ci_variables + if Feature.enabled?(:ci_pipeline_triggers_settings_vue_ui, @project) triggers = ::Ci::TriggerSerializer.new.represent( @project.triggers, current_user: current_user, project: @project @@ -122,11 +125,13 @@ module Projects .page(params[:specific_page]).per(NUMBER_OF_RUNNERS_PER_PAGE) .with_tags - @shared_runners = ::Ci::Runner.instance_type.active.with_tags - - @shared_runners_count = @shared_runners.count(:all) + active_shared_runners = ::Ci::Runner.instance_type.active + @shared_runners_count = active_shared_runners.count + @shared_runners = active_shared_runners.page(params[:shared_runners_page]).per(NUMBER_OF_RUNNERS_PER_PAGE).with_tags - @group_runners = ::Ci::Runner.belonging_to_parent_group_of_project(@project.id).with_tags + parent_group_runners = ::Ci::Runner.belonging_to_parent_group_of_project(@project.id) + @group_runners_count = parent_group_runners.count + @group_runners = parent_group_runners.page(params[:group_runners_page]).per(NUMBER_OF_RUNNERS_PER_PAGE).with_tags end def define_ci_variables diff --git a/app/controllers/projects/settings/integrations_controller.rb b/app/controllers/projects/settings/integrations_controller.rb index 2bbcd9fe20c..16c1373df2b 100644 --- a/app/controllers/projects/settings/integrations_controller.rb +++ b/app/controllers/projects/settings/integrations_controller.rb @@ -79,7 +79,7 @@ module Projects return { error: true, message: _('Validations failed.'), - service_response: integration.errors.full_messages.join(','), + service_response: integration.errors.full_messages.join(', '), test_failed: false } end @@ -90,7 +90,7 @@ module Projects return { error: true, message: s_('Integrations|Connection failed. Check your integration settings.'), - service_response: result[:message].to_s, + service_response: result[:result].to_s, test_failed: true } end diff --git a/app/controllers/projects/settings/repository_controller.rb b/app/controllers/projects/settings/repository_controller.rb index 90988645d3a..6d099aa8b3d 100644 --- a/app/controllers/projects/settings/repository_controller.rb +++ b/app/controllers/projects/settings/repository_controller.rb @@ -95,6 +95,14 @@ module Projects @protected_tags_count = @protected_tags.reduce(0) { |sum, tag| sum + tag.matching(@project.repository.tag_names).size } + if Feature.enabled?(:group_protected_branches) + @protected_group_branches = if @project.root_namespace.is_a?(Group) + @project.root_namespace.protected_branches.order(:name).page(params[:page]) + else + [] + end + end + load_gon_index end # rubocop: enable CodeReuse/ActiveRecord diff --git a/app/controllers/projects/snippets/application_controller.rb b/app/controllers/projects/snippets/application_controller.rb index 8ee12bf3795..b8faf464531 100644 --- a/app/controllers/projects/snippets/application_controller.rb +++ b/app/controllers/projects/snippets/application_controller.rb @@ -4,7 +4,7 @@ class Projects::Snippets::ApplicationController < Projects::ApplicationControlle include FindSnippet include SnippetAuthorizations - feature_category :snippets + feature_category :source_code_management private diff --git a/app/controllers/projects/tags_controller.rb b/app/controllers/projects/tags_controller.rb index 847b1baca10..3c1735c728c 100644 --- a/app/controllers/projects/tags_controller.rb +++ b/app/controllers/projects/tags_controller.rb @@ -7,7 +7,7 @@ class Projects::TagsController < Projects::ApplicationController # Authorize before_action :require_non_empty_project - before_action :authorize_download_code! + before_action :authorize_read_code! before_action :authorize_admin_tag!, only: [:new, :create, :destroy] feature_category :source_code_management diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb index fea2689db14..737a6290431 100644 --- a/app/controllers/projects/tree_controller.rb +++ b/app/controllers/projects/tree_controller.rb @@ -13,11 +13,10 @@ class Projects::TreeController < Projects::ApplicationController before_action :require_non_empty_project, except: [:new, :create] before_action :assign_ref_vars before_action :assign_dir_vars, only: [:create_dir] - before_action :authorize_download_code! + before_action :authorize_read_code! before_action :authorize_edit_tree!, only: [:create_dir] before_action do - push_frontend_feature_flag(:lazy_load_commits, @project) push_frontend_feature_flag(:highlight_js, @project) push_frontend_feature_flag(:file_line_blame, @project) push_licensed_feature(:file_locks) if @project.licensed_feature_available?(:file_locks) diff --git a/app/controllers/projects/variables_controller.rb b/app/controllers/projects/variables_controller.rb index a8f062bd7c1..a83ccccbeae 100644 --- a/app/controllers/projects/variables_controller.rb +++ b/app/controllers/projects/variables_controller.rb @@ -47,6 +47,6 @@ class Projects::VariablesController < Projects::ApplicationController end def variable_params_attributes - %i[id variable_type key secret_value protected masked environment_scope _destroy] + %i[id variable_type key secret_value protected masked raw environment_scope _destroy] end end diff --git a/app/controllers/projects/work_items_controller.rb b/app/controllers/projects/work_items_controller.rb index a7e59a28fb7..a118c6986f7 100644 --- a/app/controllers/projects/work_items_controller.rb +++ b/app/controllers/projects/work_items_controller.rb @@ -3,6 +3,7 @@ class Projects::WorkItemsController < Projects::ApplicationController before_action do push_force_frontend_feature_flag(:work_items, project&.work_items_feature_flag_enabled?) + push_force_frontend_feature_flag(:work_items_mvc, project&.work_items_mvc_feature_flag_enabled?) push_force_frontend_feature_flag(:work_items_mvc_2, project&.work_items_mvc_2_feature_flag_enabled?) push_frontend_feature_flag(:use_iid_in_work_items_path, project) end @@ -10,3 +11,5 @@ class Projects::WorkItemsController < Projects::ApplicationController feature_category :team_planning urgency :low end + +Projects::WorkItemsController.prepend_mod |