Skip to content
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

Added changes to show Catalog Item type in UI #13516

Merged
merged 1 commit into from
Feb 7, 2017

Conversation

h-kataria
Copy link
Contributor

Moved CATALOG_ITEM_TYPES and added virtual column in model so it can be used to display Catalog Item type in list view and other screens.

https://bugzilla.redhat.com/show_bug.cgi?id=1348239

@gmcculloug @dclarizio please review

see UI screenshots below show "Item Type" on list view and other screens

after1
after2
after3


default_value_for :service_type, 'unknown'
default_value_for(:generic_subtype) { |st| 'custom' if st.prov_type == 'generic' }

virtual_has_one :custom_actions, :class_name => "Hash"
virtual_has_one :custom_action_buttons, :class_name => "Array"

def prov_type_display
prov_type ? CATALOG_ITEM_TYPES[prov_type] : ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be simplified to: CATALOG_ITEM_TYPES[prov_type].to_s

@@ -63,6 +63,21 @@
end
end

context "#prov_type_display" do
before(:each) do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized this is used elsewhere in this file, but you do not need to include (:each) as it is the default.

@gmcculloug
Copy link
Member

Two minor comments but otherwise looks good.

@h-kataria
Copy link
Contributor Author

@gmcculloug addressed your comments.


default_value_for :service_type, 'unknown'
default_value_for(:generic_subtype) { |st| 'custom' if st.prov_type == 'generic' }

virtual_has_one :custom_actions, :class_name => "Hash"
virtual_has_one :custom_action_buttons, :class_name => "Array"

def prov_type_display
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@h-kataria what is a prov_type?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@h-kataria Bigger question is that this looks like UI code that should probably live in a UI presenter in the Classic UI repo? /cc @Fryguy @dclarizio

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chessbyte prov_type is a column in service_templates table, i needed to show nice display value for prov_type in the list views, which is why i have added a virtual column here

@@ -10,6 +10,20 @@ class ServiceTemplate < ApplicationRecord
"storage" => _("Storage")
}.freeze


CATALOG_ITEM_TYPES = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@h-kataria Is the idea to change the catalog_item_types method from the classic UI repo and have it reference this constant? We would not want to have this defined in multiple places.

@Fryguy @dclarizio Any thoughts here?

Ultimately this list needs to make it's way into the pluggable providers. @durandom

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmcculloug usually we try to keep list of types in a constant in models, but in this case it has been in controller from the beginning, but now since we need to expose the type as a nice display value in the list view. I thought we should move this into the model and reference the constant from controllers/views.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an object you can infer the name from? Or something like all subclasses of a base class? Who fills prov_type? Maybe this can be filled with some inflection methods https://github.com/ManageIQ/manageiq/blob/master/app/models/manageiq/providers/inflector.rb ?

I also think this is rather a UI issue, they should infer the display string from prov_type

Copy link
Member

@martinpovolny martinpovolny Jan 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that more that just one UI might need to have a nice name for the catalog item type. Also it does not make sense to me for the UIs to track what types of catalog item the backend has.

So I'd say it should stay on the backend side.

Note: although it needs not look like that now, the values might need i18n care. Ping @mzazrivec

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@martinpovolny addressed you comment, moving code to display nice value for prov_type back to UI PR.

@@ -10,6 +10,20 @@ class ServiceTemplate < ApplicationRecord
"storage" => _("Storage")
}.freeze


CATALOG_ITEM_TYPES = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an object you can infer the name from? Or something like all subclasses of a base class? Who fills prov_type? Maybe this can be filled with some inflection methods https://github.com/ManageIQ/manageiq/blob/master/app/models/manageiq/providers/inflector.rb ?

I also think this is rather a UI issue, they should infer the display string from prov_type

@miq-bot
Copy link
Member

miq-bot commented Jan 19, 2017

Checked commit h-kataria@a729022 with ruby 2.2.6, rubocop 0.46.0, and haml-lint 0.19.0
1 file checked, 2 offenses detected

app/models/service_template.rb

@h-kataria
Copy link
Contributor Author

@durandom i have revised this PR and moved out the code that deals with displaying nice value for prov_type in UI. Can you please re-review.

@durandom
Copy link
Member

@h-kataria Still you'll have to re-visit that list once we add a new provider.
There are currently methods to introspect a provider:

I thought of leveraging something like these.

But I leave it up to @gmcculloug

@h-kataria
Copy link
Contributor Author

@gmcculloug please review comments from @durandom

@martinpovolny
Copy link
Member

We should have the value somewhere at the provider so that we don't have to revisit this list when adding a new provider.

But let's fix that in a follow up PR. This is taking far too long.

@martinpovolny martinpovolny merged commit 1ab7103 into ManageIQ:master Feb 7, 2017
@martinpovolny martinpovolny added this to the Sprint 54 Ending Feb 13, 2017 milestone Feb 7, 2017
@h-kataria h-kataria deleted the show_catalog_item_type branch March 15, 2017 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants