diff options
Diffstat (limited to 'app/controllers')
71 files changed, 247 insertions, 216 deletions
diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb index 7960e5d64d0..8039fac02ec 100644 --- a/app/controllers/admin/application_settings_controller.rb +++ b/app/controllers/admin/application_settings_controller.rb @@ -2,7 +2,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController include InternalRedirect - include ServicesHelper + include IntegrationsHelper # NOTE: Use @application_setting in this controller when you need to access # application_settings after it has been modified. This is because the @@ -27,7 +27,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController feature_category :source_code_management, [:repository, :clear_repository_check_states] feature_category :continuous_integration, [:ci_cd, :reset_registration_token] - feature_category :usage_ping, [:usage_data] + feature_category :service_ping, [:usage_data] feature_category :integrations, [:integrations] feature_category :pages, [:lets_encrypt_terms_of_service] @@ -207,6 +207,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController end params[:application_setting][:import_sources]&.delete("") + params[:application_setting][:valid_runner_registrars]&.delete("") params[:application_setting][:restricted_visibility_levels]&.delete("") if params[:application_setting].key?(:required_instance_ci_template) @@ -245,7 +246,8 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController disabled_oauth_sign_in_sources: [], import_sources: [], restricted_visibility_levels: [], - repository_storages_weighted: {} + repository_storages_weighted: {}, + valid_runner_registrars: [] ] end diff --git a/app/controllers/admin/background_migrations_controller.rb b/app/controllers/admin/background_migrations_controller.rb index c1dffbf423d..65b47308e4c 100644 --- a/app/controllers/admin/background_migrations_controller.rb +++ b/app/controllers/admin/background_migrations_controller.rb @@ -15,6 +15,20 @@ class Admin::BackgroundMigrationsController < Admin::ApplicationController @successful_rows_counts = batched_migration_class.successful_rows_counts(@migrations.map(&:id)) end + def pause + migration = batched_migration_class.find(params[:id]) + migration.paused! + + redirect_back fallback_location: { action: 'index' } + end + + def resume + migration = batched_migration_class.find(params[:id]) + migration.active! + + redirect_back fallback_location: { action: 'index' } + end + private def batched_migration_class diff --git a/app/controllers/admin/ci/variables_controller.rb b/app/controllers/admin/ci/variables_controller.rb index f30ee37fa58..d4b7d750759 100644 --- a/app/controllers/admin/ci/variables_controller.rb +++ b/app/controllers/admin/ci/variables_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Admin::Ci::VariablesController < Admin::ApplicationController - feature_category :continuous_integration + feature_category :pipeline_authoring def show respond_to do |format| diff --git a/app/controllers/admin/cohorts_controller.rb b/app/controllers/admin/cohorts_controller.rb index 8163f062b62..e750b5c5ad4 100644 --- a/app/controllers/admin/cohorts_controller.rb +++ b/app/controllers/admin/cohorts_controller.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Admin::CohortsController < Admin::ApplicationController - include Analytics::UniqueVisitsHelper + include RedisTracking feature_category :devops_reports @@ -21,8 +21,6 @@ class Admin::CohortsController < Admin::ApplicationController end def track_cohorts_visit - if request.format.html? && request.headers['DNT'] != '1' - track_visit('i_analytics_cohorts') - end + track_unique_redis_hll_event('i_analytics_cohorts') if trackable_html_request? end end diff --git a/app/controllers/admin/integrations_controller.rb b/app/controllers/admin/integrations_controller.rb index 316e6d9aa74..76c1c46e0e8 100644 --- a/app/controllers/admin/integrations_controller.rb +++ b/app/controllers/admin/integrations_controller.rb @@ -2,7 +2,7 @@ class Admin::IntegrationsController < Admin::ApplicationController include IntegrationsActions - include ServicesHelper + include IntegrationsHelper before_action :not_found, unless: -> { instance_level_integrations? } diff --git a/app/controllers/admin/runners_controller.rb b/app/controllers/admin/runners_controller.rb index bf9cfa3acff..d1c91d9617f 100644 --- a/app/controllers/admin/runners_controller.rb +++ b/app/controllers/admin/runners_controller.rb @@ -8,7 +8,7 @@ class Admin::RunnersController < Admin::ApplicationController push_frontend_feature_flag(:runner_list_view_vue_ui, current_user, default_enabled: :yaml) end - feature_category :continuous_integration + feature_category :runner NUMBER_OF_RUNNERS_PER_PAGE = 30 diff --git a/app/controllers/admin/usage_trends_controller.rb b/app/controllers/admin/usage_trends_controller.rb index 7073f71a1a8..0b315517594 100644 --- a/app/controllers/admin/usage_trends_controller.rb +++ b/app/controllers/admin/usage_trends_controller.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true class Admin::UsageTrendsController < Admin::ApplicationController - include Analytics::UniqueVisitsHelper + include RedisTracking - track_unique_visits :index, target_id: 'i_analytics_instance_statistics' + track_redis_hll_event :index, name: 'i_analytics_instance_statistics' feature_category :devops_reports diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 07ecde1181f..34bad74a9fc 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -106,10 +106,6 @@ class ApplicationController < ActionController::Base redirect_back(fallback_location: default, **options) end - def check_if_gl_com_or_dev - render_404 unless ::Gitlab.dev_env_or_com? - end - def not_found render_404 end diff --git a/app/controllers/boards/issues_controller.rb b/app/controllers/boards/issues_controller.rb index 003ed45adb5..f0f074792ed 100644 --- a/app/controllers/boards/issues_controller.rb +++ b/app/controllers/boards/issues_controller.rb @@ -136,7 +136,7 @@ module Boards def issue_params params.require(:issue) .permit(:title, :milestone_id, :project_id) - .merge(board_id: params[:board_id], list_id: params[:list_id], request: request) + .merge(board_id: params[:board_id], list_id: params[:list_id]) end def serializer diff --git a/app/controllers/chaos_controller.rb b/app/controllers/chaos_controller.rb index 1cfcd2905f2..4e5af1945a4 100644 --- a/app/controllers/chaos_controller.rb +++ b/app/controllers/chaos_controller.rb @@ -31,7 +31,7 @@ class ChaosController < ActionController::Base gc_stat = Gitlab::Chaos.run_gc render json: { - worker_id: Prometheus::PidProvider.worker_id, + worker_id: ::Prometheus::PidProvider.worker_id, gc_stat: gc_stat } end diff --git a/app/controllers/concerns/authenticates_with_two_factor.rb b/app/controllers/concerns/authenticates_with_two_factor.rb index 4f4b204def8..da5b7ccfbf0 100644 --- a/app/controllers/concerns/authenticates_with_two_factor.rb +++ b/app/controllers/concerns/authenticates_with_two_factor.rb @@ -151,14 +151,14 @@ module AuthenticatesWithTwoFactor def handle_two_factor_failure(user, method, message) user.increment_failed_attempts! - log_failed_two_factor(user, method, request.remote_ip) + log_failed_two_factor(user, method) Gitlab::AppLogger.info("Failed Login: user=#{user.username} ip=#{request.remote_ip} method=#{method}") flash.now[:alert] = message prompt_for_two_factor(user) end - def log_failed_two_factor(user, method, ip_address) + def log_failed_two_factor(user, method) # overridden in EE end diff --git a/app/controllers/concerns/authenticates_with_two_factor_for_admin_mode.rb b/app/controllers/concerns/authenticates_with_two_factor_for_admin_mode.rb index a8155f1e639..574fc6c0f37 100644 --- a/app/controllers/concerns/authenticates_with_two_factor_for_admin_mode.rb +++ b/app/controllers/concerns/authenticates_with_two_factor_for_admin_mode.rb @@ -98,7 +98,7 @@ module AuthenticatesWithTwoFactorForAdminMode def admin_handle_two_factor_failure(user, method, message) user.increment_failed_attempts! - log_failed_two_factor(user, method, request.remote_ip) + log_failed_two_factor(user, method) Gitlab::AppLogger.info("Failed Admin Mode Login: user=#{user.username} ip=#{request.remote_ip} method=#{method}") flash.now[:alert] = message diff --git a/app/controllers/concerns/issuable_actions.rb b/app/controllers/concerns/issuable_actions.rb index 929e60a9e77..2664a7b7151 100644 --- a/app/controllers/concerns/issuable_actions.rb +++ b/app/controllers/concerns/issuable_actions.rb @@ -3,6 +3,7 @@ module IssuableActions extend ActiveSupport::Concern include Gitlab::Utils::StrongMemoize + include Gitlab::Cache::Helpers included do before_action :authorize_destroy_issuable!, only: :destroy @@ -129,7 +130,11 @@ module IssuableActions discussions = Discussion.build_collection(notes, issuable) - render json: discussion_serializer.represent(discussions, context: self) + if issuable.is_a?(MergeRequest) && Feature.enabled?(:merge_request_discussion_cache, issuable.target_project, default_enabled: :yaml) + render_cached(discussions, with: discussion_serializer, context: self) + else + render json: discussion_serializer.represent(discussions, context: self) + end end # rubocop:enable CodeReuse/ActiveRecord diff --git a/app/controllers/concerns/metrics/dashboard/prometheus_api_proxy.rb b/app/controllers/concerns/metrics/dashboard/prometheus_api_proxy.rb index e0e3f628cc5..65237b552ca 100644 --- a/app/controllers/concerns/metrics/dashboard/prometheus_api_proxy.rb +++ b/app/controllers/concerns/metrics/dashboard/prometheus_api_proxy.rb @@ -16,7 +16,7 @@ module Metrics::Dashboard::PrometheusApiProxy return error_response(variable_substitution_result) end - prometheus_result = Prometheus::ProxyService.new( + prometheus_result = ::Prometheus::ProxyService.new( proxyable, proxy_method, proxy_path, diff --git a/app/controllers/concerns/redis_tracking.rb b/app/controllers/concerns/redis_tracking.rb index 3155208f47c..c1135d2f759 100644 --- a/app/controllers/concerns/redis_tracking.rb +++ b/app/controllers/concerns/redis_tracking.rb @@ -12,12 +12,13 @@ # You can also pass custom conditions using `if:`, using the same format as with Rails callbacks. # You can also pass an optional block that calculates and returns a custom id to track. module RedisTracking + include Gitlab::Tracking::Helpers extend ActiveSupport::Concern class_methods do def track_redis_hll_event(*controller_actions, name:, if: nil, &block) custom_conditions = Array.wrap(binding.local_variable_get('if')) - conditions = [:trackable_request?, *custom_conditions] + conditions = [:trackable_html_request?, *custom_conditions] after_action only: controller_actions, if: conditions do track_unique_redis_hll_event(name, &block) @@ -37,10 +38,6 @@ module RedisTracking Gitlab::UsageDataCounters::HLLRedisCounter.track_event(event_name, values: unique_id) end - def trackable_request? - request.format.html? && request.headers['DNT'] != '1' - end - def visitor_id return cookies[:visitor_id] if cookies[:visitor_id].present? return unless current_user diff --git a/app/controllers/concerns/spammable_actions.rb b/app/controllers/concerns/spammable_actions.rb index 9e861d2859d..eb1223f22a9 100644 --- a/app/controllers/concerns/spammable_actions.rb +++ b/app/controllers/concerns/spammable_actions.rb @@ -47,31 +47,16 @@ module SpammableActions end end - def spammable_params - # NOTE: For the legacy reCAPTCHA implementation based on the HTML/HAML form, the - # 'g-recaptcha-response' field name comes from `Recaptcha::ClientHelper#recaptcha_tags` in the - # recaptcha gem, which is called from the HAML `_recaptcha_form.html.haml` form. - # - # It is used in the `Recaptcha::Verify#verify_recaptcha` to extract the value from `params`, - # if the `response` option is not passed explicitly. - # - # Instead of relying on this behavior, we are extracting and passing it explicitly. This will - # make it consistent with the newer, modern reCAPTCHA verification process as it will be - # implemented via the GraphQL API and in Vue components via the native reCAPTCHA Javascript API, - # which requires that the recaptcha response param be obtained and passed explicitly. - # - # It can also be expanded to multiple fields when we move to future alternative captcha - # implementations such as FriendlyCaptcha. See https://gitlab.com/gitlab-org/gitlab/-/issues/273480 - - # After this newer GraphQL/JS API process is fully supported by the backend, we can remove the - # check for the 'g-recaptcha-response' field and other HTML/HAML form-specific support. - captcha_response = params['g-recaptcha-response'] || params[:captcha_response] - - { - request: request, - spam_log_id: params[:spam_log_id], - captcha_response: captcha_response - } + # TODO: This method is currently only needed for issue create, to convert spam/CAPTCHA values from + # params, and instead be passed as headers, as the spam services now all expect. It can be removed + # when issue create is is converted to a client/JS based approach instead of the legacy HAML + # `_recaptcha_form.html.haml` which is rendered via the `projects/issues/verify` template. + # In that case, which is based on the legacy reCAPTCHA implementation using the HTML/HAML form, + # the 'g-recaptcha-response' field name comes from `Recaptcha::ClientHelper#recaptcha_tags` in the + # recaptcha gem, which is called from the HAML `_recaptcha_form.html.haml` form. + def extract_legacy_spam_params_to_headers + request.headers['X-GitLab-Captcha-Response'] = params['g-recaptcha-response'] || params[:captcha_response] + request.headers['X-GitLab-Spam-Log-Id'] = params[:spam_log_id] end def spammable diff --git a/app/controllers/concerns/wiki_actions.rb b/app/controllers/concerns/wiki_actions.rb index b7f6691ef4b..848b7ee44c5 100644 --- a/app/controllers/concerns/wiki_actions.rb +++ b/app/controllers/concerns/wiki_actions.rb @@ -14,8 +14,7 @@ module WikiActions before_action { respond_to :html } before_action :authorize_read_wiki! - before_action :authorize_create_wiki!, only: [:edit, :create] - before_action :authorize_admin_wiki!, only: :destroy + before_action :authorize_create_wiki!, only: [:edit, :create, :destroy] before_action :wiki before_action :page, only: [:show, :edit, :update, :history, :destroy, :diff] diff --git a/app/controllers/dashboard/milestones_controller.rb b/app/controllers/dashboard/milestones_controller.rb index e17b16c26a2..1369e82a69b 100644 --- a/app/controllers/dashboard/milestones_controller.rb +++ b/app/controllers/dashboard/milestones_controller.rb @@ -13,7 +13,7 @@ class Dashboard::MilestonesController < Dashboard::ApplicationController @milestones = milestones.page(params[:page]) end format.json do - render json: milestones.to_json(only: [:id, :title], methods: :name) + render json: milestones.to_json(only: [:id, :title, :due_date], methods: :name) end end end diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb index 782c8c293fd..25ac0af9731 100644 --- a/app/controllers/dashboard/todos_controller.rb +++ b/app/controllers/dashboard/todos_controller.rb @@ -3,7 +3,6 @@ class Dashboard::TodosController < Dashboard::ApplicationController include ActionView::Helpers::NumberHelper include PaginatedCollection - include Analytics::UniqueVisitsHelper before_action :authorize_read_project!, only: :index before_action :authorize_read_group!, only: :index diff --git a/app/controllers/groups/application_controller.rb b/app/controllers/groups/application_controller.rb index a3bbfc8be0d..f6c71ac8087 100644 --- a/app/controllers/groups/application_controller.rb +++ b/app/controllers/groups/application_controller.rb @@ -13,8 +13,16 @@ class Groups::ApplicationController < ApplicationController before_action :set_sorting requires_cross_project_access + helper_method :can_manage_members? + private + def can_manage_members?(group = @group) + strong_memoize(:can_manage_members) do + can?(current_user, :admin_group_member, group) + end + end + def group @group ||= find_routable!(Group, params[:group_id] || params[:id]) end diff --git a/app/controllers/groups/boards_controller.rb b/app/controllers/groups/boards_controller.rb index 3d8cdd766bf..04b4d8ea9a7 100644 --- a/app/controllers/groups/boards_controller.rb +++ b/app/controllers/groups/boards_controller.rb @@ -8,6 +8,7 @@ class Groups::BoardsController < Groups::ApplicationController before_action :assign_endpoint_vars before_action do push_frontend_feature_flag(:graphql_board_lists, group, default_enabled: false) + push_frontend_feature_flag(:issue_boards_filtered_search, group, default_enabled: :yaml) push_frontend_feature_flag(:board_multi_select, group, default_enabled: :yaml) push_frontend_feature_flag(:swimlanes_buffered_rendering, group, default_enabled: :yaml) push_frontend_feature_flag(:iteration_cadences, group, default_enabled: :yaml) diff --git a/app/controllers/groups/group_members_controller.rb b/app/controllers/groups/group_members_controller.rb index 8d9059d271f..d5e7653dea2 100644 --- a/app/controllers/groups/group_members_controller.rb +++ b/app/controllers/groups/group_members_controller.rb @@ -22,8 +22,6 @@ class Groups::GroupMembersController < Groups::ApplicationController feature_category :authentication_and_authorization - helper_method :can_manage_members? - def index @sort = params[:sort].presence || sort_value_name @@ -53,12 +51,6 @@ class Groups::GroupMembersController < Groups::ApplicationController private - def can_manage_members? - strong_memoize(:can_manage_members) do - can?(current_user, :admin_group_member, @group) - end - end - def present_invited_members(invited_members) present_members(invited_members .page(params[:invited_members_page]) diff --git a/app/controllers/groups/milestones_controller.rb b/app/controllers/groups/milestones_controller.rb index e9dce3947dd..63eff750d1b 100644 --- a/app/controllers/groups/milestones_controller.rb +++ b/app/controllers/groups/milestones_controller.rb @@ -15,7 +15,7 @@ class Groups::MilestonesController < Groups::ApplicationController @milestones = milestones.page(params[:page]) end format.json do - render json: milestones.to_json(only: [:id, :title], methods: :name) + render json: milestones.to_json(only: [:id, :title, :due_date], methods: :name) end end end diff --git a/app/controllers/groups/runners_controller.rb b/app/controllers/groups/runners_controller.rb index b02b0e85d38..1cff658dd52 100644 --- a/app/controllers/groups/runners_controller.rb +++ b/app/controllers/groups/runners_controller.rb @@ -7,7 +7,7 @@ class Groups::RunnersController < Groups::ApplicationController before_action :runner, only: [:edit, :update, :destroy, :pause, :resume, :show] - feature_category :continuous_integration + feature_category :runner def show end diff --git a/app/controllers/groups/variables_controller.rb b/app/controllers/groups/variables_controller.rb index 00ddb8d736c..9dbbd385ea8 100644 --- a/app/controllers/groups/variables_controller.rb +++ b/app/controllers/groups/variables_controller.rb @@ -6,7 +6,7 @@ module Groups skip_cross_project_access_check :show, :update - feature_category :continuous_integration + feature_category :pipeline_authoring def show respond_to do |format| diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index 06906001ef0..a1fb74cf277 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -13,7 +13,7 @@ class HelpController < ApplicationController def index # Remove YAML frontmatter so that it doesn't look weird - @help_index = File.read(Rails.root.join('doc', 'README.md')).sub(YAML_FRONT_MATTER_REGEXP, '') + @help_index = File.read(Rails.root.join('doc', 'index.md')).sub(YAML_FRONT_MATTER_REGEXP, '') # Prefix Markdown links with `help/` unless they are external links. # '//' not necessarily part of URL, e.g., mailto:mail@example.com diff --git a/app/controllers/import/bulk_imports_controller.rb b/app/controllers/import/bulk_imports_controller.rb index 9d6c0a003c4..e99b8cfa0c7 100644 --- a/app/controllers/import/bulk_imports_controller.rb +++ b/app/controllers/import/bulk_imports_controller.rb @@ -10,7 +10,7 @@ class Import::BulkImportsController < ApplicationController POLLING_INTERVAL = 3_000 - rescue_from BulkImports::Clients::HTTP::ConnectionError, with: :bulk_import_connection_error + rescue_from BulkImports::Error, with: :bulk_import_connection_error def configure session[access_token_key] = configure_params[access_token_key]&.strip @@ -87,7 +87,7 @@ class Import::BulkImportsController < ApplicationController def client @client ||= BulkImports::Clients::HTTP.new( - uri: session[url_key], + url: session[url_key], token: session[access_token_key], per_page: params[:per_page], page: params[:page] diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb index 0a9a9e03e94..e6aae144da6 100644 --- a/app/controllers/invites_controller.rb +++ b/app/controllers/invites_controller.rb @@ -86,18 +86,7 @@ class InvitesController < ApplicationController if user_sign_up? set_session_invite_params - experiment(:invite_signup_page_interaction, actor: member) do |experiment_instance| - set_originating_member_id if experiment_instance.enabled? - - experiment_instance.use do - redirect_to new_user_registration_path(invite_email: member.invite_email), notice: _("To accept this invitation, create an account or sign in.") - end - experiment_instance.try do - redirect_to new_users_sign_up_invite_path(invite_email: member.invite_email) - end - - experiment_instance.track(:view) - end + redirect_to new_user_registration_path(invite_email: member.invite_email), notice: _("To accept this invitation, create an account or sign in.") else redirect_to new_user_session_path(sign_in_redirect_params), notice: sign_in_notice end @@ -106,11 +95,7 @@ class InvitesController < ApplicationController def set_session_invite_params session[:invite_email] = member.invite_email - set_originating_member_id if Members::InviteEmailExperiment.initial_invite_email?(params[:invite_type]) - end - - def set_originating_member_id - session[:originating_member_id] = member.id + session[:originating_member_id] = member.id if Members::InviteEmailExperiment.initial_invite_email?(params[:invite_type]) end def sign_in_redirect_params diff --git a/app/controllers/jira_connect/events_controller.rb b/app/controllers/jira_connect/events_controller.rb index d833491b8f7..fe66e742c44 100644 --- a/app/controllers/jira_connect/events_controller.rb +++ b/app/controllers/jira_connect/events_controller.rb @@ -19,7 +19,7 @@ class JiraConnect::EventsController < JiraConnect::ApplicationController end def uninstalled - if current_jira_installation.destroy + if JiraConnectInstallations::DestroyService.execute(current_jira_installation, jira_connect_base_path, jira_connect_events_uninstalled_path) head :ok else head :unprocessable_entity diff --git a/app/controllers/metrics_controller.rb b/app/controllers/metrics_controller.rb index 1ef1e12bb02..a0c307a0a03 100644 --- a/app/controllers/metrics_controller.rb +++ b/app/controllers/metrics_controller.rb @@ -30,7 +30,7 @@ class MetricsController < ActionController::Base def system_metrics Gitlab::Metrics::System.summary.merge( - worker_id: Prometheus::PidProvider.worker_id + worker_id: ::Prometheus::PidProvider.worker_id ) end end diff --git a/app/controllers/profiles/gpg_keys_controller.rb b/app/controllers/profiles/gpg_keys_controller.rb index 7f04927f517..9e16d195b00 100644 --- a/app/controllers/profiles/gpg_keys_controller.rb +++ b/app/controllers/profiles/gpg_keys_controller.rb @@ -22,7 +22,7 @@ class Profiles::GpgKeysController < Profiles::ApplicationController end def destroy - @gpg_key.destroy + GpgKeys::DestroyService.new(current_user).execute(@gpg_key) respond_to do |format| format.html { redirect_to profile_gpg_keys_url, status: :found } diff --git a/app/controllers/profiles/personal_access_tokens_controller.rb b/app/controllers/profiles/personal_access_tokens_controller.rb index ba539ef808d..8dc9697c56d 100644 --- a/app/controllers/profiles/personal_access_tokens_controller.rb +++ b/app/controllers/profiles/personal_access_tokens_controller.rb @@ -9,7 +9,11 @@ class Profiles::PersonalAccessTokensController < Profiles::ApplicationController def index set_index_vars - @personal_access_token = finder.build + scopes = params[:scopes].split(',').map(&:squish).select(&:present?).map(&:to_sym) unless params[:scopes].nil? + @personal_access_token = finder.build( + name: params[:name], + scopes: scopes + ) end def create diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index f6a92b07295..7bb3ed1d109 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -15,7 +15,7 @@ class Projects::ArtifactsController < Projects::ApplicationController MAX_PER_PAGE = 20 - feature_category :continuous_integration + feature_category :build_artifacts def index # Loading artifacts is very expensive in projects with a lot of artifacts. diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index c6c9237292d..08066acb45c 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -23,6 +23,10 @@ class Projects::BlobController < Projects::ApplicationController # We need to assign the blob vars before `authorize_edit_tree!` so we can # validate access to a specific ref. before_action :assign_blob_vars + + # Since BlobController doesn't use assign_ref_vars, we have to call this explicitly + before_action :rectify_renamed_default_branch!, only: [:show] + before_action :authorize_edit_tree!, only: [:new, :create, :update, :destroy] before_action :commit, except: [:new, :create] @@ -140,11 +144,15 @@ class Projects::BlobController < Projects::ApplicationController end def commit - @commit = @repository.commit(@ref) + @commit ||= @repository.commit(@ref) return render_404 unless @commit end + def redirect_renamed_default_branch? + action_name == 'show' + end + def assign_blob_vars @id = params[:id] @ref, @path = extract_ref(@id) @@ -152,6 +160,12 @@ class Projects::BlobController < Projects::ApplicationController render_404 end + def rectify_renamed_default_branch! + @commit ||= @repository.commit(@ref) + + super + end + # rubocop: disable CodeReuse/ActiveRecord def after_edit_path from_merge_request = MergeRequestsFinder.new(current_user, project_id: @project.id).find_by(iid: params[:from_merge_request_iid]) diff --git a/app/controllers/projects/boards_controller.rb b/app/controllers/projects/boards_controller.rb index 43c9046f850..035b76abfd6 100644 --- a/app/controllers/projects/boards_controller.rb +++ b/app/controllers/projects/boards_controller.rb @@ -9,6 +9,7 @@ class Projects::BoardsController < Projects::ApplicationController 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) end diff --git a/app/controllers/projects/build_artifacts_controller.rb b/app/controllers/projects/build_artifacts_controller.rb index 148080a71f4..d5655d40429 100644 --- a/app/controllers/projects/build_artifacts_controller.rb +++ b/app/controllers/projects/build_artifacts_controller.rb @@ -8,7 +8,7 @@ class Projects::BuildArtifactsController < Projects::ApplicationController before_action :extract_ref_name_and_path before_action :validate_artifacts!, except: [:download] - feature_category :continuous_integration + feature_category :build_artifacts def download redirect_to download_project_job_artifacts_path(project, job, params: request.query_parameters) diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index 3d2398f7ee3..6748be06ded 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -52,7 +52,8 @@ class Projects::CommitController < Projects::ApplicationController # rubocop: disable CodeReuse/ActiveRecord def pipelines @pipelines = @commit.pipelines.order(id: :desc) - @pipelines = @pipelines.where(ref: params[:ref]).page(params[:page]).per(30) if params[:ref] + @pipelines = @pipelines.where(ref: params[:ref]) if params[:ref] + @pipelines = @pipelines.page(params[:page]) respond_to do |format| format.html diff --git a/app/controllers/projects/cycle_analytics_controller.rb b/app/controllers/projects/cycle_analytics_controller.rb index d1d27286c68..db5ba51ee01 100644 --- a/app/controllers/projects/cycle_analytics_controller.rb +++ b/app/controllers/projects/cycle_analytics_controller.rb @@ -4,15 +4,19 @@ class Projects::CycleAnalyticsController < Projects::ApplicationController include ActionView::Helpers::DateHelper include ActionView::Helpers::TextHelper include CycleAnalyticsParams - include Analytics::UniqueVisitsHelper include GracefulTimeoutHandling + include RedisTracking before_action :authorize_read_cycle_analytics! - track_unique_visits :show, target_id: 'p_analytics_valuestream' + track_redis_hll_event :show, name: 'p_analytics_valuestream' feature_category :planning_analytics + before_action do + push_licensed_feature(:cycle_analytics_for_groups) if project.licensed_feature_available?(:cycle_analytics_for_groups) + end + def show @cycle_analytics = Analytics::CycleAnalytics::ProjectLevel.new(project: @project, options: options(cycle_analytics_project_params)) diff --git a/app/controllers/projects/environments/prometheus_api_controller.rb b/app/controllers/projects/environments/prometheus_api_controller.rb index 97810d7d439..94fe67b5e85 100644 --- a/app/controllers/projects/environments/prometheus_api_controller.rb +++ b/app/controllers/projects/environments/prometheus_api_controller.rb @@ -14,6 +14,6 @@ class Projects::Environments::PrometheusApiController < Projects::ApplicationCon end def proxy_variable_substitution_service - Prometheus::ProxyVariableSubstitutionService + ::Prometheus::ProxyVariableSubstitutionService end end diff --git a/app/controllers/projects/feature_flags_controller.rb b/app/controllers/projects/feature_flags_controller.rb index a59824b1085..b99c233411a 100644 --- a/app/controllers/projects/feature_flags_controller.rb +++ b/app/controllers/projects/feature_flags_controller.rb @@ -13,10 +13,6 @@ class Projects::FeatureFlagsController < Projects::ApplicationController before_action :ensure_flag_writable!, only: [:update] before_action :exclude_legacy_flags_check, only: [:edit] - before_action do - push_frontend_feature_flag(:feature_flag_permissions) - end - feature_category :feature_flags def index diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb index 9e42d218ceb..0f00fda4687 100644 --- a/app/controllers/projects/forks_controller.rb +++ b/app/controllers/projects/forks_controller.rb @@ -17,7 +17,7 @@ class Projects::ForksController < Projects::ApplicationController feature_category :source_code_management before_action do - push_frontend_feature_flag(:fork_project_form) + push_frontend_feature_flag(:fork_project_form, @project, default_enabled: :yaml) end def index diff --git a/app/controllers/projects/graphs_controller.rb b/app/controllers/projects/graphs_controller.rb index ad39b317b31..7a7961c28bb 100644 --- a/app/controllers/projects/graphs_controller.rb +++ b/app/controllers/projects/graphs_controller.rb @@ -2,14 +2,14 @@ class Projects::GraphsController < Projects::ApplicationController include ExtractsPath - include Analytics::UniqueVisitsHelper + include RedisTracking # Authorize before_action :require_non_empty_project before_action :assign_ref_vars before_action :authorize_read_repository_graphs! - track_unique_visits :charts, target_id: 'p_analytics_repo' + track_redis_hll_event :charts, name: 'p_analytics_repo' feature_category :source_code_management diff --git a/app/controllers/projects/import/jira_controller.rb b/app/controllers/projects/import/jira_controller.rb index 8418a607659..46c4761b0ea 100644 --- a/app/controllers/projects/import/jira_controller.rb +++ b/app/controllers/projects/import/jira_controller.rb @@ -25,9 +25,9 @@ module Projects false end - def jira_service - strong_memoize(:jira_service) do - @project.jira_service + def jira_integration + strong_memoize(:jira_integration) do + @project.jira_integration end end diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 295213bd38c..5d38e431c8a 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -50,10 +50,9 @@ class Projects::IssuesController < Projects::ApplicationController end before_action only: :show do - real_time_feature_flag = :real_time_issue_sidebar - real_time_enabled = Gitlab::ActionCable::Config.in_app? || Feature.enabled?(real_time_feature_flag, @project) + real_time_enabled = Gitlab::ActionCable::Config.in_app? || Feature.enabled?(:real_time_issue_sidebar, @project) - push_to_gon_attributes(:features, real_time_feature_flag, real_time_enabled) + push_to_gon_attributes(:features, :real_time_issue_sidebar, real_time_enabled) push_frontend_feature_flag(:confidential_notes, @project, default_enabled: :yaml) push_frontend_feature_flag(:issue_assignees_widget, @project, default_enabled: :yaml) push_frontend_feature_flag(:labels_widget, @project, default_enabled: :yaml) @@ -130,12 +129,14 @@ class Projects::IssuesController < Projects::ApplicationController end def create - create_params = issue_params.merge(spammable_params).merge( + extract_legacy_spam_params_to_headers + create_params = issue_params.merge( merge_request_to_resolve_discussions_of: params[:merge_request_to_resolve_discussions_of], discussion_to_resolve: params[:discussion_to_resolve] ) - service = ::Issues::CreateService.new(project: project, current_user: current_user, params: create_params) + spam_params = ::Spam::SpamParams.new_from_request(request: request) + service = ::Issues::CreateService.new(project: project, current_user: current_user, params: create_params, spam_params: spam_params) @issue = service.execute create_vulnerability_issue_feedback(issue) @@ -335,8 +336,8 @@ class Projects::IssuesController < Projects::ApplicationController end def update_service - update_params = issue_params.merge(spammable_params) - ::Issues::UpdateService.new(project: project, current_user: current_user, params: update_params) + spam_params = ::Spam::SpamParams.new_from_request(request: request) + ::Issues::UpdateService.new(project: project, current_user: current_user, params: issue_params, spam_params: spam_params) end def finder_type diff --git a/app/controllers/projects/jobs_controller.rb b/app/controllers/projects/jobs_controller.rb index 92442fd4e28..49687a50ff6 100644 --- a/app/controllers/projects/jobs_controller.rb +++ b/app/controllers/projects/jobs_controller.rb @@ -17,6 +17,10 @@ class Projects::JobsController < Projects::ApplicationController before_action :verify_proxy_request!, only: :proxy_websocket_authorize before_action :push_jobs_table_vue, only: [:index] + before_action do + push_frontend_feature_flag(:infinitely_collapsible_sections, @project, default_enabled: :yaml) + end + layout 'project' feature_category :continuous_integration diff --git a/app/controllers/projects/mattermosts_controller.rb b/app/controllers/projects/mattermosts_controller.rb index ac204427885..ebba20b285a 100644 --- a/app/controllers/projects/mattermosts_controller.rb +++ b/app/controllers/projects/mattermosts_controller.rb @@ -7,7 +7,7 @@ class Projects::MattermostsController < Projects::ApplicationController layout 'project_settings' before_action :authorize_admin_project! - before_action :service + before_action :integration before_action :teams, only: [:new] feature_category :integrations @@ -16,11 +16,11 @@ class Projects::MattermostsController < Projects::ApplicationController end def create - result, message = @service.configure(current_user, configure_params) + result, message = integration.configure(current_user, configure_params) if result flash[:notice] = 'This service is now configured' - redirect_to edit_project_service_path(@project, service) + redirect_to edit_project_service_path(@project, integration) else flash[:alert] = message || 'Failed to configure service' redirect_to new_project_mattermost_path(@project) @@ -31,15 +31,15 @@ class Projects::MattermostsController < Projects::ApplicationController def configure_params params.require(:mattermost).permit(:trigger, :team_id).merge( - url: service_trigger_url(@service), + url: service_trigger_url(integration), icon_url: asset_url('slash-command-logo.png', skip_pipeline: true)) end def teams - @teams, @teams_error_message = @service.list_teams(current_user) + @teams, @teams_error_message = integration.list_teams(current_user) end - def service - @service ||= @project.find_or_initialize_service('mattermost_slash_commands') + def integration + @integration ||= @project.find_or_initialize_integration('mattermost_slash_commands') end end diff --git a/app/controllers/projects/merge_requests/diffs_controller.rb b/app/controllers/projects/merge_requests/diffs_controller.rb index f125952cb97..88423bec915 100644 --- a/app/controllers/projects/merge_requests/diffs_controller.rb +++ b/app/controllers/projects/merge_requests/diffs_controller.rb @@ -3,6 +3,7 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::ApplicationController include DiffHelper include RendersNotes + include Gitlab::Cache::Helpers before_action :commit before_action :define_diff_vars @@ -40,7 +41,16 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic pagination_data: diffs.pagination_data } - render json: PaginatedDiffSerializer.new(current_user: current_user).represent(diffs, options) + if diff_options_hash[:paths].blank? && Feature.enabled?(:diffs_batch_render_cached, project, default_enabled: :yaml) + render_cached( + diffs, + with: PaginatedDiffSerializer.new(current_user: current_user), + cache_context: -> (_) { [diff_view, params[:w], params[:expanded], params[:per_page], params[:page]] }, + **options + ) + else + render json: PaginatedDiffSerializer.new(current_user: current_user).represent(diffs, options) + end end def diffs_metadata @@ -193,7 +203,7 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic end def track_viewed_diffs_events - return if request.headers['DNT'] == '1' + return if dnt_enabled? Gitlab::UsageDataCounters::MergeRequestActivityUniqueCounter .track_mr_diffs_action(merge_request: @merge_request) diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 5958c7f66e5..cfa64bbc16d 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -30,20 +30,15 @@ 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(: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(:diffs_gradual_load, @project, default_enabled: true) 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(:codequality_mr_diff_annotations, project, default_enabled: :yaml) # Usage data feature flags push_frontend_feature_flag(:users_expanding_widgets_usage_data, @project, default_enabled: :yaml) @@ -170,7 +165,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo def pipelines set_pipeline_variables - @pipelines = @pipelines.page(params[:page]).per(30) + @pipelines = @pipelines.page(params[:page]) Gitlab::PollingInterval.set_header(response, interval: 10_000) @@ -223,7 +218,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo end def codequality_mr_diff_reports - reports_response(@merge_request.find_codequality_mr_diff_reports) + reports_response(@merge_request.find_codequality_mr_diff_reports, head_pipeline) end def codequality_reports diff --git a/app/controllers/projects/milestones_controller.rb b/app/controllers/projects/milestones_controller.rb index dcdda18784d..630e7ccd43f 100644 --- a/app/controllers/projects/milestones_controller.rb +++ b/app/controllers/projects/milestones_controller.rb @@ -33,7 +33,7 @@ class Projects::MilestonesController < Projects::ApplicationController @milestones = @milestones.page(params[:page]) end format.json do - render json: @milestones.to_json(only: [:id, :title], methods: :name) + render json: @milestones.to_json(only: [:id, :title, :due_date], methods: :name) end end end diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index 7779f3c3b65..b4196878c4f 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -2,7 +2,7 @@ class Projects::PipelinesController < Projects::ApplicationController include ::Gitlab::Utils::StrongMemoize - include Analytics::UniqueVisitsHelper + include RedisTracking before_action :disable_query_limiting, only: [:create, :retry] before_action :pipeline, except: [:index, :new, :create, :charts, :config_variables] @@ -14,7 +14,6 @@ class Projects::PipelinesController < Projects::ApplicationController before_action :authorize_update_pipeline!, only: [:retry, :cancel] before_action do 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) end @@ -25,7 +24,7 @@ class Projects::PipelinesController < Projects::ApplicationController around_action :allow_gitaly_ref_name_caching, only: [:index, :show] - track_unique_visits :charts, target_id: 'p_analytics_pipelines' + track_redis_hll_event :charts, name: 'p_analytics_pipelines' wrap_parameters Ci::Pipeline @@ -43,13 +42,11 @@ class Projects::PipelinesController < Projects::ApplicationController .new(project, current_user, index_params) .execute .page(params[:page]) - .per(20) @pipelines_count = limited_pipelines_count(project) respond_to do |format| format.html do - enable_pipeline_empty_state_templates_experiment enable_code_quality_walkthrough_experiment enable_ci_runner_templates_experiment end @@ -301,18 +298,6 @@ class Projects::PipelinesController < Projects::ApplicationController params.permit(:scope, :username, :ref, :status) end - def enable_pipeline_empty_state_templates_experiment - experiment(:pipeline_empty_state_templates, namespace: project.root_ancestor) do |e| - e.exclude! unless current_user - e.exclude! if @pipelines_count.to_i > 0 - e.exclude! if helpers.has_gitlab_ci?(project) - - e.control {} - e.candidate {} - e.record! - end - end - def enable_code_quality_walkthrough_experiment experiment(:code_quality_walkthrough, namespace: project.root_ancestor) do |e| e.exclude! unless current_user diff --git a/app/controllers/projects/prometheus/metrics_controller.rb b/app/controllers/projects/prometheus/metrics_controller.rb index d70d29a341f..f3a3d22244c 100644 --- a/app/controllers/projects/prometheus/metrics_controller.rb +++ b/app/controllers/projects/prometheus/metrics_controller.rb @@ -66,7 +66,7 @@ module Projects ) if @metric.persisted? - redirect_to edit_project_service_path(project, ::PrometheusService), + redirect_to edit_project_service_path(project, ::Integrations::Prometheus), notice: _('Metric was successfully added.') else render 'new' @@ -77,7 +77,7 @@ module Projects @metric = update_metrics_service(prometheus_metric).execute if @metric.persisted? - redirect_to edit_project_service_path(project, ::PrometheusService), + redirect_to edit_project_service_path(project, ::Integrations::Prometheus), notice: _('Metric was successfully updated.') else render 'edit' @@ -93,7 +93,7 @@ module Projects respond_to do |format| format.html do - redirect_to edit_project_service_path(project, ::PrometheusService), status: :see_other + redirect_to edit_project_service_path(project, ::Integrations::Prometheus), status: :see_other end format.json do head :ok diff --git a/app/controllers/projects/releases_controller.rb b/app/controllers/projects/releases_controller.rb index f01d10f4afa..be2abc5cddf 100644 --- a/app/controllers/projects/releases_controller.rb +++ b/app/controllers/projects/releases_controller.rb @@ -25,12 +25,6 @@ class Projects::ReleasesController < Projects::ApplicationController end end - def new - unless Feature.enabled?(:new_release_page, project, default_enabled: true) - redirect_to(new_project_tag_path(@project)) - end - end - def downloads redirect_to link.url end diff --git a/app/controllers/projects/repositories_controller.rb b/app/controllers/projects/repositories_controller.rb index 8f64a8aa1d3..8beebb52980 100644 --- a/app/controllers/projects/repositories_controller.rb +++ b/app/controllers/projects/repositories_controller.rb @@ -117,7 +117,7 @@ class Projects::RepositoriesController < Projects::ApplicationController # from Redis. def extract_ref_and_filename(id) path = id.strip - data = path.match(/(.*)\/(.*)/) + data = path.match(%r{(.*)/(.*)}) if data [data[1], data[2]] diff --git a/app/controllers/projects/runners_controller.rb b/app/controllers/projects/runners_controller.rb index ec1f57f090a..e841c3e3d49 100644 --- a/app/controllers/projects/runners_controller.rb +++ b/app/controllers/projects/runners_controller.rb @@ -6,7 +6,7 @@ class Projects::RunnersController < Projects::ApplicationController layout 'project_settings' - feature_category :continuous_integration + feature_category :runner def index redirect_to project_settings_ci_cd_path(@project, anchor: 'js-runners-settings') @@ -51,14 +51,14 @@ class Projects::RunnersController < Projects::ApplicationController end def toggle_shared_runners - if !project.shared_runners_enabled && project.group && project.group.shared_runners_setting == 'disabled_and_unoverridable' - render json: { error: _('Cannot enable shared runners because parent group does not allow it') }, status: :unauthorized - return - end - - project.toggle!(:shared_runners_enabled) + update_params = { shared_runners_enabled: !project.shared_runners_enabled } + result = Projects::UpdateService.new(project, current_user, update_params).execute - render json: {}, status: :ok + if result[:status] == :success + render json: {}, status: :ok + else + render json: { error: result[:message] }, status: :unauthorized + end end def toggle_group_runners diff --git a/app/controllers/projects/service_hook_logs_controller.rb b/app/controllers/projects/service_hook_logs_controller.rb index 5c814ea139f..88de0b7ba0d 100644 --- a/app/controllers/projects/service_hook_logs_controller.rb +++ b/app/controllers/projects/service_hook_logs_controller.rb @@ -1,20 +1,23 @@ # frozen_string_literal: true class Projects::ServiceHookLogsController < Projects::HookLogsController - before_action :service, only: [:show, :retry] + extend Gitlab::Utils::Override + + before_action :integration, only: [:show, :retry] def retry execute_hook - redirect_to edit_project_service_path(@project, @service) + redirect_to edit_project_service_path(@project, @integration) end private - def hook - @hook ||= service.service_hook + def integration + @integration ||= @project.find_or_initialize_integration(params[:service_id]) end - def service - @service ||= @project.find_or_initialize_service(params[:service_id]) + override :hook + def hook + @hook ||= integration.service_hook || not_found end end diff --git a/app/controllers/projects/usage_ping_controller.rb b/app/controllers/projects/service_ping_controller.rb index 77ee53f2e5d..00530c09be8 100644 --- a/app/controllers/projects/usage_ping_controller.rb +++ b/app/controllers/projects/service_ping_controller.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -class Projects::UsagePingController < Projects::ApplicationController +class Projects::ServicePingController < Projects::ApplicationController before_action :authenticate_user! - feature_category :usage_ping + feature_category :service_ping def web_ide_clientside_preview return render_404 unless Gitlab::CurrentSettings.web_ide_clientside_preview_enabled? diff --git a/app/controllers/projects/services_controller.rb b/app/controllers/projects/services_controller.rb index cad13d7e708..ef6d96e8737 100644 --- a/app/controllers/projects/services_controller.rb +++ b/app/controllers/projects/services_controller.rb @@ -9,8 +9,8 @@ class Projects::ServicesController < Projects::ApplicationController before_action :ensure_service_enabled before_action :integration before_action :web_hook_logs, only: [:edit, :update] - before_action :set_deprecation_notice_for_prometheus_service, only: [:edit, :update] - before_action :redirect_deprecated_prometheus_service, only: [:update] + before_action :set_deprecation_notice_for_prometheus_integration, only: [:edit, :update] + before_action :redirect_deprecated_prometheus_integration, only: [:update] respond_to :html @@ -46,7 +46,7 @@ class Projects::ServicesController < Projects::ApplicationController end def test - if integration.can_test? + if integration.testable? render json: service_test_response, status: :ok else render json: {}, status: :not_found @@ -84,7 +84,7 @@ class Projects::ServicesController < Projects::ApplicationController end def integration - @integration ||= @project.find_or_initialize_service(params[:id]) + @integration ||= @project.find_or_initialize_integration(params[:id]) end alias_method :service, :integration @@ -104,15 +104,15 @@ class Projects::ServicesController < Projects::ApplicationController .merge(errors: integration.errors.as_json) end - def redirect_deprecated_prometheus_service - redirect_to edit_project_service_path(project, integration) if integration.is_a?(::PrometheusService) && Feature.enabled?(:settings_operations_prometheus_service, project) + def redirect_deprecated_prometheus_integration + redirect_to edit_project_service_path(project, integration) if integration.is_a?(::Integrations::Prometheus) && Feature.enabled?(:settings_operations_prometheus_service, project) end - def set_deprecation_notice_for_prometheus_service - return if !integration.is_a?(::PrometheusService) || !Feature.enabled?(:settings_operations_prometheus_service, project) + def set_deprecation_notice_for_prometheus_integration + return if !integration.is_a?(::Integrations::Prometheus) || !Feature.enabled?(:settings_operations_prometheus_service, project) operations_link_start = "<a href=\"#{project_settings_operations_path(project)}\">" - message = s_('PrometheusService|You can now manage your Prometheus settings on the %{operations_link_start}Operations%{operations_link_end} page. Fields on this page has been deprecated.') % { operations_link_start: operations_link_start, operations_link_end: "</a>" } + message = s_('PrometheusService|You can now manage your Prometheus settings on the %{operations_link_start}Operations%{operations_link_end} page. Fields on this page have been deprecated.') % { operations_link_start: operations_link_start, operations_link_end: "</a>" } flash.now[:alert] = message.html_safe end end diff --git a/app/controllers/projects/settings/access_tokens_controller.rb b/app/controllers/projects/settings/access_tokens_controller.rb index e3bb8c616df..1ecede4c7a2 100644 --- a/app/controllers/projects/settings/access_tokens_controller.rb +++ b/app/controllers/projects/settings/access_tokens_controller.rb @@ -50,13 +50,17 @@ module Projects end def create_params - params.require(:project_access_token).permit(:name, :expires_at, scopes: []) + params.require(:project_access_token).permit(:name, :expires_at, :access_level, scopes: []) end def set_index_vars + # Loading project members so that we can fetch access level of the bot + # user in the project without multiple queries. + @project.project_members.load + @scopes = Gitlab::Auth.resource_bot_scopes - @active_project_access_tokens = finder(state: 'active').execute - @inactive_project_access_tokens = finder(state: 'inactive', sort: 'expires_at_asc').execute + @active_project_access_tokens = finder(state: 'active').execute.preload_users + @inactive_project_access_tokens = finder(state: 'inactive', sort: 'expires_at_asc').execute.preload_users @new_project_access_token = PersonalAccessToken.redis_getdel(key_identity) end diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb index 3254d4129d3..960c0beb244 100644 --- a/app/controllers/projects/settings/ci_cd_controller.rb +++ b/app/controllers/projects/settings/ci_cd_controller.rb @@ -12,6 +12,7 @@ module Projects before_action :define_variables before_action do push_frontend_feature_flag(:ajax_new_deploy_token, @project) + push_frontend_feature_flag(:ci_scoped_job_token, @project, default_enabled: :yaml) end helper_method :highlight_badge diff --git a/app/controllers/projects/settings/integrations_controller.rb b/app/controllers/projects/settings/integrations_controller.rb index e54f4c511db..c9d92d1aee9 100644 --- a/app/controllers/projects/settings/integrations_controller.rb +++ b/app/controllers/projects/settings/integrations_controller.rb @@ -9,7 +9,7 @@ module Projects feature_category :integrations def show - @integrations = @project.find_or_initialize_services + @integrations = @project.find_or_initialize_integrations end end end diff --git a/app/controllers/projects/settings/packages_and_registries_controller.rb b/app/controllers/projects/settings/packages_and_registries_controller.rb index fee51dc1311..8f0a19cfac5 100644 --- a/app/controllers/projects/settings/packages_and_registries_controller.rb +++ b/app/controllers/projects/settings/packages_and_registries_controller.rb @@ -16,7 +16,12 @@ module Projects private def packages_and_registries_settings_enabled! - render_404 unless settings_packages_and_registries_enabled?(project) + render_404 unless can_destroy_container_registry_image?(project) + end + + def can_destroy_container_registry_image?(project) + Gitlab.config.registry.enabled && + can?(current_user, :destroy_container_image, project) end end end diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb index b5cfc3990b2..475c9de2503 100644 --- a/app/controllers/projects/tree_controller.rb +++ b/app/controllers/projects/tree_controller.rb @@ -39,6 +39,10 @@ class Projects::TreeController < Projects::ApplicationController private + def redirect_renamed_default_branch? + action_name == 'show' + end + def assign_dir_vars @branch_name = params[:branch_name] diff --git a/app/controllers/projects/variables_controller.rb b/app/controllers/projects/variables_controller.rb index d8efc1b7b54..f93c75a203e 100644 --- a/app/controllers/projects/variables_controller.rb +++ b/app/controllers/projects/variables_controller.rb @@ -3,7 +3,7 @@ class Projects::VariablesController < Projects::ApplicationController before_action :authorize_admin_build! - feature_category :continuous_integration + feature_category :pipeline_authoring def show respond_to do |format| diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 53d80b8be58..0dbf7d40f87 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -37,11 +37,7 @@ class ProjectsController < Projects::ApplicationController before_action do push_frontend_feature_flag(:refactor_blob_viewer, @project, default_enabled: :yaml) - end - - before_action only: [:new] do - # Run experiment before render so it will be written to the `gon` for FE - helpers.new_repo_experiment_text + push_frontend_feature_flag(:increase_page_size_exponentially, @project, default_enabled: :yaml) end layout :determine_layout @@ -78,7 +74,6 @@ class ProjectsController < Projects::ApplicationController @project = ::Projects::CreateService.new(current_user, project_params(attributes: project_params_create_attributes)).execute if @project.saved? - experiment(:new_repo, user: current_user).track(:project_created) experiment(:new_project_readme, actor: current_user).track( :created, property: active_new_project_tab, @@ -162,6 +157,7 @@ class ProjectsController < Projects::ApplicationController format.atom do load_events + @events = @events.select { |event| event.visible_to_user?(current_user) } render layout: 'xml.atom' end end @@ -378,8 +374,6 @@ class ProjectsController < Projects::ApplicationController .new(projects, offset: params[:offset].to_i, filter: event_filter) .to_a .map(&:present) - - Events::RenderService.new(current_user).execute(@events, atom_request: request.format.atom?) end # rubocop: enable CodeReuse/ActiveRecord diff --git a/app/controllers/registrations/experience_levels_controller.rb b/app/controllers/registrations/experience_levels_controller.rb index d04e8d296ed..3c94bce126c 100644 --- a/app/controllers/registrations/experience_levels_controller.rb +++ b/app/controllers/registrations/experience_levels_controller.rb @@ -2,7 +2,7 @@ module Registrations class ExperienceLevelsController < ApplicationController - layout 'signup_onboarding' + layout 'minimal' before_action :ensure_namespace_path_param diff --git a/app/controllers/registrations/invites_controller.rb b/app/controllers/registrations/invites_controller.rb deleted file mode 100644 index 548714e80e9..00000000000 --- a/app/controllers/registrations/invites_controller.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -module Registrations - class InvitesController < RegistrationsController - layout 'simple_registration' - - before_action :check_if_gl_com_or_dev - end -end diff --git a/app/controllers/registrations/welcome_controller.rb b/app/controllers/registrations/welcome_controller.rb index 34283cc8db7..303ee431a4d 100644 --- a/app/controllers/registrations/welcome_controller.rb +++ b/app/controllers/registrations/welcome_controller.rb @@ -2,7 +2,7 @@ module Registrations class WelcomeController < ApplicationController - layout 'welcome' + layout 'minimal' skip_before_action :authenticate_user!, :required_signup_info, :check_two_factor_requirement, only: [:show, :update] before_action :require_current_user diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index cacd3c2da64..7b1060eba8f 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -199,7 +199,6 @@ class RegistrationsController < Devise::RegistrationsController return unless member - experiment(:invite_signup_page_interaction, actor: member).track(:form_submission) experiment('members/invite_email', actor: member).track(:accepted) end diff --git a/app/controllers/repositories/git_http_controller.rb b/app/controllers/repositories/git_http_controller.rb index 11a219b4ff0..e51bfe6a37e 100644 --- a/app/controllers/repositories/git_http_controller.rb +++ b/app/controllers/repositories/git_http_controller.rb @@ -84,11 +84,7 @@ module Repositories return if Feature.enabled?(:disable_git_http_fetch_writes) - if Feature.enabled?(:project_statistics_sync, project, default_enabled: true) - Projects::FetchStatisticsIncrementService.new(project).execute - else - ProjectDailyStatisticsWorker.perform_async(project.id) # rubocop:disable CodeReuse/Worker - end + Projects::FetchStatisticsIncrementService.new(project).execute end def access diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index ac6239615b4..4160b528301 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -16,6 +16,8 @@ class SearchController < ApplicationController search_term_present && !params[:project_id].present? end + rescue_from ActiveRecord::QueryCanceled, with: :render_timeout + layout 'search' feature_category :global_search @@ -150,6 +152,15 @@ class SearchController < ApplicationController redirect_to new_user_session_path, alert: _('You must be logged in to search across all of GitLab') end + + def render_timeout(exception) + raise exception unless action_name.to_sym == :show + + log_exception(exception) + + @timeout = true + render status: :request_timeout + end end SearchController.prepend_mod_with('SearchController') diff --git a/app/controllers/users/unsubscribes_controller.rb b/app/controllers/users/unsubscribes_controller.rb new file mode 100644 index 00000000000..9ac07083cd5 --- /dev/null +++ b/app/controllers/users/unsubscribes_controller.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Users + class UnsubscribesController < ApplicationController + skip_before_action :authenticate_user! + + feature_category :users + + def show + @user = get_user + end + + def create + @user = get_user + + if @user + @user.admin_unsubscribe! + Notify.send_unsubscribed_notification(@user.id).deliver_later + end + + redirect_to new_user_session_path, notice: 'You have been unsubscribed' + end + + protected + + # rubocop: disable CodeReuse/ActiveRecord + def get_user + @email = Base64.urlsafe_decode64(params[:email]) + User.find_by(email: @email) + end + # rubocop: enable CodeReuse/ActiveRecord + end +end |