foreman_puppet 10.1.3 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/concerns/foreman_puppet/extensions/host.rb +2 -2
- data/app/models/concerns/foreman_puppet/extensions/host_common.rb +35 -0
- data/app/models/concerns/foreman_puppet/extensions/hostgroup.rb +10 -3
- data/app/models/foreman_puppet/config_group.rb +6 -0
- data/app/models/foreman_puppet/puppetclass.rb +14 -0
- data/lib/foreman_puppet/register.rb +1 -1
- data/lib/foreman_puppet/version.rb +1 -1
- data/test/models/foreman_puppet/host_test.rb +66 -0
- data/test/models/foreman_puppet/hostgroup_test.rb +32 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkChangeProxyCommon/index.js +9 -13
- data/webpack/src/Extends/Hosts/BulkActions/BulkChangePuppetCAProxy/__tests__/index.test.js +3 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkChangePuppetCAProxy/index.js +2 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkChangePuppetProxy/__tests__/index.test.js +3 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkChangePuppetProxy/index.js +2 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkRemoveProxyCommon/index.js +8 -13
- data/webpack/src/Extends/Hosts/BulkActions/BulkRemovePuppetCAProxy/__tests__/index.test.js +3 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkRemovePuppetCAProxy/index.js +2 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkRemovePuppetProxy/__tests__/index.test.js +3 -0
- data/webpack/src/Extends/Hosts/BulkActions/BulkRemovePuppetProxy/index.js +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5a50beabd870a36bed2dbf49653e80e1766178fe79922553a227ce8ea54563c2
|
|
4
|
+
data.tar.gz: d68b2c95b690b4d5b9e38100c14d06ea0911de97587660708a0ab0b68e325e45
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d26f5e28b2c205a3484811497f0e332fef3d0ec1afede88e2ab81716038d1a103b9d8a43c1ce65c6cd4b7e77d6723ae8d0eef2fb69e3a0fd415e3b1ded2e604f
|
|
7
|
+
data.tar.gz: 37ecf68758a85dedc51f3856156bce673675b9d22fc9acec8c75848a7d819a91c022cfd1da4b08c4106b8d46e6591e00b16d1cb97f386a90c2172560c008529a
|
|
@@ -13,9 +13,9 @@ module ForemanPuppet
|
|
|
13
13
|
include_in_clone puppet: %i[config_groups host_config_groups host_classes]
|
|
14
14
|
|
|
15
15
|
scoped_search relation: :environment, on: :name, complete_value: true, rename: :environment
|
|
16
|
-
scoped_search relation: :
|
|
16
|
+
scoped_search relation: :search_puppetclasses, on: :name, complete_value: true, rename: :puppetclass, only_explicit: true, operators: ['= ', '~ '],
|
|
17
17
|
ext_method: :search_by_puppetclass
|
|
18
|
-
scoped_search relation: :
|
|
18
|
+
scoped_search relation: :search_config_groups, on: :name, complete_value: true, rename: :config_group, only_explicit: true, operators: ['= ', '~ '],
|
|
19
19
|
ext_method: :search_by_config_group
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -3,6 +3,41 @@ module ForemanPuppet
|
|
|
3
3
|
module HostCommon
|
|
4
4
|
extend ActiveSupport::Concern
|
|
5
5
|
|
|
6
|
+
ASSIGNMENT_RELATIONS = %i[search_puppetclasses search_config_groups].freeze
|
|
7
|
+
|
|
8
|
+
included do
|
|
9
|
+
singleton_class.prepend CompletionMethods
|
|
10
|
+
|
|
11
|
+
has_many :search_puppetclasses, through: :puppet, source: :puppetclasses, class_name: '::ForemanPuppet::Puppetclass'
|
|
12
|
+
has_many :search_config_groups, through: :puppet, source: :config_groups, class_name: '::ForemanPuppet::ConfigGroup'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
module CompletionMethods
|
|
16
|
+
def complete_for(query, options = {})
|
|
17
|
+
return super if query.nil?
|
|
18
|
+
|
|
19
|
+
completer = AssignmentCompleter.new(scoped_search_definition, query, options)
|
|
20
|
+
return super unless completer.assignment_field?
|
|
21
|
+
|
|
22
|
+
completer.build_autocomplete_options
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
class AssignmentCompleter < ScopedSearch::AutoCompleteBuilder
|
|
27
|
+
def assignment_field?
|
|
28
|
+
return false unless complete_options(last_node).include?(:value)
|
|
29
|
+
|
|
30
|
+
token = last_token_is(COMPARISON_OPERATORS) ? tokens[-2] : tokens[-3]
|
|
31
|
+
ASSIGNMENT_RELATIONS.include?(definition.field_by_name(token)&.relation)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def completer_scope(field)
|
|
35
|
+
return super unless ASSIGNMENT_RELATIONS.include?(field.relation)
|
|
36
|
+
|
|
37
|
+
field.klass.completer_scope(@options).reorder(Arel.sql(field.quoted_field))
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
6
41
|
def all_puppetclasses(env = environment)
|
|
7
42
|
return ForemanPuppet::Puppetclass.none unless puppet
|
|
8
43
|
puppet.all_puppetclasses(env)
|
|
@@ -16,13 +16,13 @@ module ForemanPuppet
|
|
|
16
16
|
|
|
17
17
|
# will need through relation to work properly
|
|
18
18
|
scoped_search relation: :environment, on: :name, complete_value: true, rename: :environment, only_explicit: true
|
|
19
|
-
scoped_search relation: :
|
|
19
|
+
scoped_search relation: :search_puppetclasses, on: :name,
|
|
20
20
|
complete_value: true,
|
|
21
21
|
rename: :puppetclass,
|
|
22
22
|
only_explicit: true,
|
|
23
23
|
operators: ['= ', '~ '],
|
|
24
24
|
ext_method: :search_by_puppetclass
|
|
25
|
-
scoped_search relation: :
|
|
25
|
+
scoped_search relation: :search_config_groups, on: :name,
|
|
26
26
|
complete_value: true,
|
|
27
27
|
rename: :config_group,
|
|
28
28
|
only_explicit: true,
|
|
@@ -45,9 +45,16 @@ module ForemanPuppet
|
|
|
45
45
|
def search_by_puppetclass(_key, operator, value)
|
|
46
46
|
conditions = sanitize_sql_for_conditions(["puppetclasses.name #{operator} ?", value_to_sql(operator, value)])
|
|
47
47
|
hostgroup_ids = ::Hostgroup.joins(puppet: :puppetclasses).where(conditions).map(&:subtree_ids)
|
|
48
|
+
config_group_ids = ForemanPuppet::ConfigGroup.joins(:puppetclasses).where(conditions).pluck(:id)
|
|
49
|
+
if config_group_ids.any?
|
|
50
|
+
hostgroup_cg_ids = ForemanPuppet::HostgroupPuppetFacet.joins(:host_config_groups)
|
|
51
|
+
.where(host_config_groups: { config_group_id: config_group_ids })
|
|
52
|
+
.pluck(:hostgroup_id)
|
|
53
|
+
hostgroup_ids += ::Hostgroup.where(id: hostgroup_cg_ids).map(&:subtree_ids)
|
|
54
|
+
end
|
|
48
55
|
|
|
49
56
|
conds = []
|
|
50
|
-
conds << "hostgroups.id IN (#{hostgroup_ids.join(',')})" if hostgroup_ids.present?
|
|
57
|
+
conds << "hostgroups.id IN (#{hostgroup_ids.uniq.join(',')})" if hostgroup_ids.present?
|
|
51
58
|
|
|
52
59
|
{ conditions: conds.join(' OR ').presence || 'hostgroups.id < 0' }
|
|
53
60
|
end
|
|
@@ -16,6 +16,8 @@ module ForemanPuppet
|
|
|
16
16
|
|
|
17
17
|
validates :name, presence: true, uniqueness: true
|
|
18
18
|
|
|
19
|
+
scope :assigned_to_hosts, -> { where(id: ForemanPuppet::HostConfigGroup.select(:config_group_id)) }
|
|
20
|
+
|
|
19
21
|
scoped_search on: :name, complete_value: true
|
|
20
22
|
scoped_search relation: :puppetclasses, on: :name, complete_value: true, rename: :puppetclass, only_explicit: true, operators: ['= ', '~ ']
|
|
21
23
|
|
|
@@ -41,5 +43,9 @@ module ForemanPuppet
|
|
|
41
43
|
def hostgroups_count
|
|
42
44
|
::Hostgroup.authorized.search_for(%(config_group="#{name}")).size
|
|
43
45
|
end
|
|
46
|
+
|
|
47
|
+
def self.completer_scope(options)
|
|
48
|
+
super.merge(assigned_to_hosts)
|
|
49
|
+
end
|
|
44
50
|
end
|
|
45
51
|
end
|
|
@@ -41,6 +41,16 @@ module ForemanPuppet
|
|
|
41
41
|
|
|
42
42
|
default_scope -> { order(:name) }
|
|
43
43
|
|
|
44
|
+
scope :assigned_to_hosts, lambda {
|
|
45
|
+
direct = ForemanPuppet::HostClass.select(:puppetclass_id)
|
|
46
|
+
via_hostgroup = ForemanPuppet::HostgroupClass.select(:puppetclass_id)
|
|
47
|
+
via_config_group = ForemanPuppet::ConfigGroupClass
|
|
48
|
+
.where(config_group_id: ForemanPuppet::HostConfigGroup.select(:config_group_id))
|
|
49
|
+
.select(:puppetclass_id)
|
|
50
|
+
|
|
51
|
+
where(id: direct).or(where(id: via_hostgroup)).or(where(id: via_config_group))
|
|
52
|
+
}
|
|
53
|
+
|
|
44
54
|
scoped_search on: :name, complete_value: true
|
|
45
55
|
scoped_search relation: :environments, on: :name, complete_value: true, rename: 'environment'
|
|
46
56
|
scoped_search relation: :organizations, on: :name, complete_value: true, rename: 'organization', only_explicit: true
|
|
@@ -142,5 +152,9 @@ module ForemanPuppet
|
|
|
142
152
|
puppet_classes = (direct + indirect).uniq
|
|
143
153
|
{ conditions: "puppetclasses.id IN(#{puppet_classes.join(',')})" }
|
|
144
154
|
end
|
|
155
|
+
|
|
156
|
+
def self.completer_scope(options)
|
|
157
|
+
super.merge(assigned_to_hosts)
|
|
158
|
+
end
|
|
145
159
|
end
|
|
146
160
|
end
|
|
@@ -117,6 +117,72 @@ module ForemanPuppet
|
|
|
117
117
|
end
|
|
118
118
|
end
|
|
119
119
|
|
|
120
|
+
describe '#complete_for' do
|
|
121
|
+
let(:host) { FactoryBot.create(:host, :with_puppet_enc, :with_puppetclass) }
|
|
122
|
+
|
|
123
|
+
test 'can complete Puppet class values' do
|
|
124
|
+
puppetclass = host.puppet.puppetclasses.first
|
|
125
|
+
completions = ::Host::Managed.complete_for("puppetclass = #{puppetclass.name}")
|
|
126
|
+
|
|
127
|
+
assert_includes completions, %(puppetclass = "#{puppetclass.name}")
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
test 'can complete config group values' do
|
|
131
|
+
config_group = FactoryBot.create(:config_group)
|
|
132
|
+
host.puppet.config_groups << config_group
|
|
133
|
+
completions = ::Host::Managed.complete_for("config_group = #{config_group.name}")
|
|
134
|
+
|
|
135
|
+
assert_includes completions, %(config_group = "#{config_group.name}")
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
test 'can complete Puppet class values inherited from a hostgroup' do
|
|
139
|
+
hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc, :with_puppetclass)
|
|
140
|
+
FactoryBot.create(:host, hostgroup: hostgroup)
|
|
141
|
+
puppetclass = hostgroup.puppet.puppetclasses.first
|
|
142
|
+
completions = ::Host::Managed.complete_for("puppetclass = #{puppetclass.name}")
|
|
143
|
+
|
|
144
|
+
assert_includes completions, %(puppetclass = "#{puppetclass.name}")
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
test 'can complete Puppet class values assigned through a config group' do
|
|
148
|
+
config_group = FactoryBot.create(:config_group, :with_puppetclass)
|
|
149
|
+
host.puppet.config_groups << config_group
|
|
150
|
+
puppetclass = config_group.puppetclasses.first
|
|
151
|
+
completions = ::Host::Managed.complete_for("puppetclass = #{puppetclass.name}")
|
|
152
|
+
|
|
153
|
+
assert_includes completions, %(puppetclass = "#{puppetclass.name}")
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
test 'can complete config group values inherited from a hostgroup' do
|
|
157
|
+
hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc, :with_config_group)
|
|
158
|
+
FactoryBot.create(:host, hostgroup: hostgroup)
|
|
159
|
+
config_group = hostgroup.puppet.config_groups.first
|
|
160
|
+
completions = ::Host::Managed.complete_for("config_group = #{config_group.name}")
|
|
161
|
+
|
|
162
|
+
assert_includes completions, %(config_group = "#{config_group.name}")
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
test 'does not complete unassigned Puppet class values' do
|
|
166
|
+
puppetclass = FactoryBot.create(:puppetclass)
|
|
167
|
+
completions = ::Host::Managed.complete_for("puppetclass = #{puppetclass.name}")
|
|
168
|
+
|
|
169
|
+
assert_not_includes completions, %(puppetclass = "#{puppetclass.name}")
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
test 'does not complete unassigned config group values' do
|
|
173
|
+
config_group = FactoryBot.create(:config_group)
|
|
174
|
+
completions = ::Host::Managed.complete_for("config_group = #{config_group.name}")
|
|
175
|
+
|
|
176
|
+
assert_not_includes completions, %(config_group = "#{config_group.name}")
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
test 'preserves core host value completions' do
|
|
180
|
+
completions = as_admin { ::Host::Managed.complete_for('user.login =') }
|
|
181
|
+
|
|
182
|
+
assert_includes completions, 'user.login = current_user'
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
|
|
120
186
|
describe '#info puppet bits' do
|
|
121
187
|
test 'ENC YAML omits environment if no puppet facet' do
|
|
122
188
|
host = FactoryBot.build_stubbed(:host)
|
|
@@ -22,5 +22,37 @@ module ForemanPuppet
|
|
|
22
22
|
assert_includes hostgroup.puppet.puppetclasses, puppet_class
|
|
23
23
|
assert_includes hostgroup.puppetclasses, puppet_class
|
|
24
24
|
end
|
|
25
|
+
|
|
26
|
+
test 'can complete Puppet class values' do
|
|
27
|
+
puppetclass = FactoryBot.create(:puppetclass)
|
|
28
|
+
hostgroup.puppet.puppetclasses << puppetclass
|
|
29
|
+
completions = ::Hostgroup.complete_for("puppetclass = #{puppetclass.name}")
|
|
30
|
+
|
|
31
|
+
assert_includes completions, %(puppetclass = "#{puppetclass.name}")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
test 'can complete config group values' do
|
|
35
|
+
config_group = hostgroup.puppet.config_groups.first
|
|
36
|
+
completions = ::Hostgroup.complete_for("config_group = #{config_group.name}")
|
|
37
|
+
|
|
38
|
+
assert_includes completions, %(config_group = "#{config_group.name}")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
test 'can complete Puppet class values inherited from a parent hostgroup' do
|
|
42
|
+
parent = FactoryBot.create(:hostgroup, :with_puppet_enc, :with_puppetclass)
|
|
43
|
+
FactoryBot.create(:hostgroup, parent: parent)
|
|
44
|
+
puppetclass = parent.puppet.puppetclasses.first
|
|
45
|
+
completions = ::Hostgroup.complete_for("puppetclass = #{puppetclass.name}")
|
|
46
|
+
|
|
47
|
+
assert_includes completions, %(puppetclass = "#{puppetclass.name}")
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
test 'searches Puppet class values assigned through a config group' do
|
|
51
|
+
config_group = hostgroup.puppet.config_groups.first
|
|
52
|
+
puppetclass = FactoryBot.create(:puppetclass)
|
|
53
|
+
config_group.puppetclasses << puppetclass
|
|
54
|
+
|
|
55
|
+
assert_includes ::Hostgroup.search_for("puppetclass = #{puppetclass.name}"), hostgroup
|
|
56
|
+
end
|
|
25
57
|
end
|
|
26
58
|
end
|
|
@@ -15,17 +15,11 @@ import {
|
|
|
15
15
|
} from '@patternfly/react-core';
|
|
16
16
|
import { addToast } from 'foremanReact/components/ToastsList/slice';
|
|
17
17
|
import { sprintf, translate as __ } from 'foremanReact/common/I18n';
|
|
18
|
-
import { foremanUrl } from 'foremanReact/common/helpers';
|
|
19
|
-
import { APIActions } from 'foremanReact/redux/API';
|
|
20
18
|
import { STATUS } from 'foremanReact/constants';
|
|
21
19
|
import {
|
|
22
20
|
selectAPIStatus,
|
|
23
21
|
selectAPIResponse,
|
|
24
22
|
} from 'foremanReact/redux/API/APISelectors';
|
|
25
|
-
import {
|
|
26
|
-
HOSTS_API_PATH,
|
|
27
|
-
API_REQUEST_KEY,
|
|
28
|
-
} from 'foremanReact/routes/Hosts/constants';
|
|
29
23
|
import {
|
|
30
24
|
fetchSmartProxies,
|
|
31
25
|
SMART_PROXY_KEY,
|
|
@@ -47,6 +41,7 @@ const BulkChangeProxyCommon = ({
|
|
|
47
41
|
allHostsMessage,
|
|
48
42
|
someHostsMessage,
|
|
49
43
|
isCAProxy,
|
|
44
|
+
onSuccess: onSuccessCallback,
|
|
50
45
|
}) => {
|
|
51
46
|
const dispatch = useDispatch();
|
|
52
47
|
const [smartProxyId, setSmartProxyId] = useState('');
|
|
@@ -82,6 +77,7 @@ const BulkChangeProxyCommon = ({
|
|
|
82
77
|
|
|
83
78
|
const toggle = toggleRef => (
|
|
84
79
|
<MenuToggle
|
|
80
|
+
ouiaId="bulk-change-proxy-common-select-toggle"
|
|
85
81
|
ref={toggleRef}
|
|
86
82
|
onClick={onToggleClick}
|
|
87
83
|
isExpanded={smartProxySelectOpen}
|
|
@@ -112,13 +108,11 @@ const BulkChangeProxyCommon = ({
|
|
|
112
108
|
message: response.data.message,
|
|
113
109
|
})
|
|
114
110
|
);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
);
|
|
121
|
-
handleModalClose();
|
|
111
|
+
try {
|
|
112
|
+
if (onSuccessCallback) onSuccessCallback();
|
|
113
|
+
} finally {
|
|
114
|
+
handleModalClose();
|
|
115
|
+
}
|
|
122
116
|
};
|
|
123
117
|
|
|
124
118
|
const handleConfirm = () => {
|
|
@@ -242,11 +236,13 @@ BulkChangeProxyCommon.propTypes = {
|
|
|
242
236
|
allHostsMessage: PropTypes.string.isRequired,
|
|
243
237
|
someHostsMessage: PropTypes.string.isRequired,
|
|
244
238
|
isCAProxy: PropTypes.bool.isRequired,
|
|
239
|
+
onSuccess: PropTypes.func,
|
|
245
240
|
};
|
|
246
241
|
|
|
247
242
|
BulkChangeProxyCommon.defaultProps = {
|
|
248
243
|
isOpen: false,
|
|
249
244
|
closeModal: () => {},
|
|
245
|
+
onSuccess: undefined,
|
|
250
246
|
};
|
|
251
247
|
|
|
252
248
|
export default BulkChangeProxyCommon;
|
|
@@ -18,11 +18,13 @@ jest.mock('../../BulkChangeProxyCommon', () => ({
|
|
|
18
18
|
|
|
19
19
|
describe('BulkChangePuppetCAProxyScene', () => {
|
|
20
20
|
const fetchBulkParams = jest.fn();
|
|
21
|
+
const refreshTableData = jest.fn();
|
|
21
22
|
const contextValue = {
|
|
22
23
|
selectAllHostsMode: false,
|
|
23
24
|
selectedCount: 2,
|
|
24
25
|
selectedResults: [1, 2],
|
|
25
26
|
fetchBulkParams,
|
|
27
|
+
refreshTableData,
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
beforeEach(() => {
|
|
@@ -51,6 +53,7 @@ describe('BulkChangePuppetCAProxyScene', () => {
|
|
|
51
53
|
selectAllHostsMode: false,
|
|
52
54
|
isOpen: true,
|
|
53
55
|
closeModal: expect.any(Function),
|
|
56
|
+
onSuccess: refreshTableData,
|
|
54
57
|
selectMessage: 'Select a Puppet CA Proxy',
|
|
55
58
|
handleErrorMessage: 'Failed to change Puppet CA Proxy',
|
|
56
59
|
changeMessage: 'Change Puppet CA Proxy',
|
|
@@ -11,6 +11,7 @@ const BulkChangePuppetCAProxyScene = () => {
|
|
|
11
11
|
selectedCount,
|
|
12
12
|
selectedResults,
|
|
13
13
|
fetchBulkParams,
|
|
14
|
+
refreshTableData,
|
|
14
15
|
} = useContext(ForemanActionsBarContext);
|
|
15
16
|
const { isOpen, close: closeModal } = useBulkModalOpen(
|
|
16
17
|
'bulk-change-puppet-ca-proxy'
|
|
@@ -24,6 +25,7 @@ const BulkChangePuppetCAProxyScene = () => {
|
|
|
24
25
|
selectAllHostsMode={selectAllHostsMode}
|
|
25
26
|
isOpen={isOpen}
|
|
26
27
|
closeModal={closeModal}
|
|
28
|
+
onSuccess={refreshTableData}
|
|
27
29
|
selectMessage={__('Select a Puppet CA Proxy')}
|
|
28
30
|
handleErrorMessage={__('Failed to change Puppet CA Proxy')}
|
|
29
31
|
changeMessage={__('Change Puppet CA Proxy')}
|
|
@@ -18,11 +18,13 @@ jest.mock('../../BulkChangeProxyCommon', () => ({
|
|
|
18
18
|
|
|
19
19
|
describe('BulkChangePuppetProxyScene', () => {
|
|
20
20
|
const fetchBulkParams = jest.fn();
|
|
21
|
+
const refreshTableData = jest.fn();
|
|
21
22
|
const contextValue = {
|
|
22
23
|
selectAllHostsMode: false,
|
|
23
24
|
selectedCount: 2,
|
|
24
25
|
selectedResults: [1, 2],
|
|
25
26
|
fetchBulkParams,
|
|
27
|
+
refreshTableData,
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
beforeEach(() => {
|
|
@@ -51,6 +53,7 @@ describe('BulkChangePuppetProxyScene', () => {
|
|
|
51
53
|
selectAllHostsMode: false,
|
|
52
54
|
isOpen: true,
|
|
53
55
|
closeModal: expect.any(Function),
|
|
56
|
+
onSuccess: refreshTableData,
|
|
54
57
|
selectMessage: 'Select a Puppet Proxy',
|
|
55
58
|
handleErrorMessage: 'Failed to change Puppet Proxy',
|
|
56
59
|
changeMessage: 'Change Puppet Proxy',
|
|
@@ -11,6 +11,7 @@ const BulkChangePuppetProxyScene = () => {
|
|
|
11
11
|
selectedCount,
|
|
12
12
|
selectedResults,
|
|
13
13
|
fetchBulkParams,
|
|
14
|
+
refreshTableData,
|
|
14
15
|
} = useContext(ForemanActionsBarContext);
|
|
15
16
|
const { isOpen, close: closeModal } = useBulkModalOpen(
|
|
16
17
|
'bulk-change-puppet-proxy'
|
|
@@ -24,6 +25,7 @@ const BulkChangePuppetProxyScene = () => {
|
|
|
24
25
|
selectAllHostsMode={selectAllHostsMode}
|
|
25
26
|
isOpen={isOpen}
|
|
26
27
|
closeModal={closeModal}
|
|
28
|
+
onSuccess={refreshTableData}
|
|
27
29
|
selectMessage={__('Select a Puppet Proxy')}
|
|
28
30
|
handleErrorMessage={__('Failed to change Puppet Proxy')}
|
|
29
31
|
changeMessage={__('Change Puppet Proxy')}
|
|
@@ -5,12 +5,6 @@ import { useDispatch } from 'react-redux';
|
|
|
5
5
|
import { Modal, Button, TextContent, Text } from '@patternfly/react-core';
|
|
6
6
|
import { addToast } from 'foremanReact/components/ToastsList/slice';
|
|
7
7
|
import { translate as __ } from 'foremanReact/common/I18n';
|
|
8
|
-
import { foremanUrl } from 'foremanReact/common/helpers';
|
|
9
|
-
import { APIActions } from 'foremanReact/redux/API';
|
|
10
|
-
import {
|
|
11
|
-
HOSTS_API_PATH,
|
|
12
|
-
API_REQUEST_KEY,
|
|
13
|
-
} from 'foremanReact/routes/Hosts/constants';
|
|
14
8
|
|
|
15
9
|
import {
|
|
16
10
|
BULK_REMOVE_PUPPET_PROXY_KEY,
|
|
@@ -30,6 +24,7 @@ const BulkRemoveProxyCommon = ({
|
|
|
30
24
|
removeMessage,
|
|
31
25
|
allHostsMessage,
|
|
32
26
|
someHostsMessage,
|
|
27
|
+
onSuccess: onSuccessCallback,
|
|
33
28
|
}) => {
|
|
34
29
|
const actionKey = isCAProxy
|
|
35
30
|
? BULK_REMOVE_PUPPET_CA_PROXY_KEY
|
|
@@ -57,13 +52,11 @@ const BulkRemoveProxyCommon = ({
|
|
|
57
52
|
message: response.data.message,
|
|
58
53
|
})
|
|
59
54
|
);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
);
|
|
66
|
-
handleModalClose();
|
|
55
|
+
try {
|
|
56
|
+
if (onSuccessCallback) onSuccessCallback();
|
|
57
|
+
} finally {
|
|
58
|
+
handleModalClose();
|
|
59
|
+
}
|
|
67
60
|
};
|
|
68
61
|
|
|
69
62
|
const handleConfirm = () => {
|
|
@@ -153,12 +146,14 @@ BulkRemoveProxyCommon.propTypes = {
|
|
|
153
146
|
removeMessage: PropTypes.string,
|
|
154
147
|
allHostsMessage: PropTypes.string.isRequired,
|
|
155
148
|
someHostsMessage: PropTypes.string.isRequired,
|
|
149
|
+
onSuccess: PropTypes.func,
|
|
156
150
|
};
|
|
157
151
|
|
|
158
152
|
BulkRemoveProxyCommon.defaultProps = {
|
|
159
153
|
isOpen: false,
|
|
160
154
|
closeModal: () => {},
|
|
161
155
|
removeMessage: 'Remove Puppet (CA) Proxy',
|
|
156
|
+
onSuccess: undefined,
|
|
162
157
|
};
|
|
163
158
|
|
|
164
159
|
export default BulkRemoveProxyCommon;
|
|
@@ -18,11 +18,13 @@ jest.mock('../../BulkRemoveProxyCommon', () => ({
|
|
|
18
18
|
|
|
19
19
|
describe('BulkRemovePuppetCAProxyScene', () => {
|
|
20
20
|
const fetchBulkParams = jest.fn();
|
|
21
|
+
const refreshTableData = jest.fn();
|
|
21
22
|
const contextValue = {
|
|
22
23
|
selectAllHostsMode: false,
|
|
23
24
|
selectedCount: 2,
|
|
24
25
|
selectedResults: [1, 2],
|
|
25
26
|
fetchBulkParams,
|
|
27
|
+
refreshTableData,
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
beforeEach(() => {
|
|
@@ -51,6 +53,7 @@ describe('BulkRemovePuppetCAProxyScene', () => {
|
|
|
51
53
|
fetchBulkParams,
|
|
52
54
|
isOpen: true,
|
|
53
55
|
closeModal: expect.any(Function),
|
|
56
|
+
onSuccess: refreshTableData,
|
|
54
57
|
handleErrorMessage: 'Failed to remove Puppet CA Proxy',
|
|
55
58
|
allHostsMessage:
|
|
56
59
|
'Removing the Puppet CA proxy will affect {boldCount} selected hosts. Warning: If a Puppet Proxy is still set, the Puppet CA Proxy will fall back to that value after removal!',
|
|
@@ -10,6 +10,7 @@ const BulkRemovePuppetCAProxyScene = () => {
|
|
|
10
10
|
selectedCount,
|
|
11
11
|
selectedResults,
|
|
12
12
|
fetchBulkParams,
|
|
13
|
+
refreshTableData,
|
|
13
14
|
} = useContext(ForemanActionsBarContext);
|
|
14
15
|
const { isOpen, close: closeModal } = useBulkModalOpen(
|
|
15
16
|
'bulk-remove-puppet-ca-proxy'
|
|
@@ -24,6 +25,7 @@ const BulkRemovePuppetCAProxyScene = () => {
|
|
|
24
25
|
fetchBulkParams={fetchBulkParams}
|
|
25
26
|
isOpen={isOpen}
|
|
26
27
|
closeModal={closeModal}
|
|
28
|
+
onSuccess={refreshTableData}
|
|
27
29
|
handleErrorMessage={__('Failed to remove Puppet CA Proxy')}
|
|
28
30
|
allHostsMessage={__(
|
|
29
31
|
'Removing the Puppet CA proxy will affect {boldCount} selected hosts. Warning: If a Puppet Proxy is still set, the Puppet CA Proxy will fall back to that value after removal!'
|
|
@@ -18,11 +18,13 @@ jest.mock('../../BulkRemoveProxyCommon', () => ({
|
|
|
18
18
|
|
|
19
19
|
describe('BulkRemovePuppetProxyScene', () => {
|
|
20
20
|
const fetchBulkParams = jest.fn();
|
|
21
|
+
const refreshTableData = jest.fn();
|
|
21
22
|
const contextValue = {
|
|
22
23
|
selectAllHostsMode: false,
|
|
23
24
|
selectedCount: 2,
|
|
24
25
|
selectedResults: [1, 2],
|
|
25
26
|
fetchBulkParams,
|
|
27
|
+
refreshTableData,
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
beforeEach(() => {
|
|
@@ -51,6 +53,7 @@ describe('BulkRemovePuppetProxyScene', () => {
|
|
|
51
53
|
fetchBulkParams,
|
|
52
54
|
isOpen: true,
|
|
53
55
|
closeModal: expect.any(Function),
|
|
56
|
+
onSuccess: refreshTableData,
|
|
54
57
|
handleErrorMessage: 'Failed to remove Puppet Proxy',
|
|
55
58
|
removeMessage: 'Remove Puppet Proxy',
|
|
56
59
|
})
|
|
@@ -10,6 +10,7 @@ const BulkRemovePuppetProxyScene = () => {
|
|
|
10
10
|
selectedCount,
|
|
11
11
|
selectedResults,
|
|
12
12
|
fetchBulkParams,
|
|
13
|
+
refreshTableData,
|
|
13
14
|
} = useContext(ForemanActionsBarContext);
|
|
14
15
|
const { isOpen, close: closeModal } = useBulkModalOpen(
|
|
15
16
|
'bulk-remove-puppet-proxy'
|
|
@@ -24,6 +25,7 @@ const BulkRemovePuppetProxyScene = () => {
|
|
|
24
25
|
fetchBulkParams={fetchBulkParams}
|
|
25
26
|
isOpen={isOpen}
|
|
26
27
|
closeModal={closeModal}
|
|
28
|
+
onSuccess={refreshTableData}
|
|
27
29
|
handleErrorMessage={__('Failed to remove Puppet Proxy')}
|
|
28
30
|
allHostsMessage={__(
|
|
29
31
|
'Removing the Puppet proxy will affect {boldCount} selected hosts.'
|