foreman_rh_cloud 5.0.35 → 5.0.36

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/api/v2/rh_cloud/cloud_request_controller.rb +1 -1
  3. data/app/controllers/foreman_inventory_upload/uploads_settings_controller.rb +0 -1
  4. data/app/controllers/insights_cloud/hits_controller.rb +0 -1
  5. data/app/controllers/insights_cloud/settings_controller.rb +0 -8
  6. data/app/controllers/insights_cloud/tasks_controller.rb +1 -1
  7. data/app/models/insights_facet.rb +1 -0
  8. data/app/models/insights_hit.rb +1 -0
  9. data/app/models/insights_rule.rb +2 -0
  10. data/app/models/setting/rh_cloud.rb +1 -2
  11. data/app/services/foreman_rh_cloud/cert_auth.rb +22 -0
  12. data/app/services/foreman_rh_cloud/cloud_connector.rb +10 -1
  13. data/app/services/foreman_rh_cloud/cloud_ping_service.rb +0 -27
  14. data/app/services/foreman_rh_cloud/hit_remediations_retriever.rb +4 -0
  15. data/app/services/foreman_rh_cloud/remediations_retriever.rb +7 -3
  16. data/app/services/foreman_rh_cloud/template_renderer_helper.rb +4 -3
  17. data/app/services/foreman_rh_cloud/url_remediations_retriever.rb +6 -1
  18. data/app/views/job_templates/cloud_connector.erb +6 -0
  19. data/app/views/job_templates/rh_cloud_download_playbook.erb +5 -1
  20. data/config/routes.rb +0 -1
  21. data/db/migrate/20220321000001_add_unique_to_insights_rules.foreman_rh_cloud.rb +13 -0
  22. data/lib/foreman_inventory_upload.rb +1 -1
  23. data/lib/foreman_rh_cloud/engine.rb +1 -1
  24. data/lib/foreman_rh_cloud/version.rb +1 -1
  25. data/lib/foreman_rh_cloud.rb +0 -5
  26. data/lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb +7 -1
  27. data/lib/insights_cloud/async/insights_full_sync.rb +40 -24
  28. data/lib/insights_cloud/async/insights_resolutions_sync.rb +10 -13
  29. data/lib/insights_cloud/async/insights_rules_sync.rb +27 -19
  30. data/lib/insights_cloud/async/insights_scheduled_sync.rb +1 -1
  31. data/lib/insights_cloud.rb +4 -8
  32. data/lib/inventory_sync/async/host_result.rb +3 -2
  33. data/lib/inventory_sync/async/inventory_full_sync.rb +3 -3
  34. data/lib/inventory_sync/async/inventory_hosts_sync.rb +11 -10
  35. data/lib/inventory_sync/async/inventory_self_host_sync.rb +5 -6
  36. data/lib/inventory_sync/async/query_inventory_job.rb +40 -12
  37. data/lib/tasks/insights.rake +1 -1
  38. data/package.json +1 -1
  39. data/test/controllers/insights_cloud/api/cloud_request_controller_test.rb +0 -1
  40. data/test/controllers/inventory_upload/cloud_status_controller_test.rb +0 -6
  41. data/test/jobs/insights_full_sync_test.rb +9 -5
  42. data/test/jobs/insights_resolutions_sync_test.rb +7 -1
  43. data/test/jobs/insights_rules_sync_test.rb +8 -4
  44. data/test/jobs/inventory_full_sync_test.rb +16 -5
  45. data/test/jobs/inventory_hosts_sync_test.rb +18 -4
  46. data/test/jobs/inventory_self_host_sync_test.rb +6 -1
  47. data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +0 -1
  48. data/test/unit/services/foreman_rh_cloud/cloud_status_service_test.rb +1 -14
  49. data/test/unit/services/foreman_rh_cloud/template_renderer_helper_test.rb +5 -1
  50. data/test/unit/services/foreman_rh_cloud/url_remediations_retriever_test.rb +3 -1
  51. data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettingsSelectors.js +0 -2
  52. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudPingModal/index.js +1 -10
  53. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js +3 -12
  54. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/SyncButton.test.js +1 -1
  55. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButton.test.js.snap +0 -4
  56. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/index.js +0 -2
  57. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableSelectors.js +0 -3
  58. data/webpack/InsightsCloudSync/Components/InsightsTable/Pagination.js +16 -0
  59. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/InsightsTableSelectors.test.js +0 -2
  60. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableSelectors.test.js.snap +0 -2
  61. data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/fixtures.js +0 -1
  62. data/webpack/InsightsCloudSync/InsightsCloudSync.js +1 -17
  63. data/webpack/InsightsCloudSync/InsightsCloudSync.test.js +0 -7
  64. data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +0 -4
  65. data/webpack/InsightsCloudSync/InsightsCloudSyncHelpers.js +0 -7
  66. data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +0 -9
  67. data/webpack/InsightsCloudSync/index.js +1 -5
  68. metadata +4 -9
  69. data/app/services/foreman_rh_cloud/cloud_auth.rb +0 -44
  70. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudPingModal/index.scss +0 -5
  71. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js +0 -63
  72. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/modal.scss +0 -20
  73. data/webpack/InsightsCloudSync/Components/NoTokenEmptyState.js +0 -79
  74. data/webpack/InsightsCloudSync/Components/__tests__/NoTokenEmptyState.test.js +0 -19
  75. data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/NoTokenEmptyState.test.js.snap +0 -225
@@ -2,13 +2,17 @@ require 'test_plugin_helper'
2
2
 
3
3
  class TemplateRendererHelperTest < ActiveSupport::TestCase
4
4
  include ForemanRhCloud::TemplateRendererHelper
5
+ include MockCerts
5
6
 
6
7
  setup do
7
8
  response = mock('respone')
8
9
  response.stubs(:body).returns('TEST PLAYBOOK')
9
10
  ForemanRhCloud::RemediationsRetriever.any_instance.stubs(:query_playbook).returns(response)
10
11
  @host1 = FactoryBot.create(:host)
11
- Setting[:rh_cloud_token] = 'MOCK_TOKEN'
12
+
13
+ setup_certs_expectation do
14
+ ForemanRhCloud::RemediationsRetriever.any_instance.stubs(:candlepin_id_cert)
15
+ end
12
16
  end
13
17
 
14
18
  test 'Generates a playbook for hit and remediation' do
@@ -2,8 +2,8 @@ require 'test_plugin_helper'
2
2
 
3
3
  class UrlRemediationsRetrieverTest < ActiveSupport::TestCase
4
4
  test 'Calls the given url' do
5
- Setting[:rh_cloud_token] = 'TEST_TOKEN'
6
5
  retreiver = ForemanRhCloud::UrlRemediationsRetriever.new(
6
+ organization_id: FactoryBot.create(:organization).id,
7
7
  url: 'http://test.example.com',
8
8
  payload: 'TEST_PAYLOAD',
9
9
  headers: {
@@ -11,6 +11,8 @@ class UrlRemediationsRetrieverTest < ActiveSupport::TestCase
11
11
  }
12
12
  )
13
13
 
14
+ retreiver.stubs(:cert_auth_available?).returns(true)
15
+
14
16
  response = mock('response')
15
17
  response.stubs(:body).returns('TEST_RESPONSE')
16
18
  retreiver.expects(:execute_cloud_request).with do |params|
@@ -15,5 +15,3 @@ export const selectIpsObfuscationEnabled = state =>
15
15
 
16
16
  export const selectExcludePackages = state =>
17
17
  selectSettings(state).excludePackagesEnabled;
18
-
19
- export const selectCloudToken = state => selectSettings(state).cloudToken;
@@ -21,18 +21,16 @@ import { translate as __, sprintf } from 'foremanReact/common/I18n';
21
21
  import { STATUS } from 'foremanReact/constants';
22
22
  import { selectAPIStatus } from 'foremanReact/redux/API/APISelectors';
23
23
  import { inventoryUrl } from '../../../../ForemanInventoryHelpers';
24
- import './index.scss';
25
24
 
26
25
  export const API_KEY = 'CLOUD_PING';
27
26
 
28
27
  const CloudPingModal = ({ title, isOpen, toggle }) => {
29
28
  const [rows, setRows] = useState([]);
30
- const [tokenStatus, setTokenStatus] = useState({});
31
29
  const dispatch = useDispatch();
32
30
  const handleSuccess = useCallback(
33
31
  ({
34
32
  data: {
35
- ping: { cert_auth = [], token_auth = {} },
33
+ ping: { cert_auth = [] },
36
34
  },
37
35
  }) => {
38
36
  cert_auth.length &&
@@ -53,7 +51,6 @@ const CloudPingModal = ({ title, isOpen, toggle }) => {
53
51
  ],
54
52
  }))
55
53
  );
56
- setTokenStatus(token_auth);
57
54
  },
58
55
  [status]
59
56
  );
@@ -83,12 +80,6 @@ const CloudPingModal = ({ title, isOpen, toggle }) => {
83
80
  isOpen={isOpen}
84
81
  onClose={toggle}
85
82
  >
86
- <Card className="token-status">
87
- <CardTitle>
88
- <StatusIcon isPending={isPending} authStatus={tokenStatus} />{' '}
89
- {__('API token status')}
90
- </CardTitle>
91
- </Card>
92
83
  <Card className="certs-status">
93
84
  <CardTitle>{__('Organization status')}</CardTitle>
94
85
  <CardBody>
@@ -1,9 +1,8 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { Spinner, Button } from '@patternfly/react-core';
4
- import { ExclamationTriangleIcon, RedoIcon } from '@patternfly/react-icons';
4
+ import { RedoIcon } from '@patternfly/react-icons';
5
5
  import { STATUS } from 'foremanReact/constants';
6
- import SyncModal from './components/Modal';
7
6
  import { SYNC_BUTTON_TEXT } from '../../../../ForemanInventoryConstants';
8
7
 
9
8
  class SyncButton extends React.Component {
@@ -16,12 +15,11 @@ class SyncButton extends React.Component {
16
15
  };
17
16
 
18
17
  render() {
19
- const { cloudToken, handleSync, status } = this.props;
18
+ const { handleSync, status } = this.props;
20
19
 
21
- const handleClick = !cloudToken ? this.toggleModal : handleSync;
20
+ const handleClick = handleSync;
22
21
  return (
23
22
  <React.Fragment>
24
- <SyncModal show={this.state.showModal} toggleModal={this.toggleModal} />
25
23
  <Button
26
24
  className="sync_button"
27
25
  onClick={handleClick}
@@ -29,11 +27,6 @@ class SyncButton extends React.Component {
29
27
  isDisabled={status === STATUS.PENDING}
30
28
  variant="secondary"
31
29
  >
32
- {!cloudToken && (
33
- <span>
34
- <ExclamationTriangleIcon />{' '}
35
- </span>
36
- )}
37
30
  {status === STATUS.PENDING ? <Spinner size="sm" /> : <RedoIcon />}
38
31
  {SYNC_BUTTON_TEXT}
39
32
  </Button>
@@ -43,13 +36,11 @@ class SyncButton extends React.Component {
43
36
  }
44
37
 
45
38
  SyncButton.propTypes = {
46
- cloudToken: PropTypes.bool,
47
39
  handleSync: PropTypes.func.isRequired,
48
40
  status: PropTypes.string,
49
41
  };
50
42
 
51
43
  SyncButton.defaultProps = {
52
- cloudToken: false,
53
44
  status: null,
54
45
  };
55
46
 
@@ -4,7 +4,7 @@ import { noop } from 'foremanReact/common/helpers';
4
4
  import SyncButton from '../SyncButton';
5
5
 
6
6
  const fixtures = {
7
- 'render with Props': { cloudToken: true, handleSync: noop },
7
+ 'render with Props': { handleSync: noop },
8
8
  };
9
9
 
10
10
  describe('SyncButton', () => {
@@ -2,10 +2,6 @@
2
2
 
3
3
  exports[`SyncButton rendering render with Props 1`] = `
4
4
  <Fragment>
5
- <SyncModal
6
- show={false}
7
- toggleModal={[Function]}
8
- />
9
5
  <Button
10
6
  className="sync_button"
11
7
  isDisabled={false}
@@ -3,12 +3,10 @@ import { connect } from 'react-redux';
3
3
 
4
4
  import * as actions from './SyncButtonActions';
5
5
  import SyncButton from './SyncButton';
6
- import { selectCloudToken } from '../../../InventorySettings/InventorySettingsSelectors';
7
6
  import { selectTaskStatus } from './SyncButtonSelectors';
8
7
 
9
8
  // map state to props
10
9
  const mapStateToProps = state => ({
11
- cloudToken: selectCloudToken(state),
12
10
  status: selectTaskStatus(state),
13
11
  });
14
12
 
@@ -73,6 +73,3 @@ export const selectShowSelectAllAlert = state =>
73
73
 
74
74
  export const selectItemCount = state =>
75
75
  selectAPIResponse(state, INSIGHTS_HITS_API_KEY).itemCount || 0;
76
-
77
- export const selectHasToken = state =>
78
- selectAPIResponse(state, INSIGHTS_HITS_API_KEY).hasToken;
@@ -5,6 +5,7 @@ import {
5
5
  Pagination as PfPagination,
6
6
  PaginationVariant,
7
7
  } from '@patternfly/react-core';
8
+ import { translate as __ } from 'foremanReact/common/I18n';
8
9
  import { useForemanSettings } from 'foremanReact/Root/Context/ForemanContext';
9
10
  import { onTablePerPageSelect, onTableSetPage } from './InsightsTableActions';
10
11
  import { getPerPageOptions } from './InsightsTableHelpers';
@@ -14,6 +15,20 @@ import {
14
15
  selectPerPage,
15
16
  } from './InsightsTableSelectors';
16
17
 
18
+ const paginationTitles = {
19
+ items: __('items'),
20
+ page: '', // doesn't work well with translations as it adds 's' for plural, see: https://github.com/patternfly/patternfly-react/issues/6707
21
+ itemsPerPage: __('Items per page'),
22
+ perPageSuffix: __('per page'),
23
+ toFirstPage: __('Go to first page'),
24
+ toPreviousPage: __('Go to previous page'),
25
+ toLastPage: __('Go to last page'),
26
+ toNextPage: __('Go to next page'),
27
+ optionsToggle: __('Items per page'),
28
+ currPage: __('Current page'),
29
+ paginationTitle: __('Pagination'),
30
+ };
31
+
17
32
  const Pagination = ({ variant, ...props }) => {
18
33
  const dispatch = useDispatch();
19
34
  const onSetPage = (e, pageNumber) => dispatch(onTableSetPage(e, pageNumber));
@@ -35,6 +50,7 @@ const Pagination = ({ variant, ...props }) => {
35
50
  onSetPage={onSetPage}
36
51
  onPerPageSelect={onPerPageSelect}
37
52
  perPageOptions={getPerPageOptions(urlPerPage, appPerPage)}
53
+ titles={paginationTitles}
38
54
  {...props}
39
55
  />
40
56
  );
@@ -3,7 +3,6 @@ import { insightsStateWrapper } from '../../../../ForemanRhCloudTestHelpers';
3
3
  import { routerState, APIState, APIErrorState } from './fixtures';
4
4
  import {
5
5
  selectError,
6
- selectHasToken,
7
6
  selectHits,
8
7
  selectInsightsCloudTable,
9
8
  selectIsAllSelected,
@@ -46,7 +45,6 @@ const fixtures = {
46
45
  'should return API error': () => selectError({ ...state, ...APIErrorState }),
47
46
  'should return API hits': () => selectHits(state),
48
47
  'should return API item count': () => selectItemCount(state),
49
- 'should return API has token': () => selectHasToken(state),
50
48
  'should return insights table': () => selectInsightsCloudTable(state),
51
49
  'should return insights selectedIds': () => selectSelectedIds(state),
52
50
  'should return insights isAllSelected': () => selectIsAllSelected(state),
@@ -2,8 +2,6 @@
2
2
 
3
3
  exports[`InsightsTable selectors should return API error 1`] = `"Request failed with status code 503"`;
4
4
 
5
- exports[`InsightsTable selectors should return API has token 1`] = `true`;
6
-
7
5
  exports[`InsightsTable selectors should return API hits 1`] = `
8
6
  Array [
9
7
  Object {
@@ -78,7 +78,6 @@ export const APIState = {
78
78
  url: '/insights_cloud/hits',
79
79
  },
80
80
  response: {
81
- hasToken: true,
82
81
  hits,
83
82
  itemCount: 2,
84
83
  },
@@ -2,7 +2,6 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import PageLayout from 'foremanReact/routes/common/PageLayout/PageLayout';
4
4
  import InsightsHeader from './Components/InsightsHeader';
5
- import { NoTokenEmptyState } from './Components/NoTokenEmptyState';
6
5
  import InsightsTable from './Components/InsightsTable';
7
6
  import RemediationModal from './Components/RemediationModal';
8
7
  import {
@@ -14,20 +13,7 @@ import Pagination from './Components/InsightsTable/Pagination';
14
13
  import ToolbarDropdown from './Components/ToolbarDropdown';
15
14
  import InsightsSettings from './Components/InsightsSettings';
16
15
 
17
- const InsightsCloudSync = ({
18
- syncInsights,
19
- query,
20
- fetchInsights,
21
- hasToken,
22
- }) => {
23
- if (!hasToken) {
24
- return (
25
- <PageLayout header={INSIGHTS_SYNC_PAGE_TITLE} searchable={false}>
26
- <NoTokenEmptyState />
27
- </PageLayout>
28
- );
29
- }
30
-
16
+ const InsightsCloudSync = ({ syncInsights, query, fetchInsights }) => {
31
17
  const onRecommendationSync = () => syncInsights(fetchInsights, query);
32
18
  const toolbarButtons = (
33
19
  <>
@@ -63,12 +49,10 @@ InsightsCloudSync.propTypes = {
63
49
  syncInsights: PropTypes.func.isRequired,
64
50
  fetchInsights: PropTypes.func.isRequired,
65
51
  query: PropTypes.string,
66
- hasToken: PropTypes.bool,
67
52
  };
68
53
 
69
54
  InsightsCloudSync.defaultProps = {
70
55
  query: '',
71
- hasToken: true,
72
56
  };
73
57
 
74
58
  export default InsightsCloudSync;
@@ -8,13 +8,6 @@ const fixtures = {
8
8
  syncInsights: noop,
9
9
  fetchInsights: noop,
10
10
  query: '',
11
- hasToken: true,
12
- },
13
- 'render no token': {
14
- status: 'RESOLVED',
15
- syncInsights: noop,
16
- fetchInsights: noop,
17
- hasToken: false,
18
11
  },
19
12
  };
20
13
 
@@ -10,10 +10,6 @@ export const INSIGHTS_SYNC_PAGE_TITLE = __('Red Hat Insights');
10
10
 
11
11
  export const INSIGHTS_PATH = foremanUrl('/foreman_rh_cloud/insights_cloud');
12
12
 
13
- export const INSIGHTS_SAVE_AND_SYNC_PATH = foremanUrl(
14
- '/insights_cloud/save_token_and_sync'
15
- );
16
-
17
13
  export const INSIGHTS_SEARCH_PROPS = {
18
14
  ...getControllerSearchProps('/insights_cloud/hits'),
19
15
  controller: 'insights_hits',
@@ -1,14 +1,7 @@
1
- import URI from 'urijs';
2
1
  import { foremanUrl } from '../ForemanRhCloudHelpers';
3
2
 
4
3
  export const insightsCloudUrl = path => foremanUrl(`/insights_cloud/${path}`);
5
4
 
6
- export const cloudTokenSettingUrl = () => {
7
- const settingsUrl = new URI(foremanUrl('/settings'));
8
- settingsUrl.setSearch({ search: 'name = rh_cloud_token' });
9
- return settingsUrl.toString();
10
- };
11
-
12
5
  export const redHatConsole = path => `https://console.redhat.com/${path || ''}`;
13
6
  export const redHatInsights = path => redHatConsole(`insights/${path || ''}`);
14
7
  export const redHatInventory = path =>
@@ -52,12 +52,3 @@ exports[`InsightsCloudSync render 1`] = `
52
52
  </PageLayout>
53
53
  </div>
54
54
  `;
55
-
56
- exports[`InsightsCloudSync render no token 1`] = `
57
- <PageLayout
58
- header="Red Hat Insights"
59
- searchable={false}
60
- >
61
- <NoTokenEmptyState />
62
- </PageLayout>
63
- `;
@@ -5,14 +5,10 @@ import * as actions from './InsightsCloudSyncActions';
5
5
  import { fetchInsights } from './Components/InsightsTable/InsightsTableActions';
6
6
  import InsightsCloudSync from './InsightsCloudSync';
7
7
  import insightsCloudSyncReducers from './InsightsCloudSyncReducers';
8
- import {
9
- selectSearch,
10
- selectHasToken,
11
- } from './Components/InsightsTable/InsightsTableSelectors';
8
+ import { selectSearch } from './Components/InsightsTable/InsightsTableSelectors';
12
9
  // map state to props
13
10
  const mapStateToProps = state => ({
14
11
  query: selectSearch(state),
15
- hasToken: selectHasToken(state),
16
12
  });
17
13
 
18
14
  // map action dispatchers to props
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: 5.0.35
4
+ version: 5.0.36
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: 2022-05-11 00:00:00.000000000 Z
11
+ date: 2022-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: katello
@@ -164,7 +164,7 @@ files:
164
164
  - app/overrides/hosts_list.rb
165
165
  - app/overrides/layouts/base/styles.html.erb.deface
166
166
  - app/services/foreman_rh_cloud/branch_info.rb
167
- - app/services/foreman_rh_cloud/cloud_auth.rb
167
+ - app/services/foreman_rh_cloud/cert_auth.rb
168
168
  - app/services/foreman_rh_cloud/cloud_connector.rb
169
169
  - app/services/foreman_rh_cloud/cloud_ping_service.rb
170
170
  - app/services/foreman_rh_cloud/cloud_presence.rb
@@ -198,6 +198,7 @@ files:
198
198
  - db/migrate/20210404000001_change_resolutions.foreman_rh_cloud.rb
199
199
  - db/migrate/20210720000001_remove_old_insights_statuses.foreman_rh_cloud.rb
200
200
  - db/migrate/20211027000001_create_task_output.foreman_rh_cloud.rb
201
+ - db/migrate/20220321000001_add_unique_to_insights_rules.foreman_rh_cloud.rb
201
202
  - db/seeds.d/179_ui_notifications.rb
202
203
  - db/seeds.d/50_job_templates.rb
203
204
  - lib/foreman_inventory_upload.rb
@@ -428,7 +429,6 @@ files:
428
429
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorButton.test.js.snap
429
430
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/index.js
430
431
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudPingModal/index.js
431
- - webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudPingModal/index.scss
432
432
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js
433
433
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/PageDescription.test.js
434
434
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/__snapshots__/PageDescription.test.js.snap
@@ -448,9 +448,7 @@ files:
448
448
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButtonSelectors.test.js.snap
449
449
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/integrations.test.js.snap
450
450
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/integrations.test.js
451
- - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js
452
451
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Toast.js
453
- - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/modal.scss
454
452
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/index.js
455
453
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js
456
454
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/ToolbarButtons.test.js
@@ -576,7 +574,6 @@ files:
576
574
  - webpack/InsightsCloudSync/Components/InsightsTable/__tests__/fixtures.js
577
575
  - webpack/InsightsCloudSync/Components/InsightsTable/index.js
578
576
  - webpack/InsightsCloudSync/Components/InsightsTable/table.scss
579
- - webpack/InsightsCloudSync/Components/NoTokenEmptyState.js
580
577
  - webpack/InsightsCloudSync/Components/RemediationModal/RemediationActions.js
581
578
  - webpack/InsightsCloudSync/Components/RemediationModal/RemediationHelpers.js
582
579
  - webpack/InsightsCloudSync/Components/RemediationModal/RemediationModal.js
@@ -587,9 +584,7 @@ files:
587
584
  - webpack/InsightsCloudSync/Components/RemediationModal/index.js
588
585
  - webpack/InsightsCloudSync/Components/ToolbarDropdown.js
589
586
  - webpack/InsightsCloudSync/Components/__tests__/InsightsHeader.test.js
590
- - webpack/InsightsCloudSync/Components/__tests__/NoTokenEmptyState.test.js
591
587
  - webpack/InsightsCloudSync/Components/__tests__/__snapshots__/InsightsHeader.test.js.snap
592
- - webpack/InsightsCloudSync/Components/__tests__/__snapshots__/NoTokenEmptyState.test.js.snap
593
588
  - webpack/InsightsCloudSync/InsightsCloudSync.js
594
589
  - webpack/InsightsCloudSync/InsightsCloudSync.scss
595
590
  - webpack/InsightsCloudSync/InsightsCloudSync.test.js
@@ -1,44 +0,0 @@
1
- module ForemanRhCloud
2
- module CloudAuth
3
- extend ActiveSupport::Concern
4
-
5
- include CloudRequest
6
-
7
- def cloud_auth_available?
8
- Setting[:rh_cloud_token].present?
9
- end
10
-
11
- def rh_credentials
12
- @rh_credentials ||= query_refresh_token
13
- end
14
-
15
- def query_refresh_token
16
- token_response = RestClient::Request.execute(
17
- method: :post,
18
- url: ForemanRhCloud.authentication_url,
19
- verify_ssl: ForemanRhCloud.verify_ssl_method,
20
- proxy: ForemanRhCloud.transformed_http_proxy_string(logger: logger),
21
- payload: {
22
- grant_type: 'refresh_token',
23
- client_id: 'rhsm-api',
24
- refresh_token: Setting[:rh_cloud_token],
25
- }
26
- )
27
-
28
- JSON.parse(token_response)['access_token']
29
- rescue RestClient::ExceptionWithResponse => e
30
- Foreman::Logging.exception('Unable to authenticate using rh_cloud_token setting', e)
31
- raise ::Foreman::WrappedException.new(e, N_('Unable to authenticate using rh_cloud_token setting'))
32
- end
33
-
34
- def execute_cloud_request(params)
35
- final_params = {
36
- headers: {
37
- Authorization: "Bearer #{rh_credentials}",
38
- },
39
- }.deep_merge(params)
40
-
41
- super(final_params)
42
- end
43
- end
44
- end
@@ -1,5 +0,0 @@
1
- #cloud-ping-modal {
2
- .token-status {
3
- margin-bottom: 24px;
4
- }
5
- }
@@ -1,63 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { Icon, Modal, Grid, Button } from 'patternfly-react';
4
- import { translate as __ } from 'foremanReact/common/I18n';
5
- import { foremanUrl } from '../../../../../../ForemanRhCloudHelpers';
6
- import './modal.scss';
7
-
8
- const SyncModal = ({ show, toggleModal }) => (
9
- <Modal show={show} onHide={toggleModal} id="inventory-sync-modal">
10
- <Modal.Header>
11
- <button
12
- className="close"
13
- onClick={toggleModal}
14
- aria-hidden="true"
15
- aria-label="Close"
16
- >
17
- <Icon type="pf" name="close" />
18
- </button>
19
- <Modal.Title>{__('Token is required')}</Modal.Title>
20
- </Modal.Header>
21
- <Modal.Body>
22
- <Grid>
23
- <p>
24
- {__(`Please go over the following steps to add a Red Hat API token:`)}
25
- </p>
26
- <p>
27
- {__(`1. Obtain an Red Hat API token: `)}
28
- <a
29
- href="https://access.redhat.com/management/api"
30
- target="_blank"
31
- rel="noopener noreferrer"
32
- >
33
- access.redhat.com <Icon name="external-link" />
34
- </a>
35
- <br />
36
- {__("2. Copy the token to 'Red Hat Cloud token' setting: ")}
37
- <a
38
- href={foremanUrl('/settings?search=name+%3D+rh_cloud_token')}
39
- target="_blank"
40
- rel="noopener noreferrer"
41
- >
42
- {__('Red Hat Cloud token ')}
43
- <Icon name="external-link" />
44
- </a>
45
- <br />
46
- {__(
47
- '3. Now you can synchronize inventory status manually, by clicking the "Sync inventory status" button.'
48
- )}
49
- </p>
50
- <Button bsStyle="primary" bsSize="lg" onClick={toggleModal}>
51
- {__('Close')}
52
- </Button>
53
- </Grid>
54
- </Modal.Body>
55
- </Modal>
56
- );
57
-
58
- SyncModal.propTypes = {
59
- show: PropTypes.bool.isRequired,
60
- toggleModal: PropTypes.func.isRequired,
61
- };
62
-
63
- export default SyncModal;
@@ -1,20 +0,0 @@
1
- #inventory-sync-modal {
2
- height: 300px;
3
- margin: auto;
4
- overflow: hidden;
5
-
6
- .modal-content {
7
- width: 700px;
8
- }
9
-
10
- .modal-body {
11
- .container {
12
- padding: 0;
13
-
14
- button {
15
- float: right;
16
- margin-top: 10px;
17
- }
18
- }
19
- }
20
- }
@@ -1,79 +0,0 @@
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
- };