diff options
Diffstat (limited to 'app/controllers/projects')
43 files changed, 270 insertions, 213 deletions
diff --git a/app/controllers/projects/airflow/dags_controller.rb b/app/controllers/projects/airflow/dags_controller.rb deleted file mode 100644 index 9d1f0b0d63b..00000000000 --- a/app/controllers/projects/airflow/dags_controller.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true - -module Projects - module Airflow - class DagsController < ::Projects::ApplicationController - before_action :check_feature_flag - before_action :authorize_read_airflow_dags! - - feature_category :dataops - - MAX_DAGS_PER_PAGE = 15 - def index - page = params[:page].to_i - page = 1 if page <= 0 - - @dags = ::Airflow::Dags.by_project_id(@project.id) - - return unless @dags.any? - - @dags = @dags.page(page).per(MAX_DAGS_PER_PAGE) - return redirect_to(url_for(page: @dags.total_pages)) if @dags.out_of_range? - - @pagination = { - page: page, - is_last_page: @dags.last_page?, - per_page: MAX_DAGS_PER_PAGE, - total_items: @dags.total_count - } - end - - private - - def check_feature_flag - render_404 unless Feature.enabled?(:airflow_dags, @project) - end - end - end -end diff --git a/app/controllers/projects/analytics/cycle_analytics/stages_controller.rb b/app/controllers/projects/analytics/cycle_analytics/stages_controller.rb index a61b774f9c8..e9477ee3221 100644 --- a/app/controllers/projects/analytics/cycle_analytics/stages_controller.rb +++ b/app/controllers/projects/analytics/cycle_analytics/stages_controller.rb @@ -20,6 +20,11 @@ class Projects::Analytics::CycleAnalytics::StagesController < Projects::Applicat @project.project_namespace end + override :all_cycle_analytics_params + def all_cycle_analytics_params + super.merge({ namespace: @project.project_namespace }) + end + override :cycle_analytics_configuration def cycle_analytics_configuration(stages) super(stages.select { |stage| permitted_stage?(stage) }) diff --git a/app/controllers/projects/analytics/cycle_analytics/summary_controller.rb b/app/controllers/projects/analytics/cycle_analytics/summary_controller.rb index 69327feeb02..96d7ad79e88 100644 --- a/app/controllers/projects/analytics/cycle_analytics/summary_controller.rb +++ b/app/controllers/projects/analytics/cycle_analytics/summary_controller.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true class Projects::Analytics::CycleAnalytics::SummaryController < Projects::ApplicationController + extend ::Gitlab::Utils::Override include CycleAnalyticsParams respond_to :json @@ -17,6 +18,11 @@ class Projects::Analytics::CycleAnalytics::SummaryController < Projects::Applica private + override :all_cycle_analytics_params + def all_cycle_analytics_params + super.merge({ namespace: @project.project_namespace }) + end + def project_level @project_level ||= Analytics::CycleAnalytics::ProjectLevel.new(project: @project, options: options(allowed_params)) end diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb index 5f8060ad756..65576bcade6 100644 --- a/app/controllers/projects/artifacts_controller.rb +++ b/app/controllers/projects/artifacts_controller.rb @@ -19,6 +19,10 @@ class Projects::ArtifactsController < Projects::ApplicationController before_action :validate_artifacts!, except: [:index, :download, :raw, :destroy] before_action :entry, only: [:external_file, :file] + before_action only: :index do + push_frontend_feature_flag(:ci_job_artifact_bulk_destroy, @project) + end + MAX_PER_PAGE = 20 feature_category :build_artifacts diff --git a/app/controllers/projects/avatars_controller.rb b/app/controllers/projects/avatars_controller.rb index 70d9b524e4d..5db7609e07a 100644 --- a/app/controllers/projects/avatars_controller.rb +++ b/app/controllers/projects/avatars_controller.rb @@ -3,8 +3,6 @@ class Projects::AvatarsController < Projects::ApplicationController include SendsBlob - skip_before_action :default_cache_headers, only: :show - before_action :authorize_admin_project!, only: [:destroy] feature_category :projects diff --git a/app/controllers/projects/badges_controller.rb b/app/controllers/projects/badges_controller.rb index dbbffc4c283..372da64cdfa 100644 --- a/app/controllers/projects/badges_controller.rb +++ b/app/controllers/projects/badges_controller.rb @@ -40,6 +40,7 @@ class Projects::BadgesController < Projects::ApplicationController .new(project, current_user, opts: { key_text: params[:key_text], key_width: params[:key_width], + value_width: params[:value_width], order_by: params[:order_by] }) diff --git a/app/controllers/projects/blame_controller.rb b/app/controllers/projects/blame_controller.rb index cfff281604e..d41b347dc5a 100644 --- a/app/controllers/projects/blame_controller.rb +++ b/app/controllers/projects/blame_controller.rb @@ -23,13 +23,47 @@ class Projects::BlameController < Projects::ApplicationController environment_params[:find_latest] = true @environment = ::Environments::EnvironmentsByDeploymentsFinder.new(@project, current_user, environment_params).execute.last - blame_service = Projects::BlameService.new(@blob, @commit, params.permit(:page, :no_pagination)) + permitted_params = params.permit(:page, :no_pagination, :streaming) + blame_service = Projects::BlameService.new(@blob, @commit, permitted_params) @blame = Gitlab::View::Presenter::Factory.new(blame_service.blame, project: @project, path: @path, page: blame_service.page).fabricate! - @blame_pagination = blame_service.pagination + @entire_blame_path = full_blame_path(no_pagination: true) + @blame_pages_url = blame_pages_url(permitted_params) + if blame_service.streaming_possible + @entire_blame_path = full_blame_path(streaming: true) + end + + @streaming_enabled = blame_service.streaming_enabled + @blame_pagination = blame_service.pagination unless @streaming_enabled @blame_per_page = blame_service.per_page + + render locals: { total_extra_pages: blame_service.total_extra_pages } + end + + def page + @blob = @repository.blob_at(@commit.id, @path) + + environment_params = @repository.branch_exists?(@ref) ? { ref: @ref } : { commit: @commit } + environment_params[:find_latest] = true + @environment = ::Environments::EnvironmentsByDeploymentsFinder.new(@project, current_user, environment_params).execute.last + + blame_service = Projects::BlameService.new(@blob, @commit, params.permit(:page, :streaming)) + + @blame = Gitlab::View::Presenter::Factory.new(blame_service.blame, project: @project, path: @path, page: blame_service.page).fabricate! + + render partial: 'page' + end + + private + + def full_blame_path(params) + namespace_project_blame_path(namespace_id: @project.namespace, project_id: @project, id: @id, **params) + end + + def blame_pages_url(params) + namespace_project_blame_page_url(namespace_id: @project.namespace, project_id: @project, id: @id, **params) end end diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index 59cea00e26b..3413aeb6f8a 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -10,7 +10,7 @@ class Projects::BlobController < Projects::ApplicationController include RedirectsForMissingPathOnTree include SourcegraphDecorator include DiffHelper - include RedisTracking + include ProductAnalyticsTracking extend ::Gitlab::Utils::Override prepend_before_action :authenticate_user!, only: [:edit] @@ -37,7 +37,11 @@ class Projects::BlobController < Projects::ApplicationController before_action :validate_diff_params, only: :diff before_action :set_last_commit_sha, only: [:edit, :update] - track_redis_hll_event :create, :update, name: 'g_edit_by_sfe' + track_event :create, :update, + name: 'g_edit_by_sfe', + action: 'perform_sfe_action', + label: 'usage_activity_by_stage_monthly.create.action_monthly_active_users_sfe_edit', + destinations: [:redis_hll, :snowplow] feature_category :source_code_management urgency :low, [:create, :show, :edit, :update, :diff] @@ -53,10 +57,13 @@ class Projects::BlobController < Projects::ApplicationController end def create - create_commit(Files::CreateService, success_notice: _("The file has been successfully created."), - success_path: -> { project_blob_path(@project, File.join(@branch_name, @file_path)) }, - failure_view: :new, - failure_path: project_new_blob_path(@project, @ref)) + create_commit( + Files::CreateService, + success_notice: _("The file has been successfully created."), + success_path: -> { project_blob_path(@project, File.join(@branch_name, @file_path)) }, + failure_view: :new, + failure_path: project_new_blob_path(@project, @ref) + ) end def show @@ -86,9 +93,11 @@ class Projects::BlobController < Projects::ApplicationController def update @path = params[:file_path] if params[:file_path].present? - create_commit(Files::UpdateService, success_path: -> { after_edit_path }, - failure_view: :edit, - failure_path: project_blob_path(@project, @id)) + create_commit( + Files::UpdateService, success_path: -> { after_edit_path }, + failure_view: :edit, + failure_path: project_blob_path(@project, @id) + ) rescue Files::UpdateService::FileChangedError @conflict = true render :edit @@ -106,9 +115,12 @@ class Projects::BlobController < Projects::ApplicationController end def destroy - create_commit(Files::DeleteService, success_notice: _("The file has been successfully deleted."), - success_path: -> { after_delete_path }, - failure_path: project_blob_path(@project, @id)) + create_commit( + Files::DeleteService, + success_notice: _("The file has been successfully deleted."), + success_path: -> { after_delete_path }, + failure_path: project_blob_path(@project, @id) + ) end def diff @@ -308,6 +320,12 @@ class Projects::BlobController < Projects::ApplicationController file = file.cdn_enabled_url(request.remote_ip) if file.respond_to?(:cdn_enabled_url) file.url end + + alias_method :tracking_project_source, :project + + def tracking_namespace_source + project&.namespace + end end Projects::BlobController.prepend_mod diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index f19f143816f..1e17dd586c7 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -98,7 +98,7 @@ class Projects::BranchesController < Projects::ApplicationController if success render json: { name: branch_name, url: project_tree_url(@project, branch_name) } else - render json: result[:messsage], status: :unprocessable_entity + render json: result[:message], status: :unprocessable_entity end end end diff --git a/app/controllers/projects/ci/lints_controller.rb b/app/controllers/projects/ci/lints_controller.rb index 7ef5016ac00..6762f1c7110 100644 --- a/app/controllers/projects/ci/lints_controller.rb +++ b/app/controllers/projects/ci/lints_controller.rb @@ -3,7 +3,7 @@ class Projects::Ci::LintsController < Projects::ApplicationController before_action :authorize_create_pipeline! - feature_category :pipeline_authoring + feature_category :pipeline_composition respond_to :json, only: [:create] urgency :low, [:create] diff --git a/app/controllers/projects/ci/pipeline_editor_controller.rb b/app/controllers/projects/ci/pipeline_editor_controller.rb index 3a2bc445737..45584f3048a 100644 --- a/app/controllers/projects/ci/pipeline_editor_controller.rb +++ b/app/controllers/projects/ci/pipeline_editor_controller.rb @@ -6,7 +6,7 @@ class Projects::Ci::PipelineEditorController < Projects::ApplicationController push_frontend_feature_flag(:ci_job_assistant_drawer, @project) end - feature_category :pipeline_authoring + feature_category :pipeline_composition urgency :low, [:show] diff --git a/app/controllers/projects/ci/prometheus_metrics/histograms_controller.rb b/app/controllers/projects/ci/prometheus_metrics/histograms_controller.rb index 003441d4b91..72a07269d79 100644 --- a/app/controllers/projects/ci/prometheus_metrics/histograms_controller.rb +++ b/app/controllers/projects/ci/prometheus_metrics/histograms_controller.rb @@ -4,7 +4,7 @@ module Projects module Ci module PrometheusMetrics class HistogramsController < Projects::ApplicationController - feature_category :pipeline_authoring + feature_category :pipeline_composition respond_to :json, only: [:create] diff --git a/app/controllers/projects/cluster_agents_controller.rb b/app/controllers/projects/cluster_agents_controller.rb index 3f759e5c18c..e0c9763abb6 100644 --- a/app/controllers/projects/cluster_agents_controller.rb +++ b/app/controllers/projects/cluster_agents_controller.rb @@ -1,7 +1,10 @@ # frozen_string_literal: true class Projects::ClusterAgentsController < Projects::ApplicationController + include KasCookie + before_action :authorize_can_read_cluster_agent! + before_action :set_kas_cookie, only: [:show], if: -> { current_user } feature_category :kubernetes_management urgency :low diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index 252b203b38a..a86a0fb3bd2 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -115,8 +115,12 @@ class Projects::CommitController < Projects::ApplicationController @branch_name = create_new_branch? ? @commit.revert_branch_name : @start_branch - create_commit(Commits::RevertService, success_notice: "The #{@commit.change_type_title(current_user)} has been successfully reverted.", - success_path: -> { successful_change_path(@project) }, failure_path: failed_change_path) + create_commit( + Commits::RevertService, + success_notice: "The #{@commit.change_type_title(current_user)} has been successfully reverted.", + success_path: -> { successful_change_path(@project) }, + failure_path: failed_change_path + ) end def cherry_pick @@ -131,10 +135,13 @@ class Projects::CommitController < Projects::ApplicationController @branch_name = create_new_branch? ? @commit.cherry_pick_branch_name : @start_branch - create_commit(Commits::CherryPickService, success_notice: "The #{@commit.change_type_title(current_user)} has been successfully cherry-picked into #{@branch_name}.", - success_path: -> { successful_change_path(target_project) }, - failure_path: failed_change_path, - target_project: target_project) + create_commit( + Commits::CherryPickService, + success_notice: "The #{@commit.change_type_title(current_user)} has been successfully cherry-picked into #{@branch_name}.", + success_path: -> { successful_change_path(target_project) }, + failure_path: failed_change_path, + target_project: target_project + ) end private diff --git a/app/controllers/projects/commits_controller.rb b/app/controllers/projects/commits_controller.rb index 3acc71d5dd3..c2f1d1ed362 100644 --- a/app/controllers/projects/commits_controller.rb +++ b/app/controllers/projects/commits_controller.rb @@ -7,7 +7,6 @@ class Projects::CommitsController < Projects::ApplicationController include RendersCommits COMMITS_DEFAULT_LIMIT = 40 - prepend_before_action(only: [:show]) { authenticate_sessionless_user!(:rss) } around_action :allow_gitaly_ref_name_caching before_action :require_non_empty_project @@ -77,15 +76,22 @@ class Projects::CommitsController < Projects::ApplicationController # fully_qualified_ref is available in some situations from ExtractsRef ref = @fully_qualified_ref || @ref + @commits = if search.present? @repository.find_commits_by_message(search, ref, @path, @limit, @offset) - elsif author.present? - @repository.commits(ref, author: author, path: @path, limit: @limit, offset: @offset) else - @repository.commits(ref, path: @path, limit: @limit, offset: @offset) + options = { + path: @path, + limit: @limit, + offset: @offset + } + options[:author] = author if author.present? + + @repository.commits(ref, **options) end + @commits.load_tags if Feature.enabled?(:show_tags_on_commits_view, @project) @commits.each(&:lazy_author) # preload authors @commits = @commits.with_markdown_cache.with_latest_pipeline(ref) diff --git a/app/controllers/projects/cycle_analytics_controller.rb b/app/controllers/projects/cycle_analytics_controller.rb index 9fe44659250..dbed5adf2e8 100644 --- a/app/controllers/projects/cycle_analytics_controller.rb +++ b/app/controllers/projects/cycle_analytics_controller.rb @@ -11,7 +11,7 @@ class Projects::CycleAnalyticsController < Projects::ApplicationController before_action :authorize_read_cycle_analytics! before_action :load_value_stream, only: :show - track_custom_event :show, + track_event :show, name: 'p_analytics_valuestream', action: 'perform_analytics_usage_action', label: 'redis_hll_counters.analytics.analytics_total_unique_counts_monthly', @@ -22,6 +22,8 @@ class Projects::CycleAnalyticsController < Projects::ApplicationController before_action do push_licensed_feature(:cycle_analytics_for_groups) if project.licensed_feature_available?(:cycle_analytics_for_groups) + push_licensed_feature(:group_level_analytics_dashboard) if project.licensed_feature_available?(:group_level_analytics_dashboard) + push_frontend_feature_flag(:group_analytics_dashboards_page, @project.namespace) end def show @@ -44,7 +46,7 @@ class Projects::CycleAnalyticsController < Projects::ApplicationController override :all_cycle_analytics_params def all_cycle_analytics_params - super.merge({ project: @project, value_stream: @value_stream }) + super.merge({ namespace: @project.project_namespace, value_stream: @value_stream }) end def load_value_stream diff --git a/app/controllers/projects/design_management/designs/raw_images_controller.rb b/app/controllers/projects/design_management/designs/raw_images_controller.rb index beb7e9d294b..ea406d2f2ef 100644 --- a/app/controllers/projects/design_management/designs/raw_images_controller.rb +++ b/app/controllers/projects/design_management/designs/raw_images_controller.rb @@ -7,8 +7,6 @@ module Projects class RawImagesController < Projects::DesignManagement::DesignsController include SendsBlob - skip_before_action :default_cache_headers, only: :show - def show blob = design_repository.blob_at(ref, design.full_path) diff --git a/app/controllers/projects/design_management/designs/resized_image_controller.rb b/app/controllers/projects/design_management/designs/resized_image_controller.rb index 6bf304419e1..a09d8a73892 100644 --- a/app/controllers/projects/design_management/designs/resized_image_controller.rb +++ b/app/controllers/projects/design_management/designs/resized_image_controller.rb @@ -10,8 +10,6 @@ module Projects before_action :validate_size! before_action :validate_sha! - skip_before_action :default_cache_headers, only: :show - def show relation = design.actions relation = relation.up_to_version(version) if version diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index 9a88a8160b6..ad498a4ac86 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -20,6 +20,10 @@ class Projects::EnvironmentsController < Projects::ApplicationController push_frontend_feature_flag(:environment_details_vue, @project) end + before_action only: [:index] do + push_frontend_feature_flag(:kas_user_access_project, @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] @@ -30,17 +34,8 @@ class Projects::EnvironmentsController < Projects::ApplicationController before_action :expire_etag_cache, only: [:index], unless: -> { request.format.json? } after_action :expire_etag_cache, only: [:cancel_auto_stop] - track_event :index, - :folder, - :show, - :new, - :edit, - :create, - :update, - :stop, - :cancel_auto_stop, - :terminal, - name: 'users_visiting_environments_pages' + track_event :index, :folder, :show, :new, :edit, :create, :update, :stop, :cancel_auto_stop, :terminal, + name: 'users_visiting_environments_pages' feature_category :continuous_delivery urgency :low @@ -255,11 +250,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController def search_environments(type: nil) search = params[:search] if params[:search] && params[:search].length >= MIN_SEARCH_LENGTH - @search_environments ||= - Environments::EnvironmentsFinder.new(project, - current_user, - type: type, - search: search).execute + @search_environments ||= Environments::EnvironmentsFinder.new(project, current_user, type: type, search: search).execute end def metrics_params @@ -301,16 +292,6 @@ class Projects::EnvironmentsController < Projects::ApplicationController def authorize_update_environment! access_denied! unless can?(current_user, :update_environment, environment) end - - def append_info_to_payload(payload) - super - - return unless Feature.enabled?(:environments_search_logging) && params[:search].present? - - # Merging to :metadata will ensure these are logged as top level keys - payload[:metadata] ||= {} - payload[:metadata]['meta.environment.search'] = params[:search] - end end Projects::EnvironmentsController.prepend_mod_with('Projects::EnvironmentsController') diff --git a/app/controllers/projects/error_tracking_controller.rb b/app/controllers/projects/error_tracking_controller.rb index d2e36ef5496..d70ee0fabea 100644 --- a/app/controllers/projects/error_tracking_controller.rb +++ b/app/controllers/projects/error_tracking_controller.rb @@ -74,8 +74,7 @@ class Projects::ErrorTrackingController < Projects::ErrorTracking::BaseControlle def render_errors(result) unless result[:status] == :success - render json: { message: result[:message] }, - status: result[:http_status] || :bad_request + render json: { message: result[:message] }, status: result[:http_status] || :bad_request end end diff --git a/app/controllers/projects/feature_flags_controller.rb b/app/controllers/projects/feature_flags_controller.rb index 16392775c09..83923965a45 100644 --- a/app/controllers/projects/feature_flags_controller.rb +++ b/app/controllers/projects/feature_flags_controller.rb @@ -97,23 +97,45 @@ class Projects::FeatureFlagsController < Projects::ApplicationController end def create_params - params.require(:operations_feature_flag) - .permit(:name, :description, :active, :version, - scopes_attributes: [:environment_scope, :active, - strategies: [:name, parameters: [:groupId, :percentage, :userIds]]], - strategies_attributes: [:name, :user_list_id, - parameters: [:groupId, :percentage, :userIds, :rollout, :stickiness], - scopes_attributes: [:environment_scope]]) + params.require(:operations_feature_flag).permit( + :name, + :description, + :active, + :version, + scopes_attributes: [ + :environment_scope, :active, + strategies: [:name, parameters: [:groupId, :percentage, :userIds]] + ], + strategies_attributes: [ + :name, + :user_list_id, + parameters: [:groupId, :percentage, :userIds, :rollout, :stickiness], + scopes_attributes: [:environment_scope] + ] + ) end def update_params - params.require(:operations_feature_flag) - .permit(:name, :description, :active, - scopes_attributes: [:id, :environment_scope, :active, :_destroy, - strategies: [:name, parameters: [:groupId, :percentage, :userIds]]], - strategies_attributes: [:id, :name, :user_list_id, :_destroy, - parameters: [:groupId, :percentage, :userIds, :rollout, :stickiness], - scopes_attributes: [:id, :environment_scope, :_destroy]]) + params.require(:operations_feature_flag).permit( + :name, + :description, + :active, + scopes_attributes: [ + :id, + :environment_scope, + :active, + :_destroy, + strategies: [:name, parameters: [:groupId, :percentage, :userIds]] + ], + strategies_attributes: [ + :id, + :name, + :user_list_id, + :_destroy, + parameters: [:groupId, :percentage, :userIds, :rollout, :stickiness], + scopes_attributes: [:id, :environment_scope, :_destroy] + ] + ) end def feature_flag_json(feature_flag) @@ -144,7 +166,6 @@ class Projects::FeatureFlagsController < Projects::ApplicationController end def render_error_json(messages, status = :bad_request) - render json: { message: messages }, - status: status + render json: { message: messages }, status: status end end diff --git a/app/controllers/projects/google_cloud/base_controller.rb b/app/controllers/projects/google_cloud/base_controller.rb index dfb73821b0f..7eccc0c1c77 100644 --- a/app/controllers/projects/google_cloud/base_controller.rb +++ b/app/controllers/projects/google_cloud/base_controller.rb @@ -45,8 +45,8 @@ class Projects::GoogleCloud::BaseController < Projects::ApplicationController return_url = project_google_cloud_configuration_path(project) state = generate_session_key_redirect(request.url, return_url) @authorize_url = GoogleApi::CloudPlatform::Client.new(nil, - callback_google_api_auth_url, - state: state).authorize_url + callback_google_api_auth_url, + state: state).authorize_url redirect_to @authorize_url end diff --git a/app/controllers/projects/graphs_controller.rb b/app/controllers/projects/graphs_controller.rb index d072381933a..e73e2a38149 100644 --- a/app/controllers/projects/graphs_controller.rb +++ b/app/controllers/projects/graphs_controller.rb @@ -9,7 +9,7 @@ class Projects::GraphsController < Projects::ApplicationController before_action :assign_ref_vars before_action :authorize_read_repository_graphs! - track_custom_event :charts, + track_event :charts, name: 'p_analytics_repo', action: 'perform_analytics_usage_action', label: 'redis_hll_counters.analytics.analytics_total_unique_counts_monthly', diff --git a/app/controllers/projects/hooks_controller.rb b/app/controllers/projects/hooks_controller.rb index 22b6bf6faf0..4dcc9a3a43f 100644 --- a/app/controllers/projects/hooks_controller.rb +++ b/app/controllers/projects/hooks_controller.rb @@ -4,7 +4,8 @@ class Projects::HooksController < Projects::ApplicationController include ::WebHooks::HookActions # Authorize - before_action :authorize_admin_project! + before_action :authorize_admin_project!, except: :destroy + before_action :authorize_destroy_project_hook!, only: :destroy before_action :hook_logs, only: :edit before_action -> { check_rate_limit!(:project_testing_hook, scope: [@project, current_user]) }, only: :test @@ -41,4 +42,8 @@ class Projects::HooksController < Projects::ApplicationController def trigger_values ProjectHook.triggers.values end + + def authorize_destroy_project_hook! + render_404 unless can?(current_user, :destroy_web_hook, hook) + end end diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 21227d62023..6e38de8b0ea 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -21,6 +21,7 @@ class Projects::IssuesController < Projects::ApplicationController before_action :check_issues_available! before_action :issue, 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) } + before_action :require_incident_for_incident_routes, only: :show after_action :log_issue_show, only: :show @@ -47,6 +48,7 @@ class Projects::IssuesController < Projects::ApplicationController push_frontend_feature_flag(:preserve_unchanged_markdown, project) push_frontend_feature_flag(:content_editor_on_issues, project) push_frontend_feature_flag(:service_desk_new_note_email_native_attachments, project) + push_frontend_feature_flag(:saved_replies, current_user) end before_action only: [:index, :show] do @@ -64,7 +66,6 @@ class Projects::IssuesController < Projects::ApplicationController 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&.group) push_frontend_feature_flag(:incident_event_tags, project) end @@ -443,11 +444,16 @@ class Projects::IssuesController < Projects::ApplicationController def redirect_if_work_item return unless use_work_items_path?(issue) - 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)) - else - redirect_to project_work_items_path(project, issue.id, params: request.query_parameters) - end + redirect_to project_work_items_path(project, issue.iid, params: request.query_parameters.merge(iid_path: true)) + end + + def require_incident_for_incident_routes + return unless params[:incident_tab].present? + return if issue.incident? + + # Redirect instead of 404 to gracefully handle + # issue type changes + redirect_to project_issue_path(project, issue) end end diff --git a/app/controllers/projects/jobs_controller.rb b/app/controllers/projects/jobs_controller.rb index 3fea5c694f7..36fa1fab68f 100644 --- a/app/controllers/projects/jobs_controller.rb +++ b/app/controllers/projects/jobs_controller.rb @@ -128,8 +128,7 @@ class Projects::JobsController < Projects::ApplicationController service_response = Ci::BuildEraseService.new(@build, current_user).execute if service_response.success? - redirect_to project_job_path(project, @build), - notice: _("Job has been successfully erased!") + redirect_to project_job_path(project, @build), notice: _("Job has been successfully erased!") else head service_response.http_status end @@ -138,9 +137,7 @@ class Projects::JobsController < Projects::ApplicationController def raw if @build.trace.archived? workhorse_set_content_type! - send_upload(@build.job_artifacts_trace.file, - send_params: raw_send_params, - redirect_params: raw_redirect_params) + send_upload(@build.job_artifacts_trace.file, send_params: raw_send_params, redirect_params: raw_redirect_params) else @build.trace.read do |stream| if stream.file? @@ -234,10 +231,12 @@ class Projects::JobsController < Projects::ApplicationController end def build_service_specification - @build.service_specification(service: params['service'], - port: params['port'], - path: params['path'], - subprotocols: proxy_subprotocol) + @build.service_specification( + service: params['service'], + port: params['port'], + path: params['path'], + subprotocols: proxy_subprotocol + ) end def proxy_subprotocol diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index 14f2e372bc5..649bead0b6d 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -82,9 +82,7 @@ class Projects::LabelsController < Projects::ApplicationController @label.destroy @labels = find_labels - redirect_to project_labels_path(@project), - status: :found, - notice: 'Label was removed' + redirect_to project_labels_path(@project), status: :found, notice: 'Label was removed' end def remove_priority @@ -138,8 +136,9 @@ class Projects::LabelsController < Projects::ApplicationController respond_to do |format| format.html do - redirect_to(project_labels_path(@project), - notice: _('Failed to promote label due to internal error. Please contact administrators.')) + redirect_to( + project_labels_path(@project), + notice: _('Failed to promote label due to internal error. Please contact administrators.')) end format.js end @@ -165,13 +164,14 @@ class Projects::LabelsController < Projects::ApplicationController end def find_labels - @available_labels ||= - LabelsFinder.new(current_user, - project_id: @project.id, - include_ancestor_groups: true, - search: params[:search], - subscribed: params[:subscribed], - sort: sort).execute + @available_labels ||= LabelsFinder.new( + current_user, + project_id: @project.id, + include_ancestor_groups: true, + search: params[:search], + subscribed: params[:subscribed], + sort: sort + ).execute end def sort diff --git a/app/controllers/projects/merge_requests/creations_controller.rb b/app/controllers/projects/merge_requests/creations_controller.rb index 3b399e3294e..3a03831ab88 100644 --- a/app/controllers/projects/merge_requests/creations_controller.rb +++ b/app/controllers/projects/merge_requests/creations_controller.rb @@ -114,11 +114,10 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap @target_project = @merge_request.target_project @source_project = @merge_request.source_project - @commits = - set_commits_for_rendering( - @merge_request.recent_commits.with_latest_pipeline(@merge_request.source_branch), - commits_count: @merge_request.commits_count - ) + @commits = set_commits_for_rendering( + @merge_request.recent_commits.with_latest_pipeline(@merge_request.source_branch), + commits_count: @merge_request.commits_count + ) @commit = @merge_request.diff_head_commit diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index d92ef3de6d9..a204023e34d 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -33,6 +33,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo before_action :check_user_can_push_to_source_branch!, only: [:rebase] before_action only: [:show, :diffs] do + push_frontend_feature_flag(:content_editor_on_issues, project) 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,10 +41,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo push_frontend_feature_flag(:moved_mr_sidebar, project) push_frontend_feature_flag(:mr_experience_survey, 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) + push_frontend_feature_flag(:saved_replies, current_user) end around_action :allow_gitaly_ref_name_caching, only: [:index, :show, :diffs, :discussions] @@ -383,10 +381,12 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo @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]) + 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 @@ -485,8 +485,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo AutoMergeService.new(project, current_user, merge_params).update(merge_request) else AutoMergeService.new(project, current_user, merge_params) - .execute(merge_request, - params[:auto_merge_strategy] || AutoMergeService::STRATEGY_MERGE_WHEN_PIPELINE_SUCCEEDS) + .execute(merge_request, params[:auto_merge_strategy] || AutoMergeService::STRATEGY_MERGE_WHEN_PIPELINE_SUCCEEDS) end else @merge_request.merge_async(current_user.id, merge_params) diff --git a/app/controllers/projects/pages_controller.rb b/app/controllers/projects/pages_controller.rb index db0762a6cff..13c2a3ab750 100644 --- a/app/controllers/projects/pages_controller.rb +++ b/app/controllers/projects/pages_controller.rb @@ -43,9 +43,7 @@ class Projects::PagesController < Projects::ApplicationController respond_to do |format| format.html do - redirect_to project_pages_path(@project), - status: :found, - notice: 'Pages were scheduled for removal' + redirect_to project_pages_path(@project), status: :found, notice: 'Pages were scheduled for removal' end end end @@ -77,7 +75,15 @@ class Projects::PagesController < Projects::ApplicationController end def project_params_attributes - %i[pages_https_only] + attributes = %i[pages_https_only] + + return attributes unless Feature.enabled?(:pages_unique_domain) + + attributes + [ + project_setting_attributes: [ + :pages_unique_domain_enabled + ] + ] end end diff --git a/app/controllers/projects/pages_domains_controller.rb b/app/controllers/projects/pages_domains_controller.rb index 43952a2efe4..5cb69e8bf99 100644 --- a/app/controllers/projects/pages_domains_controller.rb +++ b/app/controllers/projects/pages_domains_controller.rb @@ -69,9 +69,7 @@ class Projects::PagesDomainsController < Projects::ApplicationController respond_to do |format| format.html do - redirect_to project_pages_path(@project), - status: :found, - notice: 'Domain was removed' + redirect_to project_pages_path(@project), status: :found, notice: 'Domain was removed' end format.js end diff --git a/app/controllers/projects/pipeline_schedules_controller.rb b/app/controllers/projects/pipeline_schedules_controller.rb index 19d031bd59b..fb332fec3b5 100644 --- a/app/controllers/projects/pipeline_schedules_controller.rb +++ b/app/controllers/projects/pipeline_schedules_controller.rb @@ -8,8 +8,7 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController before_action :authorize_read_pipeline_schedule! before_action :authorize_create_pipeline_schedule!, only: [:new, :create] before_action :authorize_update_pipeline_schedule!, only: [:edit, :update] - before_action :authorize_take_ownership_pipeline_schedule!, only: [:take_ownership] - before_action :authorize_admin_pipeline_schedule!, only: [:destroy] + before_action :authorize_admin_pipeline_schedule!, only: [:take_ownership, :destroy] before_action :push_schedule_feature_flag, only: [:index, :new, :edit] feature_category :continuous_integration @@ -78,9 +77,7 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController if schedule.destroy redirect_to pipeline_schedules_path(@project), status: :found else - redirect_to pipeline_schedules_path(@project), - status: :forbidden, - alert: _("Failed to remove the pipeline schedule") + redirect_to pipeline_schedules_path(@project), status: :forbidden, alert: _("Failed to remove the pipeline schedule") end end @@ -113,10 +110,6 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController return access_denied! unless can?(current_user, :update_pipeline_schedule, schedule) end - def authorize_take_ownership_pipeline_schedule! - return access_denied! unless can?(current_user, :take_ownership_pipeline_schedule, schedule) - end - def authorize_admin_pipeline_schedule! return access_denied! unless can?(current_user, :admin_pipeline_schedule, schedule) end diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index 10f58a9f479..6fdd4906613 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -22,13 +22,14 @@ class Projects::PipelinesController < Projects::ApplicationController before_action :authorize_update_pipeline!, only: [:retry, :cancel] before_action :ensure_pipeline, only: [:show, :downloadable_artifacts] before_action :reject_if_build_artifacts_size_refreshing!, only: [:destroy] + before_action :push_frontend_feature_flags, only: [:show] # 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? } around_action :allow_gitaly_ref_name_caching, only: [:index, :show] - track_custom_event :charts, + track_event :charts, name: 'p_analytics_pipelines', action: 'perform_analytics_usage_action', label: 'redis_hll_counters.analytics.analytics_total_unique_counts_monthly', @@ -98,15 +99,15 @@ class Projects::PipelinesController < Projects::ApplicationController end format.json do if service_response.success? - render json: PipelineSerializer - .new(project: project, current_user: current_user) - .represent(@pipeline), - status: :created + render json: PipelineSerializer.new(project: project, current_user: current_user).represent(@pipeline), + status: :created else - render json: { errors: @pipeline.error_messages.map(&:content), - warnings: @pipeline.warning_messages(limit: ::Gitlab::Ci::Warnings::MAX_LIMIT).map(&:content), - total_warnings: @pipeline.warning_messages.length }, - status: :bad_request + bad_request_json = { + errors: @pipeline.error_messages.map(&:content), + warnings: @pipeline.warning_messages(limit: ::Gitlab::Ci::Warnings::MAX_LIMIT).map(&:content), + total_warnings: @pipeline.warning_messages.length + } + render json: bad_request_json, status: :bad_request end end end @@ -241,7 +242,12 @@ class Projects::PipelinesController < Projects::ApplicationController PipelineSerializer .new(project: @project, current_user: @current_user) .with_pagination(request, response) - .represent(@pipelines, disable_coverage: true, preload: true) + .represent( + @pipelines, + disable_coverage: true, + preload: true, + disable_manual_and_scheduled_actions: Feature.enabled?(:lazy_load_pipeline_dropdown_actions, @project) + ) end def render_show @@ -364,6 +370,10 @@ class Projects::PipelinesController < Projects::ApplicationController def tracking_project_source project end + + def push_frontend_feature_flags + push_frontend_feature_flag(:refactor_ci_minutes_consumption, @project) + end end Projects::PipelinesController.prepend_mod_with('Projects::PipelinesController') diff --git a/app/controllers/projects/prometheus/metrics_controller.rb b/app/controllers/projects/prometheus/metrics_controller.rb index db5471ea322..c20c80ba334 100644 --- a/app/controllers/projects/prometheus/metrics_controller.rb +++ b/app/controllers/projects/prometheus/metrics_controller.rb @@ -68,7 +68,7 @@ module Projects if @metric.persisted? redirect_to edit_project_settings_integration_path(project, ::Integrations::Prometheus), - notice: _('Metric was successfully added.') + notice: _('Metric was successfully added.') else render 'new' end @@ -79,7 +79,7 @@ module Projects if @metric.update(metrics_params) redirect_to edit_project_settings_integration_path(project, ::Integrations::Prometheus), - notice: _('Metric was successfully updated.') + notice: _('Metric was successfully updated.') else render 'edit' end diff --git a/app/controllers/projects/raw_controller.rb b/app/controllers/projects/raw_controller.rb index 895a9a00624..79b5990abba 100644 --- a/app/controllers/projects/raw_controller.rb +++ b/app/controllers/projects/raw_controller.rb @@ -6,8 +6,6 @@ class Projects::RawController < Projects::ApplicationController include SendsBlob include StaticObjectExternalStorage - skip_before_action :default_cache_headers, only: :show - prepend_before_action(only: [:show]) { authenticate_sessionless_user!(:blob) } before_action :assign_ref_vars diff --git a/app/controllers/projects/repositories_controller.rb b/app/controllers/projects/repositories_controller.rb index 1cd4c5b6137..80bc92c0b69 100644 --- a/app/controllers/projects/repositories_controller.rb +++ b/app/controllers/projects/repositories_controller.rb @@ -8,8 +8,6 @@ class Projects::RepositoriesController < Projects::ApplicationController prepend_before_action(only: [:archive]) { authenticate_sessionless_user!(:archive) } - skip_before_action :default_cache_headers, only: :archive - # Authorize before_action :check_archive_rate_limiting!, only: :archive before_action :require_non_empty_project, except: :create @@ -49,9 +47,14 @@ class Projects::RepositoriesController < Projects::ApplicationController def set_cache_headers commit_id = archive_metadata['CommitId'] - expires_in(cache_max_age(commit_id), - public: Guest.can?(:download_code, project), must_revalidate: true, stale_if_error: 5.minutes, - stale_while_revalidate: 1.minute, 's-maxage': 1.minute) + expires_in( + cache_max_age(commit_id), + public: Guest.can?(:download_code, project), + must_revalidate: true, + stale_if_error: 5.minutes, + stale_while_revalidate: 1.minute, + 's-maxage': 1.minute + ) fresh_when(strong_etag: [commit_id, archive_metadata['ArchivePath']]) end diff --git a/app/controllers/projects/security/configuration_controller.rb b/app/controllers/projects/security/configuration_controller.rb index 00a2a5d1193..ee2e60b5a1a 100644 --- a/app/controllers/projects/security/configuration_controller.rb +++ b/app/controllers/projects/security/configuration_controller.rb @@ -32,9 +32,7 @@ module Projects end def configuration_presenter - ::Projects::Security::ConfigurationPresenter.new(project, - **presenter_attributes, - current_user: current_user) + ::Projects::Security::ConfigurationPresenter.new(project, **presenter_attributes, current_user: current_user) end def presenter_attributes diff --git a/app/controllers/projects/settings/access_tokens_controller.rb b/app/controllers/projects/settings/access_tokens_controller.rb index 0884816ef62..af1527ba6a3 100644 --- a/app/controllers/projects/settings/access_tokens_controller.rb +++ b/app/controllers/projects/settings/access_tokens_controller.rb @@ -7,7 +7,7 @@ module Projects include AccessTokensActions layout 'project_settings' - feature_category :authentication_and_authorization + feature_category :system_access alias_method :resource, :project diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb index 4ca665679c0..f5588a35ad5 100644 --- a/app/controllers/projects/settings/ci_cd_controller.rb +++ b/app/controllers/projects/settings/ci_cd_controller.rb @@ -13,7 +13,7 @@ module Projects before_action :define_variables before_action do - push_frontend_feature_flag(:ci_inbound_job_token_scope, @project) + push_frontend_feature_flag(:ci_variables_pages, current_user) end helper_method :highlight_badge diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb index 737a6290431..ba18a2e0dce 100644 --- a/app/controllers/projects/tree_controller.rb +++ b/app/controllers/projects/tree_controller.rb @@ -40,9 +40,12 @@ class Projects::TreeController < Projects::ApplicationController def create_dir return render_404 unless @commit_params.values.all? - create_commit(Files::CreateDirService, success_notice: _("The directory has been successfully created."), - success_path: project_tree_path(@project, File.join(@branch_name, @dir_name)), - failure_path: project_tree_path(@project, @ref)) + create_commit( + Files::CreateDirService, + success_notice: _("The directory has been successfully created."), + success_path: project_tree_path(@project, File.join(@branch_name, @dir_name)), + failure_path: project_tree_path(@project, @ref) + ) end private diff --git a/app/controllers/projects/variables_controller.rb b/app/controllers/projects/variables_controller.rb index a83ccccbeae..e50ddf75183 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 :pipeline_authoring + feature_category :pipeline_composition urgency :low, [:show, :update] diff --git a/app/controllers/projects/web_ide_terminals_controller.rb b/app/controllers/projects/web_ide_terminals_controller.rb index cfccc949244..be7423e3919 100644 --- a/app/controllers/projects/web_ide_terminals_controller.rb +++ b/app/controllers/projects/web_ide_terminals_controller.rb @@ -29,10 +29,7 @@ class Projects::WebIdeTerminalsController < Projects::ApplicationController end def create - result = ::Ci::CreateWebIdeTerminalService.new(project, - current_user, - ref: params[:branch]) - .execute + result = ::Ci::CreateWebIdeTerminalService.new(project, current_user, ref: params[:branch]).execute if result[:status] == :error render status: :bad_request, json: result[:message] diff --git a/app/controllers/projects/work_items_controller.rb b/app/controllers/projects/work_items_controller.rb index db9dca14aab..34a71dbbb91 100644 --- a/app/controllers/projects/work_items_controller.rb +++ b/app/controllers/projects/work_items_controller.rb @@ -5,7 +5,7 @@ class Projects::WorkItemsController < Projects::ApplicationController 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&.group) + push_force_frontend_feature_flag(:saved_replies, current_user) end feature_category :team_planning |