From 9be5b4645a935d04a6b48c4f97980412d1dd587d Mon Sep 17 00:00:00 2001 From: nasark Date: Wed, 31 Aug 2022 10:07:24 -0400 Subject: [PATCH] add pluggability for miq widgets --- app/models/miq_widget.rb | 2 +- lib/vmdb/plugins.rb | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/models/miq_widget.rb b/app/models/miq_widget.rb index 3a0cb045058d..cadc7780462f 100644 --- a/app/models/miq_widget.rb +++ b/app/models/miq_widget.rb @@ -458,7 +458,7 @@ def self.get_group(group) end def self.sync_from_dir - Dir.glob(File.join(WIDGET_DIR, "*.yaml")).sort.each { |f| sync_from_file(f) } + Vmdb::Plugins.miq_widgets_content.sort.each { |f| sync_from_file(f) } end def self.sync_from_file(filename) diff --git a/lib/vmdb/plugins.rb b/lib/vmdb/plugins.rb index f5d4e40229b1..f279bd71eec5 100644 --- a/lib/vmdb/plugins.rb +++ b/lib/vmdb/plugins.rb @@ -30,8 +30,8 @@ def init end def details - each_with_object({}) do |engine, hash| - hash[engine] = { + index_with do |engine| + { :name => engine.name, :version => version(engine), :path => engine.root.to_s @@ -80,6 +80,10 @@ def automate_domains end end + def miq_widgets_content + @miq_widgets_content ||= Dir.glob(Rails.root.join("product/dashboard/widgets", "*")) + flat_map { |engine| content_directories(engine, "dashboard/widgets") } + end + def provider_plugins @provider_plugins ||= select { |engine| engine.name.start_with?("ManageIQ::Providers::") } end