Merge pull request #2541 from opf/feature/hidden_menu_items_env_override

env override for hidden menu items; + docs
pull/2542/merge
ulferts 10 years ago
commit 11fdb43186
  1. 76
      doc/CONFIGURATION.md
  2. 4
      lib/open_project/configuration.rb
  3. 34
      lib/open_project/configuration/helpers.rb

@ -83,6 +83,8 @@ storage config above like this:
* [`omniauth_direct_login_provider`](#omniauth-direct-login-provider) (default: nil)
* [`disable_password_login`](#disable-password-login) (default: false)
* [`attachments_storage`](#attachments-storage) (default: file)
* [`hidden_menu_items`](#hidden-menu-items) (default: {})
* [`disabled_modules`](#disabled-modules) (default: [])
### disable password login
@ -147,34 +149,64 @@ In the case of fog you only have to configure everything under `fog`, however. D
to `fog` just yet. Instead leave it as `file`. This is because the current attachments storage is used as the source
for the migration.
#### Hide menu items
### hidden menu items
By default user may choose which menu items can be disabled,
they should be listed as an array in yml format.
More information regarding yml format you can find here:
http://symfony.com/doc/current/components/yaml/yaml_format.html
*default: {}*
You can disable specific menu items in the menu sidebar for each main menu (such as Administration and Projects).
The following example disables all menu items except 'Users', 'Groups' and 'Custom fields' under 'Administration':
```
hidden_menu_items:
admin_menu:
- roles
- types
- statuses
- workflows
- enumerations
- settings
- ldap_authentication
- colors
- project_types
- export_card_configurations
- plugins
- info
```
The configuration can be overridden through environment variables.
You have to define one variable for each menu.
For instance 'Roles' and 'Types' under 'Administration' can be disabled by defining the following variable:
```
OPENPROJECT_HIDDEN__MENU__ITEMS_ADMIN__MENU='roles types'
```
### disabled modules
*default: []*
Modules may be disabled through the configuration.
Just give a list of the module names either as an array or as a string with values separated by spaces.
**Array example:**
```
production:
hidden_menu_items:
admin_menu:
- roles
- types
- statuses
- workflows
- enumerations
- settings
- ldap_authentication
- colors
- project_types
- export_card_configurations
- plugins
- info
disabled_modules:
- backlogs
- meetings
```
Or it can be overridden by by an environment variable:
**String example:**
OPENPROJECT_HIDDEN__MENU__ITEMS_ADMIN__MENU='roles types'
```
disabled_modules: backlogs meetings
```
The option to use a string is mostly relevant for when you want to override the disabled modules via ENV variables:
```
OPENPROJECT_DISABLED__MODULES='backlogs meetings'
```
## Email configuration

@ -75,8 +75,8 @@ module OpenProject
'omniauth_direct_login_provider' => nil,
'disable_password_choice' => false,
# allow to disable default modules
'disabled_modules' => [],
'disabled_modules' => [], # allow to disable default modules
'hidden_menu_items' => {}
}

@ -70,6 +70,18 @@ module OpenProject
available_file_uploaders[OpenProject::Configuration.attachments_storage.to_sym]
end
def hidden_menu_items
menus = self['hidden_menu_items'].map do |label, nodes|
[label, array(nodes)]
end
Hash[menus]
end
def disabled_modules
array self['disabled_modules']
end
def available_file_uploaders
{
fog: ::FogFileUploader,
@ -77,20 +89,20 @@ module OpenProject
}
end
# overrides default getter in OpenProject::Configuration
def hidden_menu_items
menus = self['hidden_menu_items'].map do |label, nodes|
if nodes =~ / /
[label, nodes.split(' ')]
else
[label, nodes]
end
private
##
# Yields the given configuration value as an array.
# Either the value already is an array or a string with values separated by spaces.
# In the latter case the string will be split and the values returned as an array.
def array(value)
if value =~ / /
value.split ' '
else
value
end
Hash[menus]
end
private
def true?(value)
['true', true].include? value # check string to accommodate ENV override
end

Loading…
Cancel
Save