diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-10 03:08:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-08-10 03:08:40 +0300 |
commit | 707312855bd32e4504638456c7043be5ca14aacd (patch) | |
tree | b86c1e7260d33d335ab720a7930d34c2ae43c8d6 /app | |
parent | 413c91fda942270905873684a58041f8c65f878c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/ci_settings_general_pipeline/index.js | 19 | ||||
-rw-r--r-- | app/assets/javascripts/pages/projects/settings/ci_cd/show/index.js | 2 | ||||
-rw-r--r-- | app/finders/admin/abuse_report_labels_finder.rb | 33 | ||||
-rw-r--r-- | app/graphql/resolvers/abuse_report_labels_resolver.rb | 19 | ||||
-rw-r--r-- | app/graphql/resolvers/abuse_report_resolver.rb | 21 | ||||
-rw-r--r-- | app/graphql/types/abuse_report_type.rb | 12 | ||||
-rw-r--r-- | app/graphql/types/query_type.rb | 12 | ||||
-rw-r--r-- | app/models/abuse_report.rb | 2 | ||||
-rw-r--r-- | app/models/admin/abuse_report_label.rb | 6 | ||||
-rw-r--r-- | app/models/application_setting.rb | 4 | ||||
-rw-r--r-- | app/policies/admin/abuse_report_label_policy.rb | 9 | ||||
-rw-r--r-- | app/validators/json_schemas/application_setting_prometheus_alert_db_indicators_settings.json | 2 |
12 files changed, 140 insertions, 1 deletions
diff --git a/app/assets/javascripts/ci_settings_general_pipeline/index.js b/app/assets/javascripts/ci_settings_general_pipeline/index.js new file mode 100644 index 00000000000..5053786fbba --- /dev/null +++ b/app/assets/javascripts/ci_settings_general_pipeline/index.js @@ -0,0 +1,19 @@ +export const initGeneralPipelinesOptions = () => { + const forwardDeploymentEnabledCheckbox = document.getElementById( + 'project_ci_cd_settings_attributes_forward_deployment_enabled', + ); + const forwardDeploymentRollbackAllowedCheckbox = document.getElementById( + 'project_ci_cd_settings_attributes_forward_deployment_rollback_allowed', + ); + + if (forwardDeploymentRollbackAllowedCheckbox && forwardDeploymentEnabledCheckbox) { + forwardDeploymentRollbackAllowedCheckbox.disabled = !forwardDeploymentEnabledCheckbox.checked; + + forwardDeploymentEnabledCheckbox.addEventListener('change', () => { + if (!forwardDeploymentEnabledCheckbox.checked) { + forwardDeploymentRollbackAllowedCheckbox.checked = false; + } + forwardDeploymentRollbackAllowedCheckbox.disabled = !forwardDeploymentEnabledCheckbox.checked; + }); + } +}; diff --git a/app/assets/javascripts/pages/projects/settings/ci_cd/show/index.js b/app/assets/javascripts/pages/projects/settings/ci_cd/show/index.js index b2681267e06..4a5d5580c08 100644 --- a/app/assets/javascripts/pages/projects/settings/ci_cd/show/index.js +++ b/app/assets/javascripts/pages/projects/settings/ci_cd/show/index.js @@ -14,6 +14,7 @@ import { initCiSecureFiles } from '~/ci_secure_files'; import initDeployTokens from '~/deploy_tokens'; import { initProjectRunners } from '~/ci/runner/project_runners'; import { initProjectRunnersRegistrationDropdown } from '~/ci/runner/project_runners/register'; +import { initGeneralPipelinesOptions } from '~/ci_settings_general_pipeline'; // Initialize expandable settings panels initSettingsPanels(); @@ -51,3 +52,4 @@ initRefSwitcherBadges(); initInstallRunner(); initTokenAccess(); initCiSecureFiles(); +initGeneralPipelinesOptions(); diff --git a/app/finders/admin/abuse_report_labels_finder.rb b/app/finders/admin/abuse_report_labels_finder.rb new file mode 100644 index 00000000000..f8ca40f77b2 --- /dev/null +++ b/app/finders/admin/abuse_report_labels_finder.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Admin + class AbuseReportLabelsFinder + def initialize(current_user, params = {}) + @current_user = current_user + @params = params + end + + def execute + return Admin::AbuseReportLabel.none unless current_user&.can_admin_all_resources? + + items = Admin::AbuseReportLabel.all + items = by_search(items) + + items.order(title: :asc) # rubocop: disable CodeReuse/ActiveRecord + end + + private + + attr_reader :current_user, :params + + def by_search(labels) + return labels unless search_term + + labels.search(search_term) + end + + def search_term + params[:search_term] + end + end +end diff --git a/app/graphql/resolvers/abuse_report_labels_resolver.rb b/app/graphql/resolvers/abuse_report_labels_resolver.rb new file mode 100644 index 00000000000..86cebe8e541 --- /dev/null +++ b/app/graphql/resolvers/abuse_report_labels_resolver.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Resolvers + class AbuseReportLabelsResolver < BaseResolver + include Gitlab::Graphql::Authorize::AuthorizeResource + + authorize :read_label + + type Types::LabelType.connection_type, null: true + + argument :search_term, GraphQL::Types::String, + required: false, + description: 'Search term to find labels with.' + + def resolve(**args) + ::Admin::AbuseReportLabelsFinder.new(context[:current_user], args).execute + end + end +end diff --git a/app/graphql/resolvers/abuse_report_resolver.rb b/app/graphql/resolvers/abuse_report_resolver.rb new file mode 100644 index 00000000000..770409601b9 --- /dev/null +++ b/app/graphql/resolvers/abuse_report_resolver.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Resolvers + class AbuseReportResolver < BaseResolver + description 'Retrieve an abuse report' + + type Types::AbuseReportType, null: true + + argument :id, Types::GlobalIDType[AbuseReport], required: true, description: 'ID of the abuse report.' + + def resolve(id:) + ::AbuseReport.find_by_id(extract_abuse_report_id(id)) + end + + private + + def extract_abuse_report_id(gid) + GitlabSchema.parse_gid(gid, expected_type: ::AbuseReport).model_id + end + end +end diff --git a/app/graphql/types/abuse_report_type.rb b/app/graphql/types/abuse_report_type.rb new file mode 100644 index 00000000000..012e709cdb5 --- /dev/null +++ b/app/graphql/types/abuse_report_type.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Types + class AbuseReportType < BaseObject + graphql_name 'AbuseReport' + description 'An abuse report' + authorize :read_abuse_report + + field :labels, ::Types::LabelType.connection_type, + null: true, description: 'Labels of the abuse report.' + end +end diff --git a/app/graphql/types/query_type.rb b/app/graphql/types/query_type.rb index b26e447f622..38b8973034d 100644 --- a/app/graphql/types/query_type.rb +++ b/app/graphql/types/query_type.rb @@ -171,6 +171,18 @@ module Types description: 'Definitions for all audit events available on the instance.', resolver: Resolvers::AuditEvents::AuditEventDefinitionsResolver + field :abuse_report, ::Types::AbuseReportType, + null: true, + alpha: { milestone: '16.3' }, + description: 'Find an abuse report.', + resolver: Resolvers::AbuseReportResolver + + field :abuse_report_labels, ::Types::LabelType.connection_type, + null: true, + alpha: { milestone: '16.3' }, + description: 'Abuse report labels.', + resolver: Resolvers::AbuseReportLabelsResolver + def design_management DesignManagementObject.new(nil) end diff --git a/app/models/abuse_report.rb b/app/models/abuse_report.rb index 210fd85ec7b..75c90d370c3 100644 --- a/app/models/abuse_report.rb +++ b/app/models/abuse_report.rb @@ -18,6 +18,8 @@ class AbuseReport < ApplicationRecord belongs_to :assignee, class_name: 'User', inverse_of: :assigned_abuse_reports has_many :events, class_name: 'ResourceEvents::AbuseReportEvent', inverse_of: :abuse_report + has_many :label_links, as: :target, inverse_of: :target + has_many :labels, through: :label_links has_many :abuse_events, class_name: 'Abuse::Event', inverse_of: :abuse_report diff --git a/app/models/admin/abuse_report_label.rb b/app/models/admin/abuse_report_label.rb new file mode 100644 index 00000000000..a2ccc8b5513 --- /dev/null +++ b/app/models/admin/abuse_report_label.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +module Admin + class AbuseReportLabel < Label + end +end diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 9824e88ca30..0f407e15fc1 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -739,6 +739,10 @@ class ApplicationSetting < MainClusterwide::ApplicationRecord validates :namespace_aggregation_schedule_lease_duration_in_seconds, numericality: { only_integer: true, greater_than: 0 } + validates :sentry_clientside_traces_sample_rate, + presence: true, + numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: 1, message: N_('must be a value between 0 and 1') } + validates :instance_level_code_suggestions_enabled, allow_nil: false, inclusion: { in: [true, false], message: N_('must be a boolean value') } diff --git a/app/policies/admin/abuse_report_label_policy.rb b/app/policies/admin/abuse_report_label_policy.rb new file mode 100644 index 00000000000..69c877c90b3 --- /dev/null +++ b/app/policies/admin/abuse_report_label_policy.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module Admin + class AbuseReportLabelPolicy < ::BasePolicy + rule { admin }.policy do + enable :read_label + end + end +end diff --git a/app/validators/json_schemas/application_setting_prometheus_alert_db_indicators_settings.json b/app/validators/json_schemas/application_setting_prometheus_alert_db_indicators_settings.json index ccd18f3d678..5e5912f6611 100644 --- a/app/validators/json_schemas/application_setting_prometheus_alert_db_indicators_settings.json +++ b/app/validators/json_schemas/application_setting_prometheus_alert_db_indicators_settings.json @@ -30,5 +30,5 @@ } } }, - "additionalProperties": false + "additionalProperties": true } |