Skip to content

Commit

Permalink
Move chargeback code to the method
Browse files Browse the repository at this point in the history
and then move this method to the building screen
it will refresh @edit[:cb_users] and
@edit[:cb_tenant]  when tab filter is pressed.

This change also wrapping tenant and user list
by RBAC.
  • Loading branch information
lpichler committed Feb 26, 2018
1 parent 77153f9 commit b283dc0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
11 changes: 1 addition & 10 deletions app/controllers/report_controller/reports/editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def build_edit_screen

get_time_profiles # Get time profiles list (global and user specific)
cb_entities_by_provider if Chargeback.db_is_chargeback?(@edit[:new][:model]) && [ChargebackContainerImage, ChargebackContainerProject, MeteringContainerImage, MeteringContainerProject].include?(@edit[:new][:model].safe_constantize)
refresh_chargeback_filter_tab if Chargeback.db_is_chargeback?(@edit[:new][:model])
case @sb[:miq_tab].split("_")[1]
when "1" # Select columns
@edit[:models] ||= reportable_models
Expand Down Expand Up @@ -1331,16 +1332,6 @@ def set_form_vars
cb_entities_by_provider if [ChargebackContainerImage, ChargebackContainerProject, MeteringContainerImage, MeteringContainerProject].include?(@rpt.db.safe_constantize)
end

# Only show chargeback users choice if an admin
if admin_user?
@edit[:cb_users] = User.all.each_with_object({}) { |u, h| h[u.userid] = u.name }
@edit[:cb_tenant] = Tenant.all.each_with_object({}) { |t, h| h[t.id] = t.name }
else
@edit[:new][:cb_show_typ] = "owner"
@edit[:new][:cb_owner_id] = session[:userid]
@edit[:cb_owner_name] = current_user.name
end

# Build trend limit cols array
if model_report_type(@rpt.db) == :trend
@edit[:limit_cols] = VimPerformanceTrend.trend_limit_cols(@edit[:new][:perf_trend_db], @edit[:new][:perf_trend_col], @edit[:new][:perf_interval])
Expand Down
5 changes: 5 additions & 0 deletions app/helpers/report_helper/editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ def cb_entities_by_provider_id(provider_id, entity_type)
def cb_image_labels
CustomAttribute.where(:section => "docker_labels").distinct('name').pluck(:name).each_with_object({}) { |l, h| h[l] = l }
end

def refresh_chargeback_filter_tab
@edit[:cb_users] = Rbac::Filterer.filtered(User.in_my_region).each_with_object({}) { |u, h| h[u.userid] = u.name }
@edit[:cb_tenant] = Rbac::Filterer.filtered(Tenant).each_with_object({}) { |t, h| h[t.id] = t.name }
end
end

0 comments on commit b283dc0

Please sign in to comment.