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.
- checksums.yaml +4 -4
- data/app/controllers/foreman_inventory_upload/accounts_controller.rb +2 -0
- data/app/controllers/foreman_inventory_upload/uploads_controller.rb +18 -0
- data/app/helpers/foreman_inventory_upload_host_helper.rb +2 -10
- data/app/models/concerns/rh_cloud_host.rb +4 -1
- data/app/models/insights_hit.rb +1 -1
- data/app/models/setting/rh_cloud.rb +2 -0
- data/app/overrides/hosts_list.rb +1 -1
- data/app/services/foreman_rh_cloud/cloud_auth.rb +28 -0
- data/app/views/foreman_rh_cloud/react/insights_cloud.html.erb +1 -6
- data/app/views/foreman_rh_cloud/react/inventory_upload.html.erb +1 -1
- data/app/views/hosts/_insights_tab.html.erb +1 -7
- data/app/views/layouts/foreman_rh_cloud/application.html.erb +0 -1
- data/config/routes.rb +2 -0
- data/db/migrate/20201007115752_add_hits_count_to_insights_facets_table.foreman_rh_cloud.rb +5 -0
- data/db/migrate/20201007121540_setup_hits_count_cache.foreman_rh_cloud.rb +10 -0
- data/lib/foreman_inventory_upload/async/upload_report_job.rb +2 -32
- data/lib/foreman_inventory_upload/generators/fact_helpers.rb +35 -0
- data/lib/foreman_inventory_upload/generators/json_stream.rb +7 -2
- data/lib/foreman_inventory_upload/generators/queries.rb +2 -0
- data/lib/foreman_inventory_upload/generators/slice.rb +27 -25
- data/lib/foreman_rh_cloud.rb +55 -0
- data/lib/foreman_rh_cloud/engine.rb +6 -4
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/insights_cloud/async/insights_full_sync.rb +5 -24
- data/lib/inventory_sync/async/inventory_full_sync.rb +3 -22
- data/lib/tasks/rh_cloud_inventory.rake +12 -10
- data/package.json +1 -1
- data/test/unit/fact_helpers_test.rb +22 -0
- data/test/unit/insights_facet_test.rb +7 -0
- data/test/unit/rh_cloud_http_proxy_test.rb +65 -0
- data/test/unit/slice_generator_test.rb +147 -2
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +14 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +22 -18
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +16 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +6 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +7 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +12 -8
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +9 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +19 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +11 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +6 -0
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.fixtures.js +2 -0
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js +10 -11
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherConstants.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcherActions.test.js +12 -2
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcher.test.js.snap +1 -1
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcherActions.test.js.snap +17 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.fixtures.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.js +30 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherActions.js +29 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherConstants.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcher.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcherActions.test.js +21 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcher.test.js.snap +38 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcherActions.test.js.snap +31 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/integration.test.js.snap +41 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/integration.test.js +36 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/excludePackagesSwitcher.scss +3 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/index.js +20 -0
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.fixtures.js +2 -1
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.scss +3 -0
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherActions.js +10 -11
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherConstants.js +0 -2
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcherActions.test.js +12 -2
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcherActions.test.js.snap +18 -1
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.js +4 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettings.test.js.snap +2 -0
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.fixtures.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.js +29 -0
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherActions.js +29 -0
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherConstants.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcher.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcherActions.test.js +21 -0
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcher.test.js.snap +38 -0
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcherActions.test.js.snap +31 -0
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/index.js +20 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js +8 -2
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +9 -11
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonConstants.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonReducer.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js +18 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonReducer.test.js +1 -8
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonActions.test.js.snap +62 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonReducer.test.js.snap +0 -7
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.js +6 -1
- data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +2 -4
- data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +8 -0
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/InventoryAutoUpload.js +92 -0
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/InventoryAutoUpload.test.js +17 -0
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/__snapshots__/InventoryAutoUpload.test.js.snap +106 -0
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/AdvancedSettings.js +60 -0
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/index.js +28 -0
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/index.js +22 -0
- data/webpack/ForemanRhCloudFills.js +23 -0
- data/webpack/ForemanRhCloudPages.js +6 -1
- data/webpack/ForemanRhCloudReducers.js +10 -1
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js +17 -20
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsConstants.js +0 -6
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsReducer.js +0 -4
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsActions.test.js +16 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsReducer.test.js +1 -24
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsActions.test.js.snap +38 -4
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettingsReducer.test.js.snap +0 -14
- data/webpack/InsightsCloudSync/InsightsCloudSync.js +3 -5
- data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +1 -3
- data/webpack/InsightsCloudSync/InsightsCloudSyncActions.js +10 -11
- data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +0 -2
- data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +1 -1
- data/webpack/InsightsHostDetailsTab/InsightsTab.js +13 -13
- data/webpack/InsightsHostDetailsTab/InsightsTab.scss +2 -2
- data/webpack/InsightsHostDetailsTab/InsightsTabActions.js +9 -8
- data/webpack/InsightsHostDetailsTab/InsightsTabConstants.js +0 -1
- data/webpack/InsightsHostDetailsTab/InsightsTabReducer.js +2 -9
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTab.fixtures.js +12 -14
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabActions.test.js +7 -1
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabReducer.test.js +0 -9
- data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTab.test.js.snap +26 -22
- data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabActions.test.js.snap +38 -2
- data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabReducer.test.js.snap +10 -19
- data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabSelectors.test.js.snap +10 -12
- data/webpack/__mocks__/foremanReact/common/MountingService.js +1 -0
- data/webpack/common/Switcher/index.js +79 -0
- data/webpack/global_index.js +5 -0
- data/webpack/index.js +4 -14
- metadata +54 -20
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/hostObfuscationSwitcher.scss +0 -0
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js +0 -34
- data/webpack/subscriptions_extension_index.js +0 -8
@@ -1,6 +1,6 @@
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
2
|
|
3
|
-
exports[`InsightsSettings actions should generate
|
3
|
+
exports[`InsightsSettings actions should generate INSIGHTS_SYNC_SETTING_SET action 1`] = `
|
4
4
|
Array [
|
5
5
|
Array [
|
6
6
|
Object {
|
@@ -9,13 +9,13 @@ Array [
|
|
9
9
|
"insightsSyncEnabled": true,
|
10
10
|
},
|
11
11
|
},
|
12
|
-
"type": "
|
12
|
+
"type": "INSIGHTS_SYNC_SETTING_SET",
|
13
13
|
},
|
14
14
|
],
|
15
15
|
]
|
16
16
|
`;
|
17
17
|
|
18
|
-
exports[`InsightsSettings actions should generate
|
18
|
+
exports[`InsightsSettings actions should generate INSIGHTS_SYNC_SETTINGS_GET_SUCCESS action 1`] = `
|
19
19
|
Array [
|
20
20
|
Array [
|
21
21
|
Object {
|
@@ -24,7 +24,41 @@ Array [
|
|
24
24
|
"insightsSyncEnabled": true,
|
25
25
|
},
|
26
26
|
},
|
27
|
-
"type": "
|
27
|
+
"type": "INSIGHTS_SYNC_SETTINGS_GET_SUCCESS",
|
28
|
+
},
|
29
|
+
],
|
30
|
+
]
|
31
|
+
`;
|
32
|
+
|
33
|
+
exports[`InsightsSettings actions should handle getInsightsSyncSettings with error 1`] = `
|
34
|
+
Array [
|
35
|
+
Array [
|
36
|
+
Object {
|
37
|
+
"payload": Object {
|
38
|
+
"message": Object {
|
39
|
+
"message": "Network error!",
|
40
|
+
"sticky": true,
|
41
|
+
"type": "error",
|
42
|
+
},
|
43
|
+
},
|
44
|
+
"type": "TOASTS_ADD",
|
45
|
+
},
|
46
|
+
],
|
47
|
+
]
|
48
|
+
`;
|
49
|
+
|
50
|
+
exports[`InsightsSettings actions should handle setInsightsSyncEnabled with error 1`] = `
|
51
|
+
Array [
|
52
|
+
Array [
|
53
|
+
Object {
|
54
|
+
"payload": Object {
|
55
|
+
"message": Object {
|
56
|
+
"message": "Network error!",
|
57
|
+
"sticky": true,
|
58
|
+
"type": "error",
|
59
|
+
},
|
60
|
+
},
|
61
|
+
"type": "TOASTS_ADD",
|
28
62
|
},
|
29
63
|
],
|
30
64
|
]
|
@@ -6,20 +6,6 @@ Object {
|
|
6
6
|
}
|
7
7
|
`;
|
8
8
|
|
9
|
-
exports[`InsightsSettings reducer should handle INSIGHTS_SYNC_SETTING_SET_FAILURE 1`] = `
|
10
|
-
Object {
|
11
|
-
"error": "test set error",
|
12
|
-
"insightsSyncEnabled": false,
|
13
|
-
}
|
14
|
-
`;
|
15
|
-
|
16
|
-
exports[`InsightsSettings reducer should handle INSIGHTS_SYNC_SETTINGS_GET_FAILURE 1`] = `
|
17
|
-
Object {
|
18
|
-
"error": "test error",
|
19
|
-
"insightsSyncEnabled": false,
|
20
|
-
}
|
21
|
-
`;
|
22
|
-
|
23
9
|
exports[`InsightsSettings reducer should handle INSIGHTS_SYNC_SETTINGS_GET_SUCCESS 1`] = `
|
24
10
|
Object {
|
25
11
|
"insightsSyncEnabled": true,
|
@@ -6,7 +6,7 @@ import { Button, Icon } from 'patternfly-react';
|
|
6
6
|
import { INSIGHTS_SYNC_PAGE_TITLE } from './InsightsCloudSyncConstants';
|
7
7
|
import InsightsSettings from './Components/InsightsSettings';
|
8
8
|
|
9
|
-
const InsightsCloudSync = ({
|
9
|
+
const InsightsCloudSync = ({ settingsUrl, syncInsights }) => {
|
10
10
|
document.title = INSIGHTS_SYNC_PAGE_TITLE;
|
11
11
|
return (
|
12
12
|
<IntlProvider locale={navigator.language}>
|
@@ -19,7 +19,7 @@ const InsightsCloudSync = ({ data: { settingsUrl }, syncInsights }) => {
|
|
19
19
|
recommendations output for hosts managed here`)}
|
20
20
|
</p>
|
21
21
|
<p>
|
22
|
-
{__(`1. Obtain an
|
22
|
+
{__(`1. Obtain an Red Hat API token: `)}
|
23
23
|
<a
|
24
24
|
href="https://access.redhat.com/management/api"
|
25
25
|
target="_blank"
|
@@ -51,9 +51,7 @@ const InsightsCloudSync = ({ data: { settingsUrl }, syncInsights }) => {
|
|
51
51
|
|
52
52
|
InsightsCloudSync.propTypes = {
|
53
53
|
syncInsights: PropTypes.func.isRequired,
|
54
|
-
|
55
|
-
settingsUrl: PropTypes.string.isRequired,
|
56
|
-
}).isRequired,
|
54
|
+
settingsUrl: PropTypes.string.isRequired,
|
57
55
|
};
|
58
56
|
|
59
57
|
export default InsightsCloudSync;
|
@@ -1,9 +1,7 @@
|
|
1
1
|
import API from 'foremanReact/API';
|
2
|
+
import { addToast } from 'foremanReact/redux/actions/toasts';
|
2
3
|
import { insightsCloudUrl } from './InsightsCloudSyncHelpers';
|
3
|
-
import {
|
4
|
-
INSIGHTS_CLOUD_SYNC_SUCCESS,
|
5
|
-
INSIGHTS_CLOUD_SYNC_FAILURE,
|
6
|
-
} from './InsightsCloudSyncConstants';
|
4
|
+
import { INSIGHTS_CLOUD_SYNC_SUCCESS } from './InsightsCloudSyncConstants';
|
7
5
|
|
8
6
|
export const syncInsights = () => async dispatch => {
|
9
7
|
try {
|
@@ -12,12 +10,13 @@ export const syncInsights = () => async dispatch => {
|
|
12
10
|
type: INSIGHTS_CLOUD_SYNC_SUCCESS,
|
13
11
|
payload: {},
|
14
12
|
});
|
15
|
-
} catch (
|
16
|
-
dispatch(
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
13
|
+
} catch ({ message }) {
|
14
|
+
dispatch(
|
15
|
+
addToast({
|
16
|
+
sticky: true,
|
17
|
+
type: 'error',
|
18
|
+
message,
|
19
|
+
})
|
20
|
+
);
|
22
21
|
}
|
23
22
|
};
|
@@ -1,6 +1,4 @@
|
|
1
1
|
import { translate as __ } from 'foremanReact/common/I18n';
|
2
2
|
|
3
3
|
export const INSIGHTS_CLOUD_SYNC_SUCCESS = 'INSIGHTS_CLOUD_SYNC_SUCCESS';
|
4
|
-
export const INSIGHTS_CLOUD_SYNC_FAILURE = 'INSIGHTS_CLOUD_SYNC_FAILURE';
|
5
|
-
|
6
4
|
export const INSIGHTS_SYNC_PAGE_TITLE = __('Red Hat Insights cloud sync');
|
@@ -17,16 +17,14 @@ class InsightsHostDetailsTab extends React.Component {
|
|
17
17
|
if (!hits.length) {
|
18
18
|
return <h2>No recommendations were found for this host!</h2>;
|
19
19
|
}
|
20
|
-
const hitsSorted = orderBy(hits, ['
|
20
|
+
const hitsSorted = orderBy(hits, ['total_risk'], ['desc']);
|
21
21
|
const items = hitsSorted.map(
|
22
22
|
(
|
23
23
|
{
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
solution_url: solutionUrl,
|
29
|
-
},
|
24
|
+
title,
|
25
|
+
total_risk: totalRisk,
|
26
|
+
results_url: resultsUrl,
|
27
|
+
solution_url: solutionUrl,
|
30
28
|
},
|
31
29
|
index
|
32
30
|
) => (
|
@@ -40,12 +38,14 @@ class InsightsHostDetailsTab extends React.Component {
|
|
40
38
|
)
|
41
39
|
);
|
42
40
|
return (
|
43
|
-
<
|
44
|
-
<Grid.
|
45
|
-
<
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
<div id="host_details_insights_tab">
|
42
|
+
<Grid.Row>
|
43
|
+
<Grid.Col xs={12}>
|
44
|
+
<h2>Recommendations</h2>
|
45
|
+
<ListView id="hits_list">{items}</ListView>
|
46
|
+
</Grid.Col>
|
47
|
+
</Grid.Row>
|
48
|
+
</div>
|
49
49
|
);
|
50
50
|
}
|
51
51
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
#host_details_insights_tab {
|
2
2
|
#btn_toolbar {
|
3
3
|
float: right;
|
4
4
|
}
|
@@ -77,7 +77,7 @@
|
|
77
77
|
}
|
78
78
|
|
79
79
|
&::-webkit-scrollbar-thumb {
|
80
|
-
background: #
|
80
|
+
background: #222;
|
81
81
|
border-radius: 6px;
|
82
82
|
border: 3px solid transparent;
|
83
83
|
background-clip: content-box;
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import API from 'foremanReact/API';
|
2
|
+
import { addToast } from 'foremanReact/redux/actions/toasts';
|
2
3
|
import { insightsCloudUrl } from '../InsightsCloudSync/InsightsCloudSyncHelpers';
|
3
4
|
import {
|
4
5
|
INSIGHTS_HITS_REQUEST,
|
5
6
|
INSIGHTS_HITS_SUCCESS,
|
6
|
-
INSIGHTS_HITS_FAILURE,
|
7
7
|
} from './InsightsTabConstants';
|
8
8
|
|
9
9
|
export const fetchHits = hostID => async dispatch => {
|
@@ -19,12 +19,13 @@ export const fetchHits = hostID => async dispatch => {
|
|
19
19
|
type: INSIGHTS_HITS_SUCCESS,
|
20
20
|
payload: { hits },
|
21
21
|
});
|
22
|
-
} catch (
|
23
|
-
dispatch(
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
} catch ({ message }) {
|
23
|
+
dispatch(
|
24
|
+
addToast({
|
25
|
+
sticky: true,
|
26
|
+
type: 'error',
|
27
|
+
message,
|
28
|
+
})
|
29
|
+
);
|
29
30
|
}
|
30
31
|
};
|
@@ -1,25 +1,18 @@
|
|
1
1
|
import Immutable from 'seamless-immutable';
|
2
|
-
import {
|
3
|
-
INSIGHTS_HITS_SUCCESS,
|
4
|
-
INSIGHTS_HITS_FAILURE,
|
5
|
-
} from './InsightsTabConstants';
|
2
|
+
import { INSIGHTS_HITS_SUCCESS } from './InsightsTabConstants';
|
6
3
|
|
7
4
|
const initialState = Immutable({
|
8
5
|
hits: [],
|
9
6
|
});
|
10
7
|
|
11
8
|
export default (state = initialState, action) => {
|
12
|
-
const { payload: { hits
|
9
|
+
const { payload: { hits } = {} } = action;
|
13
10
|
|
14
11
|
switch (action.type) {
|
15
12
|
case INSIGHTS_HITS_SUCCESS:
|
16
13
|
return state.merge({
|
17
14
|
hits,
|
18
15
|
});
|
19
|
-
case INSIGHTS_HITS_FAILURE:
|
20
|
-
return state.merge({
|
21
|
-
error,
|
22
|
-
});
|
23
16
|
default:
|
24
17
|
return state;
|
25
18
|
}
|
@@ -2,20 +2,18 @@ export const hostID = 1234;
|
|
2
2
|
|
3
3
|
export const hits = [
|
4
4
|
{
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
'https://cloud.redhat.com/insights/advisor/recommendations/ansible_deprecated_repo%7CANSIBLE_DEPRECATED_REPO/4739b323-a343-4e89-b71b-81991b8dc656/',
|
18
|
-
},
|
5
|
+
hostname: 'my-host.example.com',
|
6
|
+
rhel_version: '7.8',
|
7
|
+
uuid: '4739b323-a343-4e89-b71b-81991b8dc656',
|
8
|
+
last_seen: '2020-08-19T04:43:09.068706Z',
|
9
|
+
title:
|
10
|
+
'New Ansible Engine packages are inaccessible when dedicated Ansible repo is not enabled',
|
11
|
+
solution_url: 'https://access.redhat.com/node/3359651',
|
12
|
+
total_risk: 2,
|
13
|
+
likelihood: 2,
|
14
|
+
publish_date: '2018-04-16T10:03:16Z',
|
15
|
+
results_url:
|
16
|
+
'https://cloud.redhat.com/insights/advisor/recommendations/ansible_deprecated_repo%7CANSIBLE_DEPRECATED_REPO/4739b323-a343-4e89-b71b-81991b8dc656/',
|
19
17
|
},
|
20
18
|
];
|
21
19
|
|
@@ -4,10 +4,16 @@ import { fetchHits } from '../InsightsTabActions';
|
|
4
4
|
import { hostID, hits } from './InsightsTab.fixtures';
|
5
5
|
|
6
6
|
jest.mock('foremanReact/API');
|
7
|
-
API.get.mockImplementation(async () => hits);
|
7
|
+
API.get.mockImplementation(async () => ({ data: { hits } }));
|
8
8
|
|
9
9
|
const fixtures = {
|
10
10
|
'should fetchHits': () => fetchHits(hostID),
|
11
|
+
'should fetchHits with error': () => {
|
12
|
+
API.get.mockImplementationOnce(() =>
|
13
|
+
Promise.reject(new Error('Network error!'))
|
14
|
+
);
|
15
|
+
return fetchHits(hostID);
|
16
|
+
},
|
11
17
|
};
|
12
18
|
|
13
19
|
describe('InsightsTab actions', () => testActionSnapshotWithFixtures(fixtures));
|
@@ -4,7 +4,6 @@ import { hits } from './InsightsTab.fixtures';
|
|
4
4
|
import {
|
5
5
|
INSIGHTS_HITS_REQUEST,
|
6
6
|
INSIGHTS_HITS_SUCCESS,
|
7
|
-
INSIGHTS_HITS_FAILURE,
|
8
7
|
} from '../InsightsTabConstants';
|
9
8
|
|
10
9
|
const fixtures = {
|
@@ -21,14 +20,6 @@ const fixtures = {
|
|
21
20
|
payload: { hits },
|
22
21
|
},
|
23
22
|
},
|
24
|
-
'should handle INSIGHTS_HITS_FAILURE': {
|
25
|
-
action: {
|
26
|
-
type: INSIGHTS_HITS_FAILURE,
|
27
|
-
payload: {
|
28
|
-
error: 'some-error',
|
29
|
-
},
|
30
|
-
},
|
31
|
-
},
|
32
23
|
};
|
33
24
|
|
34
25
|
describe('AccountList reducer', () =>
|
@@ -1,30 +1,34 @@
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
2
|
|
3
3
|
exports[`InsightsTab rendering render with props 1`] = `
|
4
|
-
<
|
5
|
-
|
6
|
-
componentClass="div"
|
4
|
+
<div
|
5
|
+
id="host_details_insights_tab"
|
7
6
|
>
|
8
|
-
<
|
9
|
-
bsClass="
|
7
|
+
<Row
|
8
|
+
bsClass="row"
|
10
9
|
componentClass="div"
|
11
|
-
xs={12}
|
12
10
|
>
|
13
|
-
<
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
className=""
|
18
|
-
id="hits_list"
|
11
|
+
<Col
|
12
|
+
bsClass="col"
|
13
|
+
componentClass="div"
|
14
|
+
xs={12}
|
19
15
|
>
|
20
|
-
<
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
16
|
+
<h2>
|
17
|
+
Recommendations
|
18
|
+
</h2>
|
19
|
+
<ListView
|
20
|
+
className=""
|
21
|
+
id="hits_list"
|
22
|
+
>
|
23
|
+
<ListItem
|
24
|
+
key="0"
|
25
|
+
resultsUrl="https://cloud.redhat.com/insights/advisor/recommendations/ansible_deprecated_repo%7CANSIBLE_DEPRECATED_REPO/4739b323-a343-4e89-b71b-81991b8dc656/"
|
26
|
+
solutionUrl="https://access.redhat.com/node/3359651"
|
27
|
+
title="New Ansible Engine packages are inaccessible when dedicated Ansible repo is not enabled"
|
28
|
+
totalRisk={2}
|
29
|
+
/>
|
30
|
+
</ListView>
|
31
|
+
</Col>
|
32
|
+
</Row>
|
33
|
+
</div>
|
30
34
|
`;
|
@@ -11,9 +11,45 @@ Array [
|
|
11
11
|
Array [
|
12
12
|
Object {
|
13
13
|
"payload": Object {
|
14
|
-
"
|
14
|
+
"hits": Array [
|
15
|
+
Object {
|
16
|
+
"hostname": "my-host.example.com",
|
17
|
+
"last_seen": "2020-08-19T04:43:09.068706Z",
|
18
|
+
"likelihood": 2,
|
19
|
+
"publish_date": "2018-04-16T10:03:16Z",
|
20
|
+
"results_url": "https://cloud.redhat.com/insights/advisor/recommendations/ansible_deprecated_repo%7CANSIBLE_DEPRECATED_REPO/4739b323-a343-4e89-b71b-81991b8dc656/",
|
21
|
+
"rhel_version": "7.8",
|
22
|
+
"solution_url": "https://access.redhat.com/node/3359651",
|
23
|
+
"title": "New Ansible Engine packages are inaccessible when dedicated Ansible repo is not enabled",
|
24
|
+
"total_risk": 2,
|
25
|
+
"uuid": "4739b323-a343-4e89-b71b-81991b8dc656",
|
26
|
+
},
|
27
|
+
],
|
15
28
|
},
|
16
|
-
"type": "
|
29
|
+
"type": "INSIGHTS_HITS_SUCCESS",
|
30
|
+
},
|
31
|
+
],
|
32
|
+
]
|
33
|
+
`;
|
34
|
+
|
35
|
+
exports[`InsightsTab actions should fetchHits with error 1`] = `
|
36
|
+
Array [
|
37
|
+
Array [
|
38
|
+
Object {
|
39
|
+
"payload": Object {},
|
40
|
+
"type": "INSIGHTS_HITS_REQUEST",
|
41
|
+
},
|
42
|
+
],
|
43
|
+
Array [
|
44
|
+
Object {
|
45
|
+
"payload": Object {
|
46
|
+
"message": Object {
|
47
|
+
"message": "Network error!",
|
48
|
+
"sticky": true,
|
49
|
+
"type": "error",
|
50
|
+
},
|
51
|
+
},
|
52
|
+
"type": "TOASTS_ADD",
|
17
53
|
},
|
18
54
|
],
|
19
55
|
]
|