Skip to content

Commit

Permalink
Only show catalog types for supported EMSs
Browse files Browse the repository at this point in the history
If an EMS isn't supported by disabling it in the Vmdb::PermissionStore
we shouldn't show it as an available catalog type
  • Loading branch information
agrare committed Apr 2, 2020
1 parent 8bd930c commit 8072098
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions app/models/ext_management_system.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@ def self.leaf_subclasses
end

def self.supported_subclasses
subclasses.flat_map do |s|
s.subclasses.empty? ? s : s.supported_subclasses
end
leaf_subclasses.select(&:supported?)
end

def self.supported?
Vmdb::PermissionStores.instance.supported_ems_type?(ems_type)
end

def self.supported_types_and_descriptions_hash
supported_subclasses.each_with_object({}) do |klass, hash|
if Vmdb::PermissionStores.instance.supported_ems_type?(klass.ems_type)
hash[klass.ems_type] = klass.description
end
end
supported_subclasses.each_with_object({}) { |klass, hash| hash[klass.ems_type] = klass.description }
end

def self.api_allowed_attributes
Expand Down
2 changes: 1 addition & 1 deletion app/models/service_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def self.with_additional_tenants
end

def self.catalog_item_types
ci_types = Set.new(Rbac.filtered(ExtManagementSystem.all).flat_map(&:supported_catalog_types))
ci_types = Set.new(Rbac.filtered(ExtManagementSystem.supported_subclasses).flat_map(&:supported_catalog_types))
ci_types.add('generic_orchestration') if Rbac.filtered(OrchestrationTemplate).exists?
ci_types.add('generic')
CATALOG_ITEM_TYPES.each.with_object({}) do |(key, description), hash|
Expand Down

0 comments on commit 8072098

Please sign in to comment.