foreman_rh_cloud 3.0.16 → 3.0.17
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/controllers/concerns/insights_cloud/candlepin_cache.rb +28 -0
- data/app/controllers/concerns/insights_cloud/client_authentication.rb +23 -0
- data/app/controllers/foreman_inventory_upload/accounts_controller.rb +1 -1
- data/app/controllers/foreman_inventory_upload/uploads_controller.rb +1 -8
- data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +73 -0
- data/app/controllers/insights_cloud/hits_controller.rb +3 -3
- data/app/controllers/insights_cloud/tasks_controller.rb +6 -1
- data/app/models/insights_hit.rb +16 -1
- data/app/models/insights_resolution.rb +3 -0
- data/app/models/insights_rule.rb +3 -0
- data/app/models/setting/rh_cloud.rb +12 -2
- data/app/services/foreman_rh_cloud/branch_info.rb +57 -0
- data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +102 -0
- data/config/routes.rb +10 -0
- data/db/migrate/20210214000001_create_rules_and_resolutions.foreman_rh_cloud.rb +24 -0
- data/db/migrate/20210214000002_add_rule_id_to_hits.foreman_rh_cloud.rb +5 -0
- data/lib/foreman_inventory_upload/generators/slice.rb +3 -3
- data/lib/foreman_rh_cloud.rb +9 -0
- data/lib/foreman_rh_cloud/engine.rb +1 -0
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/insights_cloud.rb +4 -0
- data/lib/insights_cloud/async/insights_full_sync.rb +29 -0
- data/lib/insights_cloud/async/insights_rules_sync.rb +80 -0
- data/lib/insights_cloud/async/rules_result.rb +13 -0
- data/package.json +1 -1
- data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +107 -0
- data/test/factories/insights_factories.rb +2 -1
- data/test/factories/inventory_upload_factories.rb +12 -0
- data/test/jobs/insights_full_sync_test.rb +17 -0
- data/test/jobs/insights_rules_sync_test.rb +198 -0
- data/test/unit/services/foreman_rh_cloud/branch_info_test.rb +60 -0
- data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +106 -0
- data/test/unit/slice_generator_test.rb +29 -3
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +1 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +1 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +2 -2
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +4 -4
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +2 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.scss +12 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +1 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js +64 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.test.js +18 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/__snapshots__/SettingsWarning.test.js.snap +30 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/index.js +25 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButton.test.js +1 -1
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTable.js +9 -5
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableActions.js +55 -30
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableConstants.js +10 -9
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js +14 -6
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableSelectors.js +4 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/SelectAllAlert.js +4 -10
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableActions.test.js +48 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTable.test.js.snap +11 -24
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableActions.test.js.snap +132 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableSelectors.test.js.snap +1 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/fixtures.js +1 -1
- data/webpack/InsightsCloudSync/Components/InsightsTable/table.scss +10 -0
- data/webpack/InsightsCloudSync/InsightsCloudSync.js +18 -16
- data/webpack/InsightsCloudSync/InsightsCloudSyncActions.js +23 -20
- data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +1 -1
- data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +36 -36
- data/webpack/InsightsCloudSync/__tests__/InsightsCloudSyncActions.test.js +9 -0
- data/webpack/InsightsCloudSync/__tests__/__snapshots__/InsightsCloudSyncActions.test.js.snap +11 -0
- data/webpack/__mocks__/foremanReact/redux/API/index.js +1 -0
- metadata +29 -2
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require 'test_plugin_helper'
|
|
2
|
+
|
|
3
|
+
class BranchInfoTest < ActiveSupport::TestCase
|
|
4
|
+
setup do
|
|
5
|
+
User.current = User.find_by(login: 'secret_admin')
|
|
6
|
+
|
|
7
|
+
@env = FactoryBot.create(:katello_k_t_environment)
|
|
8
|
+
cv = @env.content_views << FactoryBot.create(:katello_content_view, organization: @env.organization)
|
|
9
|
+
|
|
10
|
+
@host = FactoryBot.create(
|
|
11
|
+
:host,
|
|
12
|
+
:with_subscription,
|
|
13
|
+
:with_content,
|
|
14
|
+
:with_hostgroup,
|
|
15
|
+
:with_parameter,
|
|
16
|
+
content_view: cv.first,
|
|
17
|
+
lifecycle_environment: @env,
|
|
18
|
+
organization: @env.organization
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
@host.subscription_facet.pools << FactoryBot.create(:katello_pool, account_number: '5678', cp_id: 1)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
test 'should generate branch info for host' do
|
|
25
|
+
uuid = 'abcd-1234-qwerty'
|
|
26
|
+
branch_id = 'efgh-ijkl-mnop'
|
|
27
|
+
hostname = 'test.host.example.com'
|
|
28
|
+
info = ::ForemanRhCloud::BranchInfo.new.generate(uuid, @host, branch_id, hostname)
|
|
29
|
+
|
|
30
|
+
assert_equal uuid, info[:remote_leaf]
|
|
31
|
+
assert_equal branch_id, info[:remote_branch]
|
|
32
|
+
assert_equal @host.organization.title, info[:display_name]
|
|
33
|
+
assert_equal hostname, info[:hostname]
|
|
34
|
+
assert_equal @host.organization.id, info[:organization_id]
|
|
35
|
+
assert_equal Foreman.instance_id, info[:satellite_instance_id]
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
test 'should generate appropriate labels' do
|
|
39
|
+
2.times { FactoryBot.create(:katello_host_collection, :organization_id => @host.organization.id) }
|
|
40
|
+
|
|
41
|
+
FactoryBot.create(:setting, :settings_type => 'boolean', :default => true, :name => :include_parameter_tags)
|
|
42
|
+
|
|
43
|
+
Katello::HostCollection.all.map do |collection|
|
|
44
|
+
FactoryBot.create(:katello_host_collection_host, :host_id => @host.id, :host_collection_id => collection.id)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
labels = ::ForemanRhCloud::BranchInfo.new.generate('a1', @host, 'branch', 'foo')[:labels]
|
|
48
|
+
|
|
49
|
+
org_label = labels.find { |label| label[:key] == 'Organization' }
|
|
50
|
+
loc_label = labels.find { |label| label[:key] == 'Location' }
|
|
51
|
+
assert_equal @host.organization.title, org_label[:value]
|
|
52
|
+
assert_equal @host.location.title, loc_label[:value]
|
|
53
|
+
|
|
54
|
+
hg_label = labels.find { |label| label[:key] == 'Host Group' }
|
|
55
|
+
host_colections = labels.select { |label| label[:key] == 'Host Collection' }
|
|
56
|
+
assert_equal @host.hostgroup.name, hg_label[:value]
|
|
57
|
+
assert_equal 2, host_colections.count
|
|
58
|
+
refute_empty labels.select { |label| label[:namespace] == 'SatelliteParameter' }
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
require 'test_plugin_helper'
|
|
2
|
+
require 'puma/null_io'
|
|
3
|
+
|
|
4
|
+
class CloudRequestForwarderTest < ActiveSupport::TestCase
|
|
5
|
+
setup do
|
|
6
|
+
@forwarder = ::ForemanRhCloud::CloudRequestForwarder.new
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
test 'should prepare correct cloud url' do
|
|
10
|
+
paths = {
|
|
11
|
+
"/redhat_access/r/insights/platform/module-update-router/v1/channel?module=insights-core" => "https://cloud.redhat.com/api/module-update-router/v1/channel?module=insights-core",
|
|
12
|
+
"/redhat_access/r/insights/v1/static/release/insights-core.egg" => "https://cloud.redhat.com/api/v1/static/release/insights-core.egg",
|
|
13
|
+
"/redhat_access/r/insights/v1/static/uploader.v2.json" => "https://cloud.redhat.com/api/v1/static/uploader.v2.json",
|
|
14
|
+
"/redhat_access/r/insights/v1/static/uploader.v2.json.asc" => "https://cloud.redhat.com/api/v1/static/uploader.v2.json.asc",
|
|
15
|
+
"/redhat_access/r/insights/platform/inventory/v1/hosts" => "https://cloud.redhat.com/api/inventory/v1/hosts",
|
|
16
|
+
"/redhat_access/r/insights/platform/ingress/v1/upload" => "https://cloud.redhat.com/api/ingress/v1/upload",
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
paths.each do |key, value|
|
|
20
|
+
assert_equal value, @forwarder.prepare_forward_cloud_url(ForemanRhCloud.base_url, key)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
test 'should forward payload from request parameters' do
|
|
25
|
+
params = { 'pumpkin' => 'pie' }
|
|
26
|
+
req = ActionDispatch::Request.new(
|
|
27
|
+
'REQUEST_URI' => '/foo/bar',
|
|
28
|
+
'REQUEST_METHOD' => 'GET',
|
|
29
|
+
'rack.input' => ::Puma::NullIO.new,
|
|
30
|
+
"action_dispatch.request.request_parameters" => { 'vegetables' => params }
|
|
31
|
+
)
|
|
32
|
+
assert_equal params, @forwarder.prepare_forward_payload(req, 'vegetables')
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
test 'should forward post payload' do
|
|
36
|
+
post_data = 'Random POST data'
|
|
37
|
+
req = ActionDispatch::Request.new(
|
|
38
|
+
'REQUEST_URI' => '/foo/bar?baz=awesome',
|
|
39
|
+
'REQUEST_METHOD' => 'POST',
|
|
40
|
+
'rack.input' => ::Puma::NullIO.new,
|
|
41
|
+
'RAW_POST_DATA' => post_data
|
|
42
|
+
)
|
|
43
|
+
assert_equal post_data, @forwarder.prepare_forward_payload(req, '')
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
test 'should forward put payload' do
|
|
47
|
+
put_data = 'Random PUT data'
|
|
48
|
+
req = ActionDispatch::Request.new(
|
|
49
|
+
'REQUEST_URI' => '/foo/bar?baz=awesome',
|
|
50
|
+
'REQUEST_METHOD' => 'PUT',
|
|
51
|
+
'rack.input' => ::Puma::NullIO.new,
|
|
52
|
+
'RAW_POST_DATA' => put_data
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
assert_equal put_data, @forwarder.prepare_forward_payload(req, '')
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
test 'should forward patch payload' do
|
|
59
|
+
params = { 'pumpkin' => 'pie' }
|
|
60
|
+
req = ActionDispatch::Request.new(
|
|
61
|
+
'REQUEST_URI' => '/foo/bar?baz=awesome',
|
|
62
|
+
'REQUEST_METHOD' => 'PATCH',
|
|
63
|
+
'rack.input' => ::Puma::NullIO.new,
|
|
64
|
+
'RAW_POST_DATA' => 'Random PATCH data',
|
|
65
|
+
"action_dispatch.request.path_parameters" => { :format => "json" },
|
|
66
|
+
"action_dispatch.request.request_parameters" => { 'vegetables' => params }
|
|
67
|
+
)
|
|
68
|
+
assert_equal params.to_json, @forwarder.prepare_forward_payload(req, 'vegetables')
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
test 'should forward file with metadata' do
|
|
72
|
+
file_params = { :file => 'Test file', :metadata => 'File metadata' }
|
|
73
|
+
req = ActionDispatch::Request.new(
|
|
74
|
+
'REQUEST_URI' => '/foo/bar?baz=awesome',
|
|
75
|
+
'REQUEST_METHOD' => 'POST',
|
|
76
|
+
'rack.input' => ::Puma::NullIO.new,
|
|
77
|
+
"action_dispatch.request.request_parameters" => file_params.merge(:foo => 'bar')
|
|
78
|
+
)
|
|
79
|
+
assert_equal file_params, @forwarder.prepare_forward_payload(req, '')
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
test 'should prepare params to forward' do
|
|
83
|
+
params = { :page => 5, :per_page => 42 }
|
|
84
|
+
req = ActionDispatch::Request.new(
|
|
85
|
+
'REQUEST_URI' => '/foo/bar',
|
|
86
|
+
'REQUEST_METHOD' => 'GET',
|
|
87
|
+
'rack.input' => ::Puma::NullIO.new,
|
|
88
|
+
"action_dispatch.request.query_parameters" => params
|
|
89
|
+
)
|
|
90
|
+
assert_equal params, @forwarder.prepare_forward_params(req, nil)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
test 'should add branch id into forwarded params' do
|
|
94
|
+
user_agent = { :foo => :bar }
|
|
95
|
+
params = { :page => 5, :per_page => 42 }
|
|
96
|
+
|
|
97
|
+
req = ActionDispatch::Request.new(
|
|
98
|
+
'REQUEST_URI' => '/foo/bar',
|
|
99
|
+
'REQUEST_METHOD' => 'GET',
|
|
100
|
+
'HTTP_USER_AGENT' => user_agent,
|
|
101
|
+
'rack.input' => ::Puma::NullIO.new,
|
|
102
|
+
'action_dispatch.request.query_parameters' => params
|
|
103
|
+
)
|
|
104
|
+
assert_equal params.merge(:branch_id => 74), @forwarder.prepare_forward_params(req, 74)
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -18,6 +18,8 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
|
18
18
|
)
|
|
19
19
|
|
|
20
20
|
@host.organization.pools << FactoryBot.create(:katello_pool, account_number: '1234', cp_id: 1)
|
|
21
|
+
@host.interfaces.first.identifier = 'test_nic1'
|
|
22
|
+
@host.save!
|
|
21
23
|
|
|
22
24
|
ForemanInventoryUpload::Generators::Queries.instance_variable_set(:@fact_names, nil)
|
|
23
25
|
end
|
|
@@ -81,7 +83,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
|
81
83
|
assert_not_nil(actual_nic = actual_network_interfaces.first)
|
|
82
84
|
refute actual_nic.key?('mtu')
|
|
83
85
|
refute actual_nic.key?('mac_address')
|
|
84
|
-
|
|
86
|
+
assert_equal 'test_nic1', actual_nic['name']
|
|
85
87
|
end
|
|
86
88
|
|
|
87
89
|
test 'hosts report fields should be present if fact exist' do
|
|
@@ -123,8 +125,10 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
|
123
125
|
end
|
|
124
126
|
|
|
125
127
|
test 'generates nic fields' do
|
|
128
|
+
empty_nic = FactoryBot.build(:nic_managed, ip6: '', identifier: 'empty_nic')
|
|
129
|
+
@host.interfaces << empty_nic
|
|
126
130
|
ip6 = Array.new(4) { '%x' % rand(16**4) }.join(':') + '::' + '5'
|
|
127
|
-
nic = FactoryBot.build(:nic_managed, ip6: ip6)
|
|
131
|
+
nic = FactoryBot.build(:nic_managed, ip6: ip6, identifier: 'good_nic')
|
|
128
132
|
nic.attrs['mtu'] = '1500'
|
|
129
133
|
@host.interfaces << nic
|
|
130
134
|
batch = Host.where(id: @host.id).in_batches.first
|
|
@@ -139,7 +143,9 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
|
139
143
|
assert_equal @host.interfaces.where.not(mac: nil).first.mac, actual_host['mac_addresses'].first
|
|
140
144
|
assert_not_nil(actual_system_profile = actual_host['system_profile'])
|
|
141
145
|
assert_not_nil(actual_network_interfaces = actual_system_profile['network_interfaces'])
|
|
142
|
-
assert_not_nil(
|
|
146
|
+
assert_not_nil(actual_empty_nic = actual_network_interfaces.find { |actual_nic| actual_nic['name'] == 'empty_nic' })
|
|
147
|
+
assert actual_empty_nic['ipv6_addresses'].empty?
|
|
148
|
+
assert_not_nil(actual_nic = actual_network_interfaces.find { |actual_nic| actual_nic['name'] == 'good_nic' })
|
|
143
149
|
assert_equal nic.ip, actual_nic['ipv4_addresses'].first
|
|
144
150
|
assert_equal nic.ip6, actual_nic['ipv6_addresses'].first
|
|
145
151
|
assert_equal 1500, actual_nic['mtu']
|
|
@@ -150,6 +156,26 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
|
150
156
|
assert_equal 1, generator.hosts_count
|
|
151
157
|
end
|
|
152
158
|
|
|
159
|
+
test 'skips nameless nics' do
|
|
160
|
+
ip6 = Array.new(4) { '%x' % rand(16**4) }.join(':') + '::' + '5'
|
|
161
|
+
nic = FactoryBot.build(:nic_managed, ip6: ip6, identifier: '')
|
|
162
|
+
nic.attrs['mtu'] = '1500'
|
|
163
|
+
@host.interfaces << nic
|
|
164
|
+
batch = Host.where(id: @host.id).in_batches.first
|
|
165
|
+
generator = create_generator(batch)
|
|
166
|
+
|
|
167
|
+
json_str = generator.render
|
|
168
|
+
actual = JSON.parse(json_str.join("\n"))
|
|
169
|
+
|
|
170
|
+
assert_equal 'slice_123', actual['report_slice_id']
|
|
171
|
+
assert_not_nil(actual_host = actual['hosts'].first)
|
|
172
|
+
assert_equal @host.interfaces.where.not(ip: nil).first.ip, actual_host['ip_addresses'].first
|
|
173
|
+
assert_equal @host.interfaces.where.not(mac: nil).first.mac, actual_host['mac_addresses'].first
|
|
174
|
+
assert_not_nil(actual_system_profile = actual_host['system_profile'])
|
|
175
|
+
assert_not_nil(actual_network_interfaces = actual_system_profile['network_interfaces'])
|
|
176
|
+
assert_nil actual_network_interfaces.find { |actual_nic| actual_nic['name'].empty? }
|
|
177
|
+
end
|
|
178
|
+
|
|
153
179
|
test 'generates obfuscated ip_address fields without inisghts-client' do
|
|
154
180
|
FactoryBot.create(:setting, :name => 'obfuscate_inventory_ips', :value => true)
|
|
155
181
|
|
|
@@ -22,7 +22,7 @@ Object {
|
|
|
22
22
|
|
|
23
23
|
exports[`AccountList selectors should return AccountList autoUploadEnabled 1`] = `true`;
|
|
24
24
|
|
|
25
|
-
exports[`AccountList selectors should return AccountList cloudToken 1`] = `
|
|
25
|
+
exports[`AccountList selectors should return AccountList cloudToken 1`] = `true`;
|
|
26
26
|
|
|
27
27
|
exports[`AccountList selectors should return AccountList excludePackages 1`] = `false`;
|
|
28
28
|
|
|
@@ -50,7 +50,7 @@ Object {
|
|
|
50
50
|
},
|
|
51
51
|
},
|
|
52
52
|
"autoUploadEnabled": true,
|
|
53
|
-
"cloudToken":
|
|
53
|
+
"cloudToken": true,
|
|
54
54
|
"excludePackages": false,
|
|
55
55
|
"hostObfuscationEnabled": true,
|
|
56
56
|
"pollingProcessID": 0,
|
|
@@ -67,7 +67,7 @@ export const setActiveTab = (accountID, tabName) => ({
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
export const downloadReports = accountID => {
|
|
70
|
-
window.
|
|
70
|
+
window.open(inventoryUrl(`${accountID}/uploads/file`), '_blank');
|
|
71
71
|
return {
|
|
72
72
|
type: INVENTORY_REPORTS_DOWNLOAD,
|
|
73
73
|
payload: {
|
|
@@ -36,15 +36,15 @@ const fixtures = {
|
|
|
36
36
|
};
|
|
37
37
|
|
|
38
38
|
describe('Dashboard actions', () => {
|
|
39
|
-
const {
|
|
39
|
+
const { open } = window;
|
|
40
40
|
|
|
41
41
|
beforeAll(() => {
|
|
42
|
-
delete window.
|
|
43
|
-
window.
|
|
42
|
+
delete window.open;
|
|
43
|
+
window.open = jest.fn();
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
afterAll(() => {
|
|
47
|
-
window.
|
|
47
|
+
window.open = open;
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
return testActionSnapshotWithFixtures(fixtures);
|
|
@@ -4,11 +4,13 @@ import InventorySettings from '../InventorySettings';
|
|
|
4
4
|
import PageDescription from './components/PageDescription';
|
|
5
5
|
import InventoryFilter from '../InventoryFilter';
|
|
6
6
|
import ToolbarButtons from './components/ToolbarButtons';
|
|
7
|
+
import SettingsWarning from './components/SettingsWarning';
|
|
7
8
|
import PageTitle from './PageTitle';
|
|
8
9
|
import './PageHeader.scss';
|
|
9
10
|
|
|
10
11
|
const PageHeader = () => (
|
|
11
12
|
<div className="inventory-upload-header">
|
|
13
|
+
<SettingsWarning />
|
|
12
14
|
<PageTitle />
|
|
13
15
|
<div className="inventory-upload-header-description">
|
|
14
16
|
<InventorySettings />
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
.rh-cloud-page {
|
|
2
2
|
.inventory-upload-header {
|
|
3
|
+
.settings-alert {
|
|
4
|
+
margin-bottom: 30px;
|
|
5
|
+
.pf-c-alert {
|
|
6
|
+
margin-bottom: 5px;
|
|
7
|
+
|
|
8
|
+
.pf-c-alert__title {
|
|
9
|
+
font-size: var(--pf-global--FontSize--md);
|
|
10
|
+
line-height: var(--pf-global--LineHeight--md);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
3
15
|
.inventory-upload-header-description {
|
|
4
16
|
overflow: auto;
|
|
5
17
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Alert, AlertActionCloseButton } from '@patternfly/react-core';
|
|
4
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
|
5
|
+
|
|
6
|
+
export const SettingsWarning = ({
|
|
7
|
+
autoUpload,
|
|
8
|
+
hostObfuscation,
|
|
9
|
+
isCloudConnector,
|
|
10
|
+
}) => {
|
|
11
|
+
const [showUploadWarning, setShowUploadWarning] = useState(true);
|
|
12
|
+
const [showObfuscationWarning, setShowObfuscationWarning] = useState(true);
|
|
13
|
+
if (!isCloudConnector || (!showUploadWarning && !showObfuscationWarning)) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
if (autoUpload && !hostObfuscation) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const alerts = [];
|
|
21
|
+
if (!autoUpload && showUploadWarning) {
|
|
22
|
+
alerts.push(
|
|
23
|
+
<Alert
|
|
24
|
+
key="auto-upload"
|
|
25
|
+
variant="warning"
|
|
26
|
+
title={__(
|
|
27
|
+
"Cloud Connector has been configured however the inventory auto-upload is disabled, it's recommended to enable it"
|
|
28
|
+
)}
|
|
29
|
+
actionClose={
|
|
30
|
+
<AlertActionCloseButton onClose={() => setShowUploadWarning(false)} />
|
|
31
|
+
}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
if (hostObfuscation && showObfuscationWarning) {
|
|
36
|
+
alerts.push(
|
|
37
|
+
<Alert
|
|
38
|
+
key="obfuscating-host"
|
|
39
|
+
variant="warning"
|
|
40
|
+
title={__(
|
|
41
|
+
"Cloud Connector has been configured however obfuscating host names setting is enabled, it's recommended to disable it"
|
|
42
|
+
)}
|
|
43
|
+
actionClose={
|
|
44
|
+
<AlertActionCloseButton
|
|
45
|
+
onClose={() => setShowObfuscationWarning(false)}
|
|
46
|
+
/>
|
|
47
|
+
}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
return <div className="settings-alert">{alerts}</div>;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
SettingsWarning.propTypes = {
|
|
55
|
+
autoUpload: PropTypes.bool,
|
|
56
|
+
hostObfuscation: PropTypes.bool,
|
|
57
|
+
isCloudConnector: PropTypes.bool,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
SettingsWarning.defaultProps = {
|
|
61
|
+
autoUpload: false,
|
|
62
|
+
hostObfuscation: false,
|
|
63
|
+
isCloudConnector: false,
|
|
64
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
|
2
|
+
import { SettingsWarning } from './SettingsWarning';
|
|
3
|
+
|
|
4
|
+
const fixtures = {
|
|
5
|
+
'with 2 alerts': {
|
|
6
|
+
autoUpload: false,
|
|
7
|
+
hostObfuscation: true,
|
|
8
|
+
isCloudConnector: true,
|
|
9
|
+
},
|
|
10
|
+
'with isCloudConnector false': {
|
|
11
|
+
autoUpload: true,
|
|
12
|
+
hostObfuscation: true,
|
|
13
|
+
isCloudConnector: false,
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
describe('SettingsWarning', () =>
|
|
18
|
+
testComponentSnapshotsWithFixtures(SettingsWarning, fixtures));
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`SettingsWarning with 2 alerts 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className="settings-alert"
|
|
6
|
+
>
|
|
7
|
+
<Alert
|
|
8
|
+
actionClose={
|
|
9
|
+
<AlertActionCloseButton
|
|
10
|
+
onClose={[Function]}
|
|
11
|
+
/>
|
|
12
|
+
}
|
|
13
|
+
key="auto-upload"
|
|
14
|
+
title="Cloud Connector has been configured however the inventory auto-upload is disabled, it's recommended to enable it"
|
|
15
|
+
variant="warning"
|
|
16
|
+
/>
|
|
17
|
+
<Alert
|
|
18
|
+
actionClose={
|
|
19
|
+
<AlertActionCloseButton
|
|
20
|
+
onClose={[Function]}
|
|
21
|
+
/>
|
|
22
|
+
}
|
|
23
|
+
key="obfuscating-host"
|
|
24
|
+
title="Cloud Connector has been configured however obfuscating host names setting is enabled, it's recommended to disable it"
|
|
25
|
+
variant="warning"
|
|
26
|
+
/>
|
|
27
|
+
</div>
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
exports[`SettingsWarning with isCloudConnector false 1`] = `""`;
|