Skip to content

Commit

Permalink
Refs #35274 - Revert "Make columns on host index page selectable (#9319
Browse files Browse the repository at this point in the history
…)"

This reverts commit b1b46b6.
  • Loading branch information
ShimShtein authored and upadhyeammit committed Aug 10, 2022
1 parent 4f6a448 commit 387608c
Show file tree
Hide file tree
Showing 17 changed files with 16 additions and 585 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ApplicationController < ActionController::Base
before_action :session_expiry, :update_activity_time, :unless => proc { |c| c.remote_user_provided? || c.api_request? }
before_action :set_taxonomy, :require_mail, :check_empty_taxonomy
before_action :authorize
before_action :welcome, :find_selected_columns, :only => :index, :unless => :api_request?
before_action :welcome, :only => :index, :unless => :api_request?
prepend_before_action :allow_webpack, if: -> { Rails.configuration.webpack.dev_server.enabled }
around_action :set_timezone

Expand Down
4 changes: 0 additions & 4 deletions app/controllers/concerns/application_shared.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,4 @@ def find_session_taxonomy(taxonomy, user)
end
determined_taxonomy
end

def find_selected_columns
@selected_columns = Foreman::SelectableColumns::Storage.selected_by(User.current, controller_name)
end
end
2 changes: 0 additions & 2 deletions app/controllers/hosts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class HostsController < ApplicationController
before_action :set_host_type, :only => [:update]
before_action :find_multiple, :only => MULTIPLE_ACTIONS
before_action :validate_power_action, :only => :update_multiple_power_state
# index action is already included in ApplicationController
before_action(:only => SEARCHABLE_ACTIONS.without('index')) { find_selected_columns }

helper :hosts, :reports, :interfaces

Expand Down
52 changes: 0 additions & 52 deletions app/helpers/selectable_columns_helper.rb

This file was deleted.

4 changes: 0 additions & 4 deletions app/registries/foreman/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,6 @@ def settings(&block)
SettingManager.define(id, &block)
end

def selectable_columns(table, &block)
Foreman::SelectableColumns::Storage.register(table, &block)
end

def security_block(name, &block)
@security_block = name
instance_eval(&block)
Expand Down
63 changes: 0 additions & 63 deletions app/registries/foreman/selectable_columns/category.rb

This file was deleted.

57 changes: 0 additions & 57 deletions app/registries/foreman/selectable_columns/storage.rb

This file was deleted.

28 changes: 0 additions & 28 deletions app/registries/foreman/selectable_columns/table.rb

This file was deleted.

1 change: 0 additions & 1 deletion app/views/common/_selectable_column_td.html.erb

This file was deleted.

1 change: 0 additions & 1 deletion app/views/common/_selectable_column_th.html.erb

This file was deleted.

17 changes: 15 additions & 2 deletions app/views/hosts/_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@
<% if power_status_visible? %>
<th class="ca" width="80px"><%= _('Power') %></th>
<% end %>
<%= render_selected_column_ths %>
<th width="25%"><%= sort :name, :as => _('Name') %></th>
<th class="hidden-xs" width="17%"><%= sort :os_title, :as => _("Operating system") %></th>
<th class="hidden-tablet hidden-xs" width="10%"><%= sort :model, :as => _('Model') %></th>
<th class="hidden-tablet hidden-xs" width="8%"><%= sort :owner, :as => _('Owner') %></th>
<th class="hidden-tablet hidden-xs" width="15%"><%= sort :hostgroup, :as => _("Host group") %></th>
<th class="hidden-tablet hidden-xs" width="10%"><%= sort :last_report, :as => _('Last report'), :default => 'DESC' %></th>
<%= render_pagelets_for(:hosts_table_column_header) %>
<th class="hidden-tablet hidden-xs" width="7%"><%= sort :comment, :as => _('Comment') %></th>
<th width="100px"><%= _('Actions') %></th>
</tr>
</thead>
Expand All @@ -23,8 +29,15 @@
<%= react_component('PowerStatus', id: host.id, url: power_api_host_path(host)) %>
</td>
<% end %>
<%= render_selected_column_tds(host) %>
<td class="ellipsis"><%= name_column(host) %>
</td>
<td class="hidden-xs ellipsis"><%= (icon(host.operatingsystem, :size => "16x16") + " #{host.operatingsystem.to_label}").html_safe if host.operatingsystem %></td>
<td class="hidden-tablet hidden-xs ellipsis"><%= host.compute_resource_or_model %></td>
<td class="hidden-tablet hidden-xs ellipsis"><%= host_owner_column(host) %></td>
<td class="hidden-tablet hidden-xs"><%= label_with_link host.hostgroup, 23, @hostgroup_authorizer %></td>
<td class="hidden-tablet hidden-xs ellipsis"><%= last_report_column(host) %></td>
<%= render_pagelets_for(:hosts_table_column_content, :subject => host) %>
<td class="hidden-tablet hidden-xs ca" title="<%= host.comment&.truncate(255) %>"><%= icon_text('comment', '') unless host.comment.empty? %></td>
<td>
<%= action_buttons(
display_link_if_authorized(_("Edit"), hash_for_edit_host_path(:id => host).merge(:auth_object => host, :authorizer => authorizer)),
Expand Down
21 changes: 0 additions & 21 deletions config/initializers/foreman_register.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,3 @@
partial: 'hosts/init_config_tab',
priority: 100
end

Foreman::SelectableColumns::Storage.define(:hosts) do
category :general, default: true do
column :name, th: { label: _('Name'), sortable: true, width: '25%' },
td: { class: 'ellipsis', callback: ->(host) { name_column(host) } }
column :os_title, th: { label: _('Operating system'), sortable: true, width: '17%', class: 'hidden-xs' },
td: { class: 'hidden-xs ellipsis', callback: ->(host) { (icon(host.operatingsystem, size: "16x16") + " #{host.operatingsystem.to_label}").html_safe if host.operatingsystem } }
column :model, th: { label: _('Model'), sortable: true, width: '10%', class: common_th_class },
td: { class: common_td_class, callback: ->(host) { host.compute_resource_or_model } }
column :owner, th: { label: _('Owner'), sortable: true, width: '8%', class: common_th_class },
td: { class: common_td_class, callback: ->(host) { host_owner_column(host) } }
column :hostgroup, th: { label: _('Host group'), sortable: true, width: '15%', class: common_th_class },
td: { class: common_th_class, callback: ->(host) { label_with_link host.hostgroup, 23, @hostgroup_authorizer } }
column :last_report, th: { label: _('Last report'), sortable: true, default_sort: 'DESC', width: '10%', class: common_th_class },
td: { class: common_td_class, callback: ->(host) { last_report_column(host) } }
column :comment, th: { label: _('Comment'), sortable: true, width: '7%', class: common_th_class },
td: { class: common_th_class + ' ca',
attr_callbacks: { title: ->(host) { host.comment&.truncate(255) } },
callback: ->(host) { icon_text('comment', '') unless host.comment.empty? } }
end
end
Loading

0 comments on commit 387608c

Please sign in to comment.