diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /app/controllers/projects | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) | |
download | gitlab-ce-e8d2c2579383897a1dd7f9debd359abe8ae8373d.tar.gz |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'app/controllers/projects')
31 files changed, 121 insertions, 99 deletions
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| |