summaryrefslogtreecommitdiff
path: root/app/services/groups/transfer_service.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/services/groups/transfer_service.rb')
-rw-r--r--app/services/groups/transfer_service.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/app/services/groups/transfer_service.rb b/app/services/groups/transfer_service.rb
index f2fb494500d..2bd571f60af 100644
--- a/app/services/groups/transfer_service.rb
+++ b/app/services/groups/transfer_service.rb
@@ -47,6 +47,19 @@ module Groups
raise_transfer_error(:namespace_with_same_path) if namespace_with_same_path?
raise_transfer_error(:group_contains_images) if group_projects_contain_registry_images?
raise_transfer_error(:cannot_transfer_to_subgroup) if transfer_to_subgroup?
+ raise_transfer_error(:group_contains_npm_packages) if group_with_npm_packages?
+ end
+
+ def group_with_npm_packages?
+ return false unless group.packages_feature_enabled?
+
+ npm_packages = ::Packages::GroupPackagesFinder.new(current_user, group, package_type: :npm).execute
+
+ different_root_ancestor? && npm_packages.exists?
+ end
+
+ def different_root_ancestor?
+ group.root_ancestor != new_parent_group&.root_ancestor
end
def group_is_already_root?
@@ -144,7 +157,8 @@ module Groups
same_parent_as_current: s_('TransferGroup|Group is already associated to the parent group.'),
invalid_policies: s_("TransferGroup|You don't have enough permissions."),
group_contains_images: s_('TransferGroup|Cannot update the path because there are projects under this group that contain Docker images in their Container Registry. Please remove the images from your projects first and try again.'),
- cannot_transfer_to_subgroup: s_('TransferGroup|Cannot transfer group to one of its subgroup.')
+ cannot_transfer_to_subgroup: s_('TransferGroup|Cannot transfer group to one of its subgroup.'),
+ group_contains_npm_packages: s_('TransferGroup|Group contains projects with NPM packages.')
}.freeze
end
end