diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-18 13:50:51 +0300 |
commit | db384e6b19af03b4c3c82a5760d83a3fd79f7982 (patch) | |
tree | 34beaef37df5f47ccbcf5729d7583aae093cffa0 /app/controllers/projects | |
parent | 54fd7b1bad233e3944434da91d257fa7f63c3996 (diff) |
Add latest changes from gitlab-org/gitlab@16-3-stable-eev16.3.0-rc42
Diffstat (limited to 'app/controllers/projects')
15 files changed, 52 insertions, 231 deletions
diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index b41e4d11d24..56e4b22ded2 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -48,7 +48,6 @@ class Projects::BlobController < Projects::ApplicationController urgency :low, [:create, :show, :edit, :update, :diff] before_action do - push_frontend_feature_flag(:highlight_js, @project) push_frontend_feature_flag(:highlight_js_worker, @project) push_frontend_feature_flag(:explain_code_chat, current_user) push_licensed_feature(:file_locks) if @project.licensed_feature_available?(:file_locks) @@ -275,8 +274,6 @@ class Projects::BlobController < Projects::ApplicationController @last_commit = @repository.last_commit_for_path(@commit.id, @blob.path, literal_pathspec: true) @code_navigation_path = Gitlab::CodeNavigationPath.new(@project, @blob.commit_id).full_json_path_for(@blob.path) - allow_lfs_direct_download - render 'show' end @@ -321,30 +318,6 @@ class Projects::BlobController < Projects::ApplicationController current_user&.id end - def allow_lfs_direct_download - return unless directly_downloading_lfs_object? && content_security_policy_enabled? - return unless (lfs_object = @project.lfs_objects.find_by_oid(@blob.lfs_oid)) - - request.content_security_policy.directives['connect-src'] ||= [] - request.content_security_policy.directives['connect-src'] << lfs_src(lfs_object) - end - - def directly_downloading_lfs_object? - Gitlab.config.lfs.enabled && - !Gitlab.config.lfs.object_store.proxy_download && - @blob&.stored_externally? - end - - def content_security_policy_enabled? - Gitlab.config.gitlab.content_security_policy.enabled - end - - def lfs_src(lfs_object) - file = lfs_object.file - 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 diff --git a/app/controllers/projects/ci/daily_build_group_report_results_controller.rb b/app/controllers/projects/ci/daily_build_group_report_results_controller.rb index 37138afc719..c1d325d8998 100644 --- a/app/controllers/projects/ci/daily_build_group_report_results_controller.rb +++ b/app/controllers/projects/ci/daily_build_group_report_results_controller.rb @@ -20,7 +20,7 @@ class Projects::Ci::DailyBuildGroupReportResultsController < Projects::Applicati end def render_csv(collection) - CsvBuilders::SingleBatch.new( + CsvBuilder::SingleBatch.new( collection, { date: 'date', diff --git a/app/controllers/projects/ci/pipeline_editor_controller.rb b/app/controllers/projects/ci/pipeline_editor_controller.rb index 8499bf0ced7..6e7f764c5c1 100644 --- a/app/controllers/projects/ci/pipeline_editor_controller.rb +++ b/app/controllers/projects/ci/pipeline_editor_controller.rb @@ -21,3 +21,5 @@ class Projects::Ci::PipelineEditorController < Projects::ApplicationController render_404 unless can_collaborate_with_project?(@project) end end + +Projects::Ci::PipelineEditorController.prepend_mod diff --git a/app/controllers/projects/discussions_controller.rb b/app/controllers/projects/discussions_controller.rb index 59de4fbb698..34b283b87f5 100644 --- a/app/controllers/projects/discussions_controller.rb +++ b/app/controllers/projects/discussions_controller.rb @@ -4,8 +4,8 @@ class Projects::DiscussionsController < Projects::ApplicationController include NotesHelper include RendersNotes - before_action :check_merge_requests_available! - before_action :merge_request + before_action :check_noteable_supports_resolvable_notes! + before_action :noteable before_action :discussion, only: [:resolve, :unresolve] before_action :authorize_resolve_discussion!, only: [:resolve, :unresolve] @@ -56,13 +56,26 @@ class Projects::DiscussionsController < Projects::ApplicationController end # rubocop: disable CodeReuse/ActiveRecord - def merge_request - @merge_request ||= MergeRequestsFinder.new(current_user, project_id: @project.id).find_by!(iid: params[:merge_request_id]) + def noteable + @noteable ||= noteable_finder_class.new(current_user, project_id: @project.id).find_by!(iid: params[:noteable_id]) end # rubocop: enable CodeReuse/ActiveRecord + def noteable_finder_class + case params[:noteable_type] + when 'issues' + IssuesFinder + when 'merge_requests' + MergeRequestsFinder + end + end + + def check_noteable_supports_resolvable_notes! + render_404 unless noteable_finder_class && noteable&.supports_resolvable_notes? + end + def discussion - @discussion ||= @merge_request.find_discussion(params[:id]) || render_404 + @discussion ||= @noteable.find_discussion(params[:id]) || render_404 end def authorize_resolve_discussion! diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index 4cc1ed092d2..127fe40b0e3 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -13,7 +13,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController end before_action only: [:index, :edit, :new] do - push_frontend_feature_flag(:kubernetes_namespace_for_environment) + push_frontend_feature_flag(:flux_resource_for_environment) end before_action :authorize_read_environment! @@ -110,10 +110,13 @@ class Projects::EnvironmentsController < Projects::ApplicationController return render_404 unless @environment.available? stop_actions = @environment.stop_with_actions!(current_user) + job = stop_actions.first if stop_actions&.count == 1 action_or_env_url = - if stop_actions&.count == 1 - polymorphic_url([project, stop_actions.first]) + if job.instance_of?(::Ci::Build) + polymorphic_url([project, job]) + elsif job.instance_of?(::Ci::Bridge) + project_pipeline_url(project, job.pipeline_id) else project_environment_url(project, @environment) end diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 05be34d63e0..83947c443f4 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -52,6 +52,7 @@ class Projects::IssuesController < Projects::ApplicationController push_frontend_feature_flag(:saved_replies, current_user) push_frontend_feature_flag(:issues_grid_view) push_frontend_feature_flag(:service_desk_ticket) + push_frontend_feature_flag(:issues_list_drawer, project) end before_action only: [:index, :show] do @@ -61,6 +62,7 @@ class Projects::IssuesController < Projects::ApplicationController before_action only: [:index, :service_desk] do push_frontend_feature_flag(:or_issuable_queries, project) push_frontend_feature_flag(:frontend_caching, project&.group) + push_frontend_feature_flag(:new_graphql_users_autocomplete, project) end before_action only: :show do @@ -71,6 +73,7 @@ class Projects::IssuesController < Projects::ApplicationController push_frontend_feature_flag(:epic_widget_edit_confirmation, project) push_frontend_feature_flag(:moved_mr_sidebar, project) push_frontend_feature_flag(:move_close_into_dropdown, project) + push_frontend_feature_flag(:action_cable_notes, project) end around_action :allow_gitaly_ref_name_caching, only: [:discussions] diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb index 649bead0b6d..67cff16a76b 100644 --- a/app/controllers/projects/labels_controller.rb +++ b/app/controllers/projects/labels_controller.rb @@ -79,10 +79,13 @@ class Projects::LabelsController < Projects::ApplicationController end def destroy - @label.destroy - @labels = find_labels - - redirect_to project_labels_path(@project), status: :found, notice: 'Label was removed' + if @label.destroy + redirect_to project_labels_path(@project), status: :found, + notice: format(_('%{label_name} was removed'), label_name: @label.name) + else + redirect_to project_labels_path(@project), status: :found, + alert: @label.errors.full_messages.to_sentence + end end def remove_priority diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb index 2172c91fc76..30168558eff 100644 --- a/app/controllers/projects/merge_requests_controller.rb +++ b/app/controllers/projects/merge_requests_controller.rb @@ -50,6 +50,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo push_frontend_feature_flag(:mr_activity_filters, current_user) push_frontend_feature_flag(:review_apps_redeploy_mr_widget, project) push_frontend_feature_flag(:ci_job_failures_in_mr, project) + push_frontend_feature_flag(:action_cable_notes, project) end before_action only: [:edit] do @@ -165,7 +166,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo pipelines: PipelineSerializer .new(project: @project, current_user: @current_user) .with_pagination(request, response) - .represent(@pipelines), + .represent(@pipelines, preload: true), count: { all: @pipelines.count } diff --git a/app/controllers/projects/metrics/dashboards/builder_controller.rb b/app/controllers/projects/metrics/dashboards/builder_controller.rb deleted file mode 100644 index 02e3afcdc80..00000000000 --- a/app/controllers/projects/metrics/dashboards/builder_controller.rb +++ /dev/null @@ -1,47 +0,0 @@ -# frozen_string_literal: true - -module Projects - module Metrics - module Dashboards - class BuilderController < Projects::ApplicationController - before_action :authorize_metrics_dashboard! - - feature_category :metrics - urgency :low - - def panel_preview - return not_found if Feature.enabled?(:remove_monitor_metrics) - - respond_to do |format| - format.json do - if rendered_panel.success? - render json: rendered_panel.payload - else - render json: { message: rendered_panel.message }, status: :unprocessable_entity - end - end - end - end - - private - - def rendered_panel - @panel_preview ||= ::Metrics::Dashboard::PanelPreviewService.new(project, panel_yaml, environment).execute - end - - def panel_yaml - params.require(:panel_yaml) - end - - def environment - @environment ||= - if params[:environment] - project.environments.find(params[:environment]) - else - project.default_environment - end - end - end - end - end -end diff --git a/app/controllers/projects/pages_controller.rb b/app/controllers/projects/pages_controller.rb index 6cfbb61fbb2..02579cd4283 100644 --- a/app/controllers/projects/pages_controller.rb +++ b/app/controllers/projects/pages_controller.rb @@ -65,15 +65,7 @@ class Projects::PagesController < Projects::ApplicationController end def project_params_attributes - attributes = %i[pages_https_only] - - return attributes unless Feature.enabled?(:pages_unique_domain, @project) - - attributes + [ - project_setting_attributes: [ - :pages_unique_domain_enabled - ] - ] + [:pages_https_only, { project_setting_attributes: [:pages_unique_domain_enabled] }] end end diff --git a/app/controllers/projects/performance_monitoring/dashboards_controller.rb b/app/controllers/projects/performance_monitoring/dashboards_controller.rb deleted file mode 100644 index 1255ec1dde2..00000000000 --- a/app/controllers/projects/performance_monitoring/dashboards_controller.rb +++ /dev/null @@ -1,114 +0,0 @@ -# frozen_string_literal: true - -module Projects - module PerformanceMonitoring - class DashboardsController < ::Projects::ApplicationController - include BlobHelper - - before_action :check_repository_available! - before_action :validate_required_params! - - rescue_from ActionController::ParameterMissing do |exception| - respond_error(http_status: :bad_request, message: _('Request parameter %{param} is missing.') % { param: exception.param }) - end - - feature_category :metrics - urgency :low - - def create - return not_found if Feature.enabled?(:remove_monitor_metrics) - - result = ::Metrics::Dashboard::CloneDashboardService.new(project, current_user, dashboard_params).execute - - if result[:status] == :success - respond_success(result) - else - respond_error(result) - end - end - - def update - return not_found if Feature.enabled?(:remove_monitor_metrics) - - result = ::Metrics::Dashboard::UpdateDashboardService.new(project, current_user, dashboard_params.merge(file_content_params)).execute - - if result[:status] == :success - respond_update_success(result) - else - respond_error(result) - end - end - - private - - def respond_success(result) - set_web_ide_link_notice(result.dig(:dashboard, :path)) - respond_to do |format| - format.json { render status: result.delete(:http_status), json: result } - end - end - - def respond_error(result) - respond_to do |format| - format.json { render json: { error: result[:message] }, status: result[:http_status] } - end - end - - def set_web_ide_link_notice(new_dashboard_path) - web_ide_link_start = "<a href=\"#{ide_edit_path(project, redirect_safe_branch_name, new_dashboard_path)}\">" - message = _("Your dashboard has been copied. You can %{web_ide_link_start}edit it here%{web_ide_link_end}.") % { web_ide_link_start: web_ide_link_start, web_ide_link_end: "</a>" } - flash[:notice] = message.html_safe - end - - def respond_update_success(result) - set_web_ide_link_update_notice(result.dig(:dashboard, :path)) - respond_to do |format| - format.json { render status: result.delete(:http_status), json: result } - end - end - - def set_web_ide_link_update_notice(new_dashboard_path) - web_ide_link_start = "<a href=\"#{ide_edit_path(project, redirect_safe_branch_name, new_dashboard_path)}\">" - message = _("Your dashboard has been updated. You can %{web_ide_link_start}edit it here%{web_ide_link_end}.") % { web_ide_link_start: web_ide_link_start, web_ide_link_end: "</a>" } - flash[:notice] = message.html_safe - end - - def validate_required_params! - params.require(%i[branch file_name dashboard commit_message]) - end - - def redirect_safe_branch_name - repository.find_branch(params[:branch]).name - end - - def dashboard_params - params.permit(%i[branch file_name dashboard commit_message]).to_h - end - - def file_content_params - params.permit( - file_content: [ - :dashboard, - panel_groups: [ - :group, - :priority, - panels: [ - :type, - :title, - :y_label, - :weight, - metrics: [ - :id, - :unit, - :label, - :query, - :query_range - ] - ] - ] - ] - ) - end - end - end -end diff --git a/app/controllers/projects/pipeline_schedules_controller.rb b/app/controllers/projects/pipeline_schedules_controller.rb index 96c9aa89953..42b6d83ee85 100644 --- a/app/controllers/projects/pipeline_schedules_controller.rb +++ b/app/controllers/projects/pipeline_schedules_controller.rb @@ -24,25 +24,13 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController end def create - if ::Feature.enabled?(:ci_refactoring_pipeline_schedule_create_service, @project) - response = Ci::PipelineSchedules::CreateService.new(@project, current_user, schedule_params).execute - @schedule = response.payload - - if response.success? - redirect_to pipeline_schedules_path(@project) - else - render :new - end + response = Ci::PipelineSchedules::CreateService.new(@project, current_user, schedule_params).execute + @schedule = response.payload + + if response.success? + redirect_to pipeline_schedules_path(@project) else - @schedule = Ci::CreatePipelineScheduleService - .new(@project, current_user, schedule_params) - .execute - - if @schedule.persisted? - redirect_to pipeline_schedules_path(@project) - else - render :new - end + render :new end end diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb index 0e892ef3faa..0845fbc9713 100644 --- a/app/controllers/projects/settings/ci_cd_controller.rb +++ b/app/controllers/projects/settings/ci_cd_controller.rb @@ -14,6 +14,7 @@ module Projects before_action do push_frontend_feature_flag(:ci_variables_pages, current_user) + push_frontend_feature_flag(:ci_variable_drawer, current_user) end helper_method :highlight_badge @@ -88,7 +89,7 @@ module Projects :build_timeout_human_readable, :public_builds, :ci_separated_caches, :auto_cancel_pending_pipelines, :ci_config_path, :auto_rollback_enabled, auto_devops_attributes: [:id, :domain, :enabled, :deploy_strategy], - ci_cd_settings_attributes: [:default_git_depth, :forward_deployment_enabled] + ci_cd_settings_attributes: [:default_git_depth, :forward_deployment_enabled, :forward_deployment_rollback_allowed] ].tap do |list| list << :max_artifacts_size if can?(current_user, :update_max_artifacts_size, project) end diff --git a/app/controllers/projects/tracing_controller.rb b/app/controllers/projects/tracing_controller.rb index d1218ebf344..45e773bf62b 100644 --- a/app/controllers/projects/tracing_controller.rb +++ b/app/controllers/projects/tracing_controller.rb @@ -10,6 +10,10 @@ module Projects def index; end + def show + @trace_id = params[:id] + end + private def check_tracing_enabled diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb index b961339111b..0371fb21ac8 100644 --- a/app/controllers/projects/tree_controller.rb +++ b/app/controllers/projects/tree_controller.rb @@ -18,7 +18,6 @@ class Projects::TreeController < Projects::ApplicationController before_action :authorize_edit_tree!, only: [:create_dir] before_action do - push_frontend_feature_flag(:highlight_js, @project) push_frontend_feature_flag(:highlight_js_worker, @project) push_frontend_feature_flag(:explain_code_chat, current_user) push_licensed_feature(:file_locks) if @project.licensed_feature_available?(:file_locks) |