foreman_rh_cloud 2.0.11 → 3.0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_inventory_upload/accounts_controller.rb +2 -0
  3. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +18 -0
  4. data/app/helpers/foreman_inventory_upload_host_helper.rb +2 -10
  5. data/app/models/concerns/rh_cloud_host.rb +4 -1
  6. data/app/models/insights_hit.rb +1 -1
  7. data/app/models/setting/rh_cloud.rb +2 -0
  8. data/app/overrides/hosts_list.rb +1 -1
  9. data/app/services/foreman_rh_cloud/cloud_auth.rb +28 -0
  10. data/app/views/foreman_rh_cloud/react/insights_cloud.html.erb +1 -6
  11. data/app/views/foreman_rh_cloud/react/inventory_upload.html.erb +1 -1
  12. data/app/views/hosts/_insights_tab.html.erb +1 -7
  13. data/app/views/layouts/foreman_rh_cloud/application.html.erb +0 -1
  14. data/config/routes.rb +2 -0
  15. data/db/migrate/20201007115752_add_hits_count_to_insights_facets_table.foreman_rh_cloud.rb +5 -0
  16. data/db/migrate/20201007121540_setup_hits_count_cache.foreman_rh_cloud.rb +10 -0
  17. data/lib/foreman_inventory_upload/async/upload_report_job.rb +2 -32
  18. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +35 -0
  19. data/lib/foreman_inventory_upload/generators/json_stream.rb +7 -2
  20. data/lib/foreman_inventory_upload/generators/queries.rb +2 -0
  21. data/lib/foreman_inventory_upload/generators/slice.rb +27 -25
  22. data/lib/foreman_rh_cloud.rb +55 -0
  23. data/lib/foreman_rh_cloud/engine.rb +6 -4
  24. data/lib/foreman_rh_cloud/version.rb +1 -1
  25. data/lib/insights_cloud/async/insights_full_sync.rb +5 -24
  26. data/lib/inventory_sync/async/inventory_full_sync.rb +3 -22
  27. data/lib/tasks/rh_cloud_inventory.rake +12 -10
  28. data/package.json +1 -1
  29. data/test/unit/fact_helpers_test.rb +22 -0
  30. data/test/unit/insights_facet_test.rb +7 -0
  31. data/test/unit/rh_cloud_http_proxy_test.rb +65 -0
  32. data/test/unit/slice_generator_test.rb +147 -2
  33. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +14 -1
  34. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +22 -18
  35. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +16 -0
  36. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +6 -0
  37. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +7 -0
  38. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +12 -8
  39. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +9 -0
  40. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +19 -0
  41. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +11 -0
  42. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +6 -0
  43. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.fixtures.js +2 -0
  44. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.js +1 -1
  45. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js +10 -11
  46. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherConstants.js +0 -1
  47. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcherActions.test.js +12 -2
  48. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcher.test.js.snap +1 -1
  49. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcherActions.test.js.snap +17 -0
  50. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.fixtures.js +1 -0
  51. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.js +30 -0
  52. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherActions.js +29 -0
  53. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherConstants.js +1 -0
  54. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcher.test.js +13 -0
  55. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcherActions.test.js +21 -0
  56. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcher.test.js.snap +38 -0
  57. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcherActions.test.js.snap +31 -0
  58. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/integration.test.js.snap +41 -0
  59. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/integration.test.js +36 -0
  60. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/excludePackagesSwitcher.scss +3 -0
  61. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/index.js +20 -0
  62. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.fixtures.js +2 -1
  63. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.js +1 -0
  64. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.scss +3 -0
  65. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherActions.js +10 -11
  66. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherConstants.js +0 -2
  67. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcherActions.test.js +12 -2
  68. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcherActions.test.js.snap +18 -1
  69. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.js +4 -0
  70. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettings.test.js.snap +2 -0
  71. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.fixtures.js +1 -0
  72. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.js +29 -0
  73. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherActions.js +29 -0
  74. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherConstants.js +1 -0
  75. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcher.test.js +13 -0
  76. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcherActions.test.js +21 -0
  77. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcher.test.js.snap +38 -0
  78. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcherActions.test.js.snap +31 -0
  79. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/index.js +20 -0
  80. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js +8 -2
  81. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +9 -11
  82. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonConstants.js +1 -1
  83. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonReducer.js +2 -2
  84. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js +18 -0
  85. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonReducer.test.js +1 -8
  86. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonActions.test.js.snap +62 -0
  87. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonReducer.test.js.snap +0 -7
  88. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js +2 -2
  89. data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.js +6 -1
  90. data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +2 -4
  91. data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +8 -0
  92. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/InventoryAutoUpload.js +92 -0
  93. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/InventoryAutoUpload.test.js +17 -0
  94. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/__snapshots__/InventoryAutoUpload.test.js.snap +106 -0
  95. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/AdvancedSettings.js +60 -0
  96. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/index.js +28 -0
  97. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/index.js +22 -0
  98. data/webpack/ForemanRhCloudFills.js +23 -0
  99. data/webpack/ForemanRhCloudPages.js +6 -1
  100. data/webpack/ForemanRhCloudReducers.js +10 -1
  101. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js +17 -20
  102. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsConstants.js +0 -6
  103. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsReducer.js +0 -4
  104. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsActions.test.js +16 -0
  105. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsReducer.test.js +1 -24
  106. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsActions.test.js.snap +38 -4
  107. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsReducer.test.js.snap +0 -14
  108. data/webpack/InsightsCloudSync/InsightsCloudSync.js +3 -5
  109. data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +1 -3
  110. data/webpack/InsightsCloudSync/InsightsCloudSyncActions.js +10 -11
  111. data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +0 -2
  112. data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +1 -1
  113. data/webpack/InsightsHostDetailsTab/InsightsTab.js +13 -13
  114. data/webpack/InsightsHostDetailsTab/InsightsTab.scss +2 -2
  115. data/webpack/InsightsHostDetailsTab/InsightsTabActions.js +9 -8
  116. data/webpack/InsightsHostDetailsTab/InsightsTabConstants.js +0 -1
  117. data/webpack/InsightsHostDetailsTab/InsightsTabReducer.js +2 -9
  118. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTab.fixtures.js +12 -14
  119. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabActions.test.js +7 -1
  120. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabReducer.test.js +0 -9
  121. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTab.test.js.snap +26 -22
  122. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabActions.test.js.snap +38 -2
  123. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabReducer.test.js.snap +10 -19
  124. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabSelectors.test.js.snap +10 -12
  125. data/webpack/__mocks__/foremanReact/common/MountingService.js +1 -0
  126. data/webpack/common/Switcher/index.js +79 -0
  127. data/webpack/global_index.js +5 -0
  128. data/webpack/index.js +4 -14
  129. metadata +54 -20
  130. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/hostObfuscationSwitcher.scss +0 -0
  131. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js +0 -34
  132. data/webpack/subscriptions_extension_index.js +0 -8
@@ -0,0 +1,17 @@
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
+ import { noop } from 'patternfly-react';
3
+
4
+ import InventoryAutoUpload from '../InventoryAutoUpload';
5
+
6
+ const fixtures = {
7
+ 'render with props': {
8
+ autoUploadEnabled: true,
9
+ handleToggle: noop,
10
+ fetchSettings: noop,
11
+ },
12
+ };
13
+
14
+ describe('InventoryAutoUpload', () => {
15
+ describe('rendering', () =>
16
+ testComponentSnapshotsWithFixtures(InventoryAutoUpload, fixtures));
17
+ });
@@ -0,0 +1,106 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`InventoryAutoUpload rendering render with props 1`] = `
4
+ <FormGroup
5
+ bsClass="form-group"
6
+ >
7
+ <Grid
8
+ bsClass="container"
9
+ componentClass="div"
10
+ fluid={false}
11
+ >
12
+ <h3>
13
+ Red Hat Cloud Inventory
14
+ </h3>
15
+ <hr />
16
+ <Row
17
+ bsClass="row"
18
+ componentClass="div"
19
+ >
20
+ <Switcher
21
+ SwitchCol={2}
22
+ id="auto-upload"
23
+ isChecked={true}
24
+ label="Inventory Auto Upload"
25
+ labelCol={5}
26
+ onChange={[Function]}
27
+ tooltip="Enable automatic upload of your hosts inventory to the Red Hat cloud"
28
+ />
29
+ <Col
30
+ bsClass="col"
31
+ componentClass="div"
32
+ sm={5}
33
+ >
34
+ <Popover
35
+ bodyContent={
36
+ <UNDEFINED
37
+ autoUploadEnabled={true}
38
+ handleToggle={[Function]}
39
+ />
40
+ }
41
+ headerContent={
42
+ <strong>
43
+ Advanced Inventory Settings
44
+ </strong>
45
+ }
46
+ position="right"
47
+ >
48
+ <Button
49
+ style={
50
+ Object {
51
+ "fontSize": "small",
52
+ "marginTop": "-4px",
53
+ }
54
+ }
55
+ variant="secondary"
56
+ >
57
+ Show Advanced Settings
58
+
59
+ <CaretRightIcon
60
+ color="currentColor"
61
+ noVerticalAlign={false}
62
+ size="sm"
63
+ />
64
+ </Button>
65
+ </Popover>
66
+ </Col>
67
+ </Row>
68
+ <br />
69
+ <Row
70
+ bsClass="row"
71
+ componentClass="div"
72
+ >
73
+ <Col
74
+ bsClass="col"
75
+ componentClass="div"
76
+ sm={12}
77
+ >
78
+ <Text
79
+ component="p"
80
+ >
81
+ <InfoAltIcon
82
+ color="currentColor"
83
+ noVerticalAlign={false}
84
+ size="sm"
85
+ />
86
+
87
+ More details can be found in
88
+
89
+ <Text
90
+ component="a"
91
+ href="/foreman_rh_cloud/inventory_upload"
92
+ rel="noopener noreferrer"
93
+ target="_blank"
94
+ >
95
+ <strong>
96
+ Configure
97
+ &gt;
98
+ Inventory Upload
99
+ </strong>
100
+ </Text>
101
+ </Text>
102
+ </Col>
103
+ </Row>
104
+ </Grid>
105
+ </FormGroup>
106
+ `;
@@ -0,0 +1,60 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Grid } from 'patternfly-react';
4
+ import { translate as __ } from 'foremanReact/common/I18n';
5
+ import Switcher from '../../../../../common/Switcher';
6
+
7
+ const AdvancedSettings = ({
8
+ hostObfuscationEnabled,
9
+ hostObfuscationToggle,
10
+ ipsObfuscationEnabled,
11
+ ipsObfuscationToggle,
12
+ excludePackagesEnabled,
13
+ excludePackagesToggle,
14
+ }) => (
15
+ <form style={{ padding: '5px' }}>
16
+ <Grid.Row>
17
+ <Switcher
18
+ id="obfuscate-hostnames"
19
+ label={__('Obfuscate host names')}
20
+ tooltip={__('Obfuscate host names sent to the Red Hat cloud')}
21
+ isChecked={hostObfuscationEnabled}
22
+ onChange={() => hostObfuscationToggle(hostObfuscationEnabled)}
23
+ labelCol={8}
24
+ />
25
+ </Grid.Row>
26
+ <Grid.Row>
27
+ <Switcher
28
+ id="obfuscate-ip"
29
+ label={__('Obfuscate IPs')}
30
+ tooltip={__('Obfuscate ipv4 addresses sent to the Red Hat cloud')}
31
+ isChecked={ipsObfuscationEnabled}
32
+ onChange={() => ipsObfuscationToggle(ipsObfuscationEnabled)}
33
+ labelCol={8}
34
+ />
35
+ </Grid.Row>
36
+ <Grid.Row>
37
+ <Switcher
38
+ id="exclude-packages"
39
+ label={__('Exclude packages')}
40
+ tooltip={__(
41
+ 'Exclude packages from being uploaded to the Red Hat cloud'
42
+ )}
43
+ isChecked={excludePackagesEnabled}
44
+ onChange={() => excludePackagesToggle(excludePackagesEnabled)}
45
+ labelCol={8}
46
+ />
47
+ </Grid.Row>
48
+ </form>
49
+ );
50
+
51
+ AdvancedSettings.propTypes = {
52
+ hostObfuscationEnabled: PropTypes.bool.isRequired,
53
+ hostObfuscationToggle: PropTypes.func.isRequired,
54
+ ipsObfuscationEnabled: PropTypes.bool.isRequired,
55
+ ipsObfuscationToggle: PropTypes.func.isRequired,
56
+ excludePackagesEnabled: PropTypes.bool.isRequired,
57
+ excludePackagesToggle: PropTypes.func.isRequired,
58
+ };
59
+
60
+ export default AdvancedSettings;
@@ -0,0 +1,28 @@
1
+ import { bindActionCreators } from 'redux';
2
+ import { connect } from 'react-redux';
3
+ import { handleToggle as hostObfuscationToggle } from '../../../../Components/HostObfuscationSwitcher/HostObfuscationSwitcherActions';
4
+ import { handleToggle as ipsObfuscationToggle } from '../../../../Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherActions';
5
+ import { handleToggle as excludePackagesToggle } from '../../../../Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherActions';
6
+ import AdvancedSettings from './AdvancedSettings';
7
+ import {
8
+ selectExcludePackages,
9
+ selectHostObfuscationEnabled,
10
+ selectIpsObfuscationEnabled,
11
+ } from '../../../../Components/AccountList/AccountListSelectors';
12
+
13
+ // map state to props
14
+ const mapStateToProps = state => ({
15
+ hostObfuscationEnabled: selectHostObfuscationEnabled(state),
16
+ ipsObfuscationEnabled: selectIpsObfuscationEnabled(state),
17
+ excludePackagesEnabled: selectExcludePackages(state),
18
+ });
19
+
20
+ // map action dispatchers to props
21
+ const mapDispatchToProps = dispatch =>
22
+ bindActionCreators(
23
+ { hostObfuscationToggle, ipsObfuscationToggle, excludePackagesToggle },
24
+ dispatch
25
+ );
26
+
27
+ // export connected component
28
+ export default connect(mapStateToProps, mapDispatchToProps)(AdvancedSettings);
@@ -0,0 +1,22 @@
1
+ import { bindActionCreators } from 'redux';
2
+ import { connect } from 'react-redux';
3
+
4
+ import * as actions from '../../Components/AutoUploadSwitcher/AutoUploadSwitcherActions';
5
+ import InventoryAutoUpload from './InventoryAutoUpload';
6
+ import { selectAutoUploadEnabled } from '../../Components/AccountList/AccountListSelectors';
7
+ import { fetchAccountsStatus as fetchSettings } from '../../Components/AccountList/AccountListActions';
8
+
9
+ // map state to props
10
+ const mapStateToProps = state => ({
11
+ autoUploadEnabled: selectAutoUploadEnabled(state),
12
+ });
13
+
14
+ // map action dispatchers to props
15
+ const mapDispatchToProps = dispatch =>
16
+ bindActionCreators({ ...actions, fetchSettings }, dispatch);
17
+
18
+ // export connected component
19
+ export default connect(
20
+ mapStateToProps,
21
+ mapDispatchToProps
22
+ )(InventoryAutoUpload);
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { addGlobalFill } from 'foremanReact/components/common/Fill/GlobalFill';
3
+ import InventoryAutoUploadSwitcher from './ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload';
4
+
5
+ const fills = [
6
+ {
7
+ slot: 'katello-manage-manifest-form',
8
+ name: 'InventoryAutoUpload',
9
+ component: () => <InventoryAutoUploadSwitcher />,
10
+ weight: 50,
11
+ },
12
+ ];
13
+
14
+ export const registerFills = () => {
15
+ fills.forEach(({ slot, name, component: Component, weight }, index) =>
16
+ addGlobalFill(
17
+ slot,
18
+ name,
19
+ <Component key={`rh-cloud-fill-${index}`} />,
20
+ weight
21
+ )
22
+ );
23
+ };
@@ -1,9 +1,14 @@
1
+ import componentRegistry from 'foremanReact/components/componentRegistry';
1
2
  import ForemanInventoryUpload from './ForemanInventoryUpload';
2
3
  import InsightsCloudSync from './InsightsCloudSync';
3
4
  import InsightsHostDetailsTab from './InsightsHostDetailsTab';
4
5
 
5
- export default [
6
+ const pages = [
6
7
  { name: 'ForemanInventoryUpload', type: ForemanInventoryUpload },
7
8
  { name: 'InsightsCloudSync', type: InsightsCloudSync },
8
9
  { name: 'InsightsHostDetailsTab', type: InsightsHostDetailsTab },
9
10
  ];
11
+
12
+ export const registerPages = () => {
13
+ pages.forEach(page => componentRegistry.register(page));
14
+ };
@@ -1,12 +1,21 @@
1
1
  import { combineReducers } from 'redux';
2
+ import { registerReducer } from 'foremanReact/common/MountingService';
2
3
  import inventoryUploadReducers from './ForemanInventoryUpload/ForemanInventoryUploadReducers';
3
4
  import insightsReducers from './InsightsCloudSync/InsightsCloudSyncReducers';
4
5
  import { hostInsightsReducers } from './InsightsHostDetailsTab';
5
6
 
6
- export default {
7
+ const reducers = {
7
8
  ForemanRhCloud: combineReducers({
8
9
  ...inventoryUploadReducers,
9
10
  ...insightsReducers,
10
11
  ...hostInsightsReducers,
11
12
  }),
12
13
  };
14
+
15
+ export default reducers;
16
+
17
+ export const registerReducers = () => {
18
+ Object.entries(reducers).forEach(([key, reducer]) =>
19
+ registerReducer(key, reducer)
20
+ );
21
+ };
@@ -1,10 +1,9 @@
1
1
  import API from 'foremanReact/API';
2
+ import { addToast } from 'foremanReact/redux/actions/toasts';
2
3
  import { insightsCloudUrl } from '../../InsightsCloudSyncHelpers';
3
4
  import {
4
5
  INSIGHTS_SYNC_SETTING_SET,
5
- INSIGHTS_SYNC_SETTING_SET_FAILURE,
6
6
  INSIGHTS_SYNC_SETTINGS_GET_SUCCESS,
7
- INSIGHTS_SYNC_SETTINGS_GET_FAILURE,
8
7
  } from './InsightsSettingsConstants';
9
8
 
10
9
  export const getInsightsSyncSettings = () => async dispatch => {
@@ -20,15 +19,14 @@ export const getInsightsSyncSettings = () => async dispatch => {
20
19
  },
21
20
  },
22
21
  });
23
- } catch (error) {
24
- dispatch({
25
- type: INSIGHTS_SYNC_SETTINGS_GET_FAILURE,
26
- payload: {
27
- settings: {
28
- error: error.message,
29
- },
30
- },
31
- });
22
+ } catch ({ message }) {
23
+ dispatch(
24
+ addToast({
25
+ sticky: true,
26
+ type: 'error',
27
+ message,
28
+ })
29
+ );
32
30
  }
33
31
  };
34
32
 
@@ -47,14 +45,13 @@ export const setInsightsSyncEnabled = currentInsightsSyncEnabled => async dispat
47
45
  },
48
46
  },
49
47
  });
50
- } catch (error) {
51
- dispatch({
52
- type: INSIGHTS_SYNC_SETTING_SET_FAILURE,
53
- payload: {
54
- settings: {
55
- error: error.message,
56
- },
57
- },
58
- });
48
+ } catch ({ message }) {
49
+ dispatch(
50
+ addToast({
51
+ sticky: true,
52
+ type: 'error',
53
+ message,
54
+ })
55
+ );
59
56
  }
60
57
  };
@@ -1,10 +1,4 @@
1
1
  export const INSIGHTS_SYNC_SETTING_SET = 'INSIGHTS_SYNC_SETTING_SET';
2
2
 
3
- export const INSIGHTS_SYNC_SETTING_SET_FAILURE =
4
- 'INSIGHTS_SYNC_SETTING_SET_FAILURE';
5
-
6
3
  export const INSIGHTS_SYNC_SETTINGS_GET_SUCCESS =
7
4
  'INSIGHTS_SYNC_SETTINGS_GET_SUCCESS';
8
-
9
- export const INSIGHTS_SYNC_SETTINGS_GET_FAILURE =
10
- 'INSIGHTS_SYNC_SETTINGS_GET_FAILURE';
@@ -1,9 +1,7 @@
1
1
  import Immutable from 'seamless-immutable';
2
2
  import {
3
3
  INSIGHTS_SYNC_SETTING_SET,
4
- INSIGHTS_SYNC_SETTING_SET_FAILURE,
5
4
  INSIGHTS_SYNC_SETTINGS_GET_SUCCESS,
6
- INSIGHTS_SYNC_SETTINGS_GET_FAILURE,
7
5
  } from './InsightsSettingsConstants';
8
6
 
9
7
  const initialState = Immutable({
@@ -15,9 +13,7 @@ export default (state = initialState, action) => {
15
13
 
16
14
  switch (action.type) {
17
15
  case INSIGHTS_SYNC_SETTINGS_GET_SUCCESS:
18
- case INSIGHTS_SYNC_SETTINGS_GET_FAILURE:
19
16
  case INSIGHTS_SYNC_SETTING_SET:
20
- case INSIGHTS_SYNC_SETTING_SET_FAILURE:
21
17
  return state.merge({
22
18
  ...state,
23
19
  ...settings,
@@ -22,12 +22,28 @@ const runWithGetState = (state, action, params) => dispatch => {
22
22
  const fixtures = {
23
23
  'should generate INSIGHTS_SYNC_SETTINGS_GET_SUCCESS action': () =>
24
24
  runWithGetState({ settings: {} }, getInsightsSyncSettings, {}),
25
+ 'should handle getInsightsSyncSettings with error ': () => {
26
+ API.get.mockImplementationOnce(() =>
27
+ Promise.reject(new Error('Network error!'))
28
+ );
29
+ return runWithGetState({ settings: {} }, getInsightsSyncSettings, {});
30
+ },
25
31
  'should generate INSIGHTS_SYNC_SETTING_SET action': () =>
26
32
  runWithGetState(
27
33
  { settings: { insightsSyncEnabled: false } },
28
34
  setInsightsSyncEnabled,
29
35
  true
30
36
  ),
37
+ 'should handle setInsightsSyncEnabled with error ': () => {
38
+ API.patch.mockImplementationOnce(() =>
39
+ Promise.reject(new Error('Network error!'))
40
+ );
41
+ return runWithGetState(
42
+ { settings: { insightsSyncEnabled: false } },
43
+ setInsightsSyncEnabled,
44
+ true
45
+ );
46
+ },
31
47
  };
32
48
 
33
49
  describe('InsightsSettings actions', () => {
@@ -1,12 +1,9 @@
1
1
  import { testReducerSnapshotWithFixtures } from '@theforeman/test';
2
-
2
+ import reducer from '../InsightsSettingsReducer';
3
3
  import {
4
4
  INSIGHTS_SYNC_SETTING_SET,
5
- INSIGHTS_SYNC_SETTING_SET_FAILURE,
6
5
  INSIGHTS_SYNC_SETTINGS_GET_SUCCESS,
7
- INSIGHTS_SYNC_SETTINGS_GET_FAILURE,
8
6
  } from '../InsightsSettingsConstants';
9
- import reducer from '../InsightsSettingsReducer';
10
7
 
11
8
  const fixtures = {
12
9
  'should return the initial state': {},
@@ -20,16 +17,6 @@ const fixtures = {
20
17
  },
21
18
  },
22
19
  },
23
- 'should handle INSIGHTS_SYNC_SETTINGS_GET_FAILURE': {
24
- action: {
25
- type: INSIGHTS_SYNC_SETTINGS_GET_FAILURE,
26
- payload: {
27
- settings: {
28
- error: 'test error',
29
- },
30
- },
31
- },
32
- },
33
20
  'should handle INSIGHTS_SYNC_SETTING_SET': {
34
21
  action: {
35
22
  type: INSIGHTS_SYNC_SETTING_SET,
@@ -40,16 +27,6 @@ const fixtures = {
40
27
  },
41
28
  },
42
29
  },
43
- 'should handle INSIGHTS_SYNC_SETTING_SET_FAILURE': {
44
- action: {
45
- type: INSIGHTS_SYNC_SETTING_SET_FAILURE,
46
- payload: {
47
- settings: {
48
- error: 'test set error',
49
- },
50
- },
51
- },
52
- },
53
30
  };
54
31
 
55
32
  describe('InsightsSettings reducer', () =>