Bug #10927

Resetting dashboard to default widgets adds no widgets

Added by Dominic Cleal over 2 years ago. Updated 3 months ago.

Status:Closed
Priority:Normal
Assigned To:Dominic Cleal
Category:Dashboard
Target version:-
Difficulty: Bugzilla link:1319825
Found in release:nightly Pull request:https://github.com/theforeman/foreman/pull/4472
Story points-
Velocity based estimate-
Release1.16.0Release relationshipAuto

Description

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.


Related issues

Related to Foreman - Refactor #8106: Save dashboard widgets in DB to increase flexibility Closed 10/26/2014
Related to Foreman - Bug #19317: Plugin and dashboard widget registry auto-reloaded Closed 04/19/2017
Related to Foreman - Refactor #19464: Move Dashboard::Manager out of app/registries/ to permit ... Closed 05/04/2017
Duplicated by Foreman - Bug #14300: after removing dashboard widgets none are listed to add back Duplicate 03/21/2016

Associated revisions

Revision 40fffe69
Added by Dominic Cleal 9 months ago

fixes #19317, #10927 - move registries to autoload_once path

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.

History

#1 Updated by Dominic Cleal over 2 years ago

  • Related to Refactor #8106: Save dashboard widgets in DB to increase flexibility added

#2 Updated by Dominic Cleal almost 2 years ago

  • Duplicated by Bug #14300: after removing dashboard widgets none are listed to add back added

#3 Updated by Bryan Kearney almost 2 years ago

  • Bugzilla link set to 1319825

#4 Updated by Tomer Brisker 9 months ago

  • Related to Bug #19317: Plugin and dashboard widget registry auto-reloaded added

#5 Updated by The Foreman Bot 9 months ago

  • Status changed from New to Ready For Testing
  • Assigned To set to Dominic Cleal
  • Pull request https://github.com/theforeman/foreman/pull/4472 added

#6 Updated by Dominic Cleal 9 months ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#7 Updated by Dominic Cleal 9 months ago

  • Related to Refactor #19464: Move Dashboard::Manager out of app/registries/ to permit autoloading added

#8 Updated by Marek Hulán 3 months ago

  • Release set to 1.16.0

Also available in: Atom PDF