Resetting dashboard to default widgets adds no widgets
|Assigned To:||Dominic Cleal|
|Found in release:||nightly||Pull request:||https://github.com/theforeman/foreman/pull/4472|
|Velocity based estimate||-|
When resetting the dashboard to the default widgets in a development environment, it may not add any widgets. To reproduce, edit app/services/dashboard/manager.rb and then click restore.
It appears that the class Dashboard::Manager stores a list of default widgets in a class variable which is only initialised via Dashboard::Loader on boot. When the Manager class gets reloaded by Rails, it loses the list of default widgets.
Adding a require on dashboard/manager to config/initializers/foreman.rb may disable autoloading of the class, or move logic into dashboard/loader.
Partially reverts 70ce8fe to reinstate autoload_once_paths as the
preferred way to load registry-type objects with class variables
containing data set up during app initialisation (e.g. plugin
registrations, menu items.)
autoload_once is compatible with using require_dependency, which is
preferred to allow Rails to track which constants are loaded, so eager
loading doesn't ever try to load the same file twice (7923c95.)
This moves all registry-type objects to app/registries/ and marks this
path as being autoload_once. The contents of this directory should be
kept at an absolute minimum to ease development.