foreman_rh_cloud 3.0.21 → 3.0.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/api/v2/rh_cloud/inventory_controller.rb +50 -0
  3. data/app/controllers/concerns/inventory_upload/report_actions.rb +26 -0
  4. data/app/controllers/concerns/inventory_upload/task_actions.rb +25 -0
  5. data/app/controllers/foreman_inventory_upload/reports_controller.rb +3 -1
  6. data/app/controllers/foreman_inventory_upload/tasks_controller.rb +5 -13
  7. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +4 -4
  8. data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +1 -0
  9. data/app/controllers/insights_cloud/hits_controller.rb +7 -3
  10. data/app/helpers/foreman_insights_deprecations_helper.rb +9 -0
  11. data/app/helpers/foreman_insights_host_helper.rb +19 -0
  12. data/app/models/insights_client_report_status.rb +4 -0
  13. data/app/overrides/old_plugin_deprecation.rb +20 -0
  14. data/app/services/foreman_rh_cloud/cloud_auth.rb +12 -0
  15. data/app/services/foreman_rh_cloud/cloud_request.rb +14 -0
  16. data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +1 -14
  17. data/app/services/foreman_rh_cloud/remediations_retriever.rb +1 -4
  18. data/config/package-lock.json.plugin +32774 -0
  19. data/config/routes.rb +19 -0
  20. data/lib/foreman_inventory_upload.rb +9 -1
  21. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +19 -0
  22. data/lib/foreman_inventory_upload/generators/queries.rb +1 -0
  23. data/lib/foreman_inventory_upload/generators/slice.rb +7 -6
  24. data/lib/foreman_rh_cloud/engine.rb +19 -8
  25. data/lib/foreman_rh_cloud/version.rb +1 -1
  26. data/lib/insights_cloud/async/insights_client_status_aging.rb +17 -0
  27. data/lib/insights_cloud/async/insights_full_sync.rb +4 -14
  28. data/lib/insights_cloud/async/insights_resolutions_sync.rb +1 -4
  29. data/lib/insights_cloud/async/insights_rules_sync.rb +2 -7
  30. data/lib/inventory_sync/async/host_result.rb +4 -0
  31. data/lib/inventory_sync/async/inventory_full_sync.rb +2 -1
  32. data/lib/inventory_sync/async/inventory_hosts_sync.rb +16 -2
  33. data/lib/inventory_sync/async/inventory_scheduled_sync.rb +12 -0
  34. data/lib/inventory_sync/async/inventory_self_host_sync.rb +30 -0
  35. data/lib/inventory_sync/async/query_inventory_job.rb +6 -5
  36. data/lib/tasks/rh_cloud_inventory.rake +8 -1
  37. data/package.json +1 -1
  38. data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +41 -0
  39. data/test/controllers/inventory_upload/api/inventory_controller_test.rb +53 -0
  40. data/test/factories/inventory_upload_factories.rb +1 -1
  41. data/test/jobs/insights_client_status_aging_test.rb +33 -0
  42. data/test/jobs/insights_full_sync_test.rb +3 -0
  43. data/test/jobs/insights_resolutions_sync_test.rb +3 -0
  44. data/test/jobs/insights_rules_sync_test.rb +3 -0
  45. data/test/jobs/inventory_full_sync_test.rb +3 -0
  46. data/test/jobs/inventory_hosts_sync_test.rb +267 -0
  47. data/test/jobs/inventory_scheduled_sync_test.rb +22 -0
  48. data/test/jobs/inventory_self_host_sync_test.rb +103 -0
  49. data/test/test_plugin_helper.rb +2 -0
  50. data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +3 -3
  51. data/test/unit/slice_generator_test.rb +81 -29
  52. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +1 -1
  53. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/__snapshots__/FullScreenModal.test.js.snap +1 -1
  54. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +14 -16
  55. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js +11 -0
  56. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/__snapshots__/PageDescription.test.js.snap +11 -0
  57. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +28 -63
  58. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/integrations.test.js.snap +2 -3
  59. data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +1 -1
  60. data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/Terminal.test.js +1 -1
  61. data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/__snapshots__/Terminal.test.js.snap +2 -2
  62. data/webpack/ForemanInventoryUpload/Components/Terminal/terminal.scss +25 -27
  63. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableActions.js +19 -19
  64. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableActions.test.js.snap +14 -14
  65. data/webpack/InsightsCloudSync/Components/RemediationModal/RemediateButton.js +1 -0
  66. data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/NoTokenEmptyState.test.js.snap +20 -13
  67. data/webpack/InsightsCloudSync/InsightsCloudSync.js +4 -1
  68. data/webpack/InsightsCloudSync/InsightsCloudSyncActions.js +44 -20
  69. data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +2 -0
  70. data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +2 -2
  71. data/webpack/InsightsCloudSync/__tests__/__snapshots__/InsightsCloudSyncActions.test.js.snap +11 -7
  72. data/webpack/common/ForemanTasks/ForemanTasksActions.js +64 -0
  73. data/webpack/common/ForemanTasks/ForemanTasksHelpers.js +7 -0
  74. data/webpack/common/ForemanTasks/index.js +1 -0
  75. metadata +25 -2
@@ -36,7 +36,10 @@ const InsightsCloudSync = ({
36
36
  toolbarButtons={
37
37
  <>
38
38
  <RemediationModal />
39
- <Button variant="secondary" onClick={syncInsights}>
39
+ <Button
40
+ variant="secondary"
41
+ onClick={() => syncInsights(fetchInsights, query)}
42
+ >
40
43
  {__('Start recommendations sync')}
41
44
  </Button>
42
45
  </>
@@ -1,25 +1,49 @@
1
- import React from 'react';
2
1
  import { post } from 'foremanReact/redux/API';
3
2
  import { translate as __ } from 'foremanReact/common/I18n';
4
3
  import { insightsCloudUrl } from './InsightsCloudSyncHelpers';
5
- import { INSIGHTS_CLOUD_SYNC } from './InsightsCloudSyncConstants';
6
- import { foremanUrl } from '../ForemanRhCloudHelpers';
4
+ import {
5
+ INSIGHTS_CLOUD_SYNC,
6
+ INSIGHTS_CLOUD_SYNC_TASK,
7
+ } from './InsightsCloudSyncConstants';
8
+ import { setupTaskPolling, taskRelatedToast } from '../common/ForemanTasks';
7
9
 
8
- export const syncInsights = () =>
9
- post({
10
- key: INSIGHTS_CLOUD_SYNC,
11
- url: insightsCloudUrl('tasks'),
12
- successToast: response => (
13
- <span>
14
- {__('Recommendation sync has started: ')}
15
- <a
16
- target="_blank"
17
- rel="noopener noreferrer"
18
- href={foremanUrl(`/foreman_tasks/tasks/${response.data?.task?.id}`)}
19
- >
20
- {__('view the task in progress')}
21
- </a>
22
- </span>
23
- ),
24
- errorToast: error => `${__('Recommendation sync has failed: ')} ${error}`,
10
+ export const syncInsights = (fetchInsights, query) => dispatch =>
11
+ dispatch(
12
+ post({
13
+ key: INSIGHTS_CLOUD_SYNC,
14
+ url: insightsCloudUrl('tasks'),
15
+ handleSuccess: ({
16
+ data: {
17
+ task: { id },
18
+ },
19
+ }) => {
20
+ dispatch(syncInsightsStartedToast(id));
21
+ dispatch(setupInsightsTaskPolling(id, fetchInsights, query, dispatch));
22
+ },
23
+ errorToast: error => syncInsightsError(error),
24
+ })
25
+ );
26
+
27
+ const syncInsightsError = error =>
28
+ `${__('Recommendation sync has failed: ')} ${error}`;
29
+
30
+ const syncInsightsStartedToast = taskId =>
31
+ taskRelatedToast(taskId, 'info', __('Recommendation sync has started: '));
32
+
33
+ const setupInsightsTaskPolling = (taskId, fetchInsights, query, dispatch) =>
34
+ setupTaskPolling({
35
+ taskId,
36
+ key: INSIGHTS_CLOUD_SYNC_TASK,
37
+ onTaskSuccess: () => {
38
+ fetchInsights({ query, page: 1 });
39
+ dispatch(
40
+ taskRelatedToast(
41
+ taskId,
42
+ 'success',
43
+ __('Recommendations synced successfully')
44
+ )
45
+ );
46
+ },
47
+ taskErrorMessage: data => syncInsightsError(data.humanized.errors),
48
+ dispatch,
25
49
  });
@@ -4,6 +4,8 @@ import { foremanUrl } from '../ForemanRhCloudHelpers';
4
4
 
5
5
  export const INSIGHTS_CLOUD_SYNC = 'INSIGHTS_CLOUD_SYNC';
6
6
 
7
+ export const INSIGHTS_CLOUD_SYNC_TASK = 'INSIGHTS_CLOUD_SYNC_TASK';
8
+
7
9
  export const INSIGHTS_SYNC_PAGE_TITLE = __('Red Hat Insights');
8
10
 
9
11
  export const INSIGHTS_PATH = foremanUrl('/foreman_rh_cloud/insights_cloud');
@@ -29,12 +29,12 @@ exports[`InsightsCloudSync render 1`] = `
29
29
  toolbarButtons={
30
30
  <React.Fragment>
31
31
  <UNDEFINED />
32
- <Button
32
+ <ForwardRef
33
33
  onClick={[Function]}
34
34
  variant="secondary"
35
35
  >
36
36
  Start recommendations sync
37
- </Button>
37
+ </ForwardRef>
38
38
  </React.Fragment>
39
39
  }
40
40
  >
@@ -1,11 +1,15 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`Insights cloud sync actions should syncInsights 1`] = `
4
- Object {
5
- "errorToast": [Function],
6
- "key": "INSIGHTS_CLOUD_SYNC",
7
- "successToast": [Function],
8
- "type": "post-some-type",
9
- "url": "/insights_cloud/tasks",
10
- }
4
+ Array [
5
+ Array [
6
+ Object {
7
+ "errorToast": [Function],
8
+ "handleSuccess": [Function],
9
+ "key": "INSIGHTS_CLOUD_SYNC",
10
+ "type": "post-some-type",
11
+ "url": "/insights_cloud/tasks",
12
+ },
13
+ ],
14
+ ]
11
15
  `;
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import { get } from 'foremanReact/redux/API';
3
+ import { withInterval } from 'foremanReact/redux/middlewares/IntervalMiddleware';
4
+ import { addToast } from 'foremanReact/redux/actions/toasts';
5
+ import { translate as __ } from 'foremanReact/common/I18n';
6
+ import { foremanTaskDetailsUrl } from './ForemanTasksHelpers';
7
+ import { foremanUrl } from '../../ForemanRhCloudHelpers';
8
+
9
+ export const setupTaskPolling = ({
10
+ taskId,
11
+ key,
12
+ onTaskSuccess,
13
+ onTaskError,
14
+ taskErrorMessage,
15
+ dispatch,
16
+ }) =>
17
+ withInterval(
18
+ get({
19
+ key,
20
+ url: foremanTaskDetailsUrl(taskId),
21
+ handleSuccess: ({ data }, stopTaskInterval) => {
22
+ if (data.result === 'success') {
23
+ stopTaskInterval();
24
+ onTaskSuccess(data, dispatch);
25
+ }
26
+ if (data.result === 'error') {
27
+ stopTaskInterval();
28
+ if (taskErrorMessage === undefined) {
29
+ taskErrorMessage = errorData =>
30
+ `${__('The task failed with the following error:')} ${
31
+ errorData.humanized.errors
32
+ }`;
33
+ }
34
+ if (onTaskError === undefined) {
35
+ onTaskError = errorData =>
36
+ dispatch(defaultTaskErrorHandler(errorData, taskErrorMessage));
37
+ }
38
+ onTaskError(data, dispatch);
39
+ }
40
+ },
41
+ errorToast: error => `Could not get task details: ${error}`,
42
+ })
43
+ );
44
+
45
+ export const taskRelatedToast = (taskID, type, message) =>
46
+ addToast({
47
+ type,
48
+ message: (
49
+ <span>
50
+ {message}
51
+ <br />
52
+ <a
53
+ target="_blank"
54
+ rel="noopener noreferrer"
55
+ href={foremanUrl(`/foreman_tasks/tasks/${taskID}`)}
56
+ >
57
+ {__('view the task page for more details')}
58
+ </a>
59
+ </span>
60
+ ),
61
+ });
62
+
63
+ const defaultTaskErrorHandler = (data, taskErrorMessage) =>
64
+ taskRelatedToast(data.id, 'error', taskErrorMessage(data));
@@ -0,0 +1,7 @@
1
+ import { foremanUrl } from '../../ForemanRhCloudHelpers';
2
+
3
+ export const foremanTasksApiPath = path =>
4
+ foremanUrl(`/foreman_tasks/api/tasks/${path}`);
5
+
6
+ export const foremanTaskDetailsUrl = id =>
7
+ foremanTasksApiPath(`${id}/details?include_permissions`);
@@ -0,0 +1 @@
1
+ export { setupTaskPolling, taskRelatedToast } from './ForemanTasksActions';
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_rh_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.21
4
+ version: 3.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Red Hat Cloud team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-20 00:00:00.000000000 Z
11
+ date: 2021-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: katello
@@ -146,8 +146,11 @@ files:
146
146
  - LICENSE
147
147
  - README.md
148
148
  - Rakefile
149
+ - app/controllers/api/v2/rh_cloud/inventory_controller.rb
149
150
  - app/controllers/concerns/insights_cloud/candlepin_cache.rb
150
151
  - app/controllers/concerns/insights_cloud/client_authentication.rb
152
+ - app/controllers/concerns/inventory_upload/report_actions.rb
153
+ - app/controllers/concerns/inventory_upload/task_actions.rb
151
154
  - app/controllers/foreman_inventory_upload/accounts_controller.rb
152
155
  - app/controllers/foreman_inventory_upload/reports_controller.rb
153
156
  - app/controllers/foreman_inventory_upload/tasks_controller.rb
@@ -157,6 +160,8 @@ files:
157
160
  - app/controllers/insights_cloud/hits_controller.rb
158
161
  - app/controllers/insights_cloud/settings_controller.rb
159
162
  - app/controllers/insights_cloud/tasks_controller.rb
163
+ - app/helpers/foreman_insights_deprecations_helper.rb
164
+ - app/helpers/foreman_insights_host_helper.rb
160
165
  - app/helpers/foreman_inventory_upload_helper.rb
161
166
  - app/helpers/foreman_inventory_upload_host_helper.rb
162
167
  - app/models/concerns/rh_cloud_host.rb
@@ -169,9 +174,11 @@ files:
169
174
  - app/models/setting/rh_cloud.rb
170
175
  - app/overrides/hosts_list.rb
171
176
  - app/overrides/layouts/base/styles.html.erb.deface
177
+ - app/overrides/old_plugin_deprecation.rb
172
178
  - app/services/foreman_rh_cloud/branch_info.rb
173
179
  - app/services/foreman_rh_cloud/cloud_auth.rb
174
180
  - app/services/foreman_rh_cloud/cloud_connector.rb
181
+ - app/services/foreman_rh_cloud/cloud_request.rb
175
182
  - app/services/foreman_rh_cloud/cloud_request_forwarder.rb
176
183
  - app/services/foreman_rh_cloud/remediations_retriever.rb
177
184
  - app/services/foreman_rh_cloud/template_renderer_helper.rb
@@ -182,6 +189,7 @@ files:
182
189
  - config/Gemfile.lock.gh_test
183
190
  - config/database.yml.example
184
191
  - config/package-lock.json.gh_test
192
+ - config/package-lock.json.plugin
185
193
  - config/routes.rb
186
194
  - db/migrate/20191215104806_create_insights_hits.foreman_inventory_upload.rb
187
195
  - db/migrate/20191216062008_create_insights_facets.foreman_inventory_upload.rb
@@ -215,6 +223,7 @@ files:
215
223
  - lib/foreman_rh_cloud/engine.rb
216
224
  - lib/foreman_rh_cloud/version.rb
217
225
  - lib/insights_cloud.rb
226
+ - lib/insights_cloud/async/insights_client_status_aging.rb
218
227
  - lib/insights_cloud/async/insights_full_sync.rb
219
228
  - lib/insights_cloud/async/insights_generate_notifications.rb
220
229
  - lib/insights_cloud/async/insights_resolutions_sync.rb
@@ -225,6 +234,7 @@ files:
225
234
  - lib/inventory_sync/async/inventory_full_sync.rb
226
235
  - lib/inventory_sync/async/inventory_hosts_sync.rb
227
236
  - lib/inventory_sync/async/inventory_scheduled_sync.rb
237
+ - lib/inventory_sync/async/inventory_self_host_sync.rb
228
238
  - lib/inventory_sync/async/query_inventory_job.rb
229
239
  - lib/tasks/foreman_rh_cloud_tasks.rake
230
240
  - lib/tasks/insights.rake
@@ -237,15 +247,20 @@ files:
237
247
  - test/controllers/accounts_controller_test.rb
238
248
  - test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb
239
249
  - test/controllers/insights_sync/settings_controller_test.rb
250
+ - test/controllers/inventory_upload/api/inventory_controller_test.rb
240
251
  - test/controllers/reports_controller_test.rb
241
252
  - test/controllers/uploads_controller_test.rb
242
253
  - test/controllers/uploads_settings_controller_test.rb
243
254
  - test/factories/insights_factories.rb
244
255
  - test/factories/inventory_upload_factories.rb
256
+ - test/jobs/insights_client_status_aging_test.rb
245
257
  - test/jobs/insights_full_sync_test.rb
246
258
  - test/jobs/insights_resolutions_sync_test.rb
247
259
  - test/jobs/insights_rules_sync_test.rb
248
260
  - test/jobs/inventory_full_sync_test.rb
261
+ - test/jobs/inventory_hosts_sync_test.rb
262
+ - test/jobs/inventory_scheduled_sync_test.rb
263
+ - test/jobs/inventory_self_host_sync_test.rb
249
264
  - test/jobs/upload_report_job_test.rb
250
265
  - test/models/insights_client_report_status_test.rb
251
266
  - test/test_plugin_helper.rb
@@ -620,6 +635,9 @@ files:
620
635
  - webpack/__tests__/__snapshots__/ForemanRhCloudHelpers.test.js.snap
621
636
  - webpack/__tests__/__snapshots__/ForemanRhCloudSelectors.test.js.snap
622
637
  - webpack/__tests__/__snapshots__/ForemanRhCloudTestHelpers.test.js.snap
638
+ - webpack/common/ForemanTasks/ForemanTasksActions.js
639
+ - webpack/common/ForemanTasks/ForemanTasksHelpers.js
640
+ - webpack/common/ForemanTasks/index.js
623
641
  - webpack/common/Switcher/HelpLabel.js
624
642
  - webpack/common/Switcher/SwitcherPF4.js
625
643
  - webpack/common/Switcher/SwitcherPF4.scss
@@ -659,15 +677,20 @@ test_files:
659
677
  - test/controllers/accounts_controller_test.rb
660
678
  - test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb
661
679
  - test/controllers/insights_sync/settings_controller_test.rb
680
+ - test/controllers/inventory_upload/api/inventory_controller_test.rb
662
681
  - test/controllers/reports_controller_test.rb
663
682
  - test/controllers/uploads_controller_test.rb
664
683
  - test/controllers/uploads_settings_controller_test.rb
665
684
  - test/factories/insights_factories.rb
666
685
  - test/factories/inventory_upload_factories.rb
686
+ - test/jobs/insights_client_status_aging_test.rb
667
687
  - test/jobs/insights_full_sync_test.rb
668
688
  - test/jobs/insights_resolutions_sync_test.rb
669
689
  - test/jobs/insights_rules_sync_test.rb
670
690
  - test/jobs/inventory_full_sync_test.rb
691
+ - test/jobs/inventory_hosts_sync_test.rb
692
+ - test/jobs/inventory_scheduled_sync_test.rb
693
+ - test/jobs/inventory_self_host_sync_test.rb
671
694
  - test/jobs/upload_report_job_test.rb
672
695
  - test/models/insights_client_report_status_test.rb
673
696
  - test/test_plugin_helper.rb