foreman_rh_cloud 2.0.18.1 → 3.0.14

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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +0 -13
  3. data/app/controllers/foreman_inventory_upload/accounts_controller.rb +2 -2
  4. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +8 -1
  5. data/app/helpers/foreman_inventory_upload_host_helper.rb +1 -8
  6. data/app/models/setting/rh_cloud.rb +5 -5
  7. data/lib/foreman_inventory_upload.rb +2 -3
  8. data/lib/foreman_inventory_upload/generators/archived_report.rb +1 -1
  9. data/lib/foreman_inventory_upload/generators/json_stream.rb +1 -1
  10. data/lib/foreman_inventory_upload/generators/slice.rb +3 -3
  11. data/lib/foreman_rh_cloud/engine.rb +4 -2
  12. data/lib/foreman_rh_cloud/version.rb +1 -1
  13. data/lib/tasks/rh_cloud_inventory.rake +0 -23
  14. data/package.json +1 -1
  15. data/test/controllers/accounts_controller_test.rb +1 -1
  16. data/test/unit/slice_generator_test.rb +4 -30
  17. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +3 -3
  18. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +7 -7
  19. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js +6 -6
  20. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.fixtures.js +1 -10
  21. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +7 -7
  22. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +8 -11
  23. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListHelper.test.js +3 -3
  24. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +6 -6
  25. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +3 -3
  26. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +3 -3
  27. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +6 -6
  28. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.js +1 -1
  29. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcher.test.js.snap +1 -1
  30. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +1 -1
  31. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +4 -4
  32. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/InventoryAutoUpload.js +92 -0
  33. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/InventoryAutoUpload.test.js +17 -0
  34. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/__snapshots__/InventoryAutoUpload.test.js.snap +106 -0
  35. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/AdvancedSettings.js +60 -0
  36. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/index.js +28 -0
  37. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/index.js +22 -0
  38. data/webpack/ForemanRhCloudFills.js +23 -0
  39. data/webpack/ForemanRhCloudPages.js +6 -1
  40. data/webpack/ForemanRhCloudReducers.js +10 -1
  41. data/webpack/InsightsHostDetailsTab/InsightsTab.js +5 -7
  42. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTab.fixtures.js +12 -14
  43. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabActions.test.js.snap +10 -12
  44. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabReducer.test.js.snap +10 -12
  45. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabSelectors.test.js.snap +10 -12
  46. data/webpack/__mocks__/foremanReact/common/MountingService.js +1 -0
  47. data/webpack/common/Switcher/index.js +79 -0
  48. data/webpack/global_index.js +5 -0
  49. data/webpack/index.js +4 -14
  50. metadata +25 -21
  51. data/config/Gemfile.lock.gh_test +0 -817
  52. data/config/database.yml.example +0 -17
  53. data/config/package-lock.json.gh_test +0 -36317
  54. data/db/migrate/20210307000001_add_unique_to_insights_facet.foreman_rh_cloud.rb +0 -11
  55. data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js +0 -34
  56. data/webpack/subscriptions_extension_index.js +0 -8
@@ -8,11 +8,9 @@ exports[`ListItem rendering render with Props 1`] = `
8
8
  <ListItemStatus
9
9
  account={
10
10
  Object {
11
- "test": Object {
12
- "generate_report_status": "unknown",
13
- "id": 1,
14
- "upload_report_status": "unknown",
15
- },
11
+ "generate_report_status": "unknown",
12
+ "label": "default_org_name",
13
+ "upload_report_status": "unknown",
16
14
  }
17
15
  }
18
16
  />,
@@ -22,7 +20,7 @@ exports[`ListItem rendering render with Props 1`] = `
22
20
  compoundExpand={false}
23
21
  compoundExpanded={false}
24
22
  description={null}
25
- heading="test"
23
+ heading="default_org_name"
26
24
  hideCloseIcon={true}
27
25
  initExpanded={false}
28
26
  leftContent={
@@ -41,13 +39,12 @@ exports[`ListItem rendering render with Props 1`] = `
41
39
  <Connect(Dashboard)
42
40
  account={
43
41
  Object {
44
- "test": Object {
45
- "generate_report_status": "unknown",
46
- "id": 1,
47
- "upload_report_status": "unknown",
48
- },
42
+ "generate_report_status": "unknown",
43
+ "label": "default_org_name",
44
+ "upload_report_status": "unknown",
49
45
  }
50
46
  }
47
+ accountID="1"
51
48
  />
52
49
  </ListViewItem>
53
50
  `;
@@ -1,12 +1,12 @@
1
1
  import { filterAccounts } from '../AccountListHelper';
2
- import { accounts } from '../AccountList.fixtures';
2
+ import { accounts, accountIDs } from '../AccountList.fixtures';
3
3
 
4
4
  describe('AccountList helpers', () => {
5
5
  it('account ids filter should return all accounts where label contains "test"', () => {
6
- expect(filterAccounts(accounts, 'AcCoUnT')).toEqual(accounts);
6
+ expect(filterAccounts(accounts, accountIDs, 'test')).toEqual(accountIDs);
7
7
  });
8
8
 
9
9
  it('account ids filter should not match', () => {
10
- expect(filterAccounts(accounts, 'no_match')).toEqual({});
10
+ expect(filterAccounts(accounts, accountIDs, 'no_match')).toEqual([]);
11
11
  });
12
12
  });
@@ -8,34 +8,34 @@ exports[`AccountList rendering render with props 1`] = `
8
8
  account={
9
9
  Object {
10
10
  "generate_report_status": "running",
11
- "id": 1,
11
+ "label": "test_org1",
12
12
  "upload_report_status": "running",
13
13
  }
14
14
  }
15
+ accountID="Account1"
15
16
  key="0"
16
- label="Account1"
17
17
  />
18
18
  <ListItem
19
19
  account={
20
20
  Object {
21
21
  "generate_report_status": "failure",
22
- "id": 2,
22
+ "label": "test_org2",
23
23
  "upload_report_status": "unknown",
24
24
  }
25
25
  }
26
+ accountID="Account2"
26
27
  key="1"
27
- label="Account2"
28
28
  />
29
29
  <ListItem
30
30
  account={
31
31
  Object {
32
32
  "generate_report_status": "running",
33
- "id": 3,
33
+ "label": "test_org3",
34
34
  "upload_report_status": "success",
35
35
  }
36
36
  }
37
+ accountID="Account3"
37
38
  key="2"
38
- label="Account3"
39
39
  />
40
40
  </ListView>
41
41
  `;
@@ -8,17 +8,17 @@ Array [
8
8
  "accounts": Object {
9
9
  "Account1": Object {
10
10
  "generate_report_status": "running",
11
- "id": 1,
11
+ "label": "test_org1",
12
12
  "upload_report_status": "running",
13
13
  },
14
14
  "Account2": Object {
15
15
  "generate_report_status": "failure",
16
- "id": 2,
16
+ "label": "test_org2",
17
17
  "upload_report_status": "unknown",
18
18
  },
19
19
  "Account3": Object {
20
20
  "generate_report_status": "running",
21
- "id": 3,
21
+ "label": "test_org3",
22
22
  "upload_report_status": "success",
23
23
  },
24
24
  },
@@ -23,17 +23,17 @@ Object {
23
23
  "accounts": Object {
24
24
  "Account1": Object {
25
25
  "generate_report_status": "running",
26
- "id": 1,
26
+ "label": "test_org1",
27
27
  "upload_report_status": "running",
28
28
  },
29
29
  "Account2": Object {
30
30
  "generate_report_status": "failure",
31
- "id": 2,
31
+ "label": "test_org2",
32
32
  "upload_report_status": "unknown",
33
33
  },
34
34
  "Account3": Object {
35
35
  "generate_report_status": "running",
36
- "id": 3,
36
+ "label": "test_org3",
37
37
  "upload_report_status": "success",
38
38
  },
39
39
  },
@@ -4,17 +4,17 @@ exports[`AccountList selectors should return AccountList accounts 1`] = `
4
4
  Object {
5
5
  "Account1": Object {
6
6
  "generate_report_status": "running",
7
- "id": 1,
7
+ "label": "test_org1",
8
8
  "upload_report_status": "running",
9
9
  },
10
10
  "Account2": Object {
11
11
  "generate_report_status": "failure",
12
- "id": 2,
12
+ "label": "test_org2",
13
13
  "upload_report_status": "unknown",
14
14
  },
15
15
  "Account3": Object {
16
16
  "generate_report_status": "running",
17
- "id": 3,
17
+ "label": "test_org3",
18
18
  "upload_report_status": "success",
19
19
  },
20
20
  }
@@ -35,17 +35,17 @@ Object {
35
35
  "accounts": Object {
36
36
  "Account1": Object {
37
37
  "generate_report_status": "running",
38
- "id": 1,
38
+ "label": "test_org1",
39
39
  "upload_report_status": "running",
40
40
  },
41
41
  "Account2": Object {
42
42
  "generate_report_status": "failure",
43
- "id": 2,
43
+ "label": "test_org2",
44
44
  "upload_report_status": "unknown",
45
45
  },
46
46
  "Account3": Object {
47
47
  "generate_report_status": "running",
48
- "id": 3,
48
+ "label": "test_org3",
49
49
  "upload_report_status": "success",
50
50
  },
51
51
  },
@@ -9,7 +9,7 @@ const AutoUploadSwitcher = ({ autoUploadEnabled, handleToggle }) => (
9
9
  <span>Auto upload</span>
10
10
  <FieldLevelHelp
11
11
  content={__(
12
- 'Enable automatic upload of your host inventory to the Red Hat cloud'
12
+ 'Enable automatic upload of your hosts inventory to the Red Hat cloud'
13
13
  )}
14
14
  />
15
15
  <Switch
@@ -9,7 +9,7 @@ exports[`AutoUploadSwitcher rendering render with props 1`] = `
9
9
  </span>
10
10
  <FieldLevelHelp
11
11
  buttonClass=""
12
- content="Enable automatic upload of your host inventory to the Red Hat cloud"
12
+ content="Enable automatic upload of your hosts inventory to the Red Hat cloud"
13
13
  placement="top"
14
14
  rootClose={true}
15
15
  />
@@ -67,7 +67,7 @@ export const setActiveTab = (accountID, tabName) => ({
67
67
  });
68
68
 
69
69
  export const downloadReports = accountID => {
70
- window.open(inventoryUrl(`${accountID}/uploads/file`), '_blank');
70
+ window.location.href = inventoryUrl(`${accountID}/uploads/file`);
71
71
  return {
72
72
  type: INVENTORY_REPORTS_DOWNLOAD,
73
73
  payload: {
@@ -36,15 +36,15 @@ const fixtures = {
36
36
  };
37
37
 
38
38
  describe('Dashboard actions', () => {
39
- const { open } = window;
39
+ const { location } = window;
40
40
 
41
41
  beforeAll(() => {
42
- delete window.open;
43
- window.open = jest.fn();
42
+ delete window.location;
43
+ window.location = { href: jest.fn() };
44
44
  });
45
45
 
46
46
  afterAll(() => {
47
- window.open = open;
47
+ window.location = location;
48
48
  });
49
49
 
50
50
  return testActionSnapshotWithFixtures(fixtures);
@@ -0,0 +1,92 @@
1
+ import React, { useEffect } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Text, TextVariants, Popover, Button } from '@patternfly/react-core';
4
+ import { InfoAltIcon, CaretRightIcon } from '@patternfly/react-icons';
5
+ import { FormGroup, Grid } from 'patternfly-react';
6
+ import { translate as __ } from 'foremanReact/common/I18n';
7
+ import { foremanUrl } from '../../../ForemanRhCloudHelpers';
8
+ import Switcher from '../../../common/Switcher';
9
+ import AdvancedSettings from './components/AdvancedSettings';
10
+
11
+ const InventoryAutoUploadSwitcher = ({
12
+ autoUploadEnabled,
13
+ handleToggle,
14
+ fetchSettings,
15
+ }) => {
16
+ useEffect(() => {
17
+ fetchSettings();
18
+ }, [fetchSettings]);
19
+
20
+ return (
21
+ <FormGroup>
22
+ <Grid>
23
+ <h3>{__('Red Hat Cloud Inventory')}</h3>
24
+ <hr />
25
+ <Grid.Row>
26
+ <Switcher
27
+ id="auto-upload"
28
+ label={__('Inventory Auto Upload')}
29
+ tooltip={__(
30
+ 'Enable automatic upload of your hosts inventory to the Red Hat cloud'
31
+ )}
32
+ isChecked={autoUploadEnabled}
33
+ onChange={() => handleToggle(autoUploadEnabled)}
34
+ labelCol={5}
35
+ />
36
+
37
+ <Grid.Col sm={5}>
38
+ <Popover
39
+ headerContent={<strong>Advanced Inventory Settings</strong>}
40
+ bodyContent={
41
+ <AdvancedSettings
42
+ autoUploadEnabled={autoUploadEnabled}
43
+ handleToggle={handleToggle}
44
+ />
45
+ }
46
+ position="right"
47
+ >
48
+ <Button
49
+ variant="secondary"
50
+ style={{ fontSize: 'small', marginTop: '-4px' }}
51
+ >
52
+ {__('Show Advanced Settings')} <CaretRightIcon />
53
+ </Button>
54
+ </Popover>
55
+ </Grid.Col>
56
+ </Grid.Row>
57
+ <br />
58
+ <Grid.Row>
59
+ <Grid.Col sm={12}>
60
+ <Text component={TextVariants.p}>
61
+ <InfoAltIcon /> {__('More details can be found in')}{' '}
62
+ <Text
63
+ component={TextVariants.a}
64
+ href={foremanUrl('/foreman_rh_cloud/inventory_upload')}
65
+ target="_blank"
66
+ rel="noopener noreferrer"
67
+ >
68
+ <strong>
69
+ {__('Configure')}
70
+ {' > '}
71
+ {__('Inventory Upload')}
72
+ </strong>
73
+ </Text>
74
+ </Text>
75
+ </Grid.Col>
76
+ </Grid.Row>
77
+ </Grid>
78
+ </FormGroup>
79
+ );
80
+ };
81
+
82
+ InventoryAutoUploadSwitcher.propTypes = {
83
+ autoUploadEnabled: PropTypes.bool,
84
+ handleToggle: PropTypes.func.isRequired,
85
+ fetchSettings: PropTypes.func.isRequired,
86
+ };
87
+
88
+ InventoryAutoUploadSwitcher.defaultProps = {
89
+ autoUploadEnabled: true,
90
+ };
91
+
92
+ export default InventoryAutoUploadSwitcher;
@@ -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
+ `;