diff options
Diffstat (limited to 'app/controllers/projects')
23 files changed, 115 insertions, 71 deletions
diff --git a/app/controllers/projects/analytics/cycle_analytics/summary_controller.rb b/app/controllers/projects/analytics/cycle_analytics/summary_controller.rb index c51a5ac7b88..bf8742bf6e8 100644 --- a/app/controllers/projects/analytics/cycle_analytics/summary_controller.rb +++ b/app/controllers/projects/analytics/cycle_analytics/summary_controller.rb @@ -20,7 +20,7 @@ class Projects::Analytics::CycleAnalytics::SummaryController < Projects::Applica end def allowed_params - params.permit(:created_after, :created_before) + request_params.to_data_collector_params end end diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb index cf2ecb0673e..7a03e7b84b7 100644 --- a/app/controllers/projects/application_controller.rb +++ b/app/controllers/projects/application_controller.rb @@ -26,7 +26,7 @@ class Projects::ApplicationController < ApplicationController path = File.join(params[:namespace_id], params[:project_id] || params[:id]) auth_proc = ->(project) { !project.pending_delete? } - @project = find_routable!(Project, path, request.path_info, extra_authorization_proc: auth_proc) + @project = find_routable!(Project, path, request.fullpath, extra_authorization_proc: auth_proc) end def build_canonical_path(project) diff --git a/app/controllers/projects/boards_controller.rb b/app/controllers/projects/boards_controller.rb index 035b76abfd6..316582f3994 100644 --- a/app/controllers/projects/boards_controller.rb +++ b/app/controllers/projects/boards_controller.rb @@ -8,7 +8,6 @@ class Projects::BoardsController < Projects::ApplicationController before_action :assign_endpoint_vars before_action do push_frontend_feature_flag(:swimlanes_buffered_rendering, project, default_enabled: :yaml) - push_frontend_feature_flag(:graphql_board_lists, project, default_enabled: :yaml) push_frontend_feature_flag(:issue_boards_filtered_search, project, default_enabled: :yaml) push_frontend_feature_flag(:board_multi_select, project, default_enabled: :yaml) push_frontend_feature_flag(:iteration_cadences, project&.group, default_enabled: :yaml) diff --git a/app/controllers/projects/ci/pipeline_editor_controller.rb b/app/controllers/projects/ci/pipeline_editor_controller.rb index ed1d5ca9594..550877548e1 100644 --- a/app/controllers/projects/ci/pipeline_editor_controller.rb +++ b/app/controllers/projects/ci/pipeline_editor_controller.rb @@ -4,7 +4,6 @@ class Projects::Ci::PipelineEditorController < Projects::ApplicationController before_action :check_can_collaborate! before_action do 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) push_frontend_feature_flag(:pipeline_editor_drawer, @project, default_enabled: :yaml) push_frontend_feature_flag(:schema_linting, @project, default_enabled: :yaml) end diff --git a/app/controllers/projects/clusters/integrations_controller.rb b/app/controllers/projects/clusters/integrations_controller.rb index eed6c1dccc4..77314d19469 100644 --- a/app/controllers/projects/clusters/integrations_controller.rb +++ b/app/controllers/projects/clusters/integrations_controller.rb @@ -10,6 +10,6 @@ class Projects::Clusters::IntegrationsController < ::Clusters::IntegrationsContr end def project - @project ||= find_routable!(Project, File.join(params[:namespace_id], params[:project_id]), request.path_info) + @project ||= find_routable!(Project, File.join(params[:namespace_id], params[:project_id]), request.fullpath) end end diff --git a/app/controllers/projects/clusters_controller.rb b/app/controllers/projects/clusters_controller.rb index 0aef497d28d..8f45fa1cb9f 100644 --- a/app/controllers/projects/clusters_controller.rb +++ b/app/controllers/projects/clusters_controller.rb @@ -17,7 +17,7 @@ class Projects::ClustersController < Clusters::ClustersController end def project - @project ||= find_routable!(Project, File.join(params[:namespace_id], params[:project_id]), request.path_info) + @project ||= find_routable!(Project, File.join(params[:namespace_id], params[:project_id]), request.fullpath) end def repository diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index cac0aa9d513..23dabd885c8 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -213,8 +213,14 @@ class Projects::EnvironmentsController < Projects::ApplicationController end end + def allowed_environment_attributes + attributes = [:external_url] + attributes << :name if action_name == "create" + attributes + end + def environment_params - params.require(:environment).permit(:name, :external_url) + params.require(:environment).permit(allowed_environment_attributes) end def environment diff --git a/app/controllers/projects/feature_flags_controller.rb b/app/controllers/projects/feature_flags_controller.rb index b99c233411a..7c0da8f8a24 100644 --- a/app/controllers/projects/feature_flags_controller.rb +++ b/app/controllers/projects/feature_flags_controller.rb @@ -10,9 +10,6 @@ class Projects::FeatureFlagsController < Projects::ApplicationController before_action :feature_flag, only: [:edit, :update, :destroy] - before_action :ensure_flag_writable!, only: [:update] - before_action :exclude_legacy_flags_check, only: [:edit] - feature_category :feature_flags def index @@ -98,18 +95,6 @@ class Projects::FeatureFlagsController < Projects::ApplicationController @feature_flag ||= @noteable = project.operations_feature_flags.find_by_iid!(params[:iid]) end - def ensure_flag_writable! - if feature_flag.legacy_flag? - render_error_json(['Legacy feature flags are read-only']) - end - end - - def exclude_legacy_flags_check - if feature_flag.legacy_flag? - not_found - end - end - def create_params params.require(:operations_feature_flag) .permit(:name, :description, :active, :version, diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index bdfaaf2b143..f885ff9b45b 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -42,9 +42,8 @@ class Projects::IssuesController < Projects::ApplicationController before_action do push_frontend_feature_flag(:tribute_autocomplete, @project) 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) + push_frontend_feature_flag(:vue_issues_list, project&.group, default_enabled: :yaml) push_frontend_feature_flag(:iteration_cadences, project&.group, default_enabled: :yaml) end @@ -118,7 +117,11 @@ class Projects::IssuesController < Projects::ApplicationController @issue = @noteable = service.execute @merge_request_to_resolve_discussions_of = service.merge_request_to_resolve_discussions_of - @discussion_to_resolve = service.discussions_to_resolve.first if params[:discussion_to_resolve] + + if params[:discussion_to_resolve] + Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter.track_resolve_thread_in_issue_action(user: current_user) + @discussion_to_resolve = service.discussions_to_resolve.first + end respond_with(@issue) end @@ -228,7 +231,7 @@ class Projects::IssuesController < Projects::ApplicationController IssuableExportCsvWorker.perform_async(:issue, current_user.id, project.id, finder_options.to_h) # rubocop:disable CodeReuse/Worker index_path = project_issues_path(project) - message = _('Your CSV export has started. It will be emailed to %{email} when complete.') % { email: current_user.notification_email } + message = _('Your CSV export has started. It will be emailed to %{email} when complete.') % { email: current_user.notification_email_or_default } redirect_to(index_path, notice: message) end diff --git a/app/controllers/projects/learn_gitlab_controller.rb b/app/controllers/projects/learn_gitlab_controller.rb index 162ba9bd5cb..91a43c5f03f 100644 --- a/app/controllers/projects/learn_gitlab_controller.rb +++ b/app/controllers/projects/learn_gitlab_controller.rb @@ -7,13 +7,11 @@ class Projects::LearnGitlabController < Projects::ApplicationController feature_category :users def index - push_frontend_experiment(:learn_gitlab_a, subject: current_user) - push_frontend_experiment(:learn_gitlab_b, subject: current_user) end private def check_experiment_enabled? - return access_denied! unless helpers.learn_gitlab_experiment_enabled?(project) + return access_denied! unless helpers.learn_gitlab_enabled?(project) end end diff --git a/app/controllers/projects/merge_requests/diffs_controller.rb b/app/controllers/projects/merge_requests/diffs_controller.rb index 8ccc658dfe7..1188aec24a8 100644 --- a/app/controllers/projects/merge_requests/diffs_controller.rb +++ b/app/controllers/projects/merge_requests/diffs_controller.rb @@ -42,7 +42,7 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic allow_tree_conflicts: display_merge_conflicts_in_diff? } - if diff_options_hash[:paths].blank? && Feature.enabled?(:diffs_batch_render_cached, project, default_enabled: :yaml) + if diff_options_hash[:paths].blank? # NOTE: Any variables that would affect the resulting json needs to be added to the cache_context to avoid stale cache issues. cache_context = [ current_user&.cache_key, diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 8b3f2df69df..cb68aaf4583 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -13,6 +13,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo include DiffHelper include Gitlab::Cache::Helpers + 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 :disable_query_limiting, only: [:assign_related_issues, :update] @@ -34,12 +35,12 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo push_frontend_feature_flag(:merge_request_widget_graphql, @project, default_enabled: :yaml) 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(:local_file_reviews, default_enabled: :yaml) push_frontend_feature_flag(:paginated_notes, @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) push_frontend_feature_flag(:diffs_virtual_scrolling, project, default_enabled: :yaml) + push_frontend_feature_flag(:restructured_mr_widget, project, default_enabled: :yaml) # Usage data feature flags push_frontend_feature_flag(:users_expanding_widgets_usage_data, @project, default_enabled: :yaml) @@ -85,6 +86,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo respond_to do |format| format.html + format.atom { render layout: 'xml.atom' } format.json do render json: { html: view_to_html_string("projects/merge_requests/_merge_requests") @@ -124,13 +126,17 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo set_pipeline_variables + ::Gitlab::Database.allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/336891') do + @number_of_pipelines = @pipelines.size + end + render end format.json do Gitlab::PollingInterval.set_header(response, interval: 10_000) - if params[:serializer] == 'sidebar_extras' && Feature.enabled?(:merge_request_show_render_cached, @project, default_enabled: :yaml) + if params[:serializer] == 'sidebar_extras' cache_context = [ params[:serializer], current_user&.cache_key, @@ -173,7 +179,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo # or from cache if already merged @commits = set_commits_for_rendering( - @merge_request.recent_commits.with_latest_pipeline(@merge_request.source_branch).with_markdown_cache, + @merge_request.recent_commits(load_from_gitaly: true).with_latest_pipeline(@merge_request.source_branch).with_markdown_cache, commits_count: @merge_request.commits_count ) @@ -372,7 +378,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo IssuableExportCsvWorker.perform_async(:merge_request, current_user.id, project.id, finder_options.to_h) # rubocop:disable CodeReuse/Worker index_path = project_merge_requests_path(project) - message = _('Your CSV export has started. It will be emailed to %{email} when complete.') % { email: current_user.notification_email } + message = _('Your CSV export has started. It will be emailed to %{email} when complete.') % { email: current_user.notification_email_or_default } redirect_to(index_path, notice: message) end diff --git a/app/controllers/projects/packages/packages_controller.rb b/app/controllers/projects/packages/packages_controller.rb index 15dc11f5df8..5de71466c10 100644 --- a/app/controllers/projects/packages/packages_controller.rb +++ b/app/controllers/projects/packages/packages_controller.rb @@ -9,8 +9,6 @@ module Projects def show @package = project.packages.find(params[:id]) - @package_files = @package.package_files.recent - @maven_metadatum = @package.maven_metadatum end end end diff --git a/app/controllers/projects/pipeline_schedules_controller.rb b/app/controllers/projects/pipeline_schedules_controller.rb index 006cb8a2201..4af7508b935 100644 --- a/app/controllers/projects/pipeline_schedules_controller.rb +++ b/app/controllers/projects/pipeline_schedules_controller.rb @@ -10,10 +10,6 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController before_action :authorize_update_pipeline_schedule!, except: [:index, :new, :create, :play] before_action :authorize_admin_pipeline_schedule!, only: [:destroy] - before_action do - push_frontend_feature_flag(:ci_daily_limit_for_pipeline_schedules, @project, default_enabled: :yaml) - end - feature_category :continuous_integration # rubocop: disable CodeReuse/ActiveRecord diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index a411264b350..a2312484a9b 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -14,10 +14,6 @@ class Projects::PipelinesController < Projects::ApplicationController before_action :authorize_update_pipeline!, only: [:retry, :cancel] before_action :ensure_pipeline, only: [:show, :downloadable_artifacts] - before_action do - push_frontend_feature_flag(:pipeline_source_filter, project, type: :development, default_enabled: :yaml) - 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? } @@ -195,7 +191,8 @@ class Projects::PipelinesController < Projects::ApplicationController def config_variables respond_to do |format| format.json do - result = Ci::ListConfigVariablesService.new(@project, current_user).execute(params[:sha]) + project = @project.uses_external_project_ci_config? ? @project.ci_config_external_project : @project + result = Ci::ListConfigVariablesService.new(project, current_user).execute(params[:sha]) result.nil? ? head(:no_content) : render(json: result) end @@ -297,7 +294,7 @@ class Projects::PipelinesController < Projects::ApplicationController end def index_params - params.permit(:scope, :username, :ref, :status) + params.permit(:scope, :username, :ref, :status, :source) end def enable_code_quality_walkthrough_experiment diff --git a/app/controllers/projects/runner_projects_controller.rb b/app/controllers/projects/runner_projects_controller.rb index 5da81045e02..39db7618db0 100644 --- a/app/controllers/projects/runner_projects_controller.rb +++ b/app/controllers/projects/runner_projects_controller.rb @@ -15,7 +15,7 @@ class Projects::RunnerProjectsController < Projects::ApplicationController path = project_runners_path(project) if @runner.assign_to(project, current_user) - redirect_to path + redirect_to path, notice: s_('Runners|Runner assigned to project.') else assign_to_messages = @runner.errors.messages[:assign_to] alert = assign_to_messages&.join(',') || 'Failed adding runner to project' @@ -28,6 +28,6 @@ class Projects::RunnerProjectsController < Projects::ApplicationController runner_project = project.runner_projects.find(params[:id]) runner_project.destroy - redirect_to project_runners_path(project), status: :found + redirect_to project_runners_path(project), status: :found, notice: s_('Runners|Runner unassigned from project.') end end diff --git a/app/controllers/projects/service_desk_controller.rb b/app/controllers/projects/service_desk_controller.rb index f7c0a54fb9e..1fb07c3a903 100644 --- a/app/controllers/projects/service_desk_controller.rb +++ b/app/controllers/projects/service_desk_controller.rb @@ -24,24 +24,31 @@ class Projects::ServiceDeskController < Projects::ApplicationController private def setting_params - params.permit(:issue_template_key, :outgoing_name, :project_key) + params.permit(*allowed_update_attributes) + end + + def allowed_update_attributes + %i(issue_template_key outgoing_name project_key) + end + + def service_desk_attributes + service_desk_settings = project.service_desk_setting + + { + service_desk_address: project.service_desk_address, + service_desk_enabled: project.service_desk_enabled, + issue_template_key: service_desk_settings&.issue_template_key, + template_file_missing: service_desk_settings&.issue_template_missing?, + outgoing_name: service_desk_settings&.outgoing_name, + project_key: service_desk_settings&.project_key + } end def json_response respond_to do |format| - service_desk_settings = project.service_desk_setting - - service_desk_attributes = - { - service_desk_address: project.service_desk_address, - service_desk_enabled: project.service_desk_enabled, - issue_template_key: service_desk_settings&.issue_template_key, - template_file_missing: service_desk_settings&.issue_template_missing?, - outgoing_name: service_desk_settings&.outgoing_name, - project_key: service_desk_settings&.project_key - } - format.json { render json: service_desk_attributes } end end end + +Projects::ServiceDeskController.prepend_mod diff --git a/app/controllers/projects/services_controller.rb b/app/controllers/projects/services_controller.rb index 0dcaab7160b..c42d382c4bb 100644 --- a/app/controllers/projects/services_controller.rb +++ b/app/controllers/projects/services_controller.rb @@ -26,15 +26,15 @@ class Projects::ServicesController < Projects::ApplicationController attributes = integration_params[:integration] if use_inherited_settings?(attributes) - @integration.inherit_from_id = default_integration.id + integration.inherit_from_id = default_integration.id - if saved = @integration.save(context: :manual_change) - BulkUpdateIntegrationService.new(default_integration, [@integration]).execute + if saved = integration.save(context: :manual_change) + BulkUpdateIntegrationService.new(default_integration, [integration]).execute end else attributes[:inherit_from_id] = nil - @integration.attributes = attributes - saved = @integration.save(context: :manual_change) + integration.attributes = attributes + saved = integration.save(context: :manual_change) end respond_to do |format| @@ -65,15 +65,15 @@ class Projects::ServicesController < Projects::ApplicationController private def redirect_path - safe_redirect_path(params[:redirect_to]).presence || edit_project_service_path(@project, @integration) + safe_redirect_path(params[:redirect_to]).presence || edit_project_service_path(project, integration) end def service_test_response - unless @integration.update(integration_params[:integration]) - return { error: true, message: _('Validations failed.'), service_response: @integration.errors.full_messages.join(','), test_failed: false } + unless integration.update(integration_params[:integration]) + return { error: true, message: _('Validations failed.'), service_response: integration.errors.full_messages.join(','), test_failed: false } end - result = ::Integrations::Test::ProjectService.new(@integration, current_user, params[:event]).execute + result = ::Integrations::Test::ProjectService.new(integration, current_user, params[:event]).execute unless result[:success] return { error: true, message: s_('Integrations|Connection failed. Please check your settings.'), service_response: result[:message].to_s, test_failed: true } @@ -93,7 +93,7 @@ class Projects::ServicesController < Projects::ApplicationController end def integration - @integration ||= @project.find_or_initialize_integration(params[:id]) + @integration ||= project.find_or_initialize_integration(params[:id]) end alias_method :service, :integration diff --git a/app/controllers/projects/settings/operations_controller.rb b/app/controllers/projects/settings/operations_controller.rb index e32815b6239..56e201c592f 100644 --- a/app/controllers/projects/settings/operations_controller.rb +++ b/app/controllers/projects/settings/operations_controller.rb @@ -136,6 +136,7 @@ module Projects error_tracking_setting_attributes: [ :enabled, + :integrated, :api_host, :token, project: [:slug, :name, :organization_slug, :organization_name] diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb index 475c9de2503..6fd4c632dd3 100644 --- a/app/controllers/projects/tree_controller.rb +++ b/app/controllers/projects/tree_controller.rb @@ -15,6 +15,10 @@ class Projects::TreeController < Projects::ApplicationController before_action :authorize_download_code! before_action :authorize_edit_tree!, only: [:create_dir] + before_action do + push_frontend_feature_flag(:paginated_tree_graphql_query, @project, default_enabled: :yaml) + end + feature_category :source_code_management def show diff --git a/app/controllers/projects/usage_quotas_controller.rb b/app/controllers/projects/usage_quotas_controller.rb new file mode 100644 index 00000000000..179c7fc8db1 --- /dev/null +++ b/app/controllers/projects/usage_quotas_controller.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +class Projects::UsageQuotasController < Projects::ApplicationController + before_action :authorize_admin_project! + before_action :verify_usage_quotas_enabled! + + layout "project_settings" + + feature_category :utilization + + def index + @storage_app_data = { + project_path: @project.full_path, + usage_quotas_help_page_path: help_page_path('user/usage_quotas'), + build_artifacts_help_page_path: help_page_path('ci/pipelines/job_artifacts', anchor: 'when-job-artifacts-are-deleted'), + packages_help_page_path: help_page_path('user/packages/package_registry/index.md', anchor: 'delete-a-package'), + repository_help_page_path: help_page_path('user/project/repository/reducing_the_repo_size_using_git'), + snippets_help_page_path: help_page_path('user/snippets', anchor: 'reduce-snippets-repository-size'), + wiki_help_page_path: help_page_path('administration/wikis/index.md', anchor: 'reduce-wiki-repository-size') + } + end + + private + + def verify_usage_quotas_enabled! + render_404 unless Feature.enabled?(:project_storage_ui, project&.group, default_enabled: :yaml) + end +end diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb index d1486f765e4..9ee8847004e 100644 --- a/app/controllers/projects/wikis_controller.rb +++ b/app/controllers/projects/wikis_controller.rb @@ -5,5 +5,9 @@ class Projects::WikisController < Projects::ApplicationController alias_method :container, :project + before_action do + push_frontend_feature_flag(:content_editor_block_tables, @project, default_enabled: :yaml) + end + feature_category :wiki end diff --git a/app/controllers/projects/work_items_controller.rb b/app/controllers/projects/work_items_controller.rb new file mode 100644 index 00000000000..1bd2762f277 --- /dev/null +++ b/app/controllers/projects/work_items_controller.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +class Projects::WorkItemsController < Projects::ApplicationController + before_action do + push_frontend_feature_flag(:work_items, project, default_enabled: :yaml) + end + + feature_category :not_owned + + def index + render_404 unless Feature.enabled?(:work_items, project, default_enabled: :yaml) + end +end |