foreman_rh_cloud 3.0.14 → 3.0.15

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 (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
@@ -1,12 +1,20 @@
1
1
  import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
2
  import { noop } from 'patternfly-react';
3
-
4
3
  import InsightsCloudSync from './InsightsCloudSync';
5
4
 
6
5
  const fixtures = {
7
6
  render: {
7
+ status: 'RESOLVED',
8
+ syncInsights: noop,
9
+ fetchInsights: noop,
10
+ query: '',
11
+ hasToken: true,
12
+ },
13
+ 'render no token': {
14
+ status: 'RESOLVED',
8
15
  syncInsights: noop,
9
- settingsUrl: 'www.example.com/settings',
16
+ fetchInsights: noop,
17
+ hasToken: false,
10
18
  },
11
19
  };
12
20
 
@@ -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 { INSIGHTS_CLOUD_SYNC_SUCCESS } from './InsightsCloudSyncConstants';
@@ -1,4 +1,18 @@
1
1
  import { translate as __ } from 'foremanReact/common/I18n';
2
+ import { getControllerSearchProps } from 'foremanReact/constants';
3
+ import { foremanUrl } from '../ForemanRhCloudHelpers';
2
4
 
3
5
  export const INSIGHTS_CLOUD_SYNC_SUCCESS = 'INSIGHTS_CLOUD_SYNC_SUCCESS';
4
- export const INSIGHTS_SYNC_PAGE_TITLE = __('Red Hat Insights cloud sync');
6
+
7
+ export const INSIGHTS_SYNC_PAGE_TITLE = __('Red Hat Insights');
8
+
9
+ export const INSIGHTS_PATH = foremanUrl('/foreman_rh_cloud/insights_cloud');
10
+
11
+ export const INSIGHTS_SAVE_AND_SYNC_PATH = foremanUrl(
12
+ '/insights_cloud/save_token_and_sync'
13
+ );
14
+
15
+ export const INSIGHTS_SEARCH_PROPS = {
16
+ ...getControllerSearchProps('/insights_cloud/hits'),
17
+ controller: 'insights_hits',
18
+ };
@@ -1,3 +1,10 @@
1
+ import URI from 'urijs';
1
2
  import { foremanUrl } from '../ForemanRhCloudHelpers';
2
3
 
3
4
  export const insightsCloudUrl = path => foremanUrl(`/insights_cloud/${path}`);
5
+
6
+ export const cloudTokenSettingUrl = () => {
7
+ const settingsUrl = new URI(foremanUrl('/settings'));
8
+ settingsUrl.setSearch({ search: 'name = rh_cloud_token' });
9
+ return settingsUrl.toString();
10
+ };
@@ -1,8 +1,10 @@
1
1
  import { combineReducers } from 'redux';
2
2
  import { reducers as settingsReducers } from './Components/InsightsSettings';
3
+ import { reducers as tableReducers } from './Components/InsightsTable';
3
4
 
4
5
  export default {
5
6
  InsightsCloudSync: combineReducers({
6
7
  ...settingsReducers,
8
+ ...tableReducers,
7
9
  }),
8
10
  };
@@ -1,67 +1,50 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`InsightsCloudSync render 1`] = `
4
- <IntlProvider
5
- locale="en-US"
6
- >
7
- <div
8
- className="insights-cloud-sync"
9
- >
10
- <h1>
11
- Red Hat Insights Sync
12
- </h1>
13
- <div
14
- className="insights-cloud-sync-body"
4
+ <PageLayout
5
+ beforeToolbarComponent={<InsightsHeader />}
6
+ header="Red Hat Insights"
7
+ onSearch={[Function]}
8
+ searchProps={
9
+ Object {
10
+ "autocomplete": Object {
11
+ "id": "searchBar",
12
+ "searchQuery": "",
13
+ "url": "/insights_cloud/hits/auto_complete_search",
14
+ "useKeyShortcuts": true,
15
+ },
16
+ "bookmarks": Object {
17
+ "canCreateBookmarks": true,
18
+ "documentationUrl": "4.1.5Searching",
19
+ "url": "/api/bookmarks",
20
+ },
21
+ "controller": "insights_hits",
22
+ }
23
+ }
24
+ searchQuery=""
25
+ searchable={true}
26
+ toolbarButtons={
27
+ <Button
28
+ active={false}
29
+ block={false}
30
+ bsClass="btn"
31
+ bsStyle="primary"
32
+ disabled={false}
33
+ onClick={[Function]}
15
34
  >
16
- <Connect(InsightsSettings) />
17
- <p>
18
- Insights synchronization process is used to provide Insights
19
- recommendations output for hosts managed here
20
- </p>
21
- <p>
22
- 1. Obtain an Red Hat API token:
23
- <a
24
- href="https://access.redhat.com/management/api"
25
- rel="noopener noreferrer"
26
- target="_blank"
27
- >
28
- access.redhat.com
29
- <Icon
30
- name="external-link"
31
- size="xs"
32
- type="fa"
33
- />
34
- </a>
35
- <br />
36
- 2. Copy the token to 'Red Hat Cloud token' setting:
37
- <a
38
- href="www.example.com/settings"
39
- rel="noopener noreferrer"
40
- target="_blank"
41
- >
42
- Red Hat Cloud token
43
- <Icon
44
- name="external-link"
45
- size="xs"
46
- type="fa"
47
- />
48
- </a>
49
- <br />
50
- 3. Now you can synchronize recommendations manually using the "Sync now" button.
51
- </p>
52
- <div>
53
- <Button
54
- active={false}
55
- block={false}
56
- bsClass="btn"
57
- bsStyle="primary"
58
- disabled={false}
59
- onClick={[Function]}
60
- >
61
- Sync now
62
- </Button>
63
- </div>
64
- </div>
65
- </div>
66
- </IntlProvider>
35
+ Sync now
36
+ </Button>
37
+ }
38
+ >
39
+ <Connect(InsightsTable) />
40
+ </PageLayout>
41
+ `;
42
+
43
+ exports[`InsightsCloudSync render no token 1`] = `
44
+ <PageLayout
45
+ header="Red Hat Insights"
46
+ searchable={false}
47
+ >
48
+ <NoTokenEmptyState />
49
+ </PageLayout>
67
50
  `;
@@ -2,14 +2,22 @@ import { bindActionCreators } from 'redux';
2
2
  import { connect } from 'react-redux';
3
3
 
4
4
  import * as actions from './InsightsCloudSyncActions';
5
+ import { fetchInsights } from './Components/InsightsTable/InsightsTableActions';
5
6
  import InsightsCloudSync from './InsightsCloudSync';
6
7
  import insightsCloudSyncReducers from './InsightsCloudSyncReducers';
7
-
8
+ import {
9
+ selectSearch,
10
+ selectHasToken,
11
+ } from './Components/InsightsTable/InsightsTableSelectors';
8
12
  // map state to props
9
- const mapStateToProps = state => ({});
13
+ const mapStateToProps = state => ({
14
+ query: selectSearch(state),
15
+ hasToken: selectHasToken(state),
16
+ });
10
17
 
11
18
  // map action dispatchers to props
12
- const mapDispatchToProps = dispatch => bindActionCreators(actions, dispatch);
19
+ const mapDispatchToProps = dispatch =>
20
+ bindActionCreators({ ...actions, fetchInsights }, dispatch);
13
21
 
14
22
  // export reducers
15
23
  export const reducers = insightsCloudSyncReducers;
@@ -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 '../InsightsCloudSync/InsightsCloudSyncHelpers';
4
4
  import {
@@ -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 { fetchHits } from '../InsightsTabActions';
4
4
  import { hostID, hits } from './InsightsTab.fixtures';
5
5
 
6
- jest.mock('foremanReact/API');
6
+ jest.mock('foremanReact/redux/API');
7
7
  API.get.mockImplementation(async () => ({ data: { hits } }));
8
8
 
9
9
  const fixtures = {
@@ -0,0 +1 @@
1
+ export const useForemanSettings = () => ({ perPage: 20 });
@@ -3,3 +3,22 @@ export const STATUS = {
3
3
  RESOLVED: 'RESOLVED',
4
4
  ERROR: 'ERROR',
5
5
  };
6
+
7
+ export const getControllerSearchProps = (
8
+ controller,
9
+ id = 'searchBar',
10
+ canCreateBookmarks = true
11
+ ) => ({
12
+ controller,
13
+ autocomplete: {
14
+ id,
15
+ searchQuery: '',
16
+ url: `${controller}/auto_complete_search`,
17
+ useKeyShortcuts: true,
18
+ },
19
+ bookmarks: {
20
+ url: '/api/bookmarks',
21
+ canCreateBookmarks,
22
+ documentationUrl: `4.1.5Searching`,
23
+ },
24
+ });
@@ -0,0 +1,24 @@
1
+ import { STATUS } from '../../constants';
2
+
3
+ export const selectAPI = state => state.API;
4
+
5
+ export const selectAPIByKey = (state, key) => selectAPI(state)[key] || {};
6
+
7
+ export const selectAPIStatus = (state, key) =>
8
+ selectAPIByKey(state, key).status;
9
+
10
+ export const selectAPIPayload = (state, key) =>
11
+ selectAPIByKey(state, key).payload || {};
12
+
13
+ export const selectAPIResponse = (state, key) =>
14
+ selectAPIByKey(state, key).response || {};
15
+
16
+ export const selectAPIError = (state, key) =>
17
+ selectAPIStatus(state, key) === STATUS.ERROR
18
+ ? selectAPIResponse(state, key)
19
+ : null;
20
+
21
+ export const selectAPIErrorMessage = (state, key) => {
22
+ const error = selectAPIError(state, key);
23
+ return error && error.message;
24
+ };
@@ -0,0 +1,11 @@
1
+ export const get = data => ({ type: 'get-some-type', ...data });
2
+ export const put = data => ({ type: 'put-some-type', ...data });
3
+ export const post = data => ({ type: 'post-some-type', ...data });
4
+ export const patch = data => ({ type: 'patch-some-type', ...data });
5
+ export const API = {
6
+ get: jest.fn(),
7
+ put: jest.fn(),
8
+ post: jest.fn(),
9
+ delete: jest.fn(),
10
+ patch: jest.fn(),
11
+ };
@@ -0,0 +1,2 @@
1
+ export const selectRouter = state => state.router;
2
+ export const selectRouterLocation = state => selectRouter(state).location;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ const PageLayout = ({ children }) => <div>{children}</div>;
5
+
6
+ PageLayout.propTypes = {
7
+ children: PropTypes.node.isRequired,
8
+ };
9
+
10
+ export default PageLayout;
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Popover } from '@patternfly/react-core';
4
+ import { HelpIcon } from '@patternfly/react-icons';
5
+
6
+ export const HelpLabel = ({ text, id, className }) => {
7
+ if (!text) return null;
8
+ return (
9
+ <Popover id={`${id}-help`} bodyContent={text} aria-label="help-text">
10
+ <button
11
+ onClick={e => e.preventDefault()}
12
+ className={`pf-c-form__group-label-help ${className}`}
13
+ >
14
+ <HelpIcon noVerticalAlign />
15
+ </button>
16
+ </Popover>
17
+ );
18
+ };
19
+
20
+ HelpLabel.propTypes = {
21
+ id: PropTypes.string.isRequired,
22
+ text: PropTypes.string,
23
+ className: PropTypes.string,
24
+ };
25
+ HelpLabel.defaultProps = {
26
+ text: '',
27
+ className: '',
28
+ };
29
+
30
+ export default HelpLabel;
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Switch } from '@patternfly/react-core';
4
+ import { HelpLabel } from './HelpLabel';
5
+ import './SwitcherPF4.scss';
6
+
7
+ const SwitcherPF4 = ({ id, label, tooltip, isChecked, onChange }) => (
8
+ <Switch
9
+ className="foreman-switcher"
10
+ id={`rh-cloud-switcher-${id}`}
11
+ isChecked={isChecked}
12
+ onChange={onChange}
13
+ label={
14
+ <div>
15
+ {label}
16
+ <HelpLabel text={tooltip} id={id} className="switcher-help-label" />
17
+ </div>
18
+ }
19
+ />
20
+ );
21
+
22
+ SwitcherPF4.propTypes = {
23
+ id: PropTypes.string.isRequired,
24
+ label: PropTypes.string,
25
+ tooltip: PropTypes.string,
26
+ isChecked: PropTypes.bool,
27
+ onChange: PropTypes.func.isRequired,
28
+ };
29
+
30
+ SwitcherPF4.defaultProps = {
31
+ label: null,
32
+ tooltip: null,
33
+ isChecked: true,
34
+ };
35
+
36
+ export default SwitcherPF4;
@@ -0,0 +1,10 @@
1
+ .rh-cloud-page {
2
+ label.foreman-switcher {
3
+ font-weight: 400;
4
+ margin-bottom: 5px;
5
+
6
+ .switcher-help-label {
7
+ padding-left: 5px;
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,13 @@
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
+ import { HelpLabel } from '../HelpLabel';
3
+
4
+ const fixtures = {
5
+ 'should return insights cloud Url': {
6
+ id: 'some-id',
7
+ text: 'some-text',
8
+ className: 'some-class',
9
+ },
10
+ };
11
+
12
+ describe('InsightsCloudSync helpers', () =>
13
+ testComponentSnapshotsWithFixtures(HelpLabel, fixtures));
@@ -0,0 +1,14 @@
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
+ import SwitcherPF4 from '../SwitcherPF4';
3
+
4
+ const fixtures = {
5
+ 'should return insights cloud Url': {
6
+ id: 'some-id',
7
+ tooltip: 'some-text',
8
+ label: 'some-label',
9
+ onChange: jest.fn(),
10
+ },
11
+ };
12
+
13
+ describe('InsightsCloudSync helpers', () =>
14
+ testComponentSnapshotsWithFixtures(SwitcherPF4, fixtures));
@@ -0,0 +1,20 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`InsightsCloudSync helpers should return insights cloud Url 1`] = `
4
+ <Popover
5
+ aria-label="help-text"
6
+ bodyContent="some-text"
7
+ id="some-id-help"
8
+ >
9
+ <button
10
+ className="pf-c-form__group-label-help some-class"
11
+ onClick={[Function]}
12
+ >
13
+ <HelpIcon
14
+ color="currentColor"
15
+ noVerticalAlign={true}
16
+ size="sm"
17
+ />
18
+ </button>
19
+ </Popover>
20
+ `;