foreman_rh_cloud 3.0.14 → 3.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -0
- data/app/controllers/foreman_inventory_upload/uploads_controller.rb +11 -0
- data/app/controllers/insights_cloud/hits_controller.rb +24 -0
- data/app/controllers/insights_cloud/settings_controller.rb +8 -0
- data/app/models/insights_hit.rb +5 -1
- data/app/models/setting/rh_cloud.rb +8 -6
- data/app/overrides/layouts/base/styles.html.erb.deface +2 -0
- data/app/services/foreman_rh_cloud/cloud_connector.rb +59 -0
- data/app/views/layouts/foreman_rh_cloud/application.html.erb +0 -4
- data/config/Gemfile.lock.gh_test +830 -0
- data/config/database.yml.example +17 -0
- data/config/package-lock.json.gh_test +35653 -0
- data/config/routes.rb +12 -3
- data/lib/foreman_inventory_upload.rb +1 -1
- data/lib/foreman_inventory_upload/generators/archived_report.rb +1 -1
- data/lib/foreman_rh_cloud/engine.rb +15 -5
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/tasks/rh_cloud_inventory.rake +23 -0
- data/package.json +18 -17
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +3 -2
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +33 -15
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +43 -43
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.js +6 -7
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatusHelper.js +5 -4
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/__snapshots__/ListItemStatus.test.js.snap +19 -34
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +3 -3
- data/webpack/ForemanInventoryUpload/Components/AccountList/accountList.scss +28 -5
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.js +6 -9
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcherActions.test.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcher.test.js.snap +5 -28
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.js +6 -9
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherActions.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcherActions.test.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcher.test.js.snap +5 -28
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/integration.test.js.snap +5 -0
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/integration.test.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.js +6 -9
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherActions.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcherActions.test.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcher.test.js.snap +5 -28
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterReducer.js +6 -3
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +5 -0
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/{inventorySettings.scss → InventorySettings.scss} +2 -5
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettings.test.js.snap +1 -1
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.js +6 -8
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherActions.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcherActions.test.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcher.test.js.snap +5 -28
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +10 -18
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.scss +19 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageTitle.js +53 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/{components/DocsButton/__tests__/DocsButton.test.js → __tests__/PageTitle.test.js} +3 -3
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +12 -38
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap +43 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorActions.js +27 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js +51 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorConstants.js +6 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorSelectors.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorActions.test.js +9 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorButton.test.js +22 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorActions.test.js.snap +11 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorButton.test.js.snap +48 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/index.js +27 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js +7 -9
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButton.test.js.snap +7 -9
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js +2 -4
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/__snapshots__/ToolbarButtons.test.js.snap +1 -2
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/toolbarButtons.scss +1 -2
- data/webpack/ForemanInventoryUpload/Components/Terminal/terminal.scss +1 -0
- data/webpack/ForemanInventoryUpload/ForemanInventoryConstants.js +2 -2
- data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +8 -14
- data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryUpload.test.js.snap +7 -10
- data/webpack/ForemanRhCloudPages.js +19 -0
- data/webpack/InsightsCloudSync/Components/InsightsHeader/InsightsHeader.scss +4 -0
- data/webpack/InsightsCloudSync/Components/InsightsHeader/index.js +16 -0
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js +1 -1
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsActions.test.js +2 -2
- data/webpack/InsightsCloudSync/Components/InsightsSettings/insightsSettings.scss +1 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTable.js +121 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableActions.js +129 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableConstants.js +55 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js +31 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableReducer.js +28 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableSelectors.js +74 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/SelectAllAlert.js +65 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTable.test.js +13 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableSelectors.test.js +58 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTable.test.js.snap +168 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableSelectors.test.js.snap +88 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/fixtures.js +104 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/components/EmptyState.js +53 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/index.js +45 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/table.scss +1 -0
- data/webpack/InsightsCloudSync/Components/NoTokenEmptyState.js +79 -0
- data/webpack/InsightsCloudSync/Components/__tests__/InsightsHeader.test.js +10 -0
- data/webpack/InsightsCloudSync/Components/__tests__/NoTokenEmptyState.test.js +19 -0
- data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/InsightsHeader.test.js.snap +13 -0
- data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/NoTokenEmptyState.test.js.snap +214 -0
- data/webpack/InsightsCloudSync/InsightsCloudSync.js +45 -44
- data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +10 -2
- data/webpack/InsightsCloudSync/InsightsCloudSyncActions.js +1 -1
- data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +15 -1
- data/webpack/InsightsCloudSync/InsightsCloudSyncHelpers.js +7 -0
- data/webpack/InsightsCloudSync/InsightsCloudSyncReducers.js +2 -0
- data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +45 -62
- data/webpack/InsightsCloudSync/index.js +11 -3
- data/webpack/InsightsHostDetailsTab/InsightsTabActions.js +1 -1
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabActions.test.js +2 -2
- data/webpack/__mocks__/foremanReact/Root/Context/ForemanContext.js +1 -0
- data/webpack/__mocks__/foremanReact/constants.js +19 -0
- data/webpack/__mocks__/foremanReact/redux/API/APISelectors.js +24 -0
- data/webpack/__mocks__/foremanReact/redux/API/index.js +11 -0
- data/webpack/__mocks__/foremanReact/routes/RouterSelector.js +2 -0
- data/webpack/__mocks__/foremanReact/routes/common/PageLayout/PageLayout.js +10 -0
- data/webpack/common/Switcher/HelpLabel.js +30 -0
- data/webpack/common/Switcher/SwitcherPF4.js +36 -0
- data/webpack/common/Switcher/SwitcherPF4.scss +10 -0
- data/webpack/common/Switcher/__tests__/HelpLabel.test.js +13 -0
- data/webpack/common/Switcher/__tests__/SwitcherPF4.test.js +14 -0
- data/webpack/common/Switcher/__tests__/__snapshots__/HelpLabel.test.js.snap +20 -0
- data/webpack/common/Switcher/__tests__/__snapshots__/SwitcherPF4.test.js.snap +22 -0
- data/webpack/global_index.js +2 -0
- metadata +96 -34
- data/app/controllers/foreman_rh_cloud/react_controller.rb +0 -11
- data/app/views/foreman_rh_cloud/react/insights_cloud.html.erb +0 -1
- data/app/views/foreman_rh_cloud/react/inventory_upload.html.erb +0 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/listItem.scss +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/listItemStatus.scss +0 -16
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/autoUploadSwitcher.scss +0 -3
- data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/excludePackagesSwitcher.scss +0 -3
- data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.scss +0 -3
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/DocsButton.js +0 -18
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/__tests__/__snapshots__/DocsButton.test.js.snap +0 -21
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/HistoryButton.js +0 -19
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/__tests__/HistoryButton.test.js +0 -12
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/__tests__/__snapshots__/HistoryButton.test.js.snap +0 -22
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/pageHeader.scss +0 -3
- data/webpack/__mocks__/foremanReact/API.js +0 -7
@@ -0,0 +1,14 @@
|
|
1
|
+
import { selectAPIResponse } from 'foremanReact/redux/API/APISelectors';
|
2
|
+
|
3
|
+
import {
|
4
|
+
CONFIGURE_CLOUD_CONNECTOR,
|
5
|
+
CONNECTOR_STATUS,
|
6
|
+
} from './CloudConnectorConstants';
|
7
|
+
|
8
|
+
export const selectStatus = state =>
|
9
|
+
selectAPIResponse(state, CONFIGURE_CLOUD_CONNECTOR)?.result === 'success'
|
10
|
+
? CONNECTOR_STATUS.RESOLVED
|
11
|
+
: CONNECTOR_STATUS.NOT_RESOLVED;
|
12
|
+
|
13
|
+
export const selectJobLink = state =>
|
14
|
+
selectAPIResponse(state, CONFIGURE_CLOUD_CONNECTOR).job_link || '';
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { testActionSnapshotWithFixtures } from '@theforeman/test';
|
2
|
+
import { configureCloudConnector } from '../CloudConnectorActions';
|
3
|
+
|
4
|
+
const fixtures = {
|
5
|
+
'should configureCloudConnector': () => configureCloudConnector(),
|
6
|
+
};
|
7
|
+
|
8
|
+
describe('CloudConnector button actions', () =>
|
9
|
+
testActionSnapshotWithFixtures(fixtures));
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
2
|
+
import { CloudConnectorButton } from '../CloudConnectorButton';
|
3
|
+
import { CONNECTOR_STATUS } from '../CloudConnectorConstants';
|
4
|
+
|
5
|
+
const fixtures = {
|
6
|
+
'render no cloud connector': {
|
7
|
+
status: CONNECTOR_STATUS.NOT_RESOLVED,
|
8
|
+
onClick: jest.fn(),
|
9
|
+
},
|
10
|
+
'render resolved cloud connector': {
|
11
|
+
status: CONNECTOR_STATUS.RESOLVED,
|
12
|
+
onClick: jest.fn(),
|
13
|
+
},
|
14
|
+
'render pending connector': {
|
15
|
+
jobLink: '/job-link',
|
16
|
+
status: CONNECTOR_STATUS.PENDING,
|
17
|
+
onClick: jest.fn(),
|
18
|
+
},
|
19
|
+
};
|
20
|
+
|
21
|
+
describe('CloudConnectorButton', () =>
|
22
|
+
testComponentSnapshotsWithFixtures(CloudConnectorButton, fixtures));
|
@@ -0,0 +1,11 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`CloudConnector button actions should configureCloudConnector 1`] = `
|
4
|
+
Object {
|
5
|
+
"errorToast": [Function],
|
6
|
+
"key": "CONFIGURE_CLOUD_CONNECTOR",
|
7
|
+
"successToast": [Function],
|
8
|
+
"type": "post-some-type",
|
9
|
+
"url": "/foreman_inventory_upload/cloud_connector",
|
10
|
+
}
|
11
|
+
`;
|
@@ -0,0 +1,48 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`CloudConnectorButton render no cloud connector 1`] = `
|
4
|
+
<Button
|
5
|
+
onClick={[MockFunction]}
|
6
|
+
variant="secondary"
|
7
|
+
>
|
8
|
+
Configure Cloud Connector
|
9
|
+
</Button>
|
10
|
+
`;
|
11
|
+
|
12
|
+
exports[`CloudConnectorButton render pending connector 1`] = `
|
13
|
+
<Popover
|
14
|
+
aria-label="Popover with Link to cloud connector job"
|
15
|
+
bodyContent={
|
16
|
+
<div>
|
17
|
+
Cloud connector job is still running, you can view it here:
|
18
|
+
<a
|
19
|
+
href="/job-link"
|
20
|
+
rel="noopener noreferrer"
|
21
|
+
target="_blank"
|
22
|
+
>
|
23
|
+
Open job
|
24
|
+
</a>
|
25
|
+
</div>
|
26
|
+
}
|
27
|
+
closeBtnAriaLabel="Close cloud connector Popover"
|
28
|
+
>
|
29
|
+
<Button
|
30
|
+
variant="secondary"
|
31
|
+
>
|
32
|
+
<Spinner
|
33
|
+
size="sm"
|
34
|
+
/>
|
35
|
+
|
36
|
+
Cloud Connector in progress
|
37
|
+
</Button>
|
38
|
+
</Popover>
|
39
|
+
`;
|
40
|
+
|
41
|
+
exports[`CloudConnectorButton render resolved cloud connector 1`] = `
|
42
|
+
<Button
|
43
|
+
isDisabled={true}
|
44
|
+
variant="secondary"
|
45
|
+
>
|
46
|
+
Cloud Connector is configured
|
47
|
+
</Button>
|
48
|
+
`;
|
data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/index.js
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
import React, { useEffect } from 'react';
|
2
|
+
import { useSelector, useDispatch } from 'react-redux';
|
3
|
+
import { CloudConnectorButton } from './CloudConnectorButton';
|
4
|
+
import {
|
5
|
+
configureCloudConnector,
|
6
|
+
getCloudConnector,
|
7
|
+
} from './CloudConnectorActions';
|
8
|
+
import { selectStatus, selectJobLink } from './CloudConnectorSelectors';
|
9
|
+
|
10
|
+
const ConnectedCloudConnectorButton = () => {
|
11
|
+
const status = useSelector(selectStatus);
|
12
|
+
const jobLink = useSelector(selectJobLink);
|
13
|
+
const dispatch = useDispatch();
|
14
|
+
|
15
|
+
useEffect(() => {
|
16
|
+
dispatch(getCloudConnector());
|
17
|
+
}, [dispatch]);
|
18
|
+
return (
|
19
|
+
<CloudConnectorButton
|
20
|
+
status={status}
|
21
|
+
onClick={() => dispatch(configureCloudConnector())}
|
22
|
+
jobLink={jobLink}
|
23
|
+
/>
|
24
|
+
);
|
25
|
+
};
|
26
|
+
|
27
|
+
export default ConnectedCloudConnectorButton;
|
data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import PropTypes from 'prop-types';
|
3
|
-
import {
|
3
|
+
import { Spinner, Button } from '@patternfly/react-core';
|
4
|
+
import { ExclamationTriangleIcon, RedoIcon } from '@patternfly/react-icons';
|
4
5
|
import { STATUS } from 'foremanReact/constants';
|
5
6
|
import SyncModal from './components/Modal';
|
6
7
|
import { SYNC_BUTTON_TEXT } from '../../../../ForemanInventoryConstants';
|
@@ -24,19 +25,16 @@ class SyncButton extends React.Component {
|
|
24
25
|
<Button
|
25
26
|
className="sync_button"
|
26
27
|
onClick={handleClick}
|
27
|
-
|
28
|
-
|
28
|
+
size="lg"
|
29
|
+
isDisabled={status === STATUS.PENDING}
|
30
|
+
variant="secondary"
|
29
31
|
>
|
30
32
|
{!cloudToken && (
|
31
33
|
<span>
|
32
|
-
<
|
34
|
+
<ExclamationTriangleIcon />{' '}
|
33
35
|
</span>
|
34
36
|
)}
|
35
|
-
{status === STATUS.PENDING ?
|
36
|
-
<Spinner loading size="xs" />
|
37
|
-
) : (
|
38
|
-
<Icon name="refresh" />
|
39
|
-
)}
|
37
|
+
{status === STATUS.PENDING ? <Spinner size="sm" /> : <RedoIcon />}
|
40
38
|
{SYNC_BUTTON_TEXT}
|
41
39
|
</Button>
|
42
40
|
</React.Fragment>
|
data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import API from 'foremanReact/API';
|
2
|
+
import { API } from 'foremanReact/redux/API';
|
3
3
|
import { addToast } from 'foremanReact/redux/actions/toasts';
|
4
4
|
import { inventoryUrl } from '../../../../ForemanInventoryHelpers';
|
5
5
|
import Toast from './components/Toast';
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { testActionSnapshotWithFixtures } from '@theforeman/test';
|
2
|
-
import API from 'foremanReact/API';
|
2
|
+
import { API } from 'foremanReact/redux/API';
|
3
3
|
import { handleSync } from '../SyncButtonActions';
|
4
4
|
import { successResponse } from './SyncButtonFixtures';
|
5
5
|
|
6
|
-
jest.mock('foremanReact/API');
|
6
|
+
jest.mock('foremanReact/redux/API');
|
7
7
|
API.post.mockImplementation(async () => successResponse);
|
8
8
|
|
9
9
|
const fixtures = {
|
@@ -7,18 +7,16 @@ exports[`SyncButton rendering render with Props 1`] = `
|
|
7
7
|
toggleModal={[Function]}
|
8
8
|
/>
|
9
9
|
<Button
|
10
|
-
active={false}
|
11
|
-
block={false}
|
12
|
-
bsClass="btn"
|
13
|
-
bsSize="lg"
|
14
|
-
bsStyle="default"
|
15
10
|
className="sync_button"
|
16
|
-
|
11
|
+
isDisabled={false}
|
17
12
|
onClick={[Function]}
|
13
|
+
size="lg"
|
14
|
+
variant="secondary"
|
18
15
|
>
|
19
|
-
<
|
20
|
-
|
21
|
-
|
16
|
+
<RedoIcon
|
17
|
+
color="currentColor"
|
18
|
+
noVerticalAlign={false}
|
19
|
+
size="sm"
|
22
20
|
/>
|
23
21
|
Sync inventory status
|
24
22
|
</Button>
|
@@ -1,14 +1,12 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import DocsButton from '../DocsButton';
|
3
|
-
import HistoryButton from '../HistoryButton';
|
4
2
|
import SyncButton from '../SyncButton';
|
3
|
+
import CloudConnectorButton from '../CloudConnectorButton';
|
5
4
|
import './toolbarButtons.scss';
|
6
5
|
|
7
6
|
const ToolbarButtons = () => (
|
8
7
|
<div className="inventory_toolbar_buttons">
|
8
|
+
<CloudConnectorButton />
|
9
9
|
<SyncButton />
|
10
|
-
<HistoryButton />
|
11
|
-
<DocsButton />
|
12
10
|
</div>
|
13
11
|
);
|
14
12
|
|
@@ -2,8 +2,8 @@ import { translate as __ } from 'foremanReact/common/I18n';
|
|
2
2
|
|
3
3
|
export const INVENTORY_PAGE_TITLE = __('Red Hat Inventory');
|
4
4
|
|
5
|
-
export const DOCS_BUTTON_TEXT = __('
|
5
|
+
export const DOCS_BUTTON_TEXT = __('Documentation');
|
6
6
|
|
7
|
-
export const ACTIONS_HISTORY_BUTTON_TEXT = __('
|
7
|
+
export const ACTIONS_HISTORY_BUTTON_TEXT = __('Actions history');
|
8
8
|
|
9
9
|
export const SYNC_BUTTON_TEXT = __(' Sync inventory status');
|
@@ -1,21 +1,15 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import
|
3
|
-
import { Grid } from 'patternfly-react';
|
2
|
+
import PageLayout from 'foremanReact/routes/common/PageLayout/PageLayout';
|
4
3
|
import AccountList from './Components/AccountList';
|
5
4
|
import PageHeader from './Components/PageHeader';
|
6
|
-
import { INVENTORY_PAGE_TITLE } from './ForemanInventoryConstants';
|
7
5
|
|
8
|
-
const ForemanInventoryUpload = () =>
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
</Grid>
|
16
|
-
</IntlProvider>
|
17
|
-
);
|
18
|
-
};
|
6
|
+
const ForemanInventoryUpload = () => (
|
7
|
+
<div className="rh-cloud-page">
|
8
|
+
<PageLayout searchable={false} beforeToolbarComponent={<PageHeader />}>
|
9
|
+
<AccountList />
|
10
|
+
</PageLayout>
|
11
|
+
</div>
|
12
|
+
);
|
19
13
|
|
20
14
|
ForemanInventoryUpload.propTypes = {};
|
21
15
|
|
data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryUpload.test.js.snap
CHANGED
@@ -1,17 +1,14 @@
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
2
|
|
3
3
|
exports[`ForemanInventoryUpload render without Props 1`] = `
|
4
|
-
<
|
5
|
-
|
4
|
+
<div
|
5
|
+
className="rh-cloud-page"
|
6
6
|
>
|
7
|
-
<
|
8
|
-
|
9
|
-
|
10
|
-
componentClass="div"
|
11
|
-
fluid={true}
|
7
|
+
<PageLayout
|
8
|
+
beforeToolbarComponent={<PageHeader />}
|
9
|
+
searchable={false}
|
12
10
|
>
|
13
|
-
<PageHeader />
|
14
11
|
<Connect(AccountList) />
|
15
|
-
</
|
16
|
-
</
|
12
|
+
</PageLayout>
|
13
|
+
</div>
|
17
14
|
`;
|
@@ -1,4 +1,6 @@
|
|
1
|
+
import React from 'react';
|
1
2
|
import componentRegistry from 'foremanReact/components/componentRegistry';
|
3
|
+
import { registerRoutes as foremanRegisterRoutes } from 'foremanReact/routes/RoutingService';
|
2
4
|
import ForemanInventoryUpload from './ForemanInventoryUpload';
|
3
5
|
import InsightsCloudSync from './InsightsCloudSync';
|
4
6
|
import InsightsHostDetailsTab from './InsightsHostDetailsTab';
|
@@ -12,3 +14,20 @@ const pages = [
|
|
12
14
|
export const registerPages = () => {
|
13
15
|
pages.forEach(page => componentRegistry.register(page));
|
14
16
|
};
|
17
|
+
|
18
|
+
export const routes = [
|
19
|
+
{
|
20
|
+
path: '/foreman_rh_cloud/insights_cloud',
|
21
|
+
exact: true,
|
22
|
+
render: props => <InsightsCloudSync {...props} />,
|
23
|
+
},
|
24
|
+
{
|
25
|
+
path: '/foreman_rh_cloud/inventory_upload',
|
26
|
+
exact: true,
|
27
|
+
render: props => <ForemanInventoryUpload {...props} />,
|
28
|
+
},
|
29
|
+
];
|
30
|
+
|
31
|
+
export const registerRoutes = () => {
|
32
|
+
foremanRegisterRoutes('foreman_rh_cloud', routes);
|
33
|
+
};
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
3
|
+
import InsightsSettings from '../InsightsSettings';
|
4
|
+
import './InsightsHeader.scss';
|
5
|
+
|
6
|
+
const InsightsHeader = () => (
|
7
|
+
<div className="insights-header">
|
8
|
+
<InsightsSettings />
|
9
|
+
<p>
|
10
|
+
{__(`Insights synchronization process is used to provide Insights
|
11
|
+
recommendations output for hosts managed here`)}
|
12
|
+
</p>
|
13
|
+
</div>
|
14
|
+
);
|
15
|
+
|
16
|
+
export default InsightsHeader;
|
data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsActions.test.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { testActionSnapshotWithFixtures } from '@theforeman/test';
|
2
|
-
import API from 'foremanReact/API';
|
2
|
+
import { API } from 'foremanReact/redux/API';
|
3
3
|
import {
|
4
4
|
getInsightsSyncSettings,
|
5
5
|
setInsightsSyncEnabled,
|
@@ -10,7 +10,7 @@ const serverMock = {
|
|
10
10
|
data: { insightsSyncEnabled: true },
|
11
11
|
};
|
12
12
|
|
13
|
-
jest.mock('foremanReact/API');
|
13
|
+
jest.mock('foremanReact/redux/API');
|
14
14
|
API.get.mockImplementation(() => serverMock);
|
15
15
|
API.patch.mockImplementation(() => serverMock);
|
16
16
|
|
@@ -0,0 +1,121 @@
|
|
1
|
+
/* eslint-disable react-hooks/exhaustive-deps */
|
2
|
+
import React, { useEffect } from 'react';
|
3
|
+
import PropTypes from 'prop-types';
|
4
|
+
import { Pagination, PaginationVariant } from '@patternfly/react-core';
|
5
|
+
import { Table, TableHeader, TableBody } from '@patternfly/react-table';
|
6
|
+
import { useForemanSettings } from 'foremanReact/Root/Context/ForemanContext';
|
7
|
+
import SelectAllAlert from './SelectAllAlert';
|
8
|
+
import { columns, actions } from './InsightsTableConstants';
|
9
|
+
import TableEmptyState from './components/EmptyState';
|
10
|
+
import {
|
11
|
+
modifySelectedRows,
|
12
|
+
getSortColumnIndex,
|
13
|
+
getPerPageOptions,
|
14
|
+
} from './InsightsTableHelpers';
|
15
|
+
import './table.scss';
|
16
|
+
|
17
|
+
const InsightsTable = ({
|
18
|
+
page,
|
19
|
+
perPage: urlPerPage,
|
20
|
+
status,
|
21
|
+
sortBy,
|
22
|
+
sortOrder,
|
23
|
+
hits,
|
24
|
+
query,
|
25
|
+
itemCount,
|
26
|
+
fetchInsights,
|
27
|
+
onTableSetPage,
|
28
|
+
onTablePerPageSelect,
|
29
|
+
onTableSort,
|
30
|
+
onTableSelect,
|
31
|
+
selectedIds,
|
32
|
+
showSelectAllAlert,
|
33
|
+
selectAll,
|
34
|
+
clearAllSelection,
|
35
|
+
error,
|
36
|
+
isAllSelected,
|
37
|
+
}) => {
|
38
|
+
const { perPage: appPerPage } = useForemanSettings();
|
39
|
+
const perPage = urlPerPage || appPerPage;
|
40
|
+
|
41
|
+
// acts as componentDidMount
|
42
|
+
useEffect(() => {
|
43
|
+
fetchInsights({ page, perPage, query, sortBy, sortOrder });
|
44
|
+
}, []);
|
45
|
+
|
46
|
+
return (
|
47
|
+
<React.Fragment>
|
48
|
+
<SelectAllAlert
|
49
|
+
itemCount={itemCount}
|
50
|
+
selectedIds={selectedIds}
|
51
|
+
showSelectAllAlert={showSelectAllAlert}
|
52
|
+
selectAll={selectAll}
|
53
|
+
clearAllSelection={clearAllSelection}
|
54
|
+
isAllSelected={isAllSelected}
|
55
|
+
/>
|
56
|
+
<Table
|
57
|
+
aria-label="Recommendations Table"
|
58
|
+
onSelect={(_event, isSelected, rowId) =>
|
59
|
+
onTableSelect(_event, isSelected, rowId, hits, selectedIds)
|
60
|
+
}
|
61
|
+
canSelectAll
|
62
|
+
sortBy={{ index: getSortColumnIndex(sortBy), direction: sortOrder }}
|
63
|
+
onSort={onTableSort}
|
64
|
+
cells={columns}
|
65
|
+
rows={modifySelectedRows(hits, selectedIds)}
|
66
|
+
actions={actions}
|
67
|
+
>
|
68
|
+
<TableHeader />
|
69
|
+
<TableBody />
|
70
|
+
</Table>
|
71
|
+
<TableEmptyState status={status} error={error} />
|
72
|
+
<Pagination
|
73
|
+
itemCount={itemCount}
|
74
|
+
widgetId="recommendation-pagination"
|
75
|
+
perPage={perPage}
|
76
|
+
page={page}
|
77
|
+
variant={PaginationVariant.bottom}
|
78
|
+
onSetPage={onTableSetPage}
|
79
|
+
onPerPageSelect={onTablePerPageSelect}
|
80
|
+
perPageOptions={getPerPageOptions(urlPerPage, appPerPage)}
|
81
|
+
/>
|
82
|
+
</React.Fragment>
|
83
|
+
);
|
84
|
+
};
|
85
|
+
|
86
|
+
InsightsTable.propTypes = {
|
87
|
+
page: PropTypes.number,
|
88
|
+
perPage: PropTypes.number,
|
89
|
+
status: PropTypes.string,
|
90
|
+
sortBy: PropTypes.string,
|
91
|
+
sortOrder: PropTypes.string,
|
92
|
+
hits: PropTypes.array.isRequired,
|
93
|
+
itemCount: PropTypes.number.isRequired,
|
94
|
+
onTableSetPage: PropTypes.func.isRequired,
|
95
|
+
onTablePerPageSelect: PropTypes.func.isRequired,
|
96
|
+
onTableSort: PropTypes.func.isRequired,
|
97
|
+
onTableSelect: PropTypes.func.isRequired,
|
98
|
+
selectedIds: PropTypes.object,
|
99
|
+
showSelectAllAlert: PropTypes.bool,
|
100
|
+
selectAll: PropTypes.func.isRequired,
|
101
|
+
clearAllSelection: PropTypes.func.isRequired,
|
102
|
+
fetchInsights: PropTypes.func.isRequired,
|
103
|
+
query: PropTypes.string,
|
104
|
+
error: PropTypes.string,
|
105
|
+
isAllSelected: PropTypes.bool,
|
106
|
+
};
|
107
|
+
|
108
|
+
InsightsTable.defaultProps = {
|
109
|
+
page: 1,
|
110
|
+
perPage: null,
|
111
|
+
status: null,
|
112
|
+
sortBy: '',
|
113
|
+
sortOrder: '',
|
114
|
+
selectedIds: {},
|
115
|
+
showSelectAllAlert: false,
|
116
|
+
query: '',
|
117
|
+
error: '',
|
118
|
+
isAllSelected: false,
|
119
|
+
};
|
120
|
+
|
121
|
+
export default InsightsTable;
|