foreman_rh_cloud 3.0.17 → 3.0.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_inventory_upload/accounts_controller.rb +3 -15
  3. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +0 -48
  4. data/app/controllers/foreman_inventory_upload/uploads_settings_controller.rb +26 -0
  5. data/app/controllers/insights_cloud/hits_controller.rb +1 -1
  6. data/app/services/foreman_rh_cloud/branch_info.rb +3 -14
  7. data/app/services/foreman_rh_cloud/cloud_connector.rb +12 -7
  8. data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +31 -19
  9. data/config/routes.rb +2 -5
  10. data/db/migrate/20210307000001_add_unique_to_insights_facet.foreman_rh_cloud.rb +11 -0
  11. data/lib/foreman_inventory_upload.rb +2 -1
  12. data/lib/foreman_inventory_upload/generators/json_stream.rb +1 -1
  13. data/lib/foreman_inventory_upload/generators/slice.rb +14 -21
  14. data/lib/foreman_inventory_upload/generators/tags.rb +59 -0
  15. data/lib/foreman_rh_cloud.rb +4 -0
  16. data/lib/foreman_rh_cloud/version.rb +1 -1
  17. data/package.json +1 -1
  18. data/test/controllers/accounts_controller_test.rb +1 -5
  19. data/test/controllers/uploads_controller_test.rb +0 -13
  20. data/test/controllers/uploads_settings_controller_test.rb +31 -0
  21. data/test/test_plugin_helper.rb +13 -0
  22. data/test/unit/services/foreman_rh_cloud/branch_info_test.rb +5 -5
  23. data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +39 -4
  24. data/test/unit/slice_generator_test.rb +7 -2
  25. data/test/unit/tags_generator_test.rb +60 -0
  26. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +4 -19
  27. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +7 -7
  28. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js +6 -6
  29. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +0 -34
  30. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +0 -14
  31. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyResults/emptyResults.scss +6 -4
  32. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/emptyState.scss +6 -4
  33. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/errorState.scss +14 -12
  34. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.fixtures.js +10 -1
  35. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +7 -7
  36. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +12 -9
  37. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListHelper.test.js +3 -3
  38. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +0 -30
  39. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +1 -23
  40. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +6 -6
  41. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +3 -8
  42. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +3 -35
  43. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +6 -18
  44. data/webpack/ForemanInventoryUpload/Components/AccountList/accountList.scss +24 -22
  45. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.fixtures.js +1 -1
  46. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.js +1 -1
  47. data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownload.js +2 -1
  48. data/webpack/ForemanInventoryUpload/Components/FileDownload/fileDownload.scss +4 -2
  49. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +2 -1
  50. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +16 -14
  51. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/Components/ClearButton/ClearButton.js +2 -1
  52. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.fixtures.js +1 -1
  53. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js +2 -1
  54. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterReducer.js +3 -11
  55. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilter.test.js +1 -1
  56. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterReducer.test.js +3 -3
  57. data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/AdvancedSettingActions.js +7 -0
  58. data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/AdvancedSettingsConstants.js +26 -0
  59. data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/__tests__/AdvancedSettingActions.test.js +9 -0
  60. data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/__tests__/__snapshots__/AdvancedSettingActions.test.js.snap +18 -0
  61. data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/index.js +29 -0
  62. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.js +7 -8
  63. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.scss +15 -9
  64. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettingsActions.js +23 -0
  65. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettingsConstants.js +9 -0
  66. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettingsSelectors.js +19 -0
  67. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/InventorySettingsActions.test.js +14 -0
  68. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettings.test.js.snap +16 -4
  69. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettingsActions.test.js.snap +26 -0
  70. data/webpack/ForemanInventoryUpload/Components/InventorySettings/index.js +16 -1
  71. data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.fixtures.js +1 -1
  72. data/webpack/ForemanInventoryUpload/Components/NavContainer/navContainer.scss +7 -5
  73. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.scss +1 -1
  74. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +1 -1
  75. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/index.js +1 -1
  76. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButton.test.js +1 -1
  77. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js +1 -1
  78. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/modal.scss +1 -1
  79. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/index.js +1 -1
  80. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.fixtures.js +1 -1
  81. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.js +1 -1
  82. data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.fixtures.js +1 -1
  83. data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.js +1 -1
  84. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/index.js +1 -1
  85. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/scheduledRun.scss +8 -6
  86. data/webpack/ForemanInventoryUpload/Components/StatusChart/statusChart.scss +9 -7
  87. data/webpack/ForemanInventoryUpload/Components/TabBody/tabBody.scss +4 -2
  88. data/webpack/ForemanInventoryUpload/Components/TabContainer/tabContainer.scss +7 -5
  89. data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.js +2 -1
  90. data/webpack/ForemanInventoryUpload/Components/TabHeader/tabHeader.scss +15 -13
  91. data/webpack/ForemanInventoryUpload/Components/Terminal/terminal.scss +27 -25
  92. data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +1 -1
  93. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/InventoryAutoUpload.js +13 -8
  94. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/InventoryAutoUpload.test.js +3 -3
  95. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/AdvancedSettings.js +21 -9
  96. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/index.js +3 -8
  97. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/index.js +6 -4
  98. data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryUpload.test.js.snap +1 -1
  99. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettings.test.js +1 -1
  100. data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/__tests__/InsightsSyncSwitcher.test.js +1 -1
  101. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/fixtures.js +1 -1
  102. data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +1 -1
  103. data/webpack/InsightsHostDetailsTab/InsightsTab.js +2 -1
  104. data/webpack/__mocks__/foremanReact/redux/API/APISelectors.js +1 -1
  105. data/webpack/common/Switcher/SwitcherPF4.scss +1 -1
  106. metadata +55 -56
  107. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.fixtures.js +0 -3
  108. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.js +0 -29
  109. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js +0 -29
  110. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherConstants.js +0 -1
  111. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcher.test.js +0 -14
  112. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcherActions.test.js +0 -24
  113. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcher.test.js.snap +0 -15
  114. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcherActions.test.js.snap +0 -31
  115. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/index.js +0 -17
  116. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.fixtures.js +0 -1
  117. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.js +0 -27
  118. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherActions.js +0 -29
  119. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherConstants.js +0 -1
  120. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcher.test.js +0 -13
  121. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcherActions.test.js +0 -21
  122. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcher.test.js.snap +0 -15
  123. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcherActions.test.js.snap +0 -31
  124. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/integration.test.js.snap +0 -46
  125. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/integration.test.js +0 -36
  126. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/index.js +0 -20
  127. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.fixtures.js +0 -2
  128. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.js +0 -27
  129. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherActions.js +0 -29
  130. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherConstants.js +0 -1
  131. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcher.test.js +0 -14
  132. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcherActions.test.js +0 -24
  133. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcher.test.js.snap +0 -15
  134. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcherActions.test.js.snap +0 -31
  135. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/index.js +0 -20
  136. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.fixtures.js +0 -1
  137. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.js +0 -27
  138. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherActions.js +0 -29
  139. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherConstants.js +0 -1
  140. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcher.test.js +0 -13
  141. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcherActions.test.js +0 -21
  142. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcher.test.js.snap +0 -15
  143. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcherActions.test.js.snap +0 -31
  144. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/index.js +0 -20
@@ -1,32 +1,34 @@
1
- .account-list {
2
- .pf-c-accordion__toggle {
3
- margin-top: 10px;
4
- }
1
+ .rh-cloud-inventory-page {
2
+ .account-list {
3
+ .pf-c-accordion__toggle {
4
+ margin-top: 10px;
5
+ }
5
6
 
6
- .pf-c-accordion__toggle-text {
7
- font-size: 16px;
8
- display: flex;
9
- justify-content: space-between;
10
- width: 100%;
7
+ .pf-c-accordion__toggle-text {
8
+ font-size: 16px;
9
+ display: flex;
10
+ justify-content: space-between;
11
+ width: 100%;
11
12
 
12
- .account-icon {
13
- margin-right: 5px;
13
+ .account-icon {
14
+ margin-right: 5px;
14
15
 
15
- .pf-c-label__icon {
16
- margin: 0;
16
+ .pf-c-label__icon {
17
+ margin: 0;
18
+ }
17
19
  }
18
- }
19
20
 
20
- span {
21
- align-self: center;
22
- }
21
+ span {
22
+ align-self: center;
23
+ }
23
24
 
24
- .status {
25
- margin: 0;
25
+ .status {
26
+ margin: 0;
27
+ }
26
28
  }
27
- }
28
29
 
29
- .list-item-status > span {
30
- margin-left: 7px;
30
+ .list-item-status > span {
31
+ margin-left: 7px;
32
+ }
31
33
  }
32
34
  }
@@ -1,4 +1,4 @@
1
- import { noop } from 'patternfly-react';
1
+ import { noop } from 'foremanReact/common/helpers';
2
2
 
3
3
  export const pollingProcessID = 1;
4
4
 
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { noop } from 'patternfly-react';
3
+ import { noop } from 'foremanReact/common/helpers';
4
4
  import { translate as __ } from 'foremanReact/common/I18n';
5
5
  import ReportGenerate from '../ReportGenerate';
6
6
  import ReportUpload from '../ReportUpload';
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { noop, Grid, Button, Icon } from 'patternfly-react';
3
+ import { Grid, Button, Icon } from 'patternfly-react';
4
+ import { noop } from 'foremanReact/common/helpers';
4
5
  import './fileDownload.scss';
5
6
 
6
7
  const FileDownload = ({ onClick }) => (
@@ -1,3 +1,5 @@
1
- button {
2
- float: right;
1
+ .rh-cloud-inventory-page {
2
+ button {
3
+ float: right;
4
+ }
3
5
  }
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { Modal, Icon, noop } from 'patternfly-react';
3
+ import { Modal, Icon } from 'patternfly-react';
4
+ import { noop } from 'foremanReact/common/helpers';
4
5
  import { translate as __ } from 'foremanReact/common/I18n';
5
6
  import Terminal from '../Terminal';
6
7
  import './fullScreenModal.scss';
@@ -1,19 +1,21 @@
1
- #full-screen-terminal {
2
- .modal-dialog {
3
- width: 95%;
4
- height: 95%;
5
- margin: 30px 0 0 30px;
1
+ .rh-cloud-inventory-page {
2
+ #full-screen-terminal {
3
+ .modal-dialog {
4
+ width: 95%;
5
+ height: 95%;
6
+ margin: 30px 0 0 30px;
6
7
 
7
- .modal-body {
8
- padding: 0;
9
- display: flex;
10
- height: -webkit-fill-available;
11
- height: -moz-available;
12
- height: fill-available;
8
+ .modal-body {
9
+ padding: 0;
10
+ display: flex;
11
+ height: -webkit-fill-available;
12
+ height: -moz-available;
13
+ height: fill-available;
13
14
 
14
- .terminal {
15
- margin: 0 -20px;
16
- height: 100%;
15
+ .terminal {
16
+ margin: 0 -20px;
17
+ height: 100%;
18
+ }
17
19
  }
18
20
  }
19
21
  }
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { Icon, OverlayTrigger, Tooltip, noop } from 'patternfly-react';
3
+ import { noop } from 'foremanReact/common/helpers';
4
+ import { Icon, OverlayTrigger, Tooltip } from 'patternfly-react';
4
5
  import { translate as __ } from 'foremanReact/common/I18n';
5
6
 
6
7
  const ClearButton = ({ onClear }) => (
@@ -1,2 +1,2 @@
1
1
  export const filterTerm = 'test_filter_term';
2
- export const org = { title: 'some_org', id: 1 };
2
+ export const organization = { title: 'some_org', id: 1 };
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { FormGroup, FormControl, noop } from 'patternfly-react';
3
+ import { FormGroup, FormControl } from 'patternfly-react';
4
+ import { noop } from 'foremanReact/common/helpers';
4
5
  import { translate as __ } from 'foremanReact/common/I18n';
5
6
  import ClearButton from './Components/ClearButton';
6
7
  import './inventoryFilter.scss';
@@ -16,7 +16,7 @@ const initialState = Immutable({
16
16
 
17
17
  export default (
18
18
  state = initialState,
19
- { type, payload: { filterTerm, org, organization } = {} }
19
+ { type, payload: { filterTerm, organization } = {} }
20
20
  ) => {
21
21
  switch (type) {
22
22
  case INVENTORY_FILTER_UPDATE:
@@ -27,17 +27,9 @@ export default (
27
27
  return state.merge({
28
28
  filterTerm: '',
29
29
  });
30
- case LAYOUT_CHANGE_ORG: {
31
- const { title } = org;
32
- // Any org is used only in it's translated form in the redux
33
- const term = title === __(ANY_ORGANIZATION) ? '' : title;
34
- return state.merge({
35
- filterTerm: term,
36
- });
37
- }
30
+ case LAYOUT_CHANGE_ORG:
38
31
  case LAYOUT_INITIALIZE: {
39
- // Layout action changed in Jul 20 2020 - https://github.com/theforeman/foreman/commit/e4c39a7d8f8b50ba45ef63e46f6f6914b69f247a
40
- const { title } = organization || {}; // org was renamed
32
+ const { title } = organization || {};
41
33
  // Any org is used only in it's translated form in the redux
42
34
  const term = title === __(ANY_ORGANIZATION) ? '' : title;
43
35
  return state.merge({
@@ -1,5 +1,5 @@
1
1
  import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
- import { noop } from 'patternfly-react';
2
+ import { noop } from 'foremanReact/common/helpers';
3
3
 
4
4
  import InventoryFilter from '../InventoryFilter';
5
5
 
@@ -4,7 +4,7 @@ import {
4
4
  LAYOUT_INITIALIZE,
5
5
  } from 'foremanReact/components/Layout/LayoutConstants';
6
6
  import reducer from '../InventoryFilterReducer';
7
- import { filterTerm, org } from '../InventoryFilter.fixtures';
7
+ import { filterTerm, organization } from '../InventoryFilter.fixtures';
8
8
  import {
9
9
  INVENTORY_FILTER_UPDATE,
10
10
  INVENTORY_FILTER_CLEAR,
@@ -29,13 +29,13 @@ const fixtures = {
29
29
  'should handle LAYOUT_CHANGE_ORG': {
30
30
  action: {
31
31
  type: LAYOUT_CHANGE_ORG,
32
- payload: { org },
32
+ payload: { organization },
33
33
  },
34
34
  },
35
35
  'should handle LAYOUT_INITIALIZE': {
36
36
  action: {
37
37
  type: LAYOUT_INITIALIZE,
38
- payload: { organization: org },
38
+ payload: { organization },
39
39
  },
40
40
  },
41
41
  };
@@ -0,0 +1,7 @@
1
+ import { setSetting } from '../InventorySettingsActions';
2
+
3
+ export const handleToggle = (name, current) =>
4
+ setSetting({
5
+ setting: name,
6
+ value: !current,
7
+ });
@@ -0,0 +1,26 @@
1
+ import { translate as __ } from 'foremanReact/common/I18n';
2
+
3
+ export const settingsDict = {
4
+ autoUploadEnabled: {
5
+ name: 'allow_auto_inventory_upload',
6
+ label: __('Auto upload'),
7
+ tooltip: __(
8
+ 'Enable automatic upload of your hosts inventory to the Red Hat cloud'
9
+ ),
10
+ },
11
+ hostObfuscationEnabled: {
12
+ name: 'obfuscate_inventory_hostnames',
13
+ label: __('Obfuscate host names'),
14
+ tooltip: __('Obfuscate host names sent to the Red Hat cloud'),
15
+ },
16
+ ipsObfuscationEnabled: {
17
+ name: 'obfuscate_inventory_ips',
18
+ label: __('Obfuscate host ipv4 addresses'),
19
+ tooltip: __('Obfuscate ipv4 addresses sent to the Red Hat cloud'),
20
+ },
21
+ excludePackagesEnabled: {
22
+ name: 'exclude_installed_packages',
23
+ label: __('Exclude Packages'),
24
+ tooltip: __('Exclude packages from being uploaded to the Red Hat cloud'),
25
+ },
26
+ };
@@ -0,0 +1,9 @@
1
+ import { testActionSnapshotWithFixtures } from '@theforeman/test';
2
+ import { handleToggle } from '../AdvancedSettingActions';
3
+
4
+ const fixtures = {
5
+ 'should handleToggle': () => handleToggle('autoUploadEnabled', false),
6
+ };
7
+
8
+ describe('AdvancedSetting actions', () =>
9
+ testActionSnapshotWithFixtures(fixtures));
@@ -0,0 +1,18 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`AdvancedSetting actions should handleToggle 1`] = `
4
+ Array [
5
+ Array [
6
+ Object {
7
+ "errorToast": [Function],
8
+ "key": "INVENTORY_SETTINGS",
9
+ "params": Object {
10
+ "setting": "autoUploadEnabled",
11
+ "value": true,
12
+ },
13
+ "type": "post-some-type",
14
+ "url": "/foreman_inventory_upload/setting",
15
+ },
16
+ ],
17
+ ]
18
+ `;
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { useSelector, useDispatch } from 'react-redux';
4
+ import { selectSettings } from '../InventorySettingsSelectors';
5
+ import { handleToggle } from './AdvancedSettingActions';
6
+ import SwitcherPF4 from '../../../../common/Switcher/SwitcherPF4';
7
+ import { settingsDict } from './AdvancedSettingsConstants';
8
+
9
+ const AdvancedSetting = ({ setting }) => {
10
+ const settingValue = useSelector(store => selectSettings(store)[setting]);
11
+ const dispatch = useDispatch();
12
+ const onToggle = () =>
13
+ dispatch(handleToggle(settingsDict[setting].name, settingValue));
14
+ return (
15
+ <SwitcherPF4
16
+ id={settingsDict[setting].name}
17
+ label={settingsDict[setting].label}
18
+ tooltip={settingsDict[setting].tooltip}
19
+ isChecked={settingValue}
20
+ onChange={onToggle}
21
+ />
22
+ );
23
+ };
24
+
25
+ AdvancedSetting.propTypes = {
26
+ setting: PropTypes.string.isRequired,
27
+ };
28
+
29
+ export default AdvancedSetting;
@@ -1,18 +1,17 @@
1
1
  import React from 'react';
2
2
  import { translate as __ } from 'foremanReact/common/I18n';
3
- import AutoUploadSwitcher from '../AutoUploadSwitcher';
4
- import HostObfuscationSwitcher from '../HostObfuscationSwitcher';
5
- import ExcludePackagesSwitcher from '../ExcludePackagesSwitcher';
6
- import IpsObfuscationSwitcher from '../IpsObfuscationSwitcher';
3
+
4
+ import AdvancedSetting from './AdvancedSetting';
5
+ import { settingsDict } from './AdvancedSetting/AdvancedSettingsConstants';
6
+
7
7
  import './InventorySettings.scss';
8
8
 
9
9
  const InventorySettings = () => (
10
10
  <div className="inventory-settings">
11
11
  <h3>{__('Settings')}</h3>
12
- <AutoUploadSwitcher />
13
- <ExcludePackagesSwitcher />
14
- <HostObfuscationSwitcher />
15
- <IpsObfuscationSwitcher />
12
+ {Object.keys(settingsDict).map(key => (
13
+ <AdvancedSetting setting={key} key={key} />
14
+ ))}
16
15
  </div>
17
16
  );
18
17
 
@@ -1,12 +1,18 @@
1
- .inventory-settings {
2
- border: 1px solid #ededed;
3
- border-radius: 4px;
4
- padding: 10px;
5
- margin-bottom: 15px;
6
- float: right;
1
+ .rh-cloud-inventory-page {
2
+ .inventory-settings {
3
+ border: 1px solid #ededed;
4
+ border-radius: 4px;
5
+ padding: 10px;
6
+ margin-bottom: 15px;
7
+ float: right;
7
8
 
8
- h3 {
9
- margin-top: 0;
10
- font-weight: 600;
9
+ h3 {
10
+ margin-top: 0;
11
+ font-weight: 600;
12
+ }
13
+
14
+ .foreman-switcher {
15
+ display: block;
16
+ }
11
17
  }
12
18
  }
@@ -0,0 +1,23 @@
1
+ import { get, post } from 'foremanReact/redux/API';
2
+ import {
3
+ INVENTORY_SETTINGS,
4
+ INVENTORY_GET_SETTINGS_PATH,
5
+ INVENTORY_SET_SETTINGS_PATH,
6
+ } from './InventorySettingsConstants';
7
+
8
+ export const getSettings = () =>
9
+ get({
10
+ key: INVENTORY_SETTINGS,
11
+ url: INVENTORY_GET_SETTINGS_PATH,
12
+ });
13
+
14
+ export const setSetting = setting => dispatch => {
15
+ dispatch(
16
+ post({
17
+ key: INVENTORY_SETTINGS,
18
+ url: INVENTORY_SET_SETTINGS_PATH,
19
+ params: setting,
20
+ errorToast: error => error.message,
21
+ })
22
+ );
23
+ };
@@ -0,0 +1,9 @@
1
+ import { foremanUrl } from '../../../ForemanRhCloudHelpers';
2
+
3
+ export const INVENTORY_SETTINGS = 'INVENTORY_SETTINGS';
4
+ export const INVENTORY_GET_SETTINGS_PATH = foremanUrl(
5
+ '/foreman_inventory_upload/settings'
6
+ );
7
+ export const INVENTORY_SET_SETTINGS_PATH = foremanUrl(
8
+ '/foreman_inventory_upload/setting'
9
+ );
@@ -0,0 +1,19 @@
1
+ import { selectAPIResponse } from 'foremanReact/redux/API/APISelectors';
2
+ import { INVENTORY_SETTINGS } from './InventorySettingsConstants';
3
+
4
+ export const selectSettings = state =>
5
+ selectAPIResponse(state, INVENTORY_SETTINGS);
6
+
7
+ export const selectAutoUploadEnabled = state =>
8
+ selectSettings(state).autoUploadEnabled;
9
+
10
+ export const selectHostObfuscationEnabled = state =>
11
+ selectSettings(state).hostObfuscationEnabled;
12
+
13
+ export const selectIpsObfuscationEnabled = state =>
14
+ selectSettings(state).ipsObfuscationEnabled;
15
+
16
+ export const selectExcludePackages = state =>
17
+ selectSettings(state).excludePackagesEnabled;
18
+
19
+ export const selectCloudToken = state => selectSettings(state).cloudToken;
@@ -0,0 +1,14 @@
1
+ import { testActionSnapshotWithFixtures } from '@theforeman/test';
2
+ import { getSettings, setSetting } from '../InventorySettingsActions';
3
+
4
+ const fixtures = {
5
+ 'should getSettings': () => getSettings(),
6
+ 'should setSetting hostObfuscation true': () =>
7
+ setSetting({
8
+ setting: 'hostObfuscation',
9
+ value: true,
10
+ }),
11
+ };
12
+
13
+ describe('Inventory settings actions', () =>
14
+ testActionSnapshotWithFixtures(fixtures));