foreman_rh_cloud 3.0.21 → 3.0.24

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.
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
@@ -12,7 +12,7 @@ const FullScreenModal = ({
12
12
  terminalProps,
13
13
  }) => (
14
14
  <Modal
15
- id="full-screen-terminal"
15
+ id="rh-cloud-inventory-full-screen-terminal"
16
16
  show={showFullScreen}
17
17
  onHide={toggleFullScreen}
18
18
  >
@@ -8,7 +8,7 @@ exports[`FullScreenModal rendering render without Props 1`] = `
8
8
  bsClass="modal"
9
9
  dialogComponentClass={[Function]}
10
10
  enforceFocus={true}
11
- id="full-screen-terminal"
11
+ id="rh-cloud-inventory-full-screen-terminal"
12
12
  keyboard={true}
13
13
  manager={
14
14
  ModalManager {
@@ -1,21 +1,19 @@
1
- .rh-cloud-inventory-page {
2
- #full-screen-terminal {
3
- .modal-dialog {
4
- width: 95%;
5
- height: 95%;
6
- margin: 30px 0 0 30px;
1
+ #rh-cloud-inventory-full-screen-terminal {
2
+ .modal-dialog {
3
+ width: 95%;
4
+ height: 95%;
5
+ margin: 30px 0 0 30px;
7
6
 
8
- .modal-body {
9
- padding: 0;
10
- display: flex;
11
- height: -webkit-fill-available;
12
- height: -moz-available;
13
- height: fill-available;
7
+ .modal-body {
8
+ padding: 0;
9
+ display: flex;
10
+ height: -webkit-fill-available;
11
+ height: -moz-available;
12
+ height: fill-available;
14
13
 
15
- .terminal {
16
- margin: 0 -20px;
17
- height: 100%;
18
- }
14
+ .rh-cloud-inventory-terminal {
15
+ margin: 0 -20px;
16
+ height: 100%;
19
17
  }
20
18
  }
21
19
  }
@@ -31,6 +31,17 @@ 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>
34
45
  </div>
35
46
  );
36
47
 
@@ -24,5 +24,16 @@ 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>
27
38
  </div>
28
39
  `;
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
- import { get, post } from 'foremanReact/redux/API';
3
- import { withInterval } from 'foremanReact/redux/middlewares/IntervalMiddleware';
2
+ import { post } from 'foremanReact/redux/API';
4
3
  import { addToast } from 'foremanReact/redux/actions/toasts';
5
4
  import { translate as __ } from 'foremanReact/common/I18n';
6
5
  import { inventoryUrl } from '../../../../ForemanInventoryHelpers';
@@ -9,7 +8,10 @@ import {
9
8
  INVENTORY_SYNC,
10
9
  INVENTORY_SYNC_TASK_UPDATE,
11
10
  } from './SyncButtonConstants';
12
- import { foremanUrl } from '../../../../../ForemanRhCloudHelpers';
11
+ import {
12
+ setupTaskPolling,
13
+ taskRelatedToast,
14
+ } from '../../../../../common/ForemanTasks';
13
15
 
14
16
  export const handleSync = () => dispatch => {
15
17
  dispatch(
@@ -21,9 +23,9 @@ export const handleSync = () => dispatch => {
21
23
  task: { id },
22
24
  },
23
25
  }) => {
24
- dispatch(getSyncTaskInterval(id));
26
+ dispatch(setupInventorySyncTaskPolling(id, dispatch));
25
27
  return dispatch(
26
- taskPageRefererToast(id, 'info', __('Inventory sync has started:'))
28
+ taskRelatedToast(id, 'info', __('Inventory sync has started:'))
27
29
  );
28
30
  },
29
31
  errorToast: inventorySyncErrorToast,
@@ -31,62 +33,25 @@ export const handleSync = () => dispatch => {
31
33
  );
32
34
  };
33
35
 
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
- };
72
-
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
- ),
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,
92
53
  });
54
+
55
+ const inventorySyncErrorToast = message =>
56
+ `${__('Inventory sync has failed: ')} ${message.response?.data?.message ||
57
+ message}`;
@@ -22,7 +22,7 @@ Array [
22
22
  "errorToast": [Function],
23
23
  "interval": 3000,
24
24
  "type": "API_GET",
25
- "url": "/foreman_inventory_upload/tasks/1",
25
+ "url": "/foreman_tasks/api/tasks/1/details?include_permissions",
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
-
34
+ <br />
35
35
  <a
36
36
  href="/foreman_tasks/tasks/1"
37
37
  rel="noopener noreferrer"
@@ -40,7 +40,6 @@ Array [
40
40
  view the task page for more details
41
41
  </a>
42
42
  </span>,
43
- "sticky": false,
44
43
  "type": "info",
45
44
  },
46
45
  },
@@ -72,7 +72,7 @@ class Terminal extends React.Component {
72
72
  return (
73
73
  <Grid.Col sm={12}>
74
74
  <div
75
- className="terminal"
75
+ className="rh-cloud-inventory-terminal"
76
76
  ref={this.terminal}
77
77
  onScroll={this.handleScroll}
78
78
  >
@@ -29,6 +29,6 @@ describe('Terminal', () => {
29
29
  const text = 'some-string-log';
30
30
  const modifiedProps = { ...props, logs: text };
31
31
  const wrapper = mount(<Terminal {...modifiedProps} />);
32
- expect(wrapper.find('.terminal p').text()).toEqual(text);
32
+ expect(wrapper.find('.rh-cloud-inventory-terminal p').text()).toEqual(text);
33
33
  });
34
34
  });
@@ -7,7 +7,7 @@ exports[`Terminal rendering render with props 1`] = `
7
7
  sm={12}
8
8
  >
9
9
  <div
10
- className="terminal"
10
+ className="rh-cloud-inventory-terminal"
11
11
  onScroll={[Function]}
12
12
  >
13
13
  <Grid
@@ -65,7 +65,7 @@ exports[`Terminal rendering render without Props 1`] = `
65
65
  sm={12}
66
66
  >
67
67
  <div
68
- className="terminal"
68
+ className="rh-cloud-inventory-terminal"
69
69
  onScroll={[Function]}
70
70
  >
71
71
  <Grid
@@ -1,34 +1,32 @@
1
- .rh-cloud-inventory-page {
2
- .terminal {
3
- height: 200px;
4
- background-color: #222;
5
- padding: 10px 0;
6
- margin-bottom: 20px;
7
- overflow-y: scroll;
8
- overflow-x: hidden;
1
+ .rh-cloud-inventory-terminal {
2
+ height: 200px;
3
+ background-color: #222;
4
+ padding: 10px 0;
5
+ margin-bottom: 20px;
6
+ overflow-y: scroll;
7
+ overflow-x: hidden;
9
8
 
10
- p {
11
- font-family: monospace;
12
- font-size: 16px;
13
- color: #22da26;
14
- overflow-wrap: anywhere;
9
+ p {
10
+ font-family: monospace;
11
+ font-size: 16px;
12
+ color: #22da26;
13
+ overflow-wrap: anywhere;
15
14
 
16
- &.terminal_error {
17
- color: #f00;
18
- }
15
+ &.terminal_error {
16
+ color: #f00;
19
17
  }
18
+ }
20
19
 
21
- &::-webkit-scrollbar {
22
- width: 12px;
23
- height: 12px;
24
- background: #aaa;
25
- }
20
+ &::-webkit-scrollbar {
21
+ width: 12px;
22
+ height: 12px;
23
+ background: #aaa;
24
+ }
26
25
 
27
- &::-webkit-scrollbar-thumb {
28
- background: #222;
29
- border-radius: 6px;
30
- border: 3px solid transparent;
31
- background-clip: content-box;
32
- }
26
+ &::-webkit-scrollbar-thumb {
27
+ background: #222;
28
+ border-radius: 6px;
29
+ border: 3px solid transparent;
30
+ background-clip: content-box;
33
31
  }
34
32
  }
@@ -19,25 +19,6 @@ 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
-
41
22
  const uri = new URI();
42
23
  uri.search({
43
24
  page,
@@ -58,6 +39,25 @@ export const fetchInsights = (queryParams = {}) => (dispatch, getState) => {
58
39
  if (!isSelectAll) {
59
40
  dispatch(setSelectAllAlert(false));
60
41
  }
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,6 +26,20 @@ 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
+ ],
29
43
  Array [
30
44
  Object {
31
45
  "payload": Object {
@@ -61,20 +75,6 @@ Array [
61
75
  "url": "/insights_cloud/hits",
62
76
  },
63
77
  ],
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,6 +34,7 @@ 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')}
37
38
  bodyContent={
38
39
  <div dangerouslySetInnerHTML={{ __html: popoverContent }} />
39
40
  }
@@ -190,21 +190,28 @@ exports[`NoTokenEmptyState render 1`] = `
190
190
  onClick={[Function]}
191
191
  variant="primary"
192
192
  >
193
- <button
194
- aria-disabled={true}
195
- aria-label={null}
196
- className="pf-c-button pf-m-primary pf-m-disabled"
197
- data-ouia-component-id="OUIA-Generated-Button-primary-1"
198
- data-ouia-component-type="PF4/Button"
199
- data-ouia-safe={true}
200
- disabled={true}
193
+ <ButtonBase
194
+ innerRef={null}
195
+ isDisabled={true}
201
196
  onClick={[Function]}
202
- role={null}
203
- tabIndex={null}
204
- type="button"
197
+ variant="primary"
205
198
  >
206
- Save setting and sync recommendations
207
- </button>
199
+ <button
200
+ aria-disabled={true}
201
+ aria-label={null}
202
+ className="pf-c-button pf-m-primary pf-m-disabled"
203
+ data-ouia-component-id="OUIA-Generated-Button-primary-1"
204
+ data-ouia-component-type="PF4/Button"
205
+ data-ouia-safe={true}
206
+ disabled={true}
207
+ onClick={[Function]}
208
+ role={null}
209
+ tabIndex={null}
210
+ type="button"
211
+ >
212
+ Save setting and sync recommendations
213
+ </button>
214
+ </ButtonBase>
208
215
  </Button>
209
216
  </div>
210
217
  </div>