feat: installation config in super admin console (#1641)

* feat: installation config in super admin console

* Added the ability for super admins to view, edit and update
installation config values. Also they can add new isntallation config
values. The impact of editing and adding depends on which all
installation config values are being used in the code.
* Known limitation now: Ability to edit hash values (for eg: feature
flags) are disabled. This requires more work and will be taken up in
a secondary set of changes.
* Minor UX improvement. Clicking on the Sidekiq option in the super
admin siebar will now open the sidekiq dashboard in a new tab rather
than in the same tab that you were using super admin.

* fix: method name fix in custom adminsitrate field

* feat: added locked attribute to global config
* Added the locked attribute to instalaltion config table. Added
necessary migrations. Added changes in config loader.
* Added the changes on the installation config yml
* Locked the account feature defaults in code

* feat: show only editable configs in admin console
* Added a new scope in installation config model
* Added scope in adminstrate controller for installation_config

* fix: new installation config create error
* Fixed the error in new installation config create

* fix: specs coverage
* Added specs for installation config super admin controller

* chore: update git ignore with encrypted config ext
This commit is contained in:
Sony Mathew
2021-01-15 13:21:53 +05:30
committed by GitHub
parent 2e19de5d01
commit 18d3c40fb3
16 changed files with 296 additions and 30 deletions

View File

@@ -44,19 +44,25 @@ class ConfigLoader
end
end
def save_general_config(existing_config, new_config)
if existing_config
def save_general_config(existing, latest)
if existing
# save config only if reconcile flag is false and existing configs value does not match default value
save_as_new_config(new_config) if !@reconcile_only_new && existing_config.value != new_config[:value]
save_as_new_config(latest) if !@reconcile_only_new && compare_values(existing, latest)
else
save_as_new_config(new_config)
save_as_new_config(latest)
end
end
def save_as_new_config(new_config)
config = InstallationConfig.new(name: new_config[:name])
config.value = new_config[:value]
config.save
def compare_values(existing, latest)
existing.value != latest[:value] ||
(!latest[:locked].nil? && existing.locked != latest[:locked])
end
def save_as_new_config(latest)
config = InstallationConfig.find_or_create_by(name: latest[:name])
config.value = latest[:value]
config.locked = latest[:locked]
config.save!
end
def reconcile_feature_config
@@ -67,7 +73,7 @@ class ConfigLoader
compare_and_save_feature(config)
else
save_as_new_config({ name: 'ACCOUNT_LEVEL_FEATURE_DEFAULTS', value: account_features })
save_as_new_config({ name: 'ACCOUNT_LEVEL_FEATURE_DEFAULTS', value: account_features, locked: true })
end
end
@@ -79,6 +85,6 @@ class ConfigLoader
# update the existing feature flag values with default values and add new feature flags with default values
(account_features + config.value).uniq { |h| h['name'] }
end
config.update({ name: 'ACCOUNT_LEVEL_FEATURE_DEFAULTS', value: features })
config.update({ name: 'ACCOUNT_LEVEL_FEATURE_DEFAULTS', value: features, locked: true })
end
end