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.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -0
  3. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +11 -0
  4. data/app/controllers/insights_cloud/hits_controller.rb +24 -0
  5. data/app/controllers/insights_cloud/settings_controller.rb +8 -0
  6. data/app/models/insights_hit.rb +5 -1
  7. data/app/models/setting/rh_cloud.rb +8 -6
  8. data/app/overrides/layouts/base/styles.html.erb.deface +2 -0
  9. data/app/services/foreman_rh_cloud/cloud_connector.rb +59 -0
  10. data/app/views/layouts/foreman_rh_cloud/application.html.erb +0 -4
  11. data/config/Gemfile.lock.gh_test +830 -0
  12. data/config/database.yml.example +17 -0
  13. data/config/package-lock.json.gh_test +35653 -0
  14. data/config/routes.rb +12 -3
  15. data/lib/foreman_inventory_upload.rb +1 -1
  16. data/lib/foreman_inventory_upload/generators/archived_report.rb +1 -1
  17. data/lib/foreman_rh_cloud/engine.rb +15 -5
  18. data/lib/foreman_rh_cloud/version.rb +1 -1
  19. data/lib/tasks/rh_cloud_inventory.rake +23 -0
  20. data/package.json +18 -17
  21. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +3 -2
  22. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +1 -1
  23. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +33 -15
  24. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +43 -43
  25. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.js +6 -7
  26. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatusHelper.js +5 -4
  27. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/__snapshots__/ListItemStatus.test.js.snap +19 -34
  28. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +2 -2
  29. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +3 -3
  30. data/webpack/ForemanInventoryUpload/Components/AccountList/accountList.scss +28 -5
  31. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.js +6 -9
  32. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcherActions.js +1 -1
  33. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/AutoUploadSwitcherActions.test.js +2 -2
  34. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcher.test.js.snap +5 -28
  35. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +1 -1
  36. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +2 -2
  37. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcher.js +6 -9
  38. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/ExcludePackagesSwitcherActions.js +1 -1
  39. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/ExcludePackagesSwitcherActions.test.js +2 -2
  40. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/ExcludePackagesSwitcher.test.js.snap +5 -28
  41. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/__snapshots__/integration.test.js.snap +5 -0
  42. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/__tests__/integration.test.js +2 -2
  43. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.js +6 -9
  44. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcherActions.js +1 -1
  45. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/HostObfuscationSwitcherActions.test.js +2 -2
  46. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/__tests__/__snapshots__/HostObfuscationSwitcher.test.js.snap +5 -28
  47. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterReducer.js +6 -3
  48. data/webpack/ForemanInventoryUpload/Components/InventoryFilter/__tests__/__snapshots__/integration.test.js.snap +5 -0
  49. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.js +2 -2
  50. data/webpack/ForemanInventoryUpload/Components/InventorySettings/{inventorySettings.scss → InventorySettings.scss} +2 -5
  51. data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettings.test.js.snap +1 -1
  52. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcher.js +6 -8
  53. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/IpsObfuscationSwitcherActions.js +1 -1
  54. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/IpsObfuscationSwitcherActions.test.js +2 -2
  55. data/webpack/ForemanInventoryUpload/Components/IpsObfuscationSwitcher/__tests__/__snapshots__/IpsObfuscationSwitcher.test.js.snap +5 -28
  56. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +10 -18
  57. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.scss +19 -0
  58. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageTitle.js +53 -0
  59. data/webpack/ForemanInventoryUpload/Components/PageHeader/{components/DocsButton/__tests__/DocsButton.test.js → __tests__/PageTitle.test.js} +3 -3
  60. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageHeader.test.js.snap +12 -38
  61. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap +43 -0
  62. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorActions.js +27 -0
  63. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js +51 -0
  64. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorConstants.js +6 -0
  65. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorSelectors.js +14 -0
  66. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorActions.test.js +9 -0
  67. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorButton.test.js +22 -0
  68. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorActions.test.js.snap +11 -0
  69. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorButton.test.js.snap +48 -0
  70. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/index.js +27 -0
  71. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js +7 -9
  72. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +1 -1
  73. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButtonActions.test.js +2 -2
  74. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButton.test.js.snap +7 -9
  75. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js +2 -4
  76. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/__snapshots__/ToolbarButtons.test.js.snap +1 -2
  77. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/toolbarButtons.scss +1 -2
  78. data/webpack/ForemanInventoryUpload/Components/Terminal/terminal.scss +1 -0
  79. data/webpack/ForemanInventoryUpload/ForemanInventoryConstants.js +2 -2
  80. data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +8 -14
  81. data/webpack/ForemanInventoryUpload/__tests__/__snapshots__/ForemanInventoryUpload.test.js.snap +7 -10
  82. data/webpack/ForemanRhCloudPages.js +19 -0
  83. data/webpack/InsightsCloudSync/Components/InsightsHeader/InsightsHeader.scss +4 -0
  84. data/webpack/InsightsCloudSync/Components/InsightsHeader/index.js +16 -0
  85. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js +1 -1
  86. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettingsActions.test.js +2 -2
  87. data/webpack/InsightsCloudSync/Components/InsightsSettings/insightsSettings.scss +1 -0
  88. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTable.js +121 -0
  89. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableActions.js +129 -0
  90. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableConstants.js +55 -0
  91. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js +31 -0
  92. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableReducer.js +28 -0
  93. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableSelectors.js +74 -0
  94. data/webpack/InsightsCloudSync/Components/InsightsTable/SelectAllAlert.js +65 -0
  95. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTable.test.js +13 -0
  96. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableSelectors.test.js +58 -0
  97. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTable.test.js.snap +168 -0
  98. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableSelectors.test.js.snap +88 -0
  99. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/fixtures.js +104 -0
  100. data/webpack/InsightsCloudSync/Components/InsightsTable/components/EmptyState.js +53 -0
  101. data/webpack/InsightsCloudSync/Components/InsightsTable/index.js +45 -0
  102. data/webpack/InsightsCloudSync/Components/InsightsTable/table.scss +1 -0
  103. data/webpack/InsightsCloudSync/Components/NoTokenEmptyState.js +79 -0
  104. data/webpack/InsightsCloudSync/Components/__tests__/InsightsHeader.test.js +10 -0
  105. data/webpack/InsightsCloudSync/Components/__tests__/NoTokenEmptyState.test.js +19 -0
  106. data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/InsightsHeader.test.js.snap +13 -0
  107. data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/NoTokenEmptyState.test.js.snap +214 -0
  108. data/webpack/InsightsCloudSync/InsightsCloudSync.js +45 -44
  109. data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +10 -2
  110. data/webpack/InsightsCloudSync/InsightsCloudSyncActions.js +1 -1
  111. data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +15 -1
  112. data/webpack/InsightsCloudSync/InsightsCloudSyncHelpers.js +7 -0
  113. data/webpack/InsightsCloudSync/InsightsCloudSyncReducers.js +2 -0
  114. data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +45 -62
  115. data/webpack/InsightsCloudSync/index.js +11 -3
  116. data/webpack/InsightsHostDetailsTab/InsightsTabActions.js +1 -1
  117. data/webpack/InsightsHostDetailsTab/__tests__/InsightsTabActions.test.js +2 -2
  118. data/webpack/__mocks__/foremanReact/Root/Context/ForemanContext.js +1 -0
  119. data/webpack/__mocks__/foremanReact/constants.js +19 -0
  120. data/webpack/__mocks__/foremanReact/redux/API/APISelectors.js +24 -0
  121. data/webpack/__mocks__/foremanReact/redux/API/index.js +11 -0
  122. data/webpack/__mocks__/foremanReact/routes/RouterSelector.js +2 -0
  123. data/webpack/__mocks__/foremanReact/routes/common/PageLayout/PageLayout.js +10 -0
  124. data/webpack/common/Switcher/HelpLabel.js +30 -0
  125. data/webpack/common/Switcher/SwitcherPF4.js +36 -0
  126. data/webpack/common/Switcher/SwitcherPF4.scss +10 -0
  127. data/webpack/common/Switcher/__tests__/HelpLabel.test.js +13 -0
  128. data/webpack/common/Switcher/__tests__/SwitcherPF4.test.js +14 -0
  129. data/webpack/common/Switcher/__tests__/__snapshots__/HelpLabel.test.js.snap +20 -0
  130. data/webpack/common/Switcher/__tests__/__snapshots__/SwitcherPF4.test.js.snap +22 -0
  131. data/webpack/global_index.js +2 -0
  132. metadata +96 -34
  133. data/app/controllers/foreman_rh_cloud/react_controller.rb +0 -11
  134. data/app/views/foreman_rh_cloud/react/insights_cloud.html.erb +0 -1
  135. data/app/views/foreman_rh_cloud/react/inventory_upload.html.erb +0 -1
  136. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/listItem.scss +0 -0
  137. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/listItemStatus.scss +0 -16
  138. data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/autoUploadSwitcher.scss +0 -3
  139. data/webpack/ForemanInventoryUpload/Components/ExcludePackagesSwitcher/excludePackagesSwitcher.scss +0 -3
  140. data/webpack/ForemanInventoryUpload/Components/HostObfuscationSwitcher/HostObfuscationSwitcher.scss +0 -3
  141. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/DocsButton.js +0 -18
  142. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/__tests__/__snapshots__/DocsButton.test.js.snap +0 -21
  143. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/DocsButton/index.js +0 -1
  144. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/HistoryButton.js +0 -19
  145. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/__tests__/HistoryButton.test.js +0 -12
  146. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/__tests__/__snapshots__/HistoryButton.test.js.snap +0 -22
  147. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/HistoryButton/index.js +0 -1
  148. data/webpack/ForemanInventoryUpload/Components/PageHeader/pageHeader.scss +0 -3
  149. data/webpack/__mocks__/foremanReact/API.js +0 -7
@@ -0,0 +1 @@
1
+ @import '~@redhat-cloud-services/frontend-components/index.css';
@@ -0,0 +1,79 @@
1
+ import React, { useState } from 'react';
2
+ import { useDispatch } from 'react-redux';
3
+ import {
4
+ Button,
5
+ TextInput,
6
+ FormGroup,
7
+ GridItem,
8
+ Grid,
9
+ EmptyState,
10
+ EmptyStateIcon,
11
+ EmptyStateVariant,
12
+ EmptyStateBody,
13
+ } from '@patternfly/react-core';
14
+ import { ExternalLinkAltIcon, RocketIcon } from '@patternfly/react-icons';
15
+ import { post } from 'foremanReact/redux/API';
16
+ import { translate as __ } from 'foremanReact/common/I18n';
17
+ import { INSIGHTS_SAVE_AND_SYNC_PATH } from '../InsightsCloudSyncConstants';
18
+ import { INSIGHTS_HITS_API_KEY } from './InsightsTable/InsightsTableConstants';
19
+
20
+ export const NoTokenEmptyState = () => {
21
+ const [token, setToken] = useState('');
22
+ const dispatch = useDispatch();
23
+ const onSave = () => {
24
+ dispatch(
25
+ post({
26
+ key: INSIGHTS_HITS_API_KEY,
27
+ url: INSIGHTS_SAVE_AND_SYNC_PATH,
28
+ params: { value: token },
29
+ })
30
+ );
31
+ };
32
+ return (
33
+ <EmptyState variant={EmptyStateVariant.xl}>
34
+ <EmptyStateIcon icon={RocketIcon} />
35
+ <EmptyStateBody>
36
+ <p>
37
+ {__(`Insights synchronization process is used to provide Insights
38
+ recommendations output for hosts managed here`)}
39
+ </p>
40
+ <p>
41
+ {__(
42
+ `To use recommendations please add a token to 'Red Hat Cloud token' setting here or in the settings page`
43
+ )}
44
+ <br />
45
+ {__(`You can obtain a Red Hat API token here: `)}
46
+ <a
47
+ href="https://access.redhat.com/management/api"
48
+ target="_blank"
49
+ rel="noopener noreferrer"
50
+ >
51
+ access.redhat.com <ExternalLinkAltIcon />
52
+ </a>
53
+ <br />
54
+ </p>
55
+
56
+ <br />
57
+ <FormGroup
58
+ label={__('Red Hat Cloud token:')}
59
+ fieldId="input-cloud-token"
60
+ >
61
+ <Grid>
62
+ <GridItem span={3} />
63
+ <GridItem span={6}>
64
+ <TextInput
65
+ value={token}
66
+ type="password"
67
+ onChange={newValue => setToken(newValue)}
68
+ aria-label="input-cloud-token"
69
+ />
70
+ </GridItem>
71
+ </Grid>
72
+ </FormGroup>
73
+ </EmptyStateBody>
74
+ <Button variant="primary" onClick={onSave} isDisabled={!token.length}>
75
+ {__('Save setting and sync recommendations')}
76
+ </Button>
77
+ </EmptyState>
78
+ );
79
+ };
@@ -0,0 +1,10 @@
1
+ import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
2
+
3
+ import InsightsHeader from '../InsightsHeader';
4
+
5
+ const fixtures = {
6
+ render: {},
7
+ };
8
+
9
+ describe('InsightsHeader', () =>
10
+ testComponentSnapshotsWithFixtures(InsightsHeader, fixtures));
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { mount } from '@theforeman/test';
3
+ import { Provider } from 'react-redux';
4
+ import configureMockStore from 'redux-mock-store';
5
+
6
+ import { NoTokenEmptyState } from '../NoTokenEmptyState';
7
+
8
+ const mockStore = configureMockStore();
9
+ const store = mockStore({});
10
+ describe('NoTokenEmptyState', () => {
11
+ it('render', () => {
12
+ const component = mount(
13
+ <Provider store={store}>
14
+ <NoTokenEmptyState />
15
+ </Provider>
16
+ );
17
+ expect(component).toMatchSnapshot();
18
+ });
19
+ });
@@ -0,0 +1,13 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`InsightsHeader render 1`] = `
4
+ <div
5
+ className="insights-header"
6
+ >
7
+ <Connect(InsightsSettings) />
8
+ <p>
9
+ Insights synchronization process is used to provide Insights
10
+ recommendations output for hosts managed here
11
+ </p>
12
+ </div>
13
+ `;
@@ -0,0 +1,214 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`NoTokenEmptyState render 1`] = `
4
+ <Provider
5
+ store={
6
+ Object {
7
+ "clearActions": [Function],
8
+ "dispatch": [Function],
9
+ "getActions": [Function],
10
+ "getState": [Function],
11
+ "replaceReducer": [Function],
12
+ "subscribe": [Function],
13
+ }
14
+ }
15
+ >
16
+ <NoTokenEmptyState>
17
+ <EmptyState
18
+ variant="xl"
19
+ >
20
+ <div
21
+ className="pf-c-empty-state pf-m-xl"
22
+ >
23
+ <div
24
+ className="pf-c-empty-state__content"
25
+ >
26
+ <EmptyStateIcon
27
+ icon={[Function]}
28
+ >
29
+ <RocketIcon
30
+ aria-hidden="true"
31
+ className="pf-c-empty-state__icon"
32
+ color="currentColor"
33
+ noVerticalAlign={false}
34
+ size="sm"
35
+ >
36
+ <svg
37
+ aria-hidden="true"
38
+ aria-labelledby={null}
39
+ className="pf-c-empty-state__icon"
40
+ fill="currentColor"
41
+ height="1em"
42
+ role="img"
43
+ style={
44
+ Object {
45
+ "verticalAlign": "-0.125em",
46
+ }
47
+ }
48
+ viewBox="0 0 512 512"
49
+ width="1em"
50
+ >
51
+ <path
52
+ d="M505.12019,19.09375c-1.18945-5.53125-6.65819-11-12.207-12.1875C460.716,0,435.507,0,410.40747,0,307.17523,0,245.26909,55.20312,199.05238,128H94.83772c-16.34763.01562-35.55658,11.875-42.88664,26.48438L2.51562,253.29688A28.4,28.4,0,0,0,0,264a24.00867,24.00867,0,0,0,24.00582,24H127.81618l-22.47457,22.46875c-11.36521,11.36133-12.99607,32.25781,0,45.25L156.24582,406.625c11.15623,11.1875,32.15619,13.15625,45.27726,0l22.47457-22.46875V488a24.00867,24.00867,0,0,0,24.00581,24,28.55934,28.55934,0,0,0,10.707-2.51562l98.72834-49.39063c14.62888-7.29687,26.50776-26.5,26.50776-42.85937V312.79688c72.59753-46.3125,128.03493-108.40626,128.03493-211.09376C512.07526,76.5,512.07526,51.29688,505.12019,19.09375ZM384.04033,168A40,40,0,1,1,424.05,128,40.02322,40.02322,0,0,1,384.04033,168Z"
53
+ />
54
+ </svg>
55
+ </RocketIcon>
56
+ </EmptyStateIcon>
57
+ <EmptyStateBody>
58
+ <div
59
+ className="pf-c-empty-state__body"
60
+ >
61
+ <p>
62
+ Insights synchronization process is used to provide Insights
63
+ recommendations output for hosts managed here
64
+ </p>
65
+ <p>
66
+ To use recommendations please add a token to 'Red Hat Cloud token' setting here or in the settings page
67
+ <br />
68
+ You can obtain a Red Hat API token here:
69
+ <a
70
+ href="https://access.redhat.com/management/api"
71
+ rel="noopener noreferrer"
72
+ target="_blank"
73
+ >
74
+ access.redhat.com
75
+ <ExternalLinkAltIcon
76
+ color="currentColor"
77
+ noVerticalAlign={false}
78
+ size="sm"
79
+ >
80
+ <svg
81
+ aria-hidden={true}
82
+ aria-labelledby={null}
83
+ fill="currentColor"
84
+ height="1em"
85
+ role="img"
86
+ style={
87
+ Object {
88
+ "verticalAlign": "-0.125em",
89
+ }
90
+ }
91
+ viewBox="0 0 512 512"
92
+ width="1em"
93
+ >
94
+ <path
95
+ d="M432,320H400a16,16,0,0,0-16,16V448H64V128H208a16,16,0,0,0,16-16V80a16,16,0,0,0-16-16H48A48,48,0,0,0,0,112V464a48,48,0,0,0,48,48H400a48,48,0,0,0,48-48V336A16,16,0,0,0,432,320ZM488,0h-128c-21.37,0-32.05,25.91-17,41l35.73,35.73L135,320.37a24,24,0,0,0,0,34L157.67,377a24,24,0,0,0,34,0L435.28,133.32,471,169c15,15,41,4.5,41-17V24A24,24,0,0,0,488,0Z"
96
+ />
97
+ </svg>
98
+ </ExternalLinkAltIcon>
99
+ </a>
100
+ <br />
101
+ </p>
102
+ <br />
103
+ <FormGroup
104
+ fieldId="input-cloud-token"
105
+ label="Red Hat Cloud token:"
106
+ >
107
+ <div
108
+ className="pf-c-form__group"
109
+ >
110
+ <div
111
+ className="pf-c-form__group-label"
112
+ >
113
+ <label
114
+ className="pf-c-form__label"
115
+ htmlFor="input-cloud-token"
116
+ >
117
+ <span
118
+ className="pf-c-form__label-text"
119
+ >
120
+ Red Hat Cloud token:
121
+ </span>
122
+ </label>
123
+
124
+ </div>
125
+ <div
126
+ className="pf-c-form__group-control"
127
+ >
128
+ <Grid>
129
+ <div
130
+ className="pf-l-grid"
131
+ >
132
+ <GridItem
133
+ span={3}
134
+ >
135
+ <div
136
+ className="pf-l-grid__item pf-m-3-col"
137
+ />
138
+ </GridItem>
139
+ <GridItem
140
+ span={6}
141
+ >
142
+ <div
143
+ className="pf-l-grid__item pf-m-6-col"
144
+ >
145
+ <TextInput
146
+ aria-label="input-cloud-token"
147
+ onChange={[Function]}
148
+ type="password"
149
+ value=""
150
+ >
151
+ <TextInputBase
152
+ aria-label="input-cloud-token"
153
+ className=""
154
+ innerRef={null}
155
+ isDisabled={false}
156
+ isLeftTruncated={false}
157
+ isReadOnly={false}
158
+ isRequired={false}
159
+ onChange={[Function]}
160
+ type="password"
161
+ validated="default"
162
+ value=""
163
+ >
164
+ <input
165
+ aria-invalid={false}
166
+ aria-label="input-cloud-token"
167
+ className="pf-c-form-control"
168
+ disabled={false}
169
+ onBlur={[Function]}
170
+ onChange={[Function]}
171
+ onFocus={[Function]}
172
+ readOnly={false}
173
+ required={false}
174
+ type="password"
175
+ value=""
176
+ />
177
+ </TextInputBase>
178
+ </TextInput>
179
+ </div>
180
+ </GridItem>
181
+ </div>
182
+ </Grid>
183
+ </div>
184
+ </div>
185
+ </FormGroup>
186
+ </div>
187
+ </EmptyStateBody>
188
+ <Button
189
+ isDisabled={true}
190
+ onClick={[Function]}
191
+ variant="primary"
192
+ >
193
+ <button
194
+ aria-disabled={true}
195
+ aria-label={null}
196
+ className="pf-c-button pf-m-primary pf-m-disabled"
197
+ data-ouia-component-id="OUIA-Generated-Button-primary-1"
198
+ data-ouia-component-type="PF4/Button"
199
+ data-ouia-safe={true}
200
+ disabled={true}
201
+ onClick={[Function]}
202
+ role={null}
203
+ tabIndex={null}
204
+ type="button"
205
+ >
206
+ Save setting and sync recommendations
207
+ </button>
208
+ </Button>
209
+ </div>
210
+ </div>
211
+ </EmptyState>
212
+ </NoTokenEmptyState>
213
+ </Provider>
214
+ `;
@@ -1,57 +1,58 @@
1
1
  import React from 'react';
2
- import { IntlProvider } from 'react-intl';
2
+ import { Button } from 'patternfly-react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { translate as __ } from 'foremanReact/common/I18n';
5
- import { Button, Icon } from 'patternfly-react';
6
- import { INSIGHTS_SYNC_PAGE_TITLE } from './InsightsCloudSyncConstants';
7
- import InsightsSettings from './Components/InsightsSettings';
5
+ import PageLayout from 'foremanReact/routes/common/PageLayout/PageLayout';
6
+ import InsightsHeader from './Components/InsightsHeader';
7
+ import { NoTokenEmptyState } from './Components/NoTokenEmptyState';
8
+ import InsightsTable from './Components/InsightsTable';
9
+ import {
10
+ INSIGHTS_SYNC_PAGE_TITLE,
11
+ INSIGHTS_SEARCH_PROPS,
12
+ } from './InsightsCloudSyncConstants';
8
13
 
9
- const InsightsCloudSync = ({ settingsUrl, syncInsights }) => {
10
- document.title = INSIGHTS_SYNC_PAGE_TITLE;
14
+ const InsightsCloudSync = ({
15
+ syncInsights,
16
+ query,
17
+ fetchInsights,
18
+ hasToken,
19
+ }) => {
20
+ if (!hasToken) {
21
+ return (
22
+ <PageLayout header={INSIGHTS_SYNC_PAGE_TITLE} searchable={false}>
23
+ <NoTokenEmptyState />
24
+ </PageLayout>
25
+ );
26
+ }
11
27
  return (
12
- <IntlProvider locale={navigator.language}>
13
- <div className="insights-cloud-sync">
14
- <h1>{__('Red Hat Insights Sync')}</h1>
15
- <div className="insights-cloud-sync-body">
16
- <InsightsSettings />
17
- <p>
18
- {__(`Insights synchronization process is used to provide Insights
19
- recommendations output for hosts managed here`)}
20
- </p>
21
- <p>
22
- {__(`1. Obtain an Red Hat API token: `)}
23
- <a
24
- href="https://access.redhat.com/management/api"
25
- target="_blank"
26
- rel="noopener noreferrer"
27
- >
28
- access.redhat.com <Icon name="external-link" size="xs" />
29
- </a>
30
- <br />
31
- {__("2. Copy the token to 'Red Hat Cloud token' setting: ")}
32
- <a href={settingsUrl} target="_blank" rel="noopener noreferrer">
33
- {__('Red Hat Cloud token ')}
34
- <Icon name="external-link" size="xs" />
35
- </a>
36
- <br />
37
- {__(
38
- '3. Now you can synchronize recommendations manually using the "Sync now" button.'
39
- )}
40
- </p>
41
- <div>
42
- <Button bsStyle="primary" onClick={syncInsights}>
43
- {__('Sync now')}
44
- </Button>
45
- </div>
46
- </div>
47
- </div>
48
- </IntlProvider>
28
+ <PageLayout
29
+ searchable
30
+ searchProps={INSIGHTS_SEARCH_PROPS}
31
+ onSearch={nextQuery => fetchInsights({ query: nextQuery, page: 1 })}
32
+ header={INSIGHTS_SYNC_PAGE_TITLE}
33
+ toolbarButtons={
34
+ <Button bsStyle="primary" onClick={syncInsights}>
35
+ {__('Sync now')}
36
+ </Button>
37
+ }
38
+ searchQuery={query}
39
+ beforeToolbarComponent={<InsightsHeader />}
40
+ >
41
+ <InsightsTable />
42
+ </PageLayout>
49
43
  );
50
44
  };
51
45
 
52
46
  InsightsCloudSync.propTypes = {
53
47
  syncInsights: PropTypes.func.isRequired,
54
- settingsUrl: PropTypes.string.isRequired,
48
+ fetchInsights: PropTypes.func.isRequired,
49
+ query: PropTypes.string,
50
+ hasToken: PropTypes.bool,
51
+ };
52
+
53
+ InsightsCloudSync.defaultProps = {
54
+ query: '',
55
+ hasToken: true,
55
56
  };
56
57
 
57
58
  export default InsightsCloudSync;