From c054e59754114595f2f436f7c0b6d54e7bf33df0 Mon Sep 17 00:00:00 2001 From: MariaAga Date: Fri, 10 Jan 2025 12:34:53 +0000 Subject: [PATCH] Refs #37987 - remove taxonimoes override from filter --- app/controllers/api/v2/filters_controller.rb | 3 - .../foreman/controller/parameters/filter.rb | 2 - app/controllers/filters_controller.rb | 15 ---- app/controllers/roles_controller.rb | 9 +- app/models/filter.rb | 36 ++------ app/models/role.rb | 4 - app/views/api/v2/filters/main.json.rabl | 6 +- app/views/api/v2/filters/show.json.rabl | 4 - app/views/filters/index.html.erb | 4 - app/views/roles/_form.html.erb | 3 - config/initializers/f_foreman_permissions.rb | 4 +- config/routes.rb | 2 - ..._search_for_filters_with_override_false.rb | 10 --- ...emove_taxonomy_and_override_from_filter.rb | 23 +++++ .../api/v2/filters_controller_test.rb | 22 ----- test/controllers/filters_controller_test.rb | 19 ---- test/controllers/roles_controller_test.rb | 13 --- test/models/filter_test.rb | 9 -- test/models/role_test.rb | 13 --- .../routes/FiltersForm/FiltersForm.js | 86 ++++++------------- .../routes/FiltersForm/FiltersForm.test.js | 9 -- .../routes/FiltersForm/NewFiltersFormPage.js | 2 +- .../routes/FiltersForm/Taxonomies.js | 49 ----------- 23 files changed, 63 insertions(+), 284 deletions(-) delete mode 100644 db/migrate/20241105143353_regenerate_taxonomy_search_for_filters_with_override_false.rb create mode 100644 db/migrate/20250109165511_remove_taxonomy_and_override_from_filter.rb delete mode 100644 webpack/assets/javascripts/react_app/routes/FiltersForm/Taxonomies.js diff --git a/app/controllers/api/v2/filters_controller.rb b/app/controllers/api/v2/filters_controller.rb index 0dc73113c24..1f06348d426 100644 --- a/app/controllers/api/v2/filters_controller.rb +++ b/app/controllers/api/v2/filters_controller.rb @@ -25,10 +25,7 @@ def show param :filter, Hash, :action_aware => true, :required => true do param :role_id, String, :required => true param :search, String - param :override, :bool param :permission_ids, Array - param :organization_ids, Array - param :location_ids, Array end end diff --git a/app/controllers/concerns/foreman/controller/parameters/filter.rb b/app/controllers/concerns/foreman/controller/parameters/filter.rb index c3117bf1a8d..ce6292a8a8d 100644 --- a/app/controllers/concerns/foreman/controller/parameters/filter.rb +++ b/app/controllers/concerns/foreman/controller/parameters/filter.rb @@ -8,9 +8,7 @@ def filter_params_filter filter.permit :resource_type, :role_id, :role_name, :search, - :taxonomy_search, :unlimited, - :override, :permissions => [], :permission_ids => [], :permission_names => [] add_taxonomix_params_filter(filter) end diff --git a/app/controllers/filters_controller.rb b/app/controllers/filters_controller.rb index 44040ca86a6..d05434a8a15 100644 --- a/app/controllers/filters_controller.rb +++ b/app/controllers/filters_controller.rb @@ -38,23 +38,8 @@ def destroy end end - def disable_overriding - @filter = resource_base.find(params[:id]) - @filter.disable_overriding! - process_success :success_msg => _('Filter overriding has been disabled') - end - private - def action_permission - case params[:action] - when 'disable_overriding' - 'edit' - else - super - end - end - def find_role @role = Role.find_by_id(role_id) end diff --git a/app/controllers/roles_controller.rb b/app/controllers/roles_controller.rb index 744cedea814..9dd53b3e1d3 100644 --- a/app/controllers/roles_controller.rb +++ b/app/controllers/roles_controller.rb @@ -18,7 +18,7 @@ class RolesController < ApplicationController include Foreman::Controller::AutoCompleteSearch include Foreman::Controller::Parameters::Role - before_action :find_resource, :only => [:clone, :edit, :update, :destroy, :disable_filters_overriding] + before_action :find_resource, :only => [:clone, :edit, :update, :destroy] def index params[:order] ||= 'name' @@ -69,19 +69,12 @@ def destroy end end - def disable_filters_overriding - @role.disable_filters_overriding - process_success :success_msg => _('Filters overriding has been disabled') - end - private def action_permission case params[:action] when 'clone' 'view' - when 'disable_filters_overriding' - 'edit' else super end diff --git a/app/models/filter.rb b/app/models/filter.rb index dce04fd49db..c39ddffafa3 100644 --- a/app/models/filter.rb +++ b/app/models/filter.rb @@ -1,7 +1,6 @@ class Filter < ApplicationRecord audited :associated_with => :role - include Taxonomix include Authorizable include TopbarCacheExpiry @@ -42,7 +41,6 @@ def ensure_taxonomies_not_escalated scoped_search :on => :id, :complete_enabled => false, :only_explicit => true, :validator => ScopedSearch::Validators::INTEGER scoped_search :on => :search, :complete_value => true - scoped_search :on => :override, :complete_value => { :true => true, :false => false } scoped_search :on => :limited, :complete_value => { :true => true, :false => false }, :ext_method => :search_by_limited, :only_explicit => true scoped_search :on => :unlimited, :complete_value => { :true => true, :false => false }, :ext_method => :search_by_unlimited, :only_explicit => true scoped_search :relation => :role, :on => :id, :rename => :role_id, :complete_enabled => false, :only_explicit => true, :validator => ScopedSearch::Validators::INTEGER @@ -50,7 +48,7 @@ def ensure_taxonomies_not_escalated scoped_search :relation => :permissions, :on => :resource_type, :rename => :resource scoped_search :relation => :permissions, :on => :name, :rename => :permission - before_validation :build_taxonomy_search, :nilify_empty_searches, :enforce_override_flag + before_validation :nilify_empty_searches before_save :enforce_inherited_taxonomies, :nilify_empty_searches validates :search, :presence => true, :unless => proc { |o| o.search.nil? } @@ -60,7 +58,7 @@ def ensure_taxonomies_not_escalated validate :role_not_locked before_destroy :role_not_locked - validate :same_resource_type_permissions, :not_empty_permissions, :allowed_taxonomies + validate :same_resource_type_permissions, :not_empty_permissions def self.allows_taxonomy_filtering?(_taxonomy) false @@ -153,18 +151,9 @@ def expire_topbar_cache role.usergroups.each { |g| g.expire_topbar_cache } end - def disable_overriding! - self.override = false - save! - end - def enforce_inherited_taxonomies - inherit_taxonomies! unless override? - end - - def inherit_taxonomies! - self.organization_ids = role.organization_ids if resource_taxable_by_organization? - self.location_ids = role.location_ids if resource_taxable_by_location? + @organization_ids = role.organization_ids if resource_taxable_by_organization? + @location_ids = role.location_ids if resource_taxable_by_location? build_taxonomy_search end @@ -178,7 +167,7 @@ def build_taxonomy_search def build_taxonomy_search_string_from_ids(name) return '' unless send("resource_taxable_by_#{name}?") - relation = send("#{name}_ids") + relation = name == "location" ? @location_ids : @organization_ids return '' if relation.empty? parenthesize("#{name}_id ^ (#{relation.join(',')})") @@ -218,21 +207,6 @@ def not_empty_permissions errors.add(:permissions, _('You must select at least one permission')) if permissions.blank? && filterings.blank? end - def allowed_taxonomies - if organization_ids.present? && !resource_taxable_by_organization? - errors.add(:organization_ids, _('You can\'t assign organizations to this resource')) - end - - if location_ids.present? && !resource_taxable_by_location? - errors.add(:location_ids, _('You can\'t assign locations to this resource')) - end - end - - def enforce_override_flag - self.override = false unless resource_taxable? - true - end - def role_not_locked errors.add(:role_id, _('is locked for user modifications.')) if role.locked? && !role.modify_locked errors.empty? diff --git a/app/models/role.rb b/app/models/role.rb index 842c751db3c..3e2310d6c1c 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -216,10 +216,6 @@ def remove_permissions!(*args) find_for_permission_removal(args).map(&:destroy!) end - def disable_filters_overriding - filters.where(:override => true).map { |filter| filter.disable_overriding! } - end - def clone(role_params = {}) new_role = deep_clone(:except => [:name, :builtin, :origin], :include => [:locations, :organizations, { :filters => :permissions }]) diff --git a/app/views/api/v2/filters/main.json.rabl b/app/views/api/v2/filters/main.json.rabl index b1af5a33bd7..db84f638220 100644 --- a/app/views/api/v2/filters/main.json.rabl +++ b/app/views/api/v2/filters/main.json.rabl @@ -2,10 +2,14 @@ object @filter extends "api/v2/filters/base" -attributes :search, :resource_type_label, :unlimited?, :created_at, :updated_at, :override? +attributes :search, :resource_type_label, :unlimited?, :created_at, :updated_at child :role do extends "api/v2/roles/base" + node do |role| + partial("api/v2/taxonomies/children_nodes", :object => role) + end + end child :permissions do diff --git a/app/views/api/v2/filters/show.json.rabl b/app/views/api/v2/filters/show.json.rabl index a9e2bbf991d..aea36bb4cc6 100644 --- a/app/views/api/v2/filters/show.json.rabl +++ b/app/views/api/v2/filters/show.json.rabl @@ -1,7 +1,3 @@ object @filter extends "api/v2/filters/main" - -node do |filter| - partial("api/v2/taxonomies/children_nodes", :object => filter) -end diff --git a/app/views/filters/index.html.erb b/app/views/filters/index.html.erb index f79b2f88352..67511d96f21 100644 --- a/app/views/filters/index.html.erb +++ b/app/views/filters/index.html.erb @@ -26,7 +26,6 @@ end %> <%= sort :resource, :as => s_("Filter|Resource"), :permitted => [:role_id] %> <%= s_("Filter|Permissions") %> <%= sort :search, :as => s_("Filter|Unlimited"), :permitted => [:role_id] %> - <%= sort :search, :as => s_("Filter|Override"), :permitted => [:role_id] %> <%= sort :search, :as => s_("Filter|Search"), :permitted => [:role_id] %> <% if @role && !@role.locked? %> <%= _('Actions') %> @@ -47,7 +46,6 @@ end %> <%= filter.permissions.map(&:name).join(', ') %> <%= checked_icon filter.unlimited? %> - <%= checked_icon filter.override? %> <%= content_tag('span', link_to_unless_locked(filter.search || _('N/A'), @role, hash_for_edit_filter_path(:id => filter, :role_id => @role). @@ -58,8 +56,6 @@ end %> <% buttons = [] %> <% buttons.push display_link_if_authorized(_("Edit"), hash_for_edit_filter_path(:id => filter, :role_id => @role). merge(:auth_object => filter, :authorizer => authorizer)) %> - <% buttons.push display_link_if_authorized(_("Disable overriding"), hash_for_disable_overriding_filter_path(:id => filter, :role_id => @role). - merge(:auth_object => filter, :authorizer => authorizer), :method => :patch) if filter.override? %> <% buttons.push display_delete_if_authorized(hash_for_filter_path(:id => filter, :role_id => @role). merge(:auth_object => filter, :authorizer => authorizer), :data => { :confirm => (_("Delete filter?")) } ) %> diff --git a/app/views/roles/_form.html.erb b/app/views/roles/_form.html.erb index d76e2261371..c37991e0780 100644 --- a/app/views/roles/_form.html.erb +++ b/app/views/roles/_form.html.erb @@ -28,7 +28,6 @@ <%= hidden_field_tag :original_role_id, @role.cloned_from_id if @cloned_role %> <% tax_help = N_("When the role's associated %{taxonomies} are changed,
the change will propagate to all inheriting filters. - Filters that are set to override
will remain untouched. Overriding of role filters can be easily disabled by
pressing the \"Disable overriding\" button. Note that not all filters support
%{taxonomies}, so these always remain global.") %> <% if show_location_tab? %> <% loc_help = _(tax_help) % { :taxonomies => _('locations') }%> @@ -52,8 +51,6 @@
<%= link_to_if_authorized(_("New filter"), hash_for_new_filters_path(:role_id => @role), { :class => 'btn btn-success pull-right'} ) %> - <%= link_to_if_authorized(_('Disable all filters overriding'), hash_for_disable_filters_overriding_role_path(:id => @role), - :method => :patch, :class => 'btn btn-default pull-right') %> <% end %> diff --git a/config/initializers/f_foreman_permissions.rb b/config/initializers/f_foreman_permissions.rb index f5bbda18c5b..88fdca82de0 100644 --- a/config/initializers/f_foreman_permissions.rb +++ b/config/initializers/f_foreman_permissions.rb @@ -192,7 +192,7 @@ :'api/v2/filters' => [:index, :show]} map.permission :create_filters, {:filters => [:new, :create], :'api/v2/filters' => [:create]} - map.permission :edit_filters, {:filters => [:edit, :update, :disable_overriding], :permissions => [:index, :show_resource_types_with_translations], + map.permission :edit_filters, {:filters => [:edit, :update ], :permissions => [:index, :show_resource_types_with_translations], :'api/v2/filters' => [:update], :'api/v2/permissions' => [:index, :show, :resource_types]} map.permission :destroy_filters, {:filters => [:destroy], @@ -453,7 +453,7 @@ :'api/v2/roles' => [:index, :show]} map.permission :create_roles, {:roles => [:new, :create, :clone], :'api/v2/roles' => [:create, :clone]} - map.permission :edit_roles, {:roles => [:edit, :update, :disable_filters_overriding], + map.permission :edit_roles, {:roles => [:edit, :update], :'api/v2/roles' => [:update]} map.permission :destroy_roles, {:roles => [:destroy], :'api/v2/roles' => [:destroy]} diff --git a/config/routes.rb b/config/routes.rb index e2723eee05b..178db4c95f3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -263,7 +263,6 @@ resources :roles, except: [:show] do member do get 'clone' - patch 'disable_filters_overriding' end collection do get 'auto_complete_search' @@ -272,7 +271,6 @@ resources :filters, except: [:show, :new, :edit] do member do - patch 'disable_overriding' get 'edit', to: 'react#index' end collection do diff --git a/db/migrate/20241105143353_regenerate_taxonomy_search_for_filters_with_override_false.rb b/db/migrate/20241105143353_regenerate_taxonomy_search_for_filters_with_override_false.rb deleted file mode 100644 index c71d396e3c3..00000000000 --- a/db/migrate/20241105143353_regenerate_taxonomy_search_for_filters_with_override_false.rb +++ /dev/null @@ -1,10 +0,0 @@ -class RegenerateTaxonomySearchForFiltersWithOverrideFalse < ActiveRecord::Migration[6.1] - def change - filters = Filter.where(role_id: Role.where(origin: nil).or(Role.where(builtin: 2))).where(override: false).where(taxonomy_search: nil) - - filters.each do |filter| - filter.build_taxonomy_search - filter.update_column(:taxonomy_search, filter.taxonomy_search) - end - end -end diff --git a/db/migrate/20250109165511_remove_taxonomy_and_override_from_filter.rb b/db/migrate/20250109165511_remove_taxonomy_and_override_from_filter.rb new file mode 100644 index 00000000000..b2cb41ee159 --- /dev/null +++ b/db/migrate/20250109165511_remove_taxonomy_and_override_from_filter.rb @@ -0,0 +1,23 @@ +class RemoveTaxonomyAndOverrideFromFilter < ActiveRecord::Migration[7.0] + def up + # remove_column :filters, :taxonomy_search + # remove_column :filters, :override + # filters = Filter.where(role_id: Role.where(origin: nil).or(Role.where(builtin: 2))) + + # filters.each do |filter| + # filter.enforce_inherited_taxonomies + # filter.update_column(:taxonomy_search, filter.taxonomy_search) + # end + end + + def down + # add_column :filters, :taxonomy_search, :text + # add_column :filters, :override, :boolean, :default => false, :null => false + # filters = Filter.where(role_id: Role.where(origin: nil).or(Role.where(builtin: 2))).where(override: false).where(taxonomy_search: nil) + + # filters.each do |filter| + # filter.build_taxonomy_search + # filter.update_column(:taxonomy_search, filter.taxonomy_search) + # end + end +end diff --git a/test/controllers/api/v2/filters_controller_test.rb b/test/controllers/api/v2/filters_controller_test.rb index 64317864c66..081984db45f 100644 --- a/test/controllers/api/v2/filters_controller_test.rb +++ b/test/controllers/api/v2/filters_controller_test.rb @@ -70,28 +70,6 @@ class Api::V2::FiltersControllerTest < ActionController::TestCase @loc = taxonomies(:location1) end - test "should create overridable filter" do - filter_loc = taxonomies(:location2) - filter_org = taxonomies(:organization2) - role = FactoryBot.create(:role, :name => 'New Role', :locations => [@loc], :organizations => [@org]) - assert_difference('Filter.count') do - filter_attr = { - :role_id => role.id, - :permission_ids => [permissions(:view_domains).id], - :override => true, - :location_ids => [filter_loc.id], - :organization_ids => [filter_org.id], - } - post :create, params: { :filter => filter_attr } - end - assert_response :created - result = JSON.parse(@response.body) - assert_equal true, result['override?'] - assert_equal role.id, result['role']['id'] - assert_equal filter_org.id, result['organizations'][0]['id'] - assert_equal filter_loc.id, result['locations'][0]['id'] - end - test "should disable filter override" do role = FactoryBot.create(:role, :name => 'New Role', :locations => [@loc], :organizations => [@org]) filter = FactoryBot.create(:filter, diff --git a/test/controllers/filters_controller_test.rb b/test/controllers/filters_controller_test.rb index c0830fb3277..e859ae55efa 100644 --- a/test/controllers/filters_controller_test.rb +++ b/test/controllers/filters_controller_test.rb @@ -46,23 +46,4 @@ class FiltersControllerTest < ActionController::TestCase assert_select "table[data-table='inline']" end - - test 'should disable overriding and start inheriting taxonomies from roles' do - permission1 = FactoryBot.create(:permission, :domain, :name => 'permission1') - role = FactoryBot.build(:role, :permissions => []) - role.add_permissions! [permission1.name] - org1 = FactoryBot.create(:organization) - org2 = FactoryBot.create(:organization) - role.organizations = [org1] - role.filters.reload - filter_with_org = role.filters.detect(&:resource_taxable_by_organization?) - filter_with_org.update :organizations => [org1, org2], :override => true - - patch :disable_overriding, params: { :role_id => role.id, :id => filter_with_org.id }, session: set_session_user - - assert_response :redirect - filter_with_org.reload - assert_equal [org1], filter_with_org.organizations - refute filter_with_org.override - end end diff --git a/test/controllers/roles_controller_test.rb b/test/controllers/roles_controller_test.rb index 3b3ef45714f..68b1d2dbe50 100644 --- a/test/controllers/roles_controller_test.rb +++ b/test/controllers/roles_controller_test.rb @@ -71,19 +71,6 @@ class RolesControllerTest < ActionController::TestCase @role.organizations = [@org1] end - test 'should disable filter overriding' do - @role.filters.reload - @filter_with_org = @role.filters.detect { |f| f.resource_taxable_by_organization? } - @filter_with_org.update :organizations => [@org1, @org2], :override => true - - patch :disable_filters_overriding, params: { :id => @role.id }, session: set_session_user - @filter_with_org.reload - - assert_response :redirect - assert_equal [@org1], @filter_with_org.organizations - refute @filter_with_org.override? - end - test 'update syncs filters taxonomies if configuration changed' do put :update, params: { :id => @role.id, :role => { :organization_ids => ['', @org2.id.to_s, ''] } }, session: set_session_user assert_response :redirect diff --git a/test/models/filter_test.rb b/test/models/filter_test.rb index 1db43826f43..65b13a153ac 100644 --- a/test/models/filter_test.rb +++ b/test/models/filter_test.rb @@ -215,15 +215,6 @@ class FilterTest < ActiveSupport::TestCase assert_valid f end - test 'disable overriding recalculates taxonomies' do - f = FactoryBot.build(:filter, :resource_type => 'Domain') - f.role = FactoryBot.build(:role, :organizations => [FactoryBot.build(:organization)]) - assert_empty f.organizations - f.disable_overriding! - refute f.override - assert_equal f.organizations, f.role.organizations - end - test 'enforce_inherited_taxonomies respects override configuration' do f = FactoryBot.build(:filter, :resource_type => 'Domain', :override => true) f.role = FactoryBot.build(:role, :organizations => [FactoryBot.build(:organization)]) diff --git a/test/models/role_test.rb b/test/models/role_test.rb index 98e0db99877..f14e3506fb4 100644 --- a/test/models/role_test.rb +++ b/test/models/role_test.rb @@ -427,19 +427,6 @@ def test_allow_to_modify_roles_when_bypass_locking end end - describe '#disable_filters_overriding' do - it 'disables overriding and inherits taxonomies' do - @filter_with_org.update_attribute :override, true - @role.organizations = [@org1] - as_admin do - @role.disable_filters_overriding - @filter_with_org.reload - assert_equal [@org1], @filter_with_org.organizations - refute @filter_with_org.override - end - end - end - describe '#search_by_permission' do setup do @domain_permission = FactoryBot.create(:permission, :domain, :name => 'view_test_domain') diff --git a/webpack/assets/javascripts/react_app/routes/FiltersForm/FiltersForm.js b/webpack/assets/javascripts/react_app/routes/FiltersForm/FiltersForm.js index 65c2fa598a4..929977683a8 100644 --- a/webpack/assets/javascripts/react_app/routes/FiltersForm/FiltersForm.js +++ b/webpack/assets/javascripts/react_app/routes/FiltersForm/FiltersForm.js @@ -9,6 +9,7 @@ import { Popover, ActionGroup, Button, + TextInput, } from '@patternfly/react-core'; import { HelpIcon } from '@patternfly/react-icons'; import { translate as __ } from '../../common/I18n'; @@ -18,7 +19,6 @@ import { SelectPermissions } from './SelectPermissions'; import { SelectResourceType } from './SelectResourceType'; import { SelectRole } from './SelectRole'; import { EMPTY_RESOURCE_TYPE, SEARCH_ID } from './FiltersFormConstants'; -import { Taxonomies } from './Taxonomies'; import { APIActions } from '../../redux/API'; import { addToast } from '../../components/ToastsList'; @@ -27,18 +27,9 @@ export const FiltersForm = ({ roleName, roleId, isNew, data, history }) => { const [type, setType] = useState(EMPTY_RESOURCE_TYPE); const [chosenPermissions, setChosenPermissions] = useState([]); const [isUnlimited, setIsUnlimited] = useState(!!data['unlimited?']); - const [isOverride, setIsOverride] = useState(!!data['override?']); const [isGranular, setIsGranular] = useState(false); - const [chosenOrgs, setChosenOrgs] = useState( - data.organizations?.map(o => o.id) || [] - ); - const [chosenLocations, setChosenLocations] = useState( - data.locations?.map(l => l.id) || [] - ); - const { - show_organizations: showOrgs = false, - show_locations: showLocations = false, - } = type; + const chosenOrgs = data?.role?.organizations?.map(o => o.name) || []; + const chosenLocations = data?.role?.locations?.map(l => l.name) || []; const isTaxonomySearch = useMemo( () => chosenOrgs.length || chosenLocations.length, @@ -59,10 +50,7 @@ export const FiltersForm = ({ roleName, roleId, isNew, data, history }) => { search: isUnlimited ? null : autocompleteQuery, unlimited: isUnlimited || (!autocompleteQuery.length && !isTaxonomySearch), - override: isOverride, permission_ids: chosenPermissions, - organization_ids: chosenOrgs, - location_ids: chosenLocations, }, }; const apiOptions = { @@ -129,53 +117,31 @@ export const FiltersForm = ({ roleName, roleId, isNew, data, history }) => { defaultPermissions={data.permissions} setChosenPermissions={setChosenPermissions} /> - {(showOrgs || showLocations) && ( - - {__( - 'Filters inherit organizations and locations associated with the role by default. If override field is enabled, the filter can override the set of its organizations and locations. Later role changes will not affect such filter.After disabling the override field, the role organizations and locations apply again.' - )} - - } - > - - - } - > - { - setIsOverride(checked); - }} - aria-label="is override" - id="override-check" - name="override" - /> - - )} - {isOverride && ( - + - )} + + + + {isGranular ? ( <> {!!isTaxonomySearch && ( diff --git a/webpack/assets/javascripts/react_app/routes/FiltersForm/FiltersForm.test.js b/webpack/assets/javascripts/react_app/routes/FiltersForm/FiltersForm.test.js index 9f1175f5516..5f639e7fede 100644 --- a/webpack/assets/javascripts/react_app/routes/FiltersForm/FiltersForm.test.js +++ b/webpack/assets/javascripts/react_app/routes/FiltersForm/FiltersForm.test.js @@ -30,7 +30,6 @@ const editProps = { 'unlimited?': true, created_at: '2022-04-06 14:26:22 +0200', updated_at: '2022-04-06 14:26:22 +0200', - 'override?': true, id: 567, resource_type: 'Host', role: { @@ -213,7 +212,6 @@ describe('FiltersForm', () => { expect(screen.queryAllByText('access_dashboard')).toHaveLength(0); expect(screen.queryAllByText('view_hosts')).toHaveLength(1); expect(screen.queryAllByDisplayValue('os = CentOS')).toHaveLength(1); - expect(screen.queryAllByText('Override?')).toHaveLength(1); expect(screen.queryAllByText('Unlimited?')).toHaveLength(1); expect(screen.queryAllByText('0 of 7 items selected')).toHaveLength(1); // unselected permissions expect(screen.queryAllByText('0 of 2 items selected')).toHaveLength(1); // selected permissions @@ -231,7 +229,6 @@ describe('FiltersForm', () => { ); expect(screen.queryAllByText('access_dashboard')).toHaveLength(1); expect(screen.queryAllByText('view_hosts')).toHaveLength(0); - expect(screen.queryAllByText('Override?')).toHaveLength(0); expect(screen.queryAllByText('Unlimited?')).toHaveLength(0); act(() => { fireEvent.click(screen.getByLabelText('resource type toggle')); @@ -242,7 +239,6 @@ describe('FiltersForm', () => { expect(screen.queryAllByText('access_dashboard')).toHaveLength(0); expect(screen.queryAllByText('view_hosts')).toHaveLength(1); - expect(screen.queryAllByText('Override?')).toHaveLength(1); expect(screen.queryAllByText('Unlimited?')).toHaveLength(1); expect(screen.getByPlaceholderText('Search')).not.toBeDisabled(); act(() => { @@ -250,11 +246,6 @@ describe('FiltersForm', () => { }); expect(screen.getByPlaceholderText('Search')).toBeDisabled(); - expect(screen.queryAllByText('Organizations')).toHaveLength(0); - expect(screen.queryAllByText('Locations')).toHaveLength(0); - await act(async() => { - fireEvent.click(screen.getByLabelText('is override')); - }); expect(screen.queryAllByText('Organizations')).toHaveLength(1); expect(screen.queryAllByText('Locations')).toHaveLength(1); }); diff --git a/webpack/assets/javascripts/react_app/routes/FiltersForm/NewFiltersFormPage.js b/webpack/assets/javascripts/react_app/routes/FiltersForm/NewFiltersFormPage.js index 500f952b218..9c936889629 100644 --- a/webpack/assets/javascripts/react_app/routes/FiltersForm/NewFiltersFormPage.js +++ b/webpack/assets/javascripts/react_app/routes/FiltersForm/NewFiltersFormPage.js @@ -29,7 +29,7 @@ const NewFiltersFormPage = ({ location: { search }, history }) => { isNew roleName={roleName || ''} roleId={urlRoleId} - data={{ locations, organizations }} + data={{ role: { locations, organizations } }} history={history} /> ) : ( diff --git a/webpack/assets/javascripts/react_app/routes/FiltersForm/Taxonomies.js b/webpack/assets/javascripts/react_app/routes/FiltersForm/Taxonomies.js deleted file mode 100644 index b813242a894..00000000000 --- a/webpack/assets/javascripts/react_app/routes/FiltersForm/Taxonomies.js +++ /dev/null @@ -1,49 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { FormGroup } from '@patternfly/react-core'; -import { DualListWithIds } from '../../components/common/Pf4DualList/DualListWithIds'; -import { translate as __ } from '../../common/I18n'; - -export const Taxonomies = ({ - showOrgs, - showLocations, - setChosenOrgs, - setChosenLocations, - defaultOrgs, - defaultLocations, -}) => ( - <> - {showOrgs && ( - - - - )} - {showLocations && ( - - - - )} - -); -Taxonomies.propTypes = { - showOrgs: PropTypes.bool.isRequired, - showLocations: PropTypes.bool.isRequired, - setChosenOrgs: PropTypes.func.isRequired, - setChosenLocations: PropTypes.func.isRequired, - defaultOrgs: PropTypes.array, - defaultLocations: PropTypes.array, -}; -Taxonomies.defaultProps = { - defaultOrgs: [], - defaultLocations: [], -};