foreman_rh_cloud 4.0.25.1 → 5.0.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/api/v2/rh_cloud/inventory_controller.rb +4 -1
  3. data/app/controllers/concerns/inventory_upload/report_actions.rb +1 -1
  4. data/app/controllers/foreman_inventory_upload/reports_controller.rb +1 -1
  5. data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +8 -0
  6. data/app/controllers/insights_cloud/hits_controller.rb +1 -1
  7. data/app/models/insights_hit.rb +4 -0
  8. data/app/models/setting/rh_cloud.rb +0 -1
  9. data/app/models/task_output_line.rb +2 -0
  10. data/app/models/task_output_status.rb +2 -0
  11. data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +14 -2
  12. data/config/Gemfile.lock.gh_test +169 -152
  13. data/config/database.yml.example +2 -2
  14. data/config/package-lock.json.plugin +10551 -7500
  15. data/config/routes.rb +1 -1
  16. data/db/migrate/20211027000001_create_task_output.foreman_rh_cloud.rb +18 -0
  17. data/lib/foreman_inventory_upload/async/generate_all_reports_job.rb +11 -7
  18. data/lib/foreman_inventory_upload/async/generate_report_job.rb +24 -12
  19. data/lib/foreman_inventory_upload/async/progress_output.rb +5 -28
  20. data/lib/foreman_inventory_upload/async/queue_for_upload_job.rb +20 -5
  21. data/lib/foreman_inventory_upload/async/shell_process.rb +17 -4
  22. data/lib/foreman_inventory_upload/async/upload_report_job.rb +22 -13
  23. data/lib/foreman_inventory_upload/generators/queries.rb +1 -0
  24. data/lib/foreman_inventory_upload/generators/tags.rb +1 -2
  25. data/lib/foreman_rh_cloud/engine.rb +4 -10
  26. data/lib/foreman_rh_cloud/version.rb +1 -1
  27. data/lib/foreman_rh_cloud.rb +12 -1
  28. data/lib/insights_cloud/async/insights_client_status_aging.rb +4 -0
  29. data/lib/insights_cloud/async/insights_full_sync.rb +4 -0
  30. data/lib/insights_cloud/async/insights_generate_notifications.rb +4 -0
  31. data/lib/insights_cloud/async/insights_resolutions_sync.rb +7 -2
  32. data/lib/insights_cloud/async/insights_rules_sync.rb +10 -2
  33. data/lib/insights_cloud/async/insights_scheduled_sync.rb +11 -7
  34. data/lib/inventory_sync/async/host_result.rb +0 -5
  35. data/lib/inventory_sync/async/inventory_full_sync.rb +18 -9
  36. data/lib/inventory_sync/async/inventory_hosts_sync.rb +6 -6
  37. data/lib/inventory_sync/async/inventory_scheduled_sync.rb +4 -0
  38. data/lib/inventory_sync/async/inventory_self_host_sync.rb +4 -0
  39. data/lib/inventory_sync/async/query_inventory_job.rb +4 -0
  40. data/lib/tasks/rh_cloud_inventory.rake +2 -2
  41. data/package.json +8 -13
  42. data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +16 -39
  43. data/test/controllers/insights_sync/settings_controller_test.rb +2 -2
  44. data/test/controllers/uploads_settings_controller_test.rb +2 -2
  45. data/test/factories/inventory_upload_factories.rb +14 -0
  46. data/test/jobs/insights_full_sync_test.rb +2 -2
  47. data/test/jobs/insights_resolutions_sync_test.rb +11 -2
  48. data/test/jobs/insights_rules_sync_test.rb +2 -2
  49. data/test/jobs/inventory_full_sync_test.rb +31 -5
  50. data/test/jobs/inventory_hosts_sync_test.rb +16 -1
  51. data/test/jobs/inventory_scheduled_sync_test.rb +2 -2
  52. data/test/jobs/inventory_self_host_sync_test.rb +1 -1
  53. data/test/jobs/upload_report_job_test.rb +6 -4
  54. data/test/test_plugin_helper.rb +0 -2
  55. data/test/unit/foreman_rh_cloud_self_host_test.rb +28 -0
  56. data/test/unit/rh_cloud_http_proxy_test.rb +1 -1
  57. data/test/unit/services/foreman_rh_cloud/branch_info_test.rb +1 -1
  58. data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +26 -0
  59. data/test/unit/services/foreman_rh_cloud/template_renderer_helper_test.rb +1 -1
  60. data/test/unit/shell_process_job_test.rb +3 -1
  61. data/test/unit/slice_generator_test.rb +39 -7
  62. data/test/unit/tags_generator_test.rb +20 -20
  63. data/webpack/ForemanInventoryUpload/Components/AccountList/accountList.scss +8 -0
  64. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.scss +17 -4
  65. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageTitle.js +29 -17
  66. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap +58 -47
  67. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js +12 -10
  68. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/__snapshots__/PageDescription.test.js.snap +10 -10
  69. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/__snapshots__/InventoryAutoUpload.test.js.snap +1 -1
  70. data/webpack/ForemanRhCloudFills.js +7 -0
  71. data/webpack/InsightsCloudSync/Components/InsightsHeader/index.js +0 -2
  72. data/webpack/InsightsCloudSync/Components/InsightsSettings/insightsSettings.scss +1 -0
  73. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTable.js +22 -6
  74. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableActions.js +23 -16
  75. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableConstants.js +49 -2
  76. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js +31 -14
  77. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTable.test.js.snap +19 -2
  78. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableActions.test.js.snap +0 -1
  79. data/webpack/InsightsCloudSync/Components/InsightsTable/table.scss +11 -13
  80. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationModal.scss +0 -14
  81. data/webpack/InsightsCloudSync/Components/ToolbarDropdown.js +13 -0
  82. data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/InsightsHeader.test.js.snap +0 -1
  83. data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/NoTokenEmptyState.test.js.snap +24 -13
  84. data/webpack/InsightsCloudSync/InsightsCloudSync.js +2 -0
  85. data/webpack/InsightsCloudSync/InsightsCloudSyncHelpers.js +8 -0
  86. data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +2 -1
  87. data/webpack/InsightsHostDetailsTab/InsightsTab.scss +4 -0
  88. data/webpack/InsightsHostDetailsTab/NewHostDetailsTab.js +104 -0
  89. data/webpack/__mocks__/foremanReact/components/Head.js +11 -0
  90. data/webpack/common/DropdownToggle.js +24 -0
  91. data/webpack/common/Switcher/HelpLabel.js +1 -1
  92. data/webpack/common/Switcher/__tests__/__snapshots__/HelpLabel.test.js.snap +1 -1
  93. data/webpack/common/Switcher/__tests__/__snapshots__/SwitcherPF4.test.js.snap +1 -0
  94. metadata +11 -3
@@ -22,7 +22,13 @@ class SliceGeneratorTest < ActiveSupport::TestCase
22
22
  location: location
23
23
  )
24
24
 
25
- @host.organization.pools << FactoryBot.create(:katello_pool, account_number: '1234', cp_id: 1)
25
+ @host.organization.pools << FactoryBot.create(
26
+ :katello_pool,
27
+ account_number: '1234',
28
+ cp_id: 1,
29
+ organization: env.organization,
30
+ subscription: FactoryBot.create(:katello_subscription, organization_id: env.organization.id)
31
+ )
26
32
  @host.interfaces.first.identifier = 'test_nic1'
27
33
  @host.save!
28
34
 
@@ -183,7 +189,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
183
189
  end
184
190
 
185
191
  test 'generates obfuscated ip_address fields without inisghts-client' do
186
- FactoryBot.create(:setting, :name => 'obfuscate_inventory_ips', :value => true)
192
+ Setting[:obfuscate_inventory_ips] = true
187
193
 
188
194
  @host.interfaces << FactoryBot.build(:nic_managed)
189
195
  batch = Host.where(id: @host.id).in_batches.first
@@ -254,7 +260,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
254
260
  end
255
261
 
256
262
  test 'obfuscates fqdn when setting set' do
257
- FactoryBot.create(:setting, :name => 'obfuscate_inventory_hostnames', :value => true)
263
+ Setting[:obfuscate_inventory_hostnames] = true
258
264
 
259
265
  batch = Host.where(id: @host.id).in_batches.first
260
266
  generator = create_generator(batch)
@@ -441,6 +447,18 @@ class SliceGeneratorTest < ActiveSupport::TestCase
441
447
  assert_equal 1, generator.hosts_count
442
448
  end
443
449
 
450
+ test 'excludes hosts with host_registration_insights set to false' do
451
+ @host.host_parameters << HostParameter.create(
452
+ name: 'host_registration_insights',
453
+ value: "false",
454
+ parameter_type: 'boolean'
455
+ )
456
+
457
+ count = ForemanInventoryUpload::Generators::Queries.for_org(@host.organization_id).count
458
+
459
+ assert_equal 0, count
460
+ end
461
+
444
462
  test 'shows system_memory_bytes in bytes' do
445
463
  FactoryBot.create(:fact_value, fact_name: fact_names['memory::memtotal'], value: '1', host: @host)
446
464
 
@@ -457,9 +475,23 @@ class SliceGeneratorTest < ActiveSupport::TestCase
457
475
  end
458
476
 
459
477
  test 'reports an account for hosts with multiple pools' do
460
- first_pool = @host.organization.pools.first
461
- second_pool = FactoryBot.create(:katello_pool, account_number: nil, cp_id: 2)
462
- new_org = FactoryBot.create(:organization, pools: [first_pool, second_pool])
478
+ new_org = FactoryBot.create(:organization)
479
+ first_pool = FactoryBot.create(
480
+ :katello_pool,
481
+ account_number: '5678',
482
+ cp_id: 2,
483
+ organization: new_org,
484
+ subscription: FactoryBot.create(:katello_subscription, organization_id: new_org.id)
485
+ )
486
+ second_pool = FactoryBot.create(
487
+ :katello_pool,
488
+ account_number: '9012',
489
+ cp_id: 3,
490
+ organization: new_org,
491
+ subscription: FactoryBot.create(:katello_subscription, organization_id: new_org.id)
492
+ )
493
+ new_org.pools << first_pool
494
+ new_org.pools << second_pool
463
495
 
464
496
  another_host = FactoryBot.create(
465
497
  :host,
@@ -605,7 +637,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
605
637
  end
606
638
 
607
639
  test 'include packages installed in the report' do
608
- FactoryBot.create(:setting, :name => 'exclude_installed_packages', :value => false)
640
+ Setting[:exclude_installed_packages] = false
609
641
  installed_package = ::Katello::InstalledPackage.create(name: 'test-package', nvrea: 'test-package-1.0.x86_64', nvra: 'test-package-1.0.x86_64')
610
642
 
611
643
  another_host = FactoryBot.create(
@@ -63,16 +63,16 @@ class TagsGeneratorTest < ActiveSupport::TestCase
63
63
  end
64
64
 
65
65
  test 'generates parameter tags' do
66
- FactoryBot.create(:setting, :name => 'include_parameter_tags', :settings_type => "boolean", :category => "Setting::RhCloud", :default => false, :value => true)
67
-
68
- @host.stubs(:host_inherited_params_objects).returns(
69
- [
70
- OpenStruct.new(name: 'bool_param', value: true),
71
- OpenStruct.new(name: 'false_param', value: false),
72
- OpenStruct.new(name: 'int_param', value: 1),
73
- OpenStruct.new(name: 'empty_param', value: nil),
74
- OpenStruct.new(name: 'empty_str_param', value: ''),
75
- ]
66
+ Setting[:include_parameter_tags] = true
67
+
68
+ @host.stubs(:host_params).returns(
69
+ {
70
+ 'bool_param' => true,
71
+ 'false_param' => false,
72
+ 'int_param' => 1,
73
+ 'empty_param' => nil,
74
+ 'empty_str_param' => '',
75
+ }
76
76
  )
77
77
 
78
78
  generator = create_generator
@@ -85,16 +85,16 @@ class TagsGeneratorTest < ActiveSupport::TestCase
85
85
  end
86
86
 
87
87
  test 'skips parameter tags if include_parameter_tags setting is off' do
88
- FactoryBot.create(:setting, :name => 'include_parameter_tags', :settings_type => "boolean", :category => "Setting::RhCloud", :default => false, :value => false)
89
-
90
- @host.stubs(:host_inherited_params_objects).returns(
91
- [
92
- OpenStruct.new(name: 'bool_param', value: true),
93
- OpenStruct.new(name: 'false_param', value: false),
94
- OpenStruct.new(name: 'int_param', value: 1),
95
- OpenStruct.new(name: 'empty_param', value: nil),
96
- OpenStruct.new(name: 'empty_str_param', value: ''),
97
- ]
88
+ Setting[:include_parameter_tags] = false
89
+
90
+ @host.stubs(:host_params).returns(
91
+ {
92
+ 'bool_param' => true,
93
+ 'false_param' => false,
94
+ 'int_param' => 1,
95
+ 'empty_param' => nil,
96
+ 'empty_str_param' => '',
97
+ }
98
98
  )
99
99
 
100
100
  generator = create_generator
@@ -1,4 +1,12 @@
1
1
  .rh-cloud-inventory-page {
2
+ #main {
3
+ padding: 0;
4
+
5
+ #breadcrumb {
6
+ display: none;
7
+ }
8
+ }
9
+
2
10
  .account-list {
3
11
  .pf-c-accordion__toggle {
4
12
  margin-top: 10px;
@@ -1,5 +1,21 @@
1
1
  .rh-cloud-inventory-page {
2
2
  .inventory-upload-header {
3
+ margin-top: 35px;
4
+
5
+ h1 {
6
+ font-family: 'RedHatDisplay';
7
+ font-weight: 400;
8
+ margin: 0;
9
+ }
10
+
11
+ p {
12
+ font-size: 16px;
13
+ }
14
+
15
+ .pf-c-dropdown__toggle {
16
+ margin-right: -20px;
17
+ }
18
+
3
19
  .settings-alert {
4
20
  margin-bottom: 30px;
5
21
  .pf-c-alert {
@@ -18,10 +34,7 @@
18
34
 
19
35
  .inventory-upload-header-title {
20
36
  margin-top: -15px;
21
-
22
- h1 {
23
- margin: 0;
24
- }
37
+ margin-bottom: 8px;
25
38
  }
26
39
 
27
40
  .title-dropdown {
@@ -4,7 +4,10 @@ import {
4
4
  DropdownItem,
5
5
  KebabToggle,
6
6
  DropdownPosition,
7
+ Grid,
8
+ GridItem,
7
9
  } from '@patternfly/react-core';
10
+ import Head from 'foremanReact/components/Head';
8
11
  import {
9
12
  INVENTORY_PAGE_TITLE,
10
13
  ACTIONS_HISTORY_BUTTON_TEXT,
@@ -43,23 +46,32 @@ const PageTitle = () => {
43
46
  </DropdownItem>,
44
47
  ];
45
48
  return (
46
- <div className="row form-group inventory-upload-header-title">
47
- <h1 className="col-md-8">{INVENTORY_PAGE_TITLE}</h1>
48
- <Dropdown
49
- className="title-dropdown"
50
- onSelect={() => setIsDropdownOpen(false)}
51
- toggle={<KebabToggle onToggle={isOpen => setIsDropdownOpen(isOpen)} />}
52
- isOpen={isDropdownOpen}
53
- isPlain
54
- dropdownItems={dropdownItems}
55
- position={DropdownPosition.right}
56
- />
57
- <CloudPingModal
58
- isOpen={showPingModal}
59
- toggle={togglePingModal}
60
- title={CLOUD_PING_TITLE}
61
- />
62
- </div>
49
+ <Grid className="inventory-upload-header-title">
50
+ <GridItem span={6}>
51
+ <Head>
52
+ <title>{INVENTORY_PAGE_TITLE}</title>
53
+ </Head>
54
+ <h1>{INVENTORY_PAGE_TITLE}</h1>
55
+ </GridItem>
56
+ <GridItem span={6}>
57
+ <Dropdown
58
+ className="title-dropdown"
59
+ onSelect={() => setIsDropdownOpen(false)}
60
+ toggle={
61
+ <KebabToggle onToggle={isOpen => setIsDropdownOpen(isOpen)} />
62
+ }
63
+ isOpen={isDropdownOpen}
64
+ isPlain
65
+ dropdownItems={dropdownItems}
66
+ position={DropdownPosition.right}
67
+ />
68
+ <CloudPingModal
69
+ isOpen={showPingModal}
70
+ toggle={togglePingModal}
71
+ title={CLOUD_PING_TITLE}
72
+ />
73
+ </GridItem>
74
+ </Grid>
63
75
  );
64
76
  };
65
77
  export default PageTitle;
@@ -1,53 +1,64 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`PageTitle rendering render without Props 1`] = `
4
- <div
5
- className="row form-group inventory-upload-header-title"
4
+ <Grid
5
+ className="inventory-upload-header-title"
6
6
  >
7
- <h1
8
- className="col-md-8"
7
+ <GridItem
8
+ span={6}
9
9
  >
10
- Red Hat Inventory
11
- </h1>
12
- <Dropdown
13
- className="title-dropdown"
14
- dropdownItems={
15
- Array [
16
- <DropdownItem
17
- href="/foreman_tasks/tasks?search=action++%3D++ForemanInventoryUpload%3A%3AAsync%3A%3AGenerateReportJob+or+action++%3D++ForemanInventoryUpload%3A%3AAsync%3A%3AGenerateAllReportsJob&page=1"
18
- rel="noopener noreferrer"
19
- target="_blank"
20
- >
21
- Actions history
22
- </DropdownItem>,
23
- <DropdownItem
24
- href="/links/manual/+?root_url=https%3A%2F%2Faccess.redhat.com%2Fproducts%2Fsubscription-central"
25
- rel="noopener noreferrer"
26
- target="_blank"
27
- >
28
- Documentation
29
- </DropdownItem>,
30
- <DropdownItem
31
- onClick={[Function]}
32
- >
33
- Connectivity test
34
- </DropdownItem>,
35
- ]
36
- }
37
- isOpen={false}
38
- isPlain={true}
39
- onSelect={[Function]}
40
- position="right"
41
- toggle={
42
- <KebabToggle
43
- onToggle={[Function]}
44
- />
45
- }
46
- />
47
- <CloudPingModal
48
- isOpen={false}
49
- title="Connectivity test"
50
- toggle={[Function]}
51
- />
52
- </div>
10
+ <Head>
11
+ <title>
12
+ Red Hat Inventory
13
+ </title>
14
+ </Head>
15
+ <h1>
16
+ Red Hat Inventory
17
+ </h1>
18
+ </GridItem>
19
+ <GridItem
20
+ span={6}
21
+ >
22
+ <Dropdown
23
+ className="title-dropdown"
24
+ dropdownItems={
25
+ Array [
26
+ <DropdownItem
27
+ href="/foreman_tasks/tasks?search=action++%3D++ForemanInventoryUpload%3A%3AAsync%3A%3AGenerateReportJob+or+action++%3D++ForemanInventoryUpload%3A%3AAsync%3A%3AGenerateAllReportsJob&page=1"
28
+ rel="noopener noreferrer"
29
+ target="_blank"
30
+ >
31
+ Actions history
32
+ </DropdownItem>,
33
+ <DropdownItem
34
+ href="/links/manual/+?root_url=https%3A%2F%2Faccess.redhat.com%2Fproducts%2Fsubscription-central"
35
+ rel="noopener noreferrer"
36
+ target="_blank"
37
+ >
38
+ Documentation
39
+ </DropdownItem>,
40
+ <DropdownItem
41
+ onClick={[Function]}
42
+ >
43
+ Connectivity test
44
+ </DropdownItem>,
45
+ ]
46
+ }
47
+ isOpen={false}
48
+ isPlain={true}
49
+ onSelect={[Function]}
50
+ position="right"
51
+ toggle={
52
+ <KebabToggle
53
+ onToggle={[Function]}
54
+ />
55
+ }
56
+ />
57
+ <CloudPingModal
58
+ isOpen={false}
59
+ title="Connectivity test"
60
+ toggle={[Function]}
61
+ />
62
+ </GridItem>
63
+ </Grid>
53
64
  `;
@@ -1,24 +1,26 @@
1
1
  import React from 'react';
2
+ import { Text } from '@patternfly/react-core';
3
+
2
4
  import { translate as __ } from 'foremanReact/common/I18n';
3
5
 
4
6
  export const PageDescription = () => (
5
7
  <div id="inventory_page_description">
6
- <p>
8
+ <Text>
7
9
  {__(
8
10
  'Red Hat Insights is a set of cloud services which provide unified subscription reporting, predictive analysis and remediation of issues through this Satellite instance.'
9
11
  )}
10
- </p>
11
- <p>
12
+ </Text>
13
+ <Text>
12
14
  {__(
13
15
  'You can toggle the Auto upload switch to the ON position to enable Satellite to automatically upload your host inventory once a day.'
14
16
  )}
15
- </p>
16
- <p>
17
+ </Text>
18
+ <Text>
17
19
  {__(
18
20
  'Click Restart to upload your host inventory to Red Hat Insights. Perform this step for each organization from which you want to manually upload a host inventory.'
19
21
  )}
20
- </p>
21
- <p>
22
+ </Text>
23
+ <Text>
22
24
  {__(
23
25
  'Enabling inventory uploads is required by subscription watch. For more information about subscription watch see link:'
24
26
  )}
@@ -30,8 +32,8 @@ export const PageDescription = () => (
30
32
  >
31
33
  {__('About subscription watch')}
32
34
  </a>
33
- </p>
34
- <p>
35
+ </Text>
36
+ <Text>
35
37
  {__('For more information about Insights and Cloud Connector read')}
36
38
  &nbsp;
37
39
  <a
@@ -41,7 +43,7 @@ export const PageDescription = () => (
41
43
  >
42
44
  {__('Red Hat Insights Data and Application Security')}
43
45
  </a>
44
- </p>
46
+ </Text>
45
47
  </div>
46
48
  );
47
49
 
@@ -4,16 +4,16 @@ exports[`PageDescription rendering render without Props 1`] = `
4
4
  <div
5
5
  id="inventory_page_description"
6
6
  >
7
- <p>
7
+ <Text>
8
8
  Red Hat Insights is a set of cloud services which provide unified subscription reporting, predictive analysis and remediation of issues through this Satellite instance.
9
- </p>
10
- <p>
9
+ </Text>
10
+ <Text>
11
11
  You can toggle the Auto upload switch to the ON position to enable Satellite to automatically upload your host inventory once a day.
12
- </p>
13
- <p>
12
+ </Text>
13
+ <Text>
14
14
  Click Restart to upload your host inventory to Red Hat Insights. Perform this step for each organization from which you want to manually upload a host inventory.
15
- </p>
16
- <p>
15
+ </Text>
16
+ <Text>
17
17
  Enabling inventory uploads is required by subscription watch. For more information about subscription watch see link:
18
18
   
19
19
  <a
@@ -23,8 +23,8 @@ exports[`PageDescription rendering render without Props 1`] = `
23
23
  >
24
24
  About subscription watch
25
25
  </a>
26
- </p>
27
- <p>
26
+ </Text>
27
+ <Text>
28
28
  For more information about Insights and Cloud Connector read
29
29
   
30
30
  <a
@@ -34,6 +34,6 @@ exports[`PageDescription rendering render without Props 1`] = `
34
34
  >
35
35
  Red Hat Insights Data and Application Security
36
36
  </a>
37
- </p>
37
+ </Text>
38
38
  </div>
39
39
  `;
@@ -33,7 +33,7 @@ exports[`InventoryAutoUpload rendering render with props 1`] = `
33
33
  >
34
34
  <Popover
35
35
  bodyContent={
36
- <UNDEFINED
36
+ <Memo(Connect(AdvancedSettings))
37
37
  autoUploadEnabled={true}
38
38
  handleToggle={[Function]}
39
39
  />
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { addGlobalFill } from 'foremanReact/components/common/Fill/GlobalFill';
3
3
  import InventoryAutoUploadSwitcher from './ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload';
4
+ import NewHostDetailsTab from './InsightsHostDetailsTab/NewHostDetailsTab';
4
5
 
5
6
  const fills = [
6
7
  {
@@ -9,6 +10,12 @@ const fills = [
9
10
  component: () => <InventoryAutoUploadSwitcher />,
10
11
  weight: 50,
11
12
  },
13
+ {
14
+ slot: 'host-details-page-tabs',
15
+ name: 'Insights',
16
+ component: props => <NewHostDetailsTab {...props} />,
17
+ weight: 700,
18
+ },
12
19
  ];
13
20
 
14
21
  export const registerFills = () => {
@@ -1,12 +1,10 @@
1
1
  import React from 'react';
2
2
  import { Text, TextVariants } from '@patternfly/react-core';
3
3
  import { translate as __ } from 'foremanReact/common/I18n';
4
- import InsightsSettings from '../InsightsSettings';
5
4
  import './InsightsHeader.scss';
6
5
 
7
6
  const InsightsHeader = () => (
8
7
  <div className="insights-header">
9
- <InsightsSettings />
10
8
  <Text component={TextVariants.p}>
11
9
  {__(
12
10
  'Insights synchronization process is used to provide Insights recommendations output for hosts managed here.'
@@ -1,3 +1,4 @@
1
1
  .insights_settings {
2
2
  float: right;
3
+ margin-top: 22px;
3
4
  }
@@ -4,7 +4,10 @@ import PropTypes from 'prop-types';
4
4
  import { Table, TableHeader, TableBody } from '@patternfly/react-table';
5
5
  import { useForemanSettings } from 'foremanReact/Root/Context/ForemanContext';
6
6
  import SelectAllAlert from './SelectAllAlert';
7
- import { columns } from './InsightsTableConstants';
7
+ import {
8
+ columns as defaultColumns,
9
+ getColumnsWithoutHostname,
10
+ } from './InsightsTableConstants';
8
11
  import TableEmptyState from '../../../common/table/EmptyState';
9
12
  import { modifySelectedRows, getSortColumnIndex } from './InsightsTableHelpers';
10
13
  import Pagination from './Pagination';
@@ -27,10 +30,12 @@ const InsightsTable = ({
27
30
  clearAllSelection,
28
31
  error,
29
32
  isAllSelected,
33
+ hideHost,
30
34
  }) => {
31
35
  const { perPage: appPerPage } = useForemanSettings();
32
36
  const perPage = urlPerPage || appPerPage;
33
37
  const [rows, setRows] = React.useState([]);
38
+ const [columns, setColumns] = React.useState(defaultColumns);
34
39
 
35
40
  // acts as componentDidMount
36
41
  useEffect(() => {
@@ -38,8 +43,12 @@ const InsightsTable = ({
38
43
  }, []);
39
44
 
40
45
  useEffect(() => {
41
- setRows(modifySelectedRows(hits, selectedIds, showSelectAllAlert));
42
- }, [hits, selectedIds]);
46
+ setRows(
47
+ modifySelectedRows(hits, selectedIds, showSelectAllAlert, hideHost)
48
+ );
49
+
50
+ if (hideHost) setColumns(getColumnsWithoutHostname());
51
+ }, [hits, selectedIds, hideHost]);
43
52
 
44
53
  return (
45
54
  <React.Fragment>
@@ -51,14 +60,19 @@ const InsightsTable = ({
51
60
  isAllSelected={isAllSelected}
52
61
  />
53
62
  <Table
54
- className="recommendations-table"
63
+ className="rh-cloud-recommendations-table"
55
64
  aria-label="Recommendations Table"
56
65
  onSelect={(_event, isSelected, rowId) =>
57
66
  onTableSelect(isSelected, rowId, rows, selectedIds)
58
67
  }
59
68
  canSelectAll
60
- sortBy={{ index: getSortColumnIndex(sortBy), direction: sortOrder }}
61
- onSort={onTableSort}
69
+ sortBy={{
70
+ index: getSortColumnIndex(columns, sortBy),
71
+ direction: sortOrder,
72
+ }}
73
+ onSort={(_event, index, direction) =>
74
+ onTableSort(columns, index, direction)
75
+ }
62
76
  cells={columns}
63
77
  rows={rows}
64
78
  variant="compact"
@@ -89,6 +103,7 @@ InsightsTable.propTypes = {
89
103
  query: PropTypes.string,
90
104
  error: PropTypes.string,
91
105
  isAllSelected: PropTypes.bool,
106
+ hideHost: PropTypes.bool,
92
107
  };
93
108
 
94
109
  InsightsTable.defaultProps = {
@@ -102,6 +117,7 @@ InsightsTable.defaultProps = {
102
117
  query: '',
103
118
  error: '',
104
119
  isAllSelected: false,
120
+ hideHost: false,
105
121
  };
106
122
 
107
123
  export default InsightsTable;
@@ -2,14 +2,13 @@ import URI from 'urijs';
2
2
  import { push } from 'connected-react-router';
3
3
  import { get } from 'foremanReact/redux/API';
4
4
  import { selectQueryParams } from './InsightsTableSelectors';
5
- import { INSIGHTS_PATH } from '../../InsightsCloudSyncConstants';
6
5
  import {
7
- columns,
8
6
  INSIGHTS_HITS_API_KEY,
9
7
  INSIGHTS_HITS_PATH,
10
8
  INSIGHTS_SET_SELECTED_IDS,
11
9
  INSIGHTS_SET_SELECT_ALL_ALERT,
12
10
  INSIGHTS_SET_SELECT_ALL,
11
+ NEW_HOST_PATH,
13
12
  } from './InsightsTableConstants';
14
13
 
15
14
  export const fetchInsights = (queryParams = {}) => (dispatch, getState) => {
@@ -29,17 +28,20 @@ export const fetchInsights = (queryParams = {}) => (dispatch, getState) => {
29
28
  select_all: isSelectAll,
30
29
  });
31
30
 
32
- dispatch(
33
- push({
34
- pathname: INSIGHTS_PATH,
35
- search: uri.search(),
36
- })
37
- );
31
+ updateUrl(uri, dispatch);
38
32
 
39
33
  if (!isSelectAll) {
40
34
  dispatch(setSelectAllAlert(false));
41
35
  }
42
36
 
37
+ let search = query;
38
+ if (isNewHostPage(uri)) {
39
+ const hostname = uri.pathname().split('/new/hosts/')[1];
40
+ const hostQuery = `hostname = ${hostname}`;
41
+ const q = query?.trim();
42
+ search = q ? `${hostQuery} AND (${q})` : hostQuery;
43
+ }
44
+
43
45
  return dispatch(
44
46
  get({
45
47
  key: INSIGHTS_HITS_API_KEY,
@@ -47,7 +49,7 @@ export const fetchInsights = (queryParams = {}) => (dispatch, getState) => {
47
49
  params: {
48
50
  page,
49
51
  per_page: perPage,
50
- search: query,
52
+ search,
51
53
  order: `${sortBy} ${sortOrder}`,
52
54
  },
53
55
  handleSuccess: response => {
@@ -96,7 +98,7 @@ export const clearAllSelection = () => dispatch => {
96
98
  dispatch(setSelectAll(false));
97
99
  };
98
100
 
99
- export const onTableSort = (_event, index, direction) => {
101
+ export const onTableSort = (columns, index, direction) => {
100
102
  // The checkbox column shifts the data columns by 1;
101
103
  const { sortKey } = columns[index - 1];
102
104
  return fetchInsights({
@@ -144,11 +146,16 @@ export const onTableSelect = (
144
146
  const setSelectAllUrl = selectAllValue => dispatch => {
145
147
  const uri = new URI();
146
148
  uri.setSearch({ select_all: selectAllValue });
149
+ updateUrl(uri, dispatch);
150
+ };
147
151
 
148
- dispatch(
149
- push({
150
- pathname: INSIGHTS_PATH,
151
- search: uri.search(),
152
- })
153
- );
152
+ const updateUrl = (uri, dispatch) => {
153
+ const nextUrlParams = { search: uri.search() };
154
+ if (isNewHostPage(uri)) {
155
+ // we need to keep the hash so the insights tab will remain selected in the new host details page.
156
+ nextUrlParams.hash = '/Insights';
157
+ }
158
+ dispatch(push(nextUrlParams));
154
159
  };
160
+
161
+ const isNewHostPage = uri => uri.pathname().includes(NEW_HOST_PATH);