foreman_rh_cloud 2.0.10 → 2.0.11

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 (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +27 -2
  3. data/app/controllers/insights_cloud/hits_controller.rb +17 -0
  4. data/app/models/concerns/rh_cloud_host.rb +12 -0
  5. data/app/views/hosts/_insights_tab.html.erb +15 -0
  6. data/config/routes.rb +1 -0
  7. data/lib/foreman_inventory_upload/async/generate_report_job.rb +1 -1
  8. data/lib/foreman_inventory_upload/async/shell_process.rb +15 -9
  9. data/lib/foreman_inventory_upload/async/upload_report_job.rb +19 -1
  10. data/lib/foreman_inventory_upload/generators/metadata.rb +3 -0
  11. data/lib/foreman_inventory_upload/generators/queries.rb +2 -4
  12. data/lib/foreman_rh_cloud/engine.rb +10 -0
  13. data/lib/foreman_rh_cloud/version.rb +1 -1
  14. data/lib/tasks/insights.rake +15 -0
  15. data/lib/tasks/{generator.rake → rh_cloud_inventory.rake} +7 -1
  16. data/package.json +3 -1
  17. data/test/jobs/upload_report_job_test.rb +34 -0
  18. data/test/unit/metadata_generator_test.rb +2 -0
  19. data/test/unit/slice_generator_test.rb +17 -0
  20. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterReducer.js +13 -2
  21. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/InventoryFilterReducer.test.js +10 -1
  22. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/InventoryFilterReducer.test.js.snap +6 -0
  23. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +3 -0
  24. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Toast.js +1 -1
  25. data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChart.js +1 -1
  26. data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/__snapshots__/StatusChart.test.js.snap +1 -1
  27. data/webpack/ForemanInventoryUpload/Components/TabContainer/tabContainer.scss +1 -1
  28. data/webpack/ForemanRhCloudPages.js +2 -0
  29. data/webpack/ForemanRhCloudReducers.js +2 -0
  30. data/webpack/ForemanRhCloudSelectors.js +5 -0
  31. data/webpack/ForemanRhCloudTestHelpers.js +6 -1
  32. data/webpack/InsightsHostDetailsTab/InsightsTab.js +64 -0
  33. data/webpack/InsightsHostDetailsTab/InsightsTab.scss +86 -0
  34. data/webpack/InsightsHostDetailsTab/InsightsTabActions.js +30 -0
  35. data/webpack/InsightsHostDetailsTab/InsightsTabConstants.js +3 -0
  36. data/webpack/InsightsHostDetailsTab/InsightsTabReducer.js +26 -0
  37. data/webpack/InsightsHostDetailsTab/InsightsTabSelectors.js +3 -0
  38. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTab.fixtures.js +25 -0
  39. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTab.test.js +13 -0
  40. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabActions.test.js +13 -0
  41. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabIntegration.test.js +17 -0
  42. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabReducer.test.js +35 -0
  43. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabSelectors.test.js +13 -0
  44. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTab.test.js.snap +30 -0
  45. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabActions.test.js.snap +20 -0
  46. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabReducer.test.js.snap +41 -0
  47. data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabSelectors.test.js.snap +20 -0
  48. data/webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js +69 -0
  49. data/webpack/InsightsHostDetailsTab/components/ListItem/index.js +1 -0
  50. data/webpack/InsightsHostDetailsTab/index.js +20 -0
  51. data/webpack/__mocks__/foremanReact/components/Layout/LayoutConstants.js +1 -0
  52. data/webpack/__tests__/__snapshots__/ForemanRhCloudSelectors.test.js.snap +1 -0
  53. data/webpack/__tests__/__snapshots__/ForemanRhCloudTestHelpers.test.js.snap +3 -0
  54. metadata +38 -13
@@ -0,0 +1,13 @@
1
+ import { testSelectorsSnapshotWithFixtures } from '@theforeman/test';
2
+ import { hostInsightsStateWrapper } from '../../ForemanRhCloudTestHelpers';
3
+ import { hits } from './InsightsTab.fixtures';
4
+ import { selectHits } from '../InsightsTabSelectors';
5
+
6
+ const state = hostInsightsStateWrapper({ hits });
7
+
8
+ const fixtures = {
9
+ 'should return hits': () => selectHits(state),
10
+ };
11
+
12
+ describe('InsightsTab selectors', () =>
13
+ testSelectorsSnapshotWithFixtures(fixtures));
@@ -0,0 +1,30 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`InsightsTab rendering render with props 1`] = `
4
+ <Row
5
+ bsClass="row"
6
+ componentClass="div"
7
+ >
8
+ <Col
9
+ bsClass="col"
10
+ componentClass="div"
11
+ xs={12}
12
+ >
13
+ <h2>
14
+ Recommendations
15
+ </h2>
16
+ <ListView
17
+ className=""
18
+ id="hits_list"
19
+ >
20
+ <ListItem
21
+ key="0"
22
+ resultsUrl="https://cloud.redhat.com/insights/advisor/recommendations/ansible_deprecated_repo%7CANSIBLE_DEPRECATED_REPO/4739b323-a343-4e89-b71b-81991b8dc656/"
23
+ solutionUrl="https://access.redhat.com/node/3359651"
24
+ title="New Ansible Engine packages are inaccessible when dedicated Ansible repo is not enabled"
25
+ totalRisk={2}
26
+ />
27
+ </ListView>
28
+ </Col>
29
+ </Row>
30
+ `;
@@ -0,0 +1,20 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`InsightsTab actions should fetchHits 1`] = `
4
+ Array [
5
+ Array [
6
+ Object {
7
+ "payload": Object {},
8
+ "type": "INSIGHTS_HITS_REQUEST",
9
+ },
10
+ ],
11
+ Array [
12
+ Object {
13
+ "payload": Object {
14
+ "error": "Cannot read property 'hits' of undefined",
15
+ },
16
+ "type": "INSIGHTS_HITS_FAILURE",
17
+ },
18
+ ],
19
+ ]
20
+ `;
@@ -0,0 +1,41 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`AccountList reducer should handle INSIGHTS_HITS_FAILURE 1`] = `
4
+ Object {
5
+ "error": "some-error",
6
+ "hits": Array [],
7
+ }
8
+ `;
9
+
10
+ exports[`AccountList reducer should handle INSIGHTS_HITS_REQUEST 1`] = `
11
+ Object {
12
+ "hits": Array [],
13
+ }
14
+ `;
15
+
16
+ exports[`AccountList reducer should handle INSIGHTS_HITS_SUCCESS 1`] = `
17
+ Object {
18
+ "hits": Array [
19
+ Object {
20
+ "insights_hit": Object {
21
+ "hostname": "my-host.example.com",
22
+ "last_seen": "2020-08-19T04:43:09.068706Z",
23
+ "likelihood": 2,
24
+ "publish_date": "2018-04-16T10:03:16Z",
25
+ "results_url": "https://cloud.redhat.com/insights/advisor/recommendations/ansible_deprecated_repo%7CANSIBLE_DEPRECATED_REPO/4739b323-a343-4e89-b71b-81991b8dc656/",
26
+ "rhel_version": "7.8",
27
+ "solution_url": "https://access.redhat.com/node/3359651",
28
+ "title": "New Ansible Engine packages are inaccessible when dedicated Ansible repo is not enabled",
29
+ "total_risk": 2,
30
+ "uuid": "4739b323-a343-4e89-b71b-81991b8dc656",
31
+ },
32
+ },
33
+ ],
34
+ }
35
+ `;
36
+
37
+ exports[`AccountList reducer should return the initial state 1`] = `
38
+ Object {
39
+ "hits": Array [],
40
+ }
41
+ `;
@@ -0,0 +1,20 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`InsightsTab selectors should return hits 1`] = `
4
+ Array [
5
+ Object {
6
+ "insights_hit": Object {
7
+ "hostname": "my-host.example.com",
8
+ "last_seen": "2020-08-19T04:43:09.068706Z",
9
+ "likelihood": 2,
10
+ "publish_date": "2018-04-16T10:03:16Z",
11
+ "results_url": "https://cloud.redhat.com/insights/advisor/recommendations/ansible_deprecated_repo%7CANSIBLE_DEPRECATED_REPO/4739b323-a343-4e89-b71b-81991b8dc656/",
12
+ "rhel_version": "7.8",
13
+ "solution_url": "https://access.redhat.com/node/3359651",
14
+ "title": "New Ansible Engine packages are inaccessible when dedicated Ansible repo is not enabled",
15
+ "total_risk": 2,
16
+ "uuid": "4739b323-a343-4e89-b71b-81991b8dc656",
17
+ },
18
+ },
19
+ ]
20
+ `;
@@ -0,0 +1,69 @@
1
+ import React, { Fragment } from 'react';
2
+ import { ListView, Icon } from 'patternfly-react';
3
+ import PropTypes from 'prop-types';
4
+
5
+ const labelMapper = {
6
+ 1: 'Low',
7
+ 2: 'Moderate',
8
+ 3: 'Important',
9
+ 4: 'Critical',
10
+ };
11
+
12
+ const ListItem = ({ title, totalRisk, resultsUrl, solutionUrl }) => {
13
+ const heading = (
14
+ <p className="ellipsis list-item-heading" title={title}>
15
+ {title}
16
+ </p>
17
+ );
18
+
19
+ const riskLabel = labelMapper[totalRisk];
20
+ const additionalInfo = [
21
+ <span key={`risk-info-${title}`} className={`risk-label ${riskLabel}`}>
22
+ <p>{riskLabel}</p>
23
+ </span>,
24
+ ];
25
+
26
+ const knowledgebaseLink = solutionUrl && (
27
+ <p>
28
+ <a href={solutionUrl} target="_blank" rel="noopener noreferrer">
29
+ Knowledgebase article <Icon name="external-link" />
30
+ </a>
31
+ </p>
32
+ );
33
+
34
+ const insightsCloudLink = resultsUrl && (
35
+ <p>
36
+ <a href={resultsUrl} target="_blank" rel="noopener noreferrer">
37
+ Read more about it in RH cloud insights <Icon name="external-link" />
38
+ </a>
39
+ </p>
40
+ );
41
+
42
+ return (
43
+ <ListView.Item
44
+ heading={heading}
45
+ additionalInfo={additionalInfo}
46
+ hideCloseIcon
47
+ >
48
+ <Fragment>
49
+ <p>{title}</p>
50
+ {knowledgebaseLink}
51
+ {insightsCloudLink}
52
+ </Fragment>
53
+ </ListView.Item>
54
+ );
55
+ };
56
+
57
+ ListItem.propTypes = {
58
+ title: PropTypes.string.isRequired,
59
+ totalRisk: PropTypes.number.isRequired,
60
+ resultsUrl: PropTypes.string,
61
+ solutionUrl: PropTypes.string,
62
+ };
63
+
64
+ ListItem.defaultProps = {
65
+ resultsUrl: '',
66
+ solutionUrl: '',
67
+ };
68
+
69
+ export default ListItem;
@@ -0,0 +1 @@
1
+ export { default } from './ListItem';
@@ -0,0 +1,20 @@
1
+ import { bindActionCreators } from 'redux';
2
+ import { connect } from 'react-redux';
3
+ import InsightsTab from './InsightsTab';
4
+ import * as actions from './InsightsTabActions';
5
+ import reducer from './InsightsTabReducer';
6
+ import { selectHits } from './InsightsTabSelectors';
7
+
8
+ // map state to props
9
+ const mapStateToProps = state => ({
10
+ hits: selectHits(state),
11
+ });
12
+
13
+ // map action dispatchers to props
14
+ const mapDispatchToProps = dispatch => bindActionCreators(actions, dispatch);
15
+
16
+ // export reducers
17
+ export const hostInsightsReducers = { hostInsights: reducer };
18
+
19
+ // export connected component
20
+ export default connect(mapStateToProps, mapDispatchToProps)(InsightsTab);
@@ -1 +1,2 @@
1
1
  export const LAYOUT_CHANGE_ORG = 'LAYOUT_CHANGE_ORG';
2
+ export const LAYOUT_INITIALIZE = 'LAYOUT_INITIALIZE';
@@ -11,6 +11,7 @@ Object {
11
11
  "InsightsCloudSync": Object {
12
12
  "insightsChild": Object {},
13
13
  },
14
+ "hostInsights": Object {},
14
15
  "inventoryUpload": Object {
15
16
  "inventoryChild": Object {},
16
17
  },
@@ -6,6 +6,7 @@ Object {
6
6
  "InsightsCloudSync": Object {
7
7
  "insightsChild": Object {},
8
8
  },
9
+ "hostInsights": Object {},
9
10
  "inventoryUpload": Object {},
10
11
  },
11
12
  }
@@ -15,6 +16,7 @@ exports[`ForemanRhCloud helpers should return inventory wrapper 1`] = `
15
16
  Object {
16
17
  "ForemanRhCloud": Object {
17
18
  "InsightsCloudSync": Object {},
19
+ "hostInsights": Object {},
18
20
  "inventoryUpload": Object {
19
21
  "inventoryChild": Object {},
20
22
  },
@@ -28,6 +30,7 @@ Object {
28
30
  "InsightsCloudSync": Object {
29
31
  "insightsChild": Object {},
30
32
  },
33
+ "hostInsights": Object {},
31
34
  "inventoryUpload": Object {
32
35
  "inventoryChild": Object {},
33
36
  },
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_rh_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.10
4
+ version: 2.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Red Hat Cloud team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-04 00:00:00.000000000 Z
11
+ date: 2020-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: katello
@@ -109,10 +109,12 @@ files:
109
109
  - app/controllers/foreman_inventory_upload/tasks_controller.rb
110
110
  - app/controllers/foreman_inventory_upload/uploads_controller.rb
111
111
  - app/controllers/foreman_rh_cloud/react_controller.rb
112
+ - app/controllers/insights_cloud/hits_controller.rb
112
113
  - app/controllers/insights_cloud/settings_controller.rb
113
114
  - app/controllers/insights_cloud/tasks_controller.rb
114
115
  - app/helpers/foreman_inventory_upload_helper.rb
115
116
  - app/helpers/foreman_inventory_upload_host_helper.rb
117
+ - app/models/concerns/rh_cloud_host.rb
116
118
  - app/models/insights_facet.rb
117
119
  - app/models/insights_hit.rb
118
120
  - app/models/inventory_sync/inventory_status.rb
@@ -120,6 +122,7 @@ files:
120
122
  - app/overrides/hosts_list.rb
121
123
  - app/views/foreman_rh_cloud/react/insights_cloud.html.erb
122
124
  - app/views/foreman_rh_cloud/react/inventory_upload.html.erb
125
+ - app/views/hosts/_insights_tab.html.erb
123
126
  - app/views/layouts/foreman_rh_cloud/application.html.erb
124
127
  - config/routes.rb
125
128
  - db/migrate/20191215104806_create_insights_hits.foreman_inventory_upload.rb
@@ -150,7 +153,8 @@ files:
150
153
  - lib/inventory_sync/async/host_result.rb
151
154
  - lib/inventory_sync/async/inventory_full_sync.rb
152
155
  - lib/tasks/foreman_rh_cloud_tasks.rake
153
- - lib/tasks/generator.rake
156
+ - lib/tasks/insights.rake
157
+ - lib/tasks/rh_cloud_inventory.rake
154
158
  - locale/Makefile
155
159
  - locale/en/foreman_rh_cloud.po
156
160
  - locale/foreman_rh_cloud.pot
@@ -164,6 +168,7 @@ files:
164
168
  - test/factories/inventory_upload_factories.rb
165
169
  - test/jobs/insights_full_sync_test.rb
166
170
  - test/jobs/inventory_full_sync_test.rb
171
+ - test/jobs/upload_report_job_test.rb
167
172
  - test/test_plugin_helper.rb
168
173
  - test/unit/archived_report_generator_test.rb
169
174
  - test/unit/fact_helpers_test.rb
@@ -458,6 +463,25 @@ files:
458
463
  - webpack/InsightsCloudSync/__tests__/InsightsCloudSyncHelpers.test.js
459
464
  - webpack/InsightsCloudSync/__tests__/__snapshots__/InsightsCloudSyncHelpers.test.js.snap
460
465
  - webpack/InsightsCloudSync/index.js
466
+ - webpack/InsightsHostDetailsTab/InsightsTab.js
467
+ - webpack/InsightsHostDetailsTab/InsightsTab.scss
468
+ - webpack/InsightsHostDetailsTab/InsightsTabActions.js
469
+ - webpack/InsightsHostDetailsTab/InsightsTabConstants.js
470
+ - webpack/InsightsHostDetailsTab/InsightsTabReducer.js
471
+ - webpack/InsightsHostDetailsTab/InsightsTabSelectors.js
472
+ - webpack/InsightsHostDetailsTab/__tests__/InsightsTab.fixtures.js
473
+ - webpack/InsightsHostDetailsTab/__tests__/InsightsTab.test.js
474
+ - webpack/InsightsHostDetailsTab/__tests__/InsightsTabActions.test.js
475
+ - webpack/InsightsHostDetailsTab/__tests__/InsightsTabIntegration.test.js
476
+ - webpack/InsightsHostDetailsTab/__tests__/InsightsTabReducer.test.js
477
+ - webpack/InsightsHostDetailsTab/__tests__/InsightsTabSelectors.test.js
478
+ - webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTab.test.js.snap
479
+ - webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabActions.test.js.snap
480
+ - webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabReducer.test.js.snap
481
+ - webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabSelectors.test.js.snap
482
+ - webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js
483
+ - webpack/InsightsHostDetailsTab/components/ListItem/index.js
484
+ - webpack/InsightsHostDetailsTab/index.js
461
485
  - webpack/__mocks__/foremanReact/API.js
462
486
  - webpack/__mocks__/foremanReact/common/I18n.js
463
487
  - webpack/__mocks__/foremanReact/common/helpers.js
@@ -491,23 +515,24 @@ required_rubygems_version: !ruby/object:Gem::Requirement
491
515
  - !ruby/object:Gem::Version
492
516
  version: '0'
493
517
  requirements: []
494
- rubygems_version: 3.0.6
518
+ rubygems_version: 3.0.8
495
519
  signing_key:
496
520
  specification_version: 4
497
521
  summary: Summary of ForemanRhCloud.
498
522
  test_files:
499
- - test/controllers/uploads_controller_test.rb
500
- - test/controllers/insights_sync/settings_controller_test.rb
501
- - test/controllers/accounts_controller_test.rb
502
- - test/controllers/reports_controller_test.rb
503
523
  - test/test_plugin_helper.rb
504
- - test/jobs/insights_full_sync_test.rb
505
- - test/jobs/inventory_full_sync_test.rb
506
524
  - test/factories/inventory_upload_factories.rb
507
525
  - test/factories/insights_factories.rb
508
- - test/unit/shell_process_job_test.rb
526
+ - test/controllers/reports_controller_test.rb
527
+ - test/controllers/uploads_controller_test.rb
528
+ - test/controllers/accounts_controller_test.rb
529
+ - test/controllers/insights_sync/settings_controller_test.rb
530
+ - test/unit/slice_generator_test.rb
509
531
  - test/unit/metadata_generator_test.rb
532
+ - test/unit/shell_process_job_test.rb
510
533
  - test/unit/insights_facet_test.rb
511
- - test/unit/fact_helpers_test.rb
512
534
  - test/unit/archived_report_generator_test.rb
513
- - test/unit/slice_generator_test.rb
535
+ - test/unit/fact_helpers_test.rb
536
+ - test/jobs/inventory_full_sync_test.rb
537
+ - test/jobs/insights_full_sync_test.rb
538
+ - test/jobs/upload_report_job_test.rb