-
Notifications
You must be signed in to change notification settings - Fork 897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Catalog Item type list is dependent on installed providers #16559
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,6 +69,15 @@ class ServiceTemplate < ApplicationRecord | |
scope :with_existent_service_template_catalog_id, -> { where.not(:service_template_catalog_id => nil) } | ||
scope :displayed, -> { where(:display => true) } | ||
|
||
def self.catalog_item_types | ||
ci_types = Rbac.filtered(ExtManagementSystem.all).flat_map(&:supported_catalog_types).uniq | ||
ci_types << 'generic_orchestration' if Rbac.filtered(OrchestrationTemplate).exists? | ||
ci_types << 'generic' | ||
CATALOG_ITEM_TYPES.each.with_object({}) do |(key, description), hash| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does the UI use it - gray out non-displayable item from the dropdown? Or should we simply remove non-qualified types? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bzwei @h-kataria mentioned that there is some bootstrap magic that does that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bzwei yes UI will show those items as grayed/disabled in the drop down, see screenshot in ManageIQ/manageiq-ui-classic#2908 |
||
hash[key] = { :description => description, :display => ci_types.include?(key) } | ||
end | ||
end | ||
|
||
def self.create_catalog_item(options, auth_user) | ||
transaction do | ||
create_from_options(options).tap do |service_template| | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
describe ManageIQ::Providers::EmbeddedAnsible::AutomationManager do | ||
it_behaves_like 'ansible automation_manager' | ||
|
||
context 'catalog types' do | ||
let(:ems) { FactoryGirl.create(:embedded_automation_manager) } | ||
|
||
it "#supported_catalog_types" do | ||
expect(ems.supported_catalog_types).to eq(%w(generic_ansible_playbook)) | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are building this up as an index for lookup purposes (with uniqueness), you would be better off using a
Set
object (and not manually calling unique, but letting Set do that for you).