foreman_rh_cloud 3.0.26 → 4.0.21.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_inventory_upload/reports_controller.rb +1 -3
  3. data/app/controllers/foreman_inventory_upload/tasks_controller.rb +13 -5
  4. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +4 -4
  5. data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +3 -6
  6. data/app/controllers/insights_cloud/hits_controller.rb +3 -7
  7. data/app/models/insights_client_report_status.rb +22 -11
  8. data/app/services/foreman_rh_cloud/cloud_auth.rb +0 -16
  9. data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +14 -11
  10. data/app/services/foreman_rh_cloud/remediations_retriever.rb +4 -6
  11. data/app/subscribers/foreman_rh_cloud/insights_subscriber.rb +9 -0
  12. data/config/Gemfile.lock.gh_test +95 -93
  13. data/config/routes.rb +1 -20
  14. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +0 -19
  15. data/lib/foreman_inventory_upload/generators/queries.rb +0 -1
  16. data/lib/foreman_inventory_upload/generators/slice.rb +5 -6
  17. data/lib/foreman_inventory_upload/generators/tags.rb +1 -3
  18. data/lib/foreman_inventory_upload.rb +1 -9
  19. data/lib/foreman_rh_cloud/engine.rb +10 -17
  20. data/lib/foreman_rh_cloud/version.rb +1 -1
  21. data/lib/insights_cloud/async/insights_full_sync.rb +14 -9
  22. data/lib/insights_cloud/async/insights_resolutions_sync.rb +6 -13
  23. data/lib/insights_cloud/async/insights_rules_sync.rb +9 -13
  24. data/lib/inventory_sync/async/host_result.rb +0 -4
  25. data/lib/inventory_sync/async/inventory_full_sync.rb +1 -7
  26. data/lib/inventory_sync/async/inventory_hosts_sync.rb +2 -21
  27. data/lib/inventory_sync/async/inventory_scheduled_sync.rb +0 -12
  28. data/lib/inventory_sync/async/query_inventory_job.rb +5 -6
  29. data/lib/tasks/insights.rake +0 -15
  30. data/lib/tasks/rh_cloud_inventory.rake +1 -8
  31. data/package.json +1 -1
  32. data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +0 -41
  33. data/test/factories/inventory_upload_factories.rb +1 -1
  34. data/test/jobs/insights_full_sync_test.rb +0 -1
  35. data/test/jobs/insights_resolutions_sync_test.rb +1 -11
  36. data/test/jobs/insights_rules_sync_test.rb +0 -1
  37. data/test/jobs/inventory_full_sync_test.rb +0 -10
  38. data/test/models/insights_client_report_status_test.rb +72 -70
  39. data/test/test_plugin_helper.rb +0 -2
  40. data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +3 -4
  41. data/test/unit/services/foreman_rh_cloud/template_renderer_helper_test.rb +0 -1
  42. data/test/unit/slice_generator_test.rb +27 -70
  43. data/test/unit/tags_generator_test.rb +0 -41
  44. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js +0 -11
  45. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/__snapshots__/PageDescription.test.js.snap +0 -11
  46. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +63 -28
  47. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/integrations.test.js.snap +3 -2
  48. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableActions.js +19 -19
  49. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableActions.test.js.snap +14 -14
  50. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediateButton.js +0 -1
  51. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationModal.scss +0 -14
  52. data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/NoTokenEmptyState.test.js.snap +13 -20
  53. data/webpack/InsightsCloudSync/InsightsCloudSync.js +1 -4
  54. data/webpack/InsightsCloudSync/InsightsCloudSyncActions.js +20 -44
  55. data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +0 -2
  56. data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +2 -2
  57. data/webpack/InsightsCloudSync/__tests__/__snapshots__/InsightsCloudSyncActions.test.js.snap +7 -11
  58. metadata +4 -30
  59. data/app/controllers/api/v2/rh_cloud/inventory_controller.rb +0 -50
  60. data/app/controllers/concerns/inventory_upload/report_actions.rb +0 -26
  61. data/app/controllers/concerns/inventory_upload/task_actions.rb +0 -25
  62. data/app/helpers/foreman_insights_deprecations_helper.rb +0 -9
  63. data/app/helpers/foreman_insights_host_helper.rb +0 -19
  64. data/app/overrides/old_plugin_deprecation.rb +0 -20
  65. data/app/services/foreman_rh_cloud/cloud_request.rb +0 -14
  66. data/app/services/foreman_rh_cloud/insights_status_cleaner.rb +0 -17
  67. data/config/package-lock.json.plugin +0 -32774
  68. data/db/migrate/20210720000001_remove_old_insights_statuses.foreman_rh_cloud.rb +0 -6
  69. data/lib/insights_cloud/async/insights_client_status_aging.rb +0 -23
  70. data/lib/inventory_sync/async/inventory_self_host_sync.rb +0 -39
  71. data/test/controllers/inventory_upload/api/inventory_controller_test.rb +0 -53
  72. data/test/jobs/insights_client_status_aging_test.rb +0 -33
  73. data/test/jobs/inventory_hosts_sync_test.rb +0 -268
  74. data/test/jobs/inventory_scheduled_sync_test.rb +0 -22
  75. data/test/jobs/inventory_self_host_sync_test.rb +0 -104
  76. data/test/unit/services/foreman_rh_cloud/insights_status_cleaner_test.rb +0 -31
  77. data/webpack/common/ForemanTasks/ForemanTasksActions.js +0 -64
  78. data/webpack/common/ForemanTasks/ForemanTasksHelpers.js +0 -7
  79. data/webpack/common/ForemanTasks/index.js +0 -1
@@ -53,7 +53,6 @@ class SliceGeneratorTest < ActiveSupport::TestCase
53
53
  'insights_client::hostname',
54
54
  'insights_client::obfuscate_ip_enabled',
55
55
  'insights_client::ips',
56
- 'insights_id',
57
56
  ]
58
57
  end
59
58
 
@@ -72,7 +71,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
72
71
  json_str = generator.render
73
72
  actual = JSON.parse(json_str.join("\n"))
74
73
 
75
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
74
+ assert_equal 'slice_123', actual['report_slice_id']
76
75
  assert_not_nil(actual_host = actual['hosts'].first)
77
76
  assert_nil actual_host['ip_addresses']
78
77
  assert_nil actual_host['mac_addresses']
@@ -103,7 +102,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
103
102
  json_str = generator.render
104
103
  actual = JSON.parse(json_str.join("\n"))
105
104
 
106
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
105
+ assert_equal 'slice_123', actual['report_slice_id']
107
106
  assert_not_nil(actual_host = actual['hosts'].first)
108
107
  assert_not_nil(actual_system_profile = actual_host['system_profile'])
109
108
  assert_equal 4, actual_system_profile['number_of_cpus']
@@ -121,7 +120,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
121
120
  json_str = generator.render
122
121
  actual = JSON.parse(json_str.join("\n"))
123
122
 
124
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
123
+ assert_equal 'slice_123', actual['report_slice_id']
125
124
  assert_not_nil(actual_host = actual['hosts'].first)
126
125
  assert_equal @host.interfaces.where.not(ip: nil).first.ip, actual_host['ip_addresses'].first
127
126
  assert_equal @host.interfaces.where.not(mac: nil).first.mac, actual_host['mac_addresses'].first
@@ -143,7 +142,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
143
142
  json_str = generator.render
144
143
  actual = JSON.parse(json_str.join("\n"))
145
144
 
146
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
145
+ assert_equal 'slice_123', actual['report_slice_id']
147
146
  assert_not_nil(actual_host = actual['hosts'].first)
148
147
  assert_equal @host.interfaces.where.not(ip: nil).first.ip, actual_host['ip_addresses'].first
149
148
  assert_equal @host.interfaces.where.not(mac: nil).first.mac, actual_host['mac_addresses'].first
@@ -173,7 +172,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
173
172
  json_str = generator.render
174
173
  actual = JSON.parse(json_str.join("\n"))
175
174
 
176
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
175
+ assert_equal 'slice_123', actual['report_slice_id']
177
176
  assert_not_nil(actual_host = actual['hosts'].first)
178
177
  assert_equal @host.interfaces.where.not(ip: nil).first.ip, actual_host['ip_addresses'].first
179
178
  assert_equal @host.interfaces.where.not(mac: nil).first.mac, actual_host['mac_addresses'].first
@@ -192,7 +191,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
192
191
  json_str = generator.render
193
192
  actual = JSON.parse(json_str.join("\n"))
194
193
 
195
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
194
+ assert_equal 'slice_123', actual['report_slice_id']
196
195
  assert_not_nil(actual_host = actual['hosts'].first)
197
196
  assert_equal '10.230.230.1', actual_host['ip_addresses'].first
198
197
  assert_not_nil(actual_system_profile = actual_host['system_profile'])
@@ -222,7 +221,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
222
221
  json_str = generator.render
223
222
  actual = JSON.parse(json_str.join("\n"))
224
223
 
225
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
224
+ assert_equal 'slice_123', actual['report_slice_id']
226
225
  assert_not_nil(actual_host = actual['hosts'].first)
227
226
  assert_equal '10.230.230.100', actual_host['ip_addresses'].first
228
227
  assert_not_nil(actual_system_profile = actual_host['system_profile'])
@@ -244,7 +243,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
244
243
  json_str = generator.render
245
244
  actual = JSON.parse(json_str.join("\n"))
246
245
 
247
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
246
+ assert_equal 'slice_123', actual['report_slice_id']
248
247
  assert_not_nil(actual_host = actual['hosts'].first)
249
248
  assert_equal 'obfuscated_name', actual_host['fqdn']
250
249
  assert_equal '1234', actual_host['account']
@@ -264,7 +263,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
264
263
 
265
264
  obfuscated_fqdn = Digest::SHA1.hexdigest(@host.fqdn) + '.example.com'
266
265
 
267
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
266
+ assert_equal 'slice_123', actual['report_slice_id']
268
267
  assert_not_nil(actual_host = actual['hosts'].first)
269
268
  assert_equal obfuscated_fqdn, actual_host['fqdn']
270
269
  assert_equal '1234', actual_host['account']
@@ -283,7 +282,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
283
282
  json_str = generator.render
284
283
  actual = JSON.parse(json_str.join("\n"))
285
284
 
286
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
285
+ assert_equal 'slice_123', actual['report_slice_id']
287
286
  assert_not_nil(actual_host = actual['hosts'].first)
288
287
  assert_equal @host.fqdn, actual_host['fqdn']
289
288
  assert_equal '1234', actual_host['account']
@@ -356,7 +355,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
356
355
  json_str = generator.render
357
356
  actual = JSON.parse(json_str.join("\n"))
358
357
 
359
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
358
+ assert_equal 'slice_123', actual['report_slice_id']
360
359
  assert_not_nil(actual_host = actual['hosts'].first)
361
360
  assert_equal @host.fqdn, actual_host['fqdn']
362
361
  assert_not_nil(host_facts = actual_host['facts']&.first)
@@ -378,7 +377,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
378
377
  json_str = generator.render
379
378
  actual = JSON.parse(json_str.join("\n"))
380
379
 
381
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
380
+ assert_equal 'slice_123', actual['report_slice_id']
382
381
  assert_not_nil(actual_host = actual['hosts'].first)
383
382
  assert_equal @host.fqdn, actual_host['fqdn']
384
383
  assert_not_nil(host_facts = actual_host['facts']&.first)
@@ -398,7 +397,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
398
397
  json_str = generator.render
399
398
  actual = JSON.parse(json_str.join("\n"))
400
399
 
401
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
400
+ assert_equal 'slice_123', actual['report_slice_id']
402
401
  assert_not_nil(actual_host = actual['hosts'].first)
403
402
  assert_equal @host.fqdn, actual_host['fqdn']
404
403
  assert_equal '1234', actual_host['account']
@@ -418,7 +417,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
418
417
  json_str = generator.render
419
418
  actual = JSON.parse(json_str.join("\n"))
420
419
 
421
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
420
+ assert_equal 'slice_123', actual['report_slice_id']
422
421
  assert_not_nil(actual_host = actual['hosts'].first)
423
422
  assert_equal @host.fqdn, actual_host['fqdn']
424
423
  assert_equal '1234', actual_host['account']
@@ -437,7 +436,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
437
436
  json_str = generator.render
438
437
  actual = JSON.parse(json_str.join("\n"))
439
438
 
440
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
439
+ assert_equal 'slice_123', actual['report_slice_id']
441
440
  assert_equal 1, generator.hosts_count
442
441
  end
443
442
 
@@ -450,7 +449,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
450
449
  json_str = generator.render
451
450
  actual = JSON.parse(json_str.join("\n"))
452
451
 
453
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
452
+ assert_equal 'slice_123', actual['report_slice_id']
454
453
  assert_not_nil(actual_host = actual['hosts'].first)
455
454
  assert_not_nil(actual_profile = actual_host['system_profile'])
456
455
  assert_equal 1024, actual_profile['system_memory_bytes']
@@ -476,7 +475,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
476
475
  json_str = generator.render
477
476
  actual = JSON.parse(json_str.join("\n"))
478
477
 
479
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
478
+ assert_equal 'slice_123', actual['report_slice_id']
480
479
  assert_not_nil(actual_host = actual['hosts'].first)
481
480
  assert_not_nil(actual_host['account'])
482
481
  assert_not_empty(actual_host['account'])
@@ -493,7 +492,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
493
492
  json_str = generator.render
494
493
  actual = JSON.parse(json_str.join("\n"))
495
494
 
496
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
495
+ assert_equal 'slice_123', actual['report_slice_id']
497
496
  assert_not_nil(actual_host = actual['hosts'].first)
498
497
  assert_not_nil(actual_profile = actual_host['system_profile'])
499
498
  assert_equal 'Red Hat Test Linux 7.1 (TestId)', actual_profile['os_release']
@@ -508,7 +507,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
508
507
  json_str = generator.render
509
508
  actual = JSON.parse(json_str.join("\n"))
510
509
 
511
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
510
+ assert_equal 'slice_123', actual['report_slice_id']
512
511
  assert_not_nil(actual_host = actual['hosts'].first)
513
512
  assert_not_nil(actual_profile = actual_host['system_profile'])
514
513
  assert_equal 'virtual', actual_profile['infrastructure_type']
@@ -523,7 +522,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
523
522
  json_str = generator.render
524
523
  actual = JSON.parse(json_str.join("\n"))
525
524
 
526
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
525
+ assert_equal 'slice_123', actual['report_slice_id']
527
526
  assert_not_nil(actual_host = actual['hosts'].first)
528
527
  assert_not_nil(actual_profile = actual_host['system_profile'])
529
528
  assert_equal 'physical', actual_profile['infrastructure_type']
@@ -538,7 +537,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
538
537
  json_str = generator.render
539
538
  actual = JSON.parse(json_str.join("\n"))
540
539
 
541
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
540
+ assert_equal 'slice_123', actual['report_slice_id']
542
541
  assert_not_nil(actual_host = actual['hosts'].first)
543
542
  assert_not_nil(actual_profile = actual_host['system_profile'])
544
543
  assert_equal 'aws', actual_profile['cloud_provider']
@@ -553,7 +552,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
553
552
  json_str = generator.render
554
553
  actual = JSON.parse(json_str.join("\n"))
555
554
 
556
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
555
+ assert_equal 'slice_123', actual['report_slice_id']
557
556
  assert_not_nil(actual_host = actual['hosts'].first)
558
557
  assert_not_nil(actual_profile = actual_host['system_profile'])
559
558
  assert_equal 'google', actual_profile['cloud_provider']
@@ -568,7 +567,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
568
567
  json_str = generator.render
569
568
  actual = JSON.parse(json_str.join("\n"))
570
569
 
571
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
570
+ assert_equal 'slice_123', actual['report_slice_id']
572
571
  assert_not_nil(actual_host = actual['hosts'].first)
573
572
  assert_not_nil(actual_profile = actual_host['system_profile'])
574
573
  assert_equal 'azure', actual_profile['cloud_provider']
@@ -583,7 +582,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
583
582
  json_str = generator.render
584
583
  actual = JSON.parse(json_str.join("\n"))
585
584
 
586
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
585
+ assert_equal 'slice_123', actual['report_slice_id']
587
586
  assert_not_nil(actual_host = actual['hosts'].first)
588
587
  assert_not_nil(actual_profile = actual_host['system_profile'])
589
588
  assert_equal 'alibaba', actual_profile['cloud_provider']
@@ -598,7 +597,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
598
597
  json_str = generator.render
599
598
  actual = JSON.parse(json_str.join("\n"))
600
599
 
601
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
600
+ assert_equal 'slice_123', actual['report_slice_id']
602
601
  assert_not_nil(actual_host = actual['hosts'].first)
603
602
  assert_not_nil(actual_profile = actual_host['system_profile'])
604
603
  assert_equal 'alibaba', actual_profile['cloud_provider']
@@ -624,57 +623,15 @@ class SliceGeneratorTest < ActiveSupport::TestCase
624
623
  json_str = generator.render
625
624
  actual = JSON.parse(json_str.join("\n"))
626
625
 
627
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
626
+ assert_equal 'slice_123', actual['report_slice_id']
628
627
  assert_not_nil(actual_host = actual['hosts'].first)
629
628
  assert_not_nil(actual_profile = actual_host['system_profile'])
630
629
  assert_not_nil(actual_profile['installed_packages'])
631
630
  end
632
631
 
633
- test 'omits malformed bios_uuid field' do
634
- FactoryBot.create(:fact_value, fact_name: fact_names['dmi::system::uuid'], value: 'test value', host: @host)
635
-
636
- batch = Host.where(id: @host.id).in_batches.first
637
- generator = create_generator(batch)
638
-
639
- json_str = generator.render
640
- actual = JSON.parse(json_str.join("\n"))
641
-
642
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
643
- assert_not_nil(actual_host = actual['hosts'].first)
644
- assert_nil actual_host['bios_uuid']
645
- end
646
-
647
- test 'passes valid bios_uuid field' do
648
- FactoryBot.create(:fact_value, fact_name: fact_names['dmi::system::uuid'], value: 'D30B0B42-7824-2635-C62D-491394DE43F7', host: @host)
649
-
650
- batch = Host.where(id: @host.id).in_batches.first
651
- generator = create_generator(batch)
652
-
653
- json_str = generator.render
654
- actual = JSON.parse(json_str.join("\n"))
655
-
656
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
657
- assert_not_nil(actual_host = actual['hosts'].first)
658
- assert_not_nil actual_host['bios_uuid']
659
- end
660
-
661
- test 'passes valid insights_id field' do
662
- FactoryBot.create(:fact_value, fact_name: fact_names['insights_id'], value: 'D30B0B42-7824-2635-C62D-491394DE43F7', host: @host)
663
-
664
- batch = Host.where(id: @host.id).in_batches.first
665
- generator = create_generator(batch)
666
-
667
- json_str = generator.render
668
- actual = JSON.parse(json_str.join("\n"))
669
-
670
- assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
671
- assert_not_nil(actual_host = actual['hosts'].first)
672
- assert_not_nil actual_host['insights_id']
673
- end
674
-
675
632
  private
676
633
 
677
- def create_generator(batch, name = '00000000-0000-0000-0000-000000000000')
634
+ def create_generator(batch, name = 'slice_123')
678
635
  generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], name)
679
636
  if block_given?
680
637
  yield(generator)
@@ -62,47 +62,6 @@ class TagsGeneratorTest < ActiveSupport::TestCase
62
62
  assert_equal false, actual.key?('content_view')
63
63
  end
64
64
 
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
- ]
76
- )
77
-
78
- generator = create_generator
79
- actual = Hash[generator.generate_parameters]
80
-
81
- assert_equal 3, actual.count
82
- assert_equal true, actual['bool_param']
83
- assert_equal false, actual['false_param']
84
- assert_equal 1, actual['int_param']
85
- end
86
-
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
- ]
98
- )
99
-
100
- generator = create_generator
101
- actual = generator.generate_parameters.group_by { |key, value| key }
102
-
103
- assert_equal 0, actual.count
104
- end
105
-
106
65
  private
107
66
 
108
67
  def create_generator
@@ -31,17 +31,6 @@ export const PageDescription = () => (
31
31
  About subscription watch
32
32
  </a>
33
33
  </p>
34
- <p>
35
- {__('For more information about Insights and Cloud Connector read')}
36
- &nbsp;
37
- <a
38
- href="https://console.redhat.com/security/insights/"
39
- target="_blank"
40
- rel="noopener noreferrer"
41
- >
42
- Red Hat Insights Data and Application Security
43
- </a>
44
- </p>
45
34
  </div>
46
35
  );
47
36
 
@@ -24,16 +24,5 @@ exports[`PageDescription rendering render without Props 1`] = `
24
24
  About subscription watch
25
25
  </a>
26
26
  </p>
27
- <p>
28
- For more information about Insights and Cloud Connector read
29
-  
30
- <a
31
- href="https://console.redhat.com/security/insights/"
32
- rel="noopener noreferrer"
33
- target="_blank"
34
- >
35
- Red Hat Insights Data and Application Security
36
- </a>
37
- </p>
38
27
  </div>
39
28
  `;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { post } from 'foremanReact/redux/API';
2
+ import { get, post } from 'foremanReact/redux/API';
3
+ import { withInterval } from 'foremanReact/redux/middlewares/IntervalMiddleware';
3
4
  import { addToast } from 'foremanReact/redux/actions/toasts';
4
5
  import { translate as __ } from 'foremanReact/common/I18n';
5
6
  import { inventoryUrl } from '../../../../ForemanInventoryHelpers';
@@ -8,10 +9,7 @@ import {
8
9
  INVENTORY_SYNC,
9
10
  INVENTORY_SYNC_TASK_UPDATE,
10
11
  } from './SyncButtonConstants';
11
- import {
12
- setupTaskPolling,
13
- taskRelatedToast,
14
- } from '../../../../../common/ForemanTasks';
12
+ import { foremanUrl } from '../../../../../ForemanRhCloudHelpers';
15
13
 
16
14
  export const handleSync = () => dispatch => {
17
15
  dispatch(
@@ -23,9 +21,9 @@ export const handleSync = () => dispatch => {
23
21
  task: { id },
24
22
  },
25
23
  }) => {
26
- dispatch(setupInventorySyncTaskPolling(id, dispatch));
24
+ dispatch(getSyncTaskInterval(id));
27
25
  return dispatch(
28
- taskRelatedToast(id, 'info', __('Inventory sync has started:'))
26
+ taskPageRefererToast(id, 'info', __('Inventory sync has started:'))
29
27
  );
30
28
  },
31
29
  errorToast: inventorySyncErrorToast,
@@ -33,25 +31,62 @@ export const handleSync = () => dispatch => {
33
31
  );
34
32
  };
35
33
 
36
- export const setupInventorySyncTaskPolling = (id, dispatch) =>
37
- setupTaskPolling({
38
- taskId: id,
39
- key: INVENTORY_SYNC_TASK_UPDATE,
40
- onTaskSuccess: ({
41
- output: {
42
- host_statuses: { sync, disconnect },
43
- },
44
- }) =>
45
- dispatch(
46
- addToast({
47
- sticky: true,
48
- type: 'success',
49
- message: <Toast syncHosts={sync} disconnectHosts={disconnect} />,
50
- })
51
- ),
52
- dispatch,
53
- });
34
+ export const getSyncTaskInterval = id => dispatch => {
35
+ dispatch(
36
+ withInterval(
37
+ get({
38
+ key: INVENTORY_SYNC_TASK_UPDATE,
39
+ url: inventoryUrl(`tasks/${id}`),
40
+ handleSuccess: ({ data: { result, output } }, stopTaskInterval) => {
41
+ if (result === 'success') {
42
+ const {
43
+ host_statuses: { sync, disconnect },
44
+ } = output;
45
+ dispatch(
46
+ addToast({
47
+ sticky: true,
48
+ type: 'success',
49
+ message: (
50
+ <Toast syncHosts={sync} disconnectHosts={disconnect} />
51
+ ),
52
+ })
53
+ );
54
+ }
55
+ if (result === 'error') {
56
+ dispatch(
57
+ taskPageRefererToast(
58
+ id,
59
+ 'error',
60
+ __('Inventory sync has failed:'),
61
+ true
62
+ )
63
+ );
64
+ }
65
+ stopTaskInterval();
66
+ },
67
+ errorToast: inventorySyncErrorToast,
68
+ })
69
+ )
70
+ );
71
+ };
54
72
 
55
- const inventorySyncErrorToast = message =>
56
- `${__('Inventory sync has failed: ')} ${message.response?.data?.message ||
57
- message}`;
73
+ const inventorySyncErrorToast = ({ message, response }) =>
74
+ `${__('Inventory sync has failed: ')} ${response.data?.message || message}`;
75
+
76
+ const taskPageRefererToast = (taskID, toastType, prefix, sticky = false) =>
77
+ addToast({
78
+ sticky,
79
+ type: toastType,
80
+ message: (
81
+ <span>
82
+ {prefix}{' '}
83
+ <a
84
+ target="_blank"
85
+ rel="noopener noreferrer"
86
+ href={foremanUrl(`/foreman_tasks/tasks/${taskID}`)}
87
+ >
88
+ {__('view the task page for more details')}
89
+ </a>
90
+ </span>
91
+ ),
92
+ });
@@ -22,7 +22,7 @@ Array [
22
22
  "errorToast": [Function],
23
23
  "interval": 3000,
24
24
  "type": "API_GET",
25
- "url": "/foreman_tasks/api/tasks/1/details?include_permissions",
25
+ "url": "/foreman_inventory_upload/tasks/1",
26
26
  },
27
27
  ],
28
28
  Array [
@@ -31,7 +31,7 @@ Array [
31
31
  "message": Object {
32
32
  "message": <span>
33
33
  Inventory sync has started:
34
- <br />
34
+
35
35
  <a
36
36
  href="/foreman_tasks/tasks/1"
37
37
  rel="noopener noreferrer"
@@ -40,6 +40,7 @@ Array [
40
40
  view the task page for more details
41
41
  </a>
42
42
  </span>,
43
+ "sticky": false,
43
44
  "type": "info",
44
45
  },
45
46
  },
@@ -19,6 +19,25 @@ export const fetchInsights = (queryParams = {}) => (dispatch, getState) => {
19
19
  ...queryParams,
20
20
  };
21
21
 
22
+ dispatch(
23
+ get({
24
+ key: INSIGHTS_HITS_API_KEY,
25
+ url: INSIGHTS_HITS_PATH,
26
+ params: {
27
+ page,
28
+ per_page: perPage,
29
+ search: query,
30
+ order: `${sortBy} ${sortOrder}`,
31
+ },
32
+ handleSuccess: response => {
33
+ if (isSelectAll) {
34
+ selectAllIds(dispatch, response.data.hits || []);
35
+ dispatch(selectAll());
36
+ }
37
+ },
38
+ })
39
+ );
40
+
22
41
  const uri = new URI();
23
42
  uri.search({
24
43
  page,
@@ -39,25 +58,6 @@ export const fetchInsights = (queryParams = {}) => (dispatch, getState) => {
39
58
  if (!isSelectAll) {
40
59
  dispatch(setSelectAllAlert(false));
41
60
  }
42
-
43
- return dispatch(
44
- get({
45
- key: INSIGHTS_HITS_API_KEY,
46
- url: INSIGHTS_HITS_PATH,
47
- params: {
48
- page,
49
- per_page: perPage,
50
- search: query,
51
- order: `${sortBy} ${sortOrder}`,
52
- },
53
- handleSuccess: response => {
54
- if (isSelectAll) {
55
- selectAllIds(dispatch, response.data.hits || []);
56
- dispatch(selectAll());
57
- }
58
- },
59
- })
60
- );
61
61
  };
62
62
 
63
63
  const selectAllIds = (dispatch, results, prevSelectedIds = {}) => {
@@ -26,20 +26,6 @@ Array [
26
26
 
27
27
  exports[`insights table actions should fetchInsights 1`] = `
28
28
  Array [
29
- Array [
30
- Object {
31
- "payload": Object {
32
- "args": Array [
33
- Object {
34
- "pathname": "/foreman_rh_cloud/insights_cloud",
35
- "search": "?page=2&per_page=7&search=&sort_by=&sort_order=&select_all=true",
36
- },
37
- ],
38
- "method": "push",
39
- },
40
- "type": "@@router/CALL_HISTORY_METHOD",
41
- },
42
- ],
43
29
  Array [
44
30
  Object {
45
31
  "payload": Object {
@@ -75,6 +61,20 @@ Array [
75
61
  "url": "/insights_cloud/hits",
76
62
  },
77
63
  ],
64
+ Array [
65
+ Object {
66
+ "payload": Object {
67
+ "args": Array [
68
+ Object {
69
+ "pathname": "/foreman_rh_cloud/insights_cloud",
70
+ "search": "?page=2&per_page=7&search=&sort_by=&sort_order=&select_all=true",
71
+ },
72
+ ],
73
+ "method": "push",
74
+ },
75
+ "type": "@@router/CALL_HISTORY_METHOD",
76
+ },
77
+ ],
78
78
  ]
79
79
  `;
80
80
 
@@ -34,7 +34,6 @@ const RemediateButton = ({ isExperimentalMode, selectedIds, toggleModal }) => {
34
34
  button = (
35
35
  <Popover
36
36
  isVisible={isVisible}
37
- aria-label={__('Please enable lab features to use this button')}
38
37
  bodyContent={
39
38
  <div dangerouslySetInnerHTML={{ __html: popoverContent }} />
40
39
  }
@@ -6,18 +6,4 @@
6
6
  margin-top: 5px;
7
7
  }
8
8
  }
9
-
10
- // applies to the backdrop parent of the modal
11
- @at-root .pf-c-backdrop {
12
- width: calc(100% - 200px) !important;
13
- left: 200px !important;
14
- }
15
-
16
- // where the vertical nav breaks: https://github.com/theforeman/foreman/blob/3347fa49d500964f0209122d8d36c920d1feafcc/webpack/assets/javascripts/react_app/components/Layout/components/Toolbar/HeaderToolbar.scss#L26
17
- @media (max-width: 768px) {
18
- @at-root .pf-c-backdrop {
19
- width: 100% !important;
20
- left: 0 !important;
21
- }
22
- }
23
9
  }