Commit fd486c93 authored by Stan Hu's avatar Stan Hu

Merge branch '55344-add-npm-package-requests-forwarding-to-application-setting' into 'master'

Add npm_package_requests_forwarding to ApplicationSetting

See merge request gitlab-org/gitlab!25346
parents bd3f826c 281109e4
# frozen_string_literal: true
class AddNpmPackageRequestsForwardingToApplicationSettings < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_column_with_default(:application_settings, :npm_package_requests_forwarding,
:boolean,
default: false,
allow_null: false)
end
def down
remove_column(:application_settings, :npm_package_requests_forwarding)
end
end
...@@ -351,6 +351,7 @@ ActiveRecord::Schema.define(version: 2020_02_14_034836) do ...@@ -351,6 +351,7 @@ ActiveRecord::Schema.define(version: 2020_02_14_034836) do
t.boolean "prevent_merge_requests_committers_approval", default: false, null: false t.boolean "prevent_merge_requests_committers_approval", default: false, null: false
t.boolean "email_restrictions_enabled", default: false, null: false t.boolean "email_restrictions_enabled", default: false, null: false
t.text "email_restrictions" t.text "email_restrictions"
t.boolean "npm_package_requests_forwarding", default: false, null: false
t.index ["custom_project_templates_group_id"], name: "index_application_settings_on_custom_project_templates_group_id" t.index ["custom_project_templates_group_id"], name: "index_application_settings_on_custom_project_templates_group_id"
t.index ["file_template_project_id"], name: "index_application_settings_on_file_template_project_id" t.index ["file_template_project_id"], name: "index_application_settings_on_file_template_project_id"
t.index ["instance_administration_project_id"], name: "index_applicationsettings_on_instance_administration_project_id" t.index ["instance_administration_project_id"], name: "index_applicationsettings_on_instance_administration_project_id"
......
...@@ -54,6 +54,10 @@ module EE ...@@ -54,6 +54,10 @@ module EE
attrs += EE::ApplicationSettingsHelper.merge_request_appovers_rules_attributes attrs += EE::ApplicationSettingsHelper.merge_request_appovers_rules_attributes
end end
if License.feature_available?(:packages)
attrs << :npm_package_requests_forwarding
end
attrs attrs
end end
......
...@@ -94,6 +94,7 @@ module EE ...@@ -94,6 +94,7 @@ module EE
default_project_deletion_protection default_project_deletion_protection
deletion_adjourned_period deletion_adjourned_period
updating_name_disabled_for_users updating_name_disabled_for_users
npm_package_requests_forwarding
] ]
end end
......
---
title: Add npm_package_requests_forwarding to application settings
merge_request: 25346
author:
type: added
...@@ -220,6 +220,7 @@ module EE ...@@ -220,6 +220,7 @@ module EE
expose :default_project_deletion_protection, if: ->(_instance, _opts) { ::License.feature_available?(:default_project_deletion_protection) } expose :default_project_deletion_protection, if: ->(_instance, _opts) { ::License.feature_available?(:default_project_deletion_protection) }
expose :deletion_adjourned_period, if: ->(_instance, _opts) { ::License.feature_available?(:adjourned_deletion_for_projects_and_groups) } expose :deletion_adjourned_period, if: ->(_instance, _opts) { ::License.feature_available?(:adjourned_deletion_for_projects_and_groups) }
expose :updating_name_disabled_for_users, if: ->(_instance, _opts) { ::License.feature_available?(:disable_name_update_for_users) } expose :updating_name_disabled_for_users, if: ->(_instance, _opts) { ::License.feature_available?(:disable_name_update_for_users) }
expose :npm_package_requests_forwarding, if: ->(_instance, _opts) { ::License.feature_available?(:packages) }
end end
end end
......
...@@ -41,6 +41,7 @@ module EE ...@@ -41,6 +41,7 @@ module EE
optional :disable_overriding_approvers_per_merge_request, type: Grape::API::Boolean, desc: 'Disable Users ability to overwrite approvers in merge requests.' optional :disable_overriding_approvers_per_merge_request, type: Grape::API::Boolean, desc: 'Disable Users ability to overwrite approvers in merge requests.'
optional :prevent_merge_requests_author_approval, type: Grape::API::Boolean, desc: 'Disable Merge request author ability to approve request.' optional :prevent_merge_requests_author_approval, type: Grape::API::Boolean, desc: 'Disable Merge request author ability to approve request.'
optional :prevent_merge_requests_committers_approval, type: Grape::API::Boolean, desc: 'Disable Merge request committer ability to approve request.' optional :prevent_merge_requests_committers_approval, type: Grape::API::Boolean, desc: 'Disable Merge request committer ability to approve request.'
optional :npm_package_requests_forwarding, type: Grape::API::Boolean, desc: 'NPM package requests are forwarded to npmjs.org if not found on GitLab.'
end end
end end
......
...@@ -39,6 +39,10 @@ module EE ...@@ -39,6 +39,10 @@ module EE
attrs = attrs.except(*EE::ApplicationSettingsHelper.merge_request_appovers_rules_attributes) attrs = attrs.except(*EE::ApplicationSettingsHelper.merge_request_appovers_rules_attributes)
end end
unless License.feature_available?(:packages)
attrs = attrs.except(:npm_package_requests_forwarding)
end
attrs attrs
end end
end end
......
...@@ -111,6 +111,13 @@ describe Admin::ApplicationSettingsController do ...@@ -111,6 +111,13 @@ describe Admin::ApplicationSettingsController do
it_behaves_like 'settings for licensed features' it_behaves_like 'settings for licensed features'
end end
context 'updating npm packages request forwarding setting' do
let(:settings) { { npm_package_requests_forwarding: true } }
let(:feature) { :packages }
it_behaves_like 'settings for licensed features'
end
context 'project deletion adjourned period' do context 'project deletion adjourned period' do
let(:settings) { { deletion_adjourned_period: 6 } } let(:settings) { { deletion_adjourned_period: 6 } }
let(:feature) { :adjourned_deletion_for_projects_and_groups } let(:feature) { :adjourned_deletion_for_projects_and_groups }
......
...@@ -176,4 +176,11 @@ describe API::Settings, 'EE Settings' do ...@@ -176,4 +176,11 @@ describe API::Settings, 'EE Settings' do
it_behaves_like 'settings for licensed features' it_behaves_like 'settings for licensed features'
end end
context 'updating npm packages request forwarding' do
let(:settings) { { npm_package_requests_forwarding: true } }
let(:feature) { :packages }
it_behaves_like 'settings for licensed features'
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment