Skip to content

Commit

Permalink
Refs #35287 - Improve locked pagelet handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ofedoren committed Oct 30, 2022
1 parent 5a927ed commit 364c27c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/controllers/api/v2/table_preferences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ def show
api :POST, "/users/:user_id/table_preferences/", N_("Creates a table preference for a given table")
param_group :table_preference
def create
@table_preference = @user.table_preferences.build(:name => params[:name], :columns => params[:columns])
@table_preference = @user.table_preferences.build(:name => params[:name], :columns => params[:columns]&.uniq)
process_response @table_preference.save
end

api :PUT, "/users/:user_id/table_preferences/:name", N_("Updates a table preference for a given table")
param_group :table_preference
def update
process_response @table_preference.update(:columns => params[:columns])
process_response @table_preference.update(:columns => params[:columns]&.uniq)
end

api :DELETE, "/users/:user_id/table_preferences/:name/", N_("Delete a table preference for a given table")
Expand Down
2 changes: 1 addition & 1 deletion app/registries/pagelets/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(items)

def filter(opts = {})
result = if opts[:selected]
items.select { |pagelet| opts[:selected].include?(pagelet.key.to_s) }
items.select { |pagelet| pagelet.locked || opts[:selected].include?(pagelet.key.to_s) }
else
items.select do |pagelet|
pagelet.profiles.empty? ? true : pagelet.profiles.any? { |profile| profile.default? }
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/foreman_register.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
common_th_class = 'hidden-tablet hidden-xs'
common_td_class = common_th_class + ' ellipsis'
add_pagelet :hosts_table_column_header, key: :name, label: _('Name'), sortable: true, width: '25%', locked: true
add_pagelet :hosts_table_column_content, key: :name, class: 'ellipsis', callback: ->(host) { name_column(host) }
add_pagelet :hosts_table_column_content, key: :name, class: 'ellipsis', callback: ->(host) { name_column(host) }, locked: true
add_pagelet :hosts_table_column_header, key: :os_title, label: _('Operating system'), sortable: true, width: '17%', class: 'hidden-xs'
add_pagelet :hosts_table_column_content, key: :os_title, class: 'hidden-xs ellipsis', callback: ->(host) { (icon(host.operatingsystem, size: "16x16") + " #{host.operatingsystem.to_label}").html_safe if host.operatingsystem }
add_pagelet :hosts_table_column_header, key: :model, label: _('Model'), sortable: true, width: '10%', class: common_th_class
Expand Down

0 comments on commit 364c27c

Please sign in to comment.