Refactor #19464

Move Dashboard::Manager out of app/registries/ to permit autoloading

Added by Dominic Cleal 12 months ago. Updated 6 months ago.

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

Description

Dashbaord::Manager has always been excluded from autoloading as it kept a list of known widgets in a class variable. In #10927, it was moved to app/registries/ to preserve this status and keep it from being autoloaded.

It is possible to rewrite this class in an autoload-friendly manner, where the list of builtin widgets is hardcoded inside the class and then the total list of default widgets is retrieved from Foreman::Plugin when required, instead of plugins appending to the dashboard class variable.

This would:

  1. Allow the source file to be kept in app/services/, easier for people to find
  2. Allow the class to be reloaded in development, so changes to builtin widgets are immediately visible
  3. Allow initialisation to be removed from config/initializers/, speeding up the application load time
  4. Make the class more testable, by removing modifications to class variables

Related issues

Related to Foreman - Bug #10927: Resetting dashboard to default widgets adds no widgets Closed 06/25/2015

Associated revisions

Revision d3f47405
Added by Dominic Cleal 12 months ago

fixes #19464 - rewrite Dashboard::Manager to support autoloading

Replaces class-level widget storage with a static list of built-in
widgets, then appends the registered plugin widgets to get the full
default list of widgets. As a result, the class can safely be reloaded
when modified and is more testable as class-level state is removed.

History

#1 Updated by Dominic Cleal 12 months ago

  • Related to Bug #10927: Resetting dashboard to default widgets adds no widgets added

#2 Updated by The Foreman Bot 12 months ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/4506 added

#3 Updated by Dominic Cleal 12 months ago

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

#4 Updated by Marek Hulán 6 months ago

  • Release set to 1.16.0

Also available in: Atom PDF