diff --git a/config/locales/en.yml b/config/locales/en.yml index 5b036d638a..24988c935f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -28,3 +28,6 @@ en: label_not_changeable: (not changeable) label_no_assignable_role: No global role available for assignment label_global: Global + + seeders: + default_role_project_creator: 'Project creator' diff --git a/lib/open_project/global_roles/engine.rb b/lib/open_project/global_roles/engine.rb index 16d14a29b2..a22eae85fb 100644 --- a/lib/open_project/global_roles/engine.rb +++ b/lib/open_project/global_roles/engine.rb @@ -32,6 +32,7 @@ module OpenProject::GlobalRoles assets %w(global_roles/global_roles.js) patches [:Principal, :Role, :User, :RolesController, :UsersController] + patch_with_namespace :BasicData, :RoleSeeder initializer 'patch helper' do require_relative 'patches/roles_helper_patch' diff --git a/lib/open_project/global_roles/patches/role_seeder_patch.rb b/lib/open_project/global_roles/patches/role_seeder_patch.rb new file mode 100644 index 0000000000..473b6abe3e --- /dev/null +++ b/lib/open_project/global_roles/patches/role_seeder_patch.rb @@ -0,0 +1,21 @@ +module OpenProject::GlobalRoles::Patches + module RoleSeederPatch + def self.included(base) + base.prepend InstanceMethods + end + + module InstanceMethods + def roles + super + [project_creator] + end + + def project_creator + { name: I18n.t(:'seeders.default_role_project_creator'), + position: 6, + permissions: [:add_project], + type: 'GlobalRole' + } + end + end + end +end