Commit 47899fb3 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Allow to disable packages feature per project

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 0f024c82
......@@ -38,6 +38,11 @@
required: false,
default: false,
},
packagesAvailable: {
type: Boolean,
required: false,
default: false,
},
visibilityHelpPath: {
type: String,
required: false,
......@@ -50,6 +55,10 @@
type: String,
required: false,
},
packagesHelpPath: {
type: String,
required: false,
},
},
data() {
......@@ -64,6 +73,7 @@
snippetsAccessLevel: 20,
containerRegistryEnabled: true,
lfsEnabled: true,
packagesEnabled: true,
requestAccessEnabled: true,
highlightChangesClass: false,
};
......@@ -129,12 +139,14 @@
if (value === 0) {
this.containerRegistryEnabled = false;
this.lfsEnabled = false;
this.packagesEnabled = false;
}
} else if (oldValue === 0) {
this.mergeRequestsAccessLevel = value;
this.buildsAccessLevel = value;
this.containerRegistryEnabled = true;
this.lfsEnabled = true;
this.packagesEnabled = true;
}
},
......@@ -300,6 +312,18 @@
name="project[lfs_enabled]"
/>
</project-setting-row>
<project-setting-row
v-if="packagesAvailable"
:help-path="packagesHelpPath"
label="Packages"
help-text="Every project can have its own space to store its Maven packages"
>
<project-feature-toggle
v-model="packagesEnabled"
:disabled-input="!repositoryEnabled"
name="project[packages_enabled]"
/>
</project-setting-row>
</div>
<project-setting-row
label="Wiki"
......
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180816193530) do
ActiveRecord::Schema.define(version: 20180823132905) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......@@ -2229,6 +2229,7 @@ ActiveRecord::Schema.define(version: 20180816193530) do
t.boolean "mirror_overwrites_diverged_branches"
t.boolean "pages_https_only", default: true
t.string "external_webhook_token"
t.boolean "packages_enabled", default: false, null: false
end
add_index "projects", ["ci_id"], name: "index_projects_on_ci_id", using: :btree
......
......@@ -22,6 +22,7 @@ module EE
external_authorization_classification_label
ci_cd_only
use_custom_template
packages_enabled
]
if allow_mirror_params?
......
......@@ -28,6 +28,21 @@ module EE
nav_tabs
end
override :project_permissions_settings
def project_permissions_settings
super.merge(
packagesEnabled: !!project.packages_enabled
)
end
override :project_permissions_panel_data
def project_permissions_panel_data
super.merge(
packagesAvailable: Gitlab.config.packages.enabled,
packagesHelpPath: help_page_path('user/project/maven_packages')
)
end
override :default_url_to_repo
def default_url_to_repo(project = @project)
case default_clone_protocol
......
......@@ -23,6 +23,9 @@ module EE
with_scope :subject
condition(:deploy_board_disabled) { !@subject.feature_available?(:deploy_board) }
with_scope :subject
condition(:packages_disabled) { !@subject.packages_enabled }
with_scope :subject
condition(:classification_label_authorized, score: 32) do
EE::Gitlab::ExternalAuthorization.access_allowed?(
......@@ -110,6 +113,10 @@ module EE
rule { deploy_board_disabled & ~is_development }.prevent :read_deploy_board
rule { packages_disabled }.policy do
prevent(*create_read_update_admin_destroy(:package))
end
rule { can?(:maintainer_access) }.policy do
enable :push_code_to_protected_branches
enable :admin_path_locks
......
# frozen_string_literal: true
class AddPackagesEnabledToProject < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_column_with_default(:projects, :packages_enabled, :boolean, default: false, allow_null: false)
end
def down
if column_exists?(:projects, :packages_enabled)
remove_column(:projects, :packages_enabled)
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