-
Notifications
You must be signed in to change notification settings - Fork 356
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
Chargeback Rates non explorer #7039
Conversation
3970544
to
6059134
Compare
5260a86
to
c3381c0
Compare
/cc @gtanzillo |
c3381c0
to
6c35fd4
Compare
- Added a button in GTL view toolbar to add ability to toggle between list view and tree view. Tree has links to Chargeback Rate records, User can click on "Rates" link in breadcrumbs to go back to list view. - Updated all toolbar buttons to work in non-explorer modes Follow up PR for ManageIQ#7016 Fixes ManageIQ#6996
6c35fd4
to
c083fc0
Compare
@@ -211,7 +211,7 @@ def set_summary_pdf_data | |||
:page_layout => "portrait", | |||
:page_size => "us-letter", | |||
:run_date => run_time.strftime("%m/%d/%y %l:%m %p %z"), | |||
:title => "#{klass} \"#{@record.name}\"".html_safe, | |||
:title => "#{klass} \"#{@record.respond_to?(:name) ? @record.name : @record.description}\"".html_safe, |
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.
Can you please explain why is this extra complexity necessary?
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.
@skateman because ChargebackRate
record does not have name field. Previously we did not have download buttons on the Chargeback Rates list view because we did not render gtl view toolbar on the screen.
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.
This is a good start, but let's make some stuff nicer. I'd like to have things here as a pattern to how to convert from explorer to non-explorer.
Also I think it would need more people to review the complexity stuff. We want to simplify things, not add more if-else and constant in global places if possible.
@breadcrumbs = [] | ||
@explorer = true | ||
build_accordions_and_trees | ||
send_action = CB_X_BUTTON_ALLOWED_ACTIONS[action] |
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.
Can we rename this to just BUTTON_ALLOWED_ACTIONS
? The X_
prefix means explorer and I guess we want this as a pattern in other screens, so there's no reason to keep the CB_
. Also maybe merge the test with the ˙sendand move it to the
GenericButtonMixin`? Here we should keep something like:
BUTTON_ALLOWED_ACTIONS = {}.freeze
evaluate_button(action, BUTTON_ALLOWED_ACTIONS)
|
||
render :layout => "application" unless request.xml_http_request? | ||
if params[:pressed].ends_with?("_copy", "_edit", "_new") && @flash_array.nil? |
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.
You're testing params[:pressed]
but above you allocated it as action
|
||
render :layout => "application" unless request.xml_http_request? | ||
if params[:pressed].ends_with?("_copy", "_edit", "_new") && @flash_array.nil? | ||
if @flash_array |
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.
One line above you test against the @flash_array˙ if it's
nil` and I think this is dead code then...
replace_gtl_main_div | ||
else | ||
render_flash unless performed? | ||
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.
In general this huge if-else thing isn't really clean, I think we should do something like on other non-explorer controllers. This is from CloudNetworkController
:
def button
@edit = session[:edit] # Restore @edit for adv search box
params[:display] = @display if %w[vms instances images].include?(@display)
params[:page] = @current_page unless @current_page.nil? # Save current page for list refresh
@refresh_div = "main_div"
case params[:pressed]
when 'cloud_network_delete'
delete_networks
javascript_redirect(previous_breadcrumb_url)
when "cloud_network_edit"
javascript_redirect(:action => "edit", :id => checked_item_id)
when "cloud_network_new"
javascript_redirect(:action => "new")
else
super
end
end
I would prefer something like this even if it goes against my suggestion above about evaluate_button
. Consistency is more important 😉
super | ||
# only need these gtl type buttons on the screen | ||
@gtl_buttons = %w[view_list view_tree] | ||
cb_rates_build_tree if @gtl_type == 'tree' |
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.
Maybe we want to keep this a little bit cleaner, what about defining them similarly to the toolbar
in some of the explorers and pulling it in and adding the logic into the GenericListMixin#show_list
the same way as we do with @center_toolbar
?
I need to dig a little more, because my fulltext search on @gtl_buttons
doesn't find much, so I don't completely understand the dataflow yet, but you might come up with a better idea in the meantime.
@@ -2,7 +2,7 @@ class TreeBuilderChargeback < TreeBuilder | |||
private | |||
|
|||
def tree_init_options | |||
{:open_all => true, :full_ids => true} | |||
{:open_all => true, :full_ids => true, :click_url => "/chargeback_rate/tree_select/", :onclick => "miqOnClickGeneric"} |
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.
You're doing this in the wrong TreeBuilder
as it could break stuff in the other subclasses. Can you please redefine it in the TreeBuilderChargebackRates
and call super.merge
? Also let's make it there a multiline and you can set full_ids
to false (there). Maybe it would need a slight change at the tree_select
but it should probably simplify stuff.
@@ -13,6 +13,7 @@ def x_get_tree_roots | |||
{ | |||
:id => type, | |||
:text => type, | |||
:selectable => false, |
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.
Again, this breaks stuff in the other trees. Please redefine it TreeBuilderChargeBackRates
and call super.map
to set them non-selectable.
@@ -0,0 +1 @@ | |||
= render(:partial => "shared/tree", :locals => {:tree => @tree, :name => @tree.name}) |
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.
This won't make @brumik happy 😆 not really this one, but that his PR is still not in 😕
@@ -0,0 +1,3 @@ | |||
#main_div | |||
= render :partial => 'layouts/gtl' | |||
= render :partial => 'tree' if @tree.present? |
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.
I don't really like this, but as long as we're not using the react component, why not. Maybe you could move the one-liner from the tree.html.haml
directly here...
Added condition to only render gtl or tree
moved out chargeback rates tree specific code changes to `TreeBuilderChargeBackRates`
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.
Tested in UI. LGTM 👍
And changed to use toolbar module to load toolbars for chargeback rates list/show
- Removed `db_list` that was accidentally added in this PR - Fixed routing spec tests. - Reverted changes made in toolbar_chooser, see ManageIQ#7039 (comment) for more info
config/routes.rb
Outdated
cb_rate_form_field_changed | ||
cb_rate_show | ||
cb_rates_delete |
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.
Can we simplify this into just delete
?
Checked commits h-kataria/manageiq-ui-classic@c083fc0~...bf3fb4d with ruby 2.5.7, rubocop 0.69.0, haml-lint 0.28.0, and yamllint app/controllers/application_controller/report_downloads.rb
app/controllers/chargeback_rate_controller.rb
app/helpers/application_helper/toolbar/chargeback_rate_center.rb
app/helpers/application_helper/toolbar_chooser.rb
app/presenters/menu/default_menu.rb
app/views/chargeback_rate/_cb_rate_edit_table.html.haml
app/views/chargeback_rate/_cb_rate_show.html.haml
app/views/chargeback_rate/_edit.html.haml
app/views/chargeback_rate/_tier_first_row.haml
app/views/chargeback_rate/_tier_row.haml
app/views/chargeback_rate/edit.html.haml
app/views/chargeback_rate/show_list.html.haml
spec/controllers/chargeback_rate_controller_spec.rb
spec/presenters/tree_builder_spec.rb
|
When I try to copy a chargeback rate and edit it's name, the new name doesn't get saved. |
`javascript_tag(javascript_focus('description'))` for some reason was not working well with `javascript_redirect`
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.
Missed removal of these in ManageIQ#7039
Chargeback Rates non explorer (cherry picked from commit cdf3b48)
Jansa backport details:
|
ManageIQ#7039 (comment). Reverted any gtl_view buttons related code that was introduced in this PR.
- Removed `db_list` that was accidentally added in this PR - Fixed routing spec tests. - Reverted changes made in toolbar_chooser, see ManageIQ#7039 (comment) for more info
Missed removal of these in ManageIQ#7039
Converted Chargeback Rates explorer to be a non-explorer screen, this will help with direct linking of Chargeback Rates list/show screen.
Added a new Tree View button to GTL views toolbar, to support switching between list/tree view on the Chargeback Rates screen
Added a new
Type
drop down on Add a new Chargeback Rate form, that defaults toCompute
Depends on #7016
Direct link to list view: http://localhost:3000/chargeback_rate/show_list
Direct link to summary screen: http://localhost:3000/chargeback_rate/show/7