foreman_rh_cloud 3.0.14 → 3.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -0
  3. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +11 -0
  4. data/app/controllers/insights_cloud/hits_controller.rb +24 -0
  5. data/app/controllers/insights_cloud/settings_controller.rb +8 -0
  6. data/app/models/insights_hit.rb +5 -1
  7. data/app/models/setting/rh_cloud.rb +8 -6
  8. data/app/overrides/layouts/base/styles.html.erb.deface +2 -0
  9. data/app/services/foreman_rh_cloud/cloud_connector.rb +59 -0
  10. data/app/views/layouts/foreman_rh_cloud/application.html.erb +0 -4
  11. data/config/Gemfile.lock.gh_test +830 -0
  12. data/config/database.yml.example +17 -0
  13. data/config/package-lock.json.gh_test +35653 -0
  14. data/config/routes.rb +12 -3
  15. data/lib/foreman_inventory_upload.rb +1 -1
  16. data/lib/foreman_inventory_upload/generators/archived_report.rb +1 -1
  17. data/lib/foreman_rh_cloud/engine.rb +15 -5
  18. data/lib/foreman_rh_cloud/version.rb +1 -1
  19. data/lib/tasks/rh_cloud_inventory.rake +23 -0
  20. data/package.json +18 -17
  21. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +3 -2
  22. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +1 -1
  23. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +33 -15
  24. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +43 -43
  25. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.js +6 -7
  26. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatusHelper.js +5 -4
  27. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/__snapshots__/ListItemStatus.test.js.snap +19 -34
  28. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +2 -2
  29. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +3 -3
  30. data/webpack/ForemanInventoryUpload/Components/AccountList/accountList.scss +28 -5
  31. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.js +6 -9
  32. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js +1 -1
  33. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcherActions.test.js +2 -2
  34. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcher.test.js.snap +5 -28
  35. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +1 -1
  36. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +2 -2
  37. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.js +6 -9
  38. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherActions.js +1 -1
  39. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcherActions.test.js +2 -2
  40. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcher.test.js.snap +5 -28
  41. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/integration.test.js.snap +5 -0
  42. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/integration.test.js +2 -2
  43. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.js +6 -9
  44. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherActions.js +1 -1
  45. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcherActions.test.js +2 -2
  46. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcher.test.js.snap +5 -28
  47. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterReducer.js +6 -3
  48. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +5 -0
  49. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.js +2 -2
  50. data/webpack/ForemanInventoryUpload/Components/InventorySettings/{inventorySettings.scss → InventorySettings.scss} +2 -5
  51. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettings.test.js.snap +1 -1
  52. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.js +6 -8
  53. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherActions.js +1 -1
  54. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcherActions.test.js +2 -2
  55. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcher.test.js.snap +5 -28
  56. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +10 -18
  57. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.scss +19 -0
  58. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageTitle.js +53 -0
  59. data/webpack/ForemanInventoryUpload/Components/PageHeader/{components/DocsButton/__tests__/DocsButton.test.js → __tests__/PageTitle.test.js} +3 -3
  60. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +12 -38
  61. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap +43 -0
  62. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorActions.js +27 -0
  63. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js +51 -0
  64. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorConstants.js +6 -0
  65. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorSelectors.js +14 -0
  66. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorActions.test.js +9 -0
  67. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorButton.test.js +22 -0
  68. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorActions.test.js.snap +11 -0
  69. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorButton.test.js.snap +48 -0
  70. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/index.js +27 -0
  71. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js +7 -9
  72. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +1 -1
  73. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js +2 -2
  74. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButton.test.js.snap +7 -9
  75. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js +2 -4
  76. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/__snapshots__/ToolbarButtons.test.js.snap +1 -2
  77. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/toolbarButtons.scss +1 -2
  78. data/webpack/ForemanInventoryUpload/Components/Terminal/terminal.scss +1 -0
  79. data/webpack/ForemanInventoryUpload/ForemanInventoryConstants.js +2 -2
  80. data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +8 -14
  81. data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryUpload.test.js.snap +7 -10
  82. data/webpack/ForemanRhCloudPages.js +19 -0
  83. data/webpack/InsightsCloudSync/Components/InsightsHeader/InsightsHeader.scss +4 -0
  84. data/webpack/InsightsCloudSync/Components/InsightsHeader/index.js +16 -0
  85. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js +1 -1
  86. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsActions.test.js +2 -2
  87. data/webpack/InsightsCloudSync/Components/InsightsSettings/insightsSettings.scss +1 -0
  88. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTable.js +121 -0
  89. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableActions.js +129 -0
  90. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableConstants.js +55 -0
  91. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js +31 -0
  92. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableReducer.js +28 -0
  93. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableSelectors.js +74 -0
  94. data/webpack/InsightsCloudSync/Components/InsightsTable/SelectAllAlert.js +65 -0
  95. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTable.test.js +13 -0
  96. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableSelectors.test.js +58 -0
  97. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTable.test.js.snap +168 -0
  98. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableSelectors.test.js.snap +88 -0
  99. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/fixtures.js +104 -0
  100. data/webpack/InsightsCloudSync/Components/InsightsTable/components/EmptyState.js +53 -0
  101. data/webpack/InsightsCloudSync/Components/InsightsTable/index.js +45 -0
  102. data/webpack/InsightsCloudSync/Components/InsightsTable/table.scss +1 -0
  103. data/webpack/InsightsCloudSync/Components/NoTokenEmptyState.js +79 -0
  104. data/webpack/InsightsCloudSync/Components/__tests__/InsightsHeader.test.js +10 -0
  105. data/webpack/InsightsCloudSync/Components/__tests__/NoTokenEmptyState.test.js +19 -0
  106. data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/InsightsHeader.test.js.snap +13 -0
  107. data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/NoTokenEmptyState.test.js.snap +214 -0
  108. data/webpack/InsightsCloudSync/InsightsCloudSync.js +45 -44
  109. data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +10 -2
  110. data/webpack/InsightsCloudSync/InsightsCloudSyncActions.js +1 -1
  111. data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +15 -1
  112. data/webpack/InsightsCloudSync/InsightsCloudSyncHelpers.js +7 -0
  113. data/webpack/InsightsCloudSync/InsightsCloudSyncReducers.js +2 -0
  114. data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +45 -62
  115. data/webpack/InsightsCloudSync/index.js +11 -3
  116. data/webpack/InsightsHostDetailsTab/InsightsTabActions.js +1 -1
  117. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabActions.test.js +2 -2
  118. data/webpack/__mocks__/foremanReact/Root/Context/ForemanContext.js +1 -0
  119. data/webpack/__mocks__/foremanReact/constants.js +19 -0
  120. data/webpack/__mocks__/foremanReact/redux/API/APISelectors.js +24 -0
  121. data/webpack/__mocks__/foremanReact/redux/API/index.js +11 -0
  122. data/webpack/__mocks__/foremanReact/routes/RouterSelector.js +2 -0
  123. data/webpack/__mocks__/foremanReact/routes/common/PageLayout/PageLayout.js +10 -0
  124. data/webpack/common/Switcher/HelpLabel.js +30 -0
  125. data/webpack/common/Switcher/SwitcherPF4.js +36 -0
  126. data/webpack/common/Switcher/SwitcherPF4.scss +10 -0
  127. data/webpack/common/Switcher/__tests__/HelpLabel.test.js +13 -0
  128. data/webpack/common/Switcher/__tests__/SwitcherPF4.test.js +14 -0
  129. data/webpack/common/Switcher/__tests__/__snapshots__/HelpLabel.test.js.snap +20 -0
  130. data/webpack/common/Switcher/__tests__/__snapshots__/SwitcherPF4.test.js.snap +22 -0
  131. data/webpack/global_index.js +2 -0
  132. metadata +96 -34
  133. data/app/controllers/foreman_rh_cloud/react_controller.rb +0 -11
  134. data/app/views/foreman_rh_cloud/react/insights_cloud.html.erb +0 -1
  135. data/app/views/foreman_rh_cloud/react/inventory_upload.html.erb +0 -1
  136. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/listItem.scss +0 -0
  137. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/listItemStatus.scss +0 -16
  138. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/autoUploadSwitcher.scss +0 -3
  139. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/excludePackagesSwitcher.scss +0 -3
  140. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.scss +0 -3
  141. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/DocsButton.js +0 -18
  142. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/__tests__/__snapshots__/DocsButton.test.js.snap +0 -21
  143. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/index.js +0 -1
  144. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/HistoryButton.js +0 -19
  145. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/__tests__/HistoryButton.test.js +0 -12
  146. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/__tests__/__snapshots__/HistoryButton.test.js.snap +0 -22
  147. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/index.js +0 -1
  148. data/webpack/ForemanInventoryUpload/Components/PageHeader/pageHeader.scss +0 -3
  149. data/webpack/__mocks__/foremanReact/API.js +0 -7
@@ -0,0 +1,6 @@
1
+ export const CONFIGURE_CLOUD_CONNECTOR = 'CONFIGURE_CLOUD_CONNECTOR';
2
+ export const CONNECTOR_STATUS = {
3
+ PENDING: 'PENDING',
4
+ RESOLVED: 'RESOLVED',
5
+ NOT_RESOLVED: 'NOT_RESOLVED',
6
+ };
@@ -0,0 +1,14 @@
1
+ import { selectAPIResponse } from 'foremanReact/redux/API/APISelectors';
2
+
3
+ import {
4
+ CONFIGURE_CLOUD_CONNECTOR,
5
+ CONNECTOR_STATUS,
6
+ } from './CloudConnectorConstants';
7
+
8
+ export const selectStatus = state =>
9
+ selectAPIResponse(state, CONFIGURE_CLOUD_CONNECTOR)?.result === 'success'
10
+ ? CONNECTOR_STATUS.RESOLVED
11
+ : CONNECTOR_STATUS.NOT_RESOLVED;
12
+
13
+ export const selectJobLink = state =>
14
+ selectAPIResponse(state, CONFIGURE_CLOUD_CONNECTOR).job_link || '';
@@ -0,0 +1,9 @@
1
+ import { testActionSnapshotWithFixtures } from '@theforeman/test';
2
+ import { configureCloudConnector } from '../CloudConnectorActions';
3
+
4
+ const fixtures = {
5
+ 'should configureCloudConnector': () => configureCloudConnector(),
6
+ };
7
+
8
+ describe('CloudConnector button actions', () =>
9
+ testActionSnapshotWithFixtures(fixtures));
@@ -0,0 +1,22 @@
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
+ import { CloudConnectorButton } from '../CloudConnectorButton';
3
+ import { CONNECTOR_STATUS } from '../CloudConnectorConstants';
4
+
5
+ const fixtures = {
6
+ 'render no cloud connector': {
7
+ status: CONNECTOR_STATUS.NOT_RESOLVED,
8
+ onClick: jest.fn(),
9
+ },
10
+ 'render resolved cloud connector': {
11
+ status: CONNECTOR_STATUS.RESOLVED,
12
+ onClick: jest.fn(),
13
+ },
14
+ 'render pending connector': {
15
+ jobLink: '/job-link',
16
+ status: CONNECTOR_STATUS.PENDING,
17
+ onClick: jest.fn(),
18
+ },
19
+ };
20
+
21
+ describe('CloudConnectorButton', () =>
22
+ testComponentSnapshotsWithFixtures(CloudConnectorButton, fixtures));
@@ -0,0 +1,11 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`CloudConnector button actions should configureCloudConnector 1`] = `
4
+ Object {
5
+ "errorToast": [Function],
6
+ "key": "CONFIGURE_CLOUD_CONNECTOR",
7
+ "successToast": [Function],
8
+ "type": "post-some-type",
9
+ "url": "/foreman_inventory_upload/cloud_connector",
10
+ }
11
+ `;
@@ -0,0 +1,48 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`CloudConnectorButton render no cloud connector 1`] = `
4
+ <Button
5
+ onClick={[MockFunction]}
6
+ variant="secondary"
7
+ >
8
+ Configure Cloud Connector
9
+ </Button>
10
+ `;
11
+
12
+ exports[`CloudConnectorButton render pending connector 1`] = `
13
+ <Popover
14
+ aria-label="Popover with Link to cloud connector job"
15
+ bodyContent={
16
+ <div>
17
+ Cloud connector job is still running, you can view it here:
18
+ <a
19
+ href="/job-link"
20
+ rel="noopener noreferrer"
21
+ target="_blank"
22
+ >
23
+ Open job
24
+ </a>
25
+ </div>
26
+ }
27
+ closeBtnAriaLabel="Close cloud connector Popover"
28
+ >
29
+ <Button
30
+ variant="secondary"
31
+ >
32
+ <Spinner
33
+ size="sm"
34
+ />
35
+
36
+ Cloud Connector in progress
37
+ </Button>
38
+ </Popover>
39
+ `;
40
+
41
+ exports[`CloudConnectorButton render resolved cloud connector 1`] = `
42
+ <Button
43
+ isDisabled={true}
44
+ variant="secondary"
45
+ >
46
+ Cloud Connector is configured
47
+ </Button>
48
+ `;
@@ -0,0 +1,27 @@
1
+ import React, { useEffect } from 'react';
2
+ import { useSelector, useDispatch } from 'react-redux';
3
+ import { CloudConnectorButton } from './CloudConnectorButton';
4
+ import {
5
+ configureCloudConnector,
6
+ getCloudConnector,
7
+ } from './CloudConnectorActions';
8
+ import { selectStatus, selectJobLink } from './CloudConnectorSelectors';
9
+
10
+ const ConnectedCloudConnectorButton = () => {
11
+ const status = useSelector(selectStatus);
12
+ const jobLink = useSelector(selectJobLink);
13
+ const dispatch = useDispatch();
14
+
15
+ useEffect(() => {
16
+ dispatch(getCloudConnector());
17
+ }, [dispatch]);
18
+ return (
19
+ <CloudConnectorButton
20
+ status={status}
21
+ onClick={() => dispatch(configureCloudConnector())}
22
+ jobLink={jobLink}
23
+ />
24
+ );
25
+ };
26
+
27
+ export default ConnectedCloudConnectorButton;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { Button, Icon, Spinner } from 'patternfly-react';
3
+ import { Spinner, Button } from '@patternfly/react-core';
4
+ import { ExclamationTriangleIcon, RedoIcon } from '@patternfly/react-icons';
4
5
  import { STATUS } from 'foremanReact/constants';
5
6
  import SyncModal from './components/Modal';
6
7
  import { SYNC_BUTTON_TEXT } from '../../../../ForemanInventoryConstants';
@@ -24,19 +25,16 @@ class SyncButton extends React.Component {
24
25
  <Button
25
26
  className="sync_button"
26
27
  onClick={handleClick}
27
- bsSize="lg"
28
- disabled={status === STATUS.PENDING}
28
+ size="lg"
29
+ isDisabled={status === STATUS.PENDING}
30
+ variant="secondary"
29
31
  >
30
32
  {!cloudToken && (
31
33
  <span>
32
- <Icon name="warning" />{' '}
34
+ <ExclamationTriangleIcon />{' '}
33
35
  </span>
34
36
  )}
35
- {status === STATUS.PENDING ? (
36
- <Spinner loading size="xs" />
37
- ) : (
38
- <Icon name="refresh" />
39
- )}
37
+ {status === STATUS.PENDING ? <Spinner size="sm" /> : <RedoIcon />}
40
38
  {SYNC_BUTTON_TEXT}
41
39
  </Button>
42
40
  </React.Fragment>
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import API from 'foremanReact/API';
2
+ import { API } from 'foremanReact/redux/API';
3
3
  import { addToast } from 'foremanReact/redux/actions/toasts';
4
4
  import { inventoryUrl } from '../../../../ForemanInventoryHelpers';
5
5
  import Toast from './components/Toast';
@@ -1,9 +1,9 @@
1
1
  import { testActionSnapshotWithFixtures } from '@theforeman/test';
2
- import API from 'foremanReact/API';
2
+ import { API } from 'foremanReact/redux/API';
3
3
  import { handleSync } from '../SyncButtonActions';
4
4
  import { successResponse } from './SyncButtonFixtures';
5
5
 
6
- jest.mock('foremanReact/API');
6
+ jest.mock('foremanReact/redux/API');
7
7
  API.post.mockImplementation(async () => successResponse);
8
8
 
9
9
  const fixtures = {
@@ -7,18 +7,16 @@ exports[`SyncButton rendering render with Props 1`] = `
7
7
  toggleModal={[Function]}
8
8
  />
9
9
  <Button
10
- active={false}
11
- block={false}
12
- bsClass="btn"
13
- bsSize="lg"
14
- bsStyle="default"
15
10
  className="sync_button"
16
- disabled={false}
11
+ isDisabled={false}
17
12
  onClick={[Function]}
13
+ size="lg"
14
+ variant="secondary"
18
15
  >
19
- <Icon
20
- name="refresh"
21
- type="fa"
16
+ <RedoIcon
17
+ color="currentColor"
18
+ noVerticalAlign={false}
19
+ size="sm"
22
20
  />
23
21
  Sync inventory status
24
22
  </Button>
@@ -1,14 +1,12 @@
1
1
  import React from 'react';
2
- import DocsButton from '../DocsButton';
3
- import HistoryButton from '../HistoryButton';
4
2
  import SyncButton from '../SyncButton';
3
+ import CloudConnectorButton from '../CloudConnectorButton';
5
4
  import './toolbarButtons.scss';
6
5
 
7
6
  const ToolbarButtons = () => (
8
7
  <div className="inventory_toolbar_buttons">
8
+ <CloudConnectorButton />
9
9
  <SyncButton />
10
- <HistoryButton />
11
- <DocsButton />
12
10
  </div>
13
11
  );
14
12
 
@@ -4,8 +4,7 @@ exports[`ToolbarButtons rendering render without Props 1`] = `
4
4
  <div
5
5
  className="inventory_toolbar_buttons"
6
6
  >
7
+ <ConnectedCloudConnectorButton />
7
8
  <Connect(SyncButton) />
8
- <HistoryButton />
9
- <DocsButton />
10
9
  </div>
11
10
  `;
@@ -1,9 +1,8 @@
1
1
  .inventory_toolbar_buttons {
2
2
  float: right;
3
3
 
4
- .tasks_history_button,
5
4
  .sync_button {
6
- margin-right: 5px;
5
+ margin-left: 5px;
7
6
  }
8
7
 
9
8
  .sync_button .spinner {
@@ -10,6 +10,7 @@
10
10
  font-family: monospace;
11
11
  font-size: 16px;
12
12
  color: #22da26;
13
+ overflow-wrap: anywhere;
13
14
 
14
15
  &.terminal_error {
15
16
  color: #f00;
@@ -2,8 +2,8 @@ import { translate as __ } from 'foremanReact/common/I18n';
2
2
 
3
3
  export const INVENTORY_PAGE_TITLE = __('Red Hat Inventory');
4
4
 
5
- export const DOCS_BUTTON_TEXT = __(' Documentation');
5
+ export const DOCS_BUTTON_TEXT = __('Documentation');
6
6
 
7
- export const ACTIONS_HISTORY_BUTTON_TEXT = __(' Actions history');
7
+ export const ACTIONS_HISTORY_BUTTON_TEXT = __('Actions history');
8
8
 
9
9
  export const SYNC_BUTTON_TEXT = __(' Sync inventory status');
@@ -1,21 +1,15 @@
1
1
  import React from 'react';
2
- import { IntlProvider } from 'react-intl';
3
- import { Grid } from 'patternfly-react';
2
+ import PageLayout from 'foremanReact/routes/common/PageLayout/PageLayout';
4
3
  import AccountList from './Components/AccountList';
5
4
  import PageHeader from './Components/PageHeader';
6
- import { INVENTORY_PAGE_TITLE } from './ForemanInventoryConstants';
7
5
 
8
- const ForemanInventoryUpload = () => {
9
- document.title = INVENTORY_PAGE_TITLE;
10
- return (
11
- <IntlProvider locale={navigator.language}>
12
- <Grid fluid className="inventory-upload">
13
- <PageHeader />
14
- <AccountList />
15
- </Grid>
16
- </IntlProvider>
17
- );
18
- };
6
+ const ForemanInventoryUpload = () => (
7
+ <div className="rh-cloud-page">
8
+ <PageLayout searchable={false} beforeToolbarComponent={<PageHeader />}>
9
+ <AccountList />
10
+ </PageLayout>
11
+ </div>
12
+ );
19
13
 
20
14
  ForemanInventoryUpload.propTypes = {};
21
15
 
@@ -1,17 +1,14 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`ForemanInventoryUpload render without Props 1`] = `
4
- <IntlProvider
5
- locale="en-US"
4
+ <div
5
+ className="rh-cloud-page"
6
6
  >
7
- <Grid
8
- bsClass="container"
9
- className="inventory-upload"
10
- componentClass="div"
11
- fluid={true}
7
+ <PageLayout
8
+ beforeToolbarComponent={<PageHeader />}
9
+ searchable={false}
12
10
  >
13
- <PageHeader />
14
11
  <Connect(AccountList) />
15
- </Grid>
16
- </IntlProvider>
12
+ </PageLayout>
13
+ </div>
17
14
  `;
@@ -1,4 +1,6 @@
1
+ import React from 'react';
1
2
  import componentRegistry from 'foremanReact/components/componentRegistry';
3
+ import { registerRoutes as foremanRegisterRoutes } from 'foremanReact/routes/RoutingService';
2
4
  import ForemanInventoryUpload from './ForemanInventoryUpload';
3
5
  import InsightsCloudSync from './InsightsCloudSync';
4
6
  import InsightsHostDetailsTab from './InsightsHostDetailsTab';
@@ -12,3 +14,20 @@ const pages = [
12
14
  export const registerPages = () => {
13
15
  pages.forEach(page => componentRegistry.register(page));
14
16
  };
17
+
18
+ export const routes = [
19
+ {
20
+ path: '/foreman_rh_cloud/insights_cloud',
21
+ exact: true,
22
+ render: props => <InsightsCloudSync {...props} />,
23
+ },
24
+ {
25
+ path: '/foreman_rh_cloud/inventory_upload',
26
+ exact: true,
27
+ render: props => <ForemanInventoryUpload {...props} />,
28
+ },
29
+ ];
30
+
31
+ export const registerRoutes = () => {
32
+ foremanRegisterRoutes('foreman_rh_cloud', routes);
33
+ };
@@ -0,0 +1,4 @@
1
+ .insights-header {
2
+ margin-bottom: '15px';
3
+ overflow: auto;
4
+ }
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { translate as __ } from 'foremanReact/common/I18n';
3
+ import InsightsSettings from '../InsightsSettings';
4
+ import './InsightsHeader.scss';
5
+
6
+ const InsightsHeader = () => (
7
+ <div className="insights-header">
8
+ <InsightsSettings />
9
+ <p>
10
+ {__(`Insights synchronization process is used to provide Insights
11
+ recommendations output for hosts managed here`)}
12
+ </p>
13
+ </div>
14
+ );
15
+
16
+ export default InsightsHeader;
@@ -1,4 +1,4 @@
1
- import API from 'foremanReact/API';
1
+ import { API } from 'foremanReact/redux/API';
2
2
  import { addToast } from 'foremanReact/redux/actions/toasts';
3
3
  import { insightsCloudUrl } from '../../InsightsCloudSyncHelpers';
4
4
  import {
@@ -1,5 +1,5 @@
1
1
  import { testActionSnapshotWithFixtures } from '@theforeman/test';
2
- import API from 'foremanReact/API';
2
+ import { API } from 'foremanReact/redux/API';
3
3
  import {
4
4
  getInsightsSyncSettings,
5
5
  setInsightsSyncEnabled,
@@ -10,7 +10,7 @@ const serverMock = {
10
10
  data: { insightsSyncEnabled: true },
11
11
  };
12
12
 
13
- jest.mock('foremanReact/API');
13
+ jest.mock('foremanReact/redux/API');
14
14
  API.get.mockImplementation(() => serverMock);
15
15
  API.patch.mockImplementation(() => serverMock);
16
16
 
@@ -1,4 +1,5 @@
1
1
  .insights_settings {
2
+ margin-left: 10px;
2
3
  border: 1px solid #ededed;
3
4
  border-radius: 4px;
4
5
  padding: 10px;
@@ -0,0 +1,121 @@
1
+ /* eslint-disable react-hooks/exhaustive-deps */
2
+ import React, { useEffect } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { Pagination, PaginationVariant } from '@patternfly/react-core';
5
+ import { Table, TableHeader, TableBody } from '@patternfly/react-table';
6
+ import { useForemanSettings } from 'foremanReact/Root/Context/ForemanContext';
7
+ import SelectAllAlert from './SelectAllAlert';
8
+ import { columns, actions } from './InsightsTableConstants';
9
+ import TableEmptyState from './components/EmptyState';
10
+ import {
11
+ modifySelectedRows,
12
+ getSortColumnIndex,
13
+ getPerPageOptions,
14
+ } from './InsightsTableHelpers';
15
+ import './table.scss';
16
+
17
+ const InsightsTable = ({
18
+ page,
19
+ perPage: urlPerPage,
20
+ status,
21
+ sortBy,
22
+ sortOrder,
23
+ hits,
24
+ query,
25
+ itemCount,
26
+ fetchInsights,
27
+ onTableSetPage,
28
+ onTablePerPageSelect,
29
+ onTableSort,
30
+ onTableSelect,
31
+ selectedIds,
32
+ showSelectAllAlert,
33
+ selectAll,
34
+ clearAllSelection,
35
+ error,
36
+ isAllSelected,
37
+ }) => {
38
+ const { perPage: appPerPage } = useForemanSettings();
39
+ const perPage = urlPerPage || appPerPage;
40
+
41
+ // acts as componentDidMount
42
+ useEffect(() => {
43
+ fetchInsights({ page, perPage, query, sortBy, sortOrder });
44
+ }, []);
45
+
46
+ return (
47
+ <React.Fragment>
48
+ <SelectAllAlert
49
+ itemCount={itemCount}
50
+ selectedIds={selectedIds}
51
+ showSelectAllAlert={showSelectAllAlert}
52
+ selectAll={selectAll}
53
+ clearAllSelection={clearAllSelection}
54
+ isAllSelected={isAllSelected}
55
+ />
56
+ <Table
57
+ aria-label="Recommendations Table"
58
+ onSelect={(_event, isSelected, rowId) =>
59
+ onTableSelect(_event, isSelected, rowId, hits, selectedIds)
60
+ }
61
+ canSelectAll
62
+ sortBy={{ index: getSortColumnIndex(sortBy), direction: sortOrder }}
63
+ onSort={onTableSort}
64
+ cells={columns}
65
+ rows={modifySelectedRows(hits, selectedIds)}
66
+ actions={actions}
67
+ >
68
+ <TableHeader />
69
+ <TableBody />
70
+ </Table>
71
+ <TableEmptyState status={status} error={error} />
72
+ <Pagination
73
+ itemCount={itemCount}
74
+ widgetId="recommendation-pagination"
75
+ perPage={perPage}
76
+ page={page}
77
+ variant={PaginationVariant.bottom}
78
+ onSetPage={onTableSetPage}
79
+ onPerPageSelect={onTablePerPageSelect}
80
+ perPageOptions={getPerPageOptions(urlPerPage, appPerPage)}
81
+ />
82
+ </React.Fragment>
83
+ );
84
+ };
85
+
86
+ InsightsTable.propTypes = {
87
+ page: PropTypes.number,
88
+ perPage: PropTypes.number,
89
+ status: PropTypes.string,
90
+ sortBy: PropTypes.string,
91
+ sortOrder: PropTypes.string,
92
+ hits: PropTypes.array.isRequired,
93
+ itemCount: PropTypes.number.isRequired,
94
+ onTableSetPage: PropTypes.func.isRequired,
95
+ onTablePerPageSelect: PropTypes.func.isRequired,
96
+ onTableSort: PropTypes.func.isRequired,
97
+ onTableSelect: PropTypes.func.isRequired,
98
+ selectedIds: PropTypes.object,
99
+ showSelectAllAlert: PropTypes.bool,
100
+ selectAll: PropTypes.func.isRequired,
101
+ clearAllSelection: PropTypes.func.isRequired,
102
+ fetchInsights: PropTypes.func.isRequired,
103
+ query: PropTypes.string,
104
+ error: PropTypes.string,
105
+ isAllSelected: PropTypes.bool,
106
+ };
107
+
108
+ InsightsTable.defaultProps = {
109
+ page: 1,
110
+ perPage: null,
111
+ status: null,
112
+ sortBy: '',
113
+ sortOrder: '',
114
+ selectedIds: {},
115
+ showSelectAllAlert: false,
116
+ query: '',
117
+ error: '',
118
+ isAllSelected: false,
119
+ };
120
+
121
+ export default InsightsTable;