diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-20 17:22:11 +0300 |
commit | 0c872e02b2c822e3397515ec324051ff540f0cd5 (patch) | |
tree | ce2fb6ce7030e4dad0f4118d21ab6453e5938cdd /app/services/groups/import_export/import_service.rb | |
parent | f7e05a6853b12f02911494c4b3fe53d9540d74fc (diff) |
Add latest changes from gitlab-org/gitlab@15-7-stable-eev15.7.0-rc42
Diffstat (limited to 'app/services/groups/import_export/import_service.rb')
-rw-r--r-- | app/services/groups/import_export/import_service.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/services/groups/import_export/import_service.rb b/app/services/groups/import_export/import_service.rb index 4092ded67bc..ac181245986 100644 --- a/app/services/groups/import_export/import_service.rb +++ b/app/services/groups/import_export/import_service.rb @@ -8,6 +8,7 @@ module Groups def initialize(group:, user:) @group = group @current_user = user + @user_role = user_role @shared = Gitlab::ImportExport::Shared.new(@group) @logger = Gitlab::Import::Logger.build end @@ -31,6 +32,14 @@ module Groups if valid_user_permissions? && import_file && restorers.all?(&:restore) notify_success + Gitlab::Tracking.event( + self.class.name, + 'create', + label: 'import_access_level', + user: current_user, + extra: { user_role: user_role, import_type: 'import_group_from_file' } + ) + group else notify_error! @@ -43,6 +52,15 @@ module Groups private + def user_role + # rubocop:disable CodeReuse/ActiveRecord, Style/MultilineTernaryOperator + access_level = group.parent ? + current_user&.group_members&.find_by(source_id: group.parent&.id)&.access_level : + Gitlab::Access::OWNER + Gitlab::Access.human_access(access_level) + # rubocop:enable CodeReuse/ActiveRecord, Style/MultilineTernaryOperator + end + def import_file @import_file ||= Gitlab::ImportExport::FileImporter.import( importable: group, |