foreman_rh_cloud 14.1.3 → 14.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/app/services/foreman_rh_cloud/insights_api_forwarder.rb +157 -5
  3. data/lib/foreman_rh_cloud/plugin.rb +16 -5
  4. data/lib/foreman_rh_cloud/version.rb +1 -1
  5. data/package.json +1 -1
  6. data/test/unit/services/foreman_rh_cloud/insights_api_forwarder_test.rb +240 -4
  7. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +0 -6
  8. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +0 -2
  9. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +0 -2
  10. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.js +0 -2
  11. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.scss +1 -2
  12. data/webpack/ForemanInventoryUpload/Components/PageHeader/PageTitle.js +13 -7
  13. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageHeader.test.js +0 -5
  14. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageTitle.test.js +34 -1
  15. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js +0 -4
  16. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/ToolbarButtons.test.js +18 -47
  17. data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +4 -4
  18. data/webpack/ForemanInventoryUpload/__tests__/ForemanInventoryHelpers.test.js +16 -1
  19. metadata +2 -11
  20. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorActions.js +0 -21
  21. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js +0 -59
  22. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorConstants.js +0 -6
  23. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorSelectors.js +0 -19
  24. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorButton.test.js +0 -51
  25. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/index.js +0 -34
  26. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js +0 -66
  27. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.test.js +0 -61
  28. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/index.js +0 -25
@@ -18,9 +18,11 @@ import {
18
18
  getInventoryDocsUrl,
19
19
  } from '../../ForemanInventoryHelpers';
20
20
  import CloudPingModal from './components/CloudPingModal';
21
+ import { useIopConfig } from '../../../common/Hooks/ConfigHooks';
21
22
 
22
23
  const PageTitle = () => {
23
24
  const [isDropdownOpen, setIsDropdownOpen] = useState(false);
25
+ const isIop = useIopConfig();
24
26
  const [showPingModal, setPingModal] = useState(false);
25
27
  const togglePingModal = () => setPingModal(v => !v);
26
28
  const dropdownItems = [
@@ -42,13 +44,17 @@ const PageTitle = () => {
42
44
  >
43
45
  {DOCS_BUTTON_TEXT}
44
46
  </DropdownItem>,
45
- <DropdownItem
46
- key="cloud-ping"
47
- ouiaId="dropdownItem-cloud-ping"
48
- onClick={togglePingModal}
49
- >
50
- {CLOUD_PING_TITLE}
51
- </DropdownItem>,
47
+ ...(!isIop
48
+ ? [
49
+ <DropdownItem
50
+ key="cloud-ping"
51
+ ouiaId="dropdownItem-cloud-ping"
52
+ onClick={togglePingModal}
53
+ >
54
+ {CLOUD_PING_TITLE}
55
+ </DropdownItem>,
56
+ ]
57
+ : []),
52
58
  ];
53
59
  return (
54
60
  <Grid className="inventory-upload-header-title">
@@ -20,9 +20,6 @@ jest.mock('foremanReact/Root/Context/ForemanContext', () => ({
20
20
 
21
21
  // Mock child components to isolate PageHeader testing
22
22
  // This prevents child component complexity from affecting our tests
23
- jest.mock('../components/SettingsWarning', () => () => (
24
- <div data-testid="settings-warning">SettingsWarning</div>
25
- ));
26
23
  jest.mock('../PageTitle', () => () => (
27
24
  <div data-testid="page-title">PageTitle</div>
28
25
  ));
@@ -59,7 +56,6 @@ describe('PageHeader', () => {
59
56
  });
60
57
 
61
58
  // All components should be present when not in IoP mode
62
- expect(screen.getByTestId('settings-warning')).toBeTruthy();
63
59
  expect(screen.getByTestId('page-title')).toBeTruthy();
64
60
  expect(screen.getByTestId('inventory-settings')).toBeTruthy();
65
61
  expect(screen.getByTestId('page-description')).toBeTruthy();
@@ -83,7 +79,6 @@ describe('PageHeader', () => {
83
79
  });
84
80
 
85
81
  // Core components should still be present
86
- expect(screen.getByTestId('settings-warning')).toBeTruthy();
87
82
  expect(screen.getByTestId('page-title')).toBeTruthy();
88
83
  expect(screen.getByTestId('inventory-filter')).toBeTruthy();
89
84
  expect(screen.getByTestId('toolbar-buttons')).toBeTruthy();
@@ -1,12 +1,30 @@
1
1
  import React from 'react';
2
- import { render, screen } from '@testing-library/react';
2
+ import { fireEvent, render, screen } from '@testing-library/react';
3
3
  import PageTitle from '../PageTitle';
4
4
 
5
+ let mockIopMode = false;
6
+
7
+ jest.mock('foremanReact/Root/Context/ForemanContext', () => ({
8
+ useForemanContext: () => ({
9
+ metadata: {
10
+ foreman_rh_cloud: {
11
+ iop: mockIopMode,
12
+ },
13
+ },
14
+ UI: {},
15
+ }),
16
+ }));
17
+
5
18
  jest.mock('../components/CloudPingModal', () => () => (
6
19
  <div data-testid="cloud-ping-modal">CloudPingModal</div>
7
20
  ));
21
+ jest.mock('foremanReact/common/helpers', () => ({ getDocsURL: () => {} }));
8
22
 
9
23
  describe('PageTitle', () => {
24
+ afterEach(() => {
25
+ mockIopMode = false;
26
+ });
27
+
10
28
  it('renders the page title', () => {
11
29
  render(<PageTitle />);
12
30
  expect(screen.getByText('Red Hat Inventory')).toBeTruthy();
@@ -16,4 +34,19 @@ describe('PageTitle', () => {
16
34
  const { container } = render(<PageTitle />);
17
35
  expect(container.querySelector('.title-dropdown')).toBeTruthy();
18
36
  });
37
+
38
+ it('renders cloud-ping dropdown item when not in IoP mode', () => {
39
+ mockIopMode = false;
40
+ render(<PageTitle />);
41
+ fireEvent.click(screen.getByLabelText('Actions'));
42
+ expect(screen.getByText('Connectivity test')).toBeTruthy();
43
+ });
44
+
45
+ it('does not render cloud-ping dropdown item when in IoP mode', () => {
46
+ mockIopMode = true;
47
+ render(<PageTitle />);
48
+ fireEvent.click(screen.getByLabelText('Actions'));
49
+ expect(screen.queryByText('Connectivity test')).toBeNull();
50
+ mockIopMode = false;
51
+ });
19
52
  });
@@ -1,16 +1,13 @@
1
1
  import React from 'react';
2
2
  import { useSelector } from 'react-redux';
3
3
  import SyncButton from '../SyncButton';
4
- import CloudConnectorButton from '../CloudConnectorButton';
5
4
  import './toolbarButtons.scss';
6
5
  import { selectSubscriptionConnectionEnabled } from '../../../InventorySettings/InventorySettingsSelectors';
7
- import { useIopConfig } from '../../../../../common/Hooks/ConfigHooks';
8
6
 
9
7
  const ToolbarButtons = () => {
10
8
  const subscriptionConnectionEnabled = useSelector(
11
9
  selectSubscriptionConnectionEnabled
12
10
  );
13
- const isIop = useIopConfig();
14
11
 
15
12
  if (!subscriptionConnectionEnabled) {
16
13
  return null;
@@ -18,7 +15,6 @@ const ToolbarButtons = () => {
18
15
 
19
16
  return (
20
17
  <div className="inventory_toolbar_buttons">
21
- {!isIop && <CloudConnectorButton />}
22
18
  <SyncButton />
23
19
  </div>
24
20
  );
@@ -1,21 +1,13 @@
1
1
  import React from 'react';
2
- import { screen } from '@testing-library/react';
3
- import { rtlHelpers } from 'foremanReact/common/rtlTestHelpers';
2
+ import { render, screen } from '@testing-library/react';
3
+ import '@testing-library/jest-dom';
4
+ import * as reactRedux from 'react-redux';
4
5
  import ToolbarButtons from '../ToolbarButtons';
5
- import { useIopConfig } from '../../../../../../common/Hooks/ConfigHooks';
6
- import { selectSubscriptionConnectionEnabled } from '../../../../InventorySettings/InventorySettingsSelectors';
7
6
 
8
- // Mock the config hook
9
- jest.mock('../../../../../../common/Hooks/ConfigHooks', () => ({
10
- useIopConfig: jest.fn(),
7
+ jest.mock('react-redux', () => ({
8
+ useSelector: jest.fn(),
11
9
  }));
12
10
 
13
- // Mock the selector
14
- jest.mock('../../../../InventorySettings/InventorySettingsSelectors', () => ({
15
- selectSubscriptionConnectionEnabled: jest.fn(),
16
- }));
17
-
18
- // Mock child components to isolate ToolbarButtons testing
19
11
  jest.mock(
20
12
  '../../SyncButton',
21
13
  () =>
@@ -23,56 +15,35 @@ jest.mock(
23
15
  return <div data-testid="sync-button">Sync all inventory status</div>;
24
16
  }
25
17
  );
26
- jest.mock(
27
- '../../CloudConnectorButton',
28
- () =>
29
- function MockCloudConnectorButton() {
30
- return (
31
- <div data-testid="cloud-connector-button">
32
- Configure cloud connector
33
- </div>
34
- );
35
- }
36
- );
37
-
38
- const { renderWithStore } = rtlHelpers;
39
18
 
40
19
  describe('ToolbarButtons', () => {
41
- test('renders both buttons when subscription connection is enabled and not in IOP mode', () => {
42
- useIopConfig.mockReturnValue(false);
43
- selectSubscriptionConnectionEnabled.mockReturnValue(true);
44
-
45
- renderWithStore(<ToolbarButtons />);
46
-
47
- expect(screen.getByTestId('cloud-connector-button')).toBeTruthy();
48
- expect(screen.getByTestId('sync-button')).toBeTruthy();
20
+ afterEach(() => {
21
+ jest.clearAllMocks();
49
22
  });
50
23
 
51
- test('renders only sync button when in IOP mode', () => {
52
- useIopConfig.mockReturnValue(true);
53
- selectSubscriptionConnectionEnabled.mockReturnValue(true);
24
+ test('renders sync button when subscription connection is enabled', () => {
25
+ reactRedux.useSelector.mockReturnValue(true);
54
26
 
55
- renderWithStore(<ToolbarButtons />);
27
+ render(<ToolbarButtons />);
56
28
 
57
- expect(screen.queryByTestId('cloud-connector-button')).toBeNull();
58
- expect(screen.getByTestId('sync-button')).toBeTruthy();
29
+ expect(screen.getByTestId('sync-button')).toBeInTheDocument();
59
30
  });
60
31
 
61
32
  test('renders nothing when subscription connection is not enabled', () => {
62
- useIopConfig.mockReturnValue(false);
63
- selectSubscriptionConnectionEnabled.mockReturnValue(false);
33
+ reactRedux.useSelector.mockReturnValue(false);
64
34
 
65
- const { container } = renderWithStore(<ToolbarButtons />);
35
+ const { container } = render(<ToolbarButtons />);
66
36
 
67
37
  expect(container.firstChild).toBeNull();
68
38
  });
69
39
 
70
40
  test('renders toolbar buttons container with correct className when enabled', () => {
71
- useIopConfig.mockReturnValue(false);
72
- selectSubscriptionConnectionEnabled.mockReturnValue(true);
41
+ reactRedux.useSelector.mockReturnValue(true);
73
42
 
74
- const { container } = renderWithStore(<ToolbarButtons />);
43
+ const { container } = render(<ToolbarButtons />);
75
44
 
76
- expect(container.querySelector('.inventory_toolbar_buttons')).toBeTruthy();
45
+ expect(
46
+ container.querySelector('.inventory_toolbar_buttons')
47
+ ).toBeInTheDocument();
77
48
  });
78
49
  });
@@ -1,14 +1,14 @@
1
1
  import URI from 'urijs';
2
+ import { getDocsURL } from 'foremanReact/common/helpers';
2
3
  import { foremanUrl } from '../ForemanRhCloudHelpers';
3
4
 
4
5
  export const inventoryUrl = path =>
5
6
  foremanUrl(`/foreman_inventory_upload/${path}`);
6
7
 
7
8
  export const getInventoryDocsUrl = () =>
8
- foremanUrl(
9
- `/links/manual/?root_url=${URI.encode(
10
- 'https://docs.redhat.com/en/documentation/red_hat_lightspeed/1-latest/html-single/red_hat_lightspeed_remediations_guide/index'
11
- )}`
9
+ getDocsURL(
10
+ 'Managing_Hosts',
11
+ 'configuring-foreman-server-for-cloud-connection'
12
12
  );
13
13
 
14
14
  export const getSubscriptionServiceDocsUrl = () =>
@@ -1,6 +1,21 @@
1
- import { isExitCodeLoading } from '../ForemanInventoryHelpers';
1
+ jest.mock('foremanReact/common/helpers', () => ({
2
+ getDocsURL: jest.fn(),
3
+ }));
4
+
5
+ import { getDocsURL } from 'foremanReact/common/helpers';
6
+ import { getInventoryDocsUrl, isExitCodeLoading } from '../ForemanInventoryHelpers';
2
7
 
3
8
  describe('ForemanInventoryUpload helpers', () => {
9
+ describe('getInventoryDocsUrl', () => {
10
+ it('requests the Managing Hosts guide at the cloud connection chapter', () => {
11
+ getInventoryDocsUrl();
12
+ expect(getDocsURL).toHaveBeenCalledWith(
13
+ 'Managing_Hosts',
14
+ 'configuring-foreman-server-for-cloud-connection'
15
+ );
16
+ });
17
+ });
18
+
4
19
  describe('isExitCodeLoading', () => {
5
20
  it('returns true when exit code contains "running"', () => {
6
21
  expect(isExitCodeLoading('currently running')).toBe(true);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_rh_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.1.3
4
+ version: 14.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Red Hat Cloud team
@@ -373,19 +373,10 @@ files:
373
373
  - webpack/ForemanInventoryUpload/Components/PageHeader/PageTitle.js
374
374
  - webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageHeader.test.js
375
375
  - webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/PageTitle.test.js
376
- - webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorActions.js
377
- - webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js
378
- - webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorConstants.js
379
- - webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorSelectors.js
380
- - webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/CloudConnectorButton.test.js
381
- - webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/index.js
382
376
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudPingModal/index.js
383
377
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js
384
378
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/PageDescription.test.js
385
379
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/index.js
386
- - webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.js
387
- - webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/SettingsWarning.test.js
388
- - webpack/ForemanInventoryUpload/Components/PageHeader/components/SettingsWarning/index.js
389
380
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButton.js
390
381
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js
391
382
  - webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonConstants.js
@@ -584,7 +575,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
584
575
  - !ruby/object:Gem::Version
585
576
  version: '0'
586
577
  requirements: []
587
- rubygems_version: 4.0.6
578
+ rubygems_version: 4.0.10
588
579
  specification_version: 4
589
580
  summary: Summary of ForemanRhCloud.
590
581
  test_files:
@@ -1,21 +0,0 @@
1
- import React from 'react';
2
- import { translate as __ } from 'foremanReact/common/I18n';
3
- import { post } from 'foremanReact/redux/API';
4
- import { CONFIGURE_CLOUD_CONNECTOR } from './CloudConnectorConstants';
5
- import { inventoryUrl } from '../../../../ForemanInventoryHelpers';
6
- import { foremanUrl } from '../../../../../ForemanRhCloudHelpers';
7
-
8
- export const configureCloudConnector = () =>
9
- post({
10
- key: CONFIGURE_CLOUD_CONNECTOR,
11
- url: inventoryUrl('cloud_connector'),
12
- successToast: response => (
13
- <span>
14
- {__('Cloud connector setup is in progress now: ')}
15
- <a href={foremanUrl(`/job_invocations/${response.data.id}`)}>
16
- {__('Cloud connector job link')}
17
- </a>
18
- </span>
19
- ),
20
- errorToast: error => `${__('Cloud connector setup has failed: ')} ${error}`,
21
- });
@@ -1,59 +0,0 @@
1
- import React, { useState } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { Spinner, Button, Popover } from '@patternfly/react-core';
4
- import { translate as __ } from 'foremanReact/common/I18n';
5
- import { CONNECTOR_STATUS } from './CloudConnectorConstants';
6
-
7
- export const CloudConnectorButton = ({ status, onClick, jobLink }) => {
8
- const [isPopoverVisible, setIsPopoverVisible] = useState(false);
9
- if (status === CONNECTOR_STATUS.PENDING) {
10
- return (
11
- <Popover
12
- isVisible={isPopoverVisible}
13
- shouldClose={() => setIsPopoverVisible(false)}
14
- bodyContent={
15
- <div>
16
- {__('Cloud connector setup has started: ')}
17
- <a href={jobLink} target="_blank" rel="noopener noreferrer">
18
- {__('view the job in progress')}
19
- </a>
20
- </div>
21
- }
22
- aria-label="Popover with Link to cloud connector job"
23
- closeBtnAriaLabel="Close cloud connector Popover"
24
- >
25
- <div
26
- className="cloud-connector-pending-button"
27
- onMouseEnter={() => setIsPopoverVisible(true)}
28
- >
29
- <Button variant="secondary" ouiaId="button-in-progress" isDisabled>
30
- <Spinner size="sm" /> {__('Cloud Connector is in progress')}
31
- </Button>
32
- </div>
33
- </Popover>
34
- );
35
- }
36
-
37
- if (status === CONNECTOR_STATUS.RESOLVED) {
38
- return (
39
- <Button variant="secondary" ouiaId="button-reconfigure" onClick={onClick}>
40
- {__('Reconfigure cloud connector')}
41
- </Button>
42
- );
43
- }
44
-
45
- return (
46
- <Button variant="secondary" ouiaId="button-configure" onClick={onClick}>
47
- {__('Configure cloud connector')}
48
- </Button>
49
- );
50
- };
51
-
52
- CloudConnectorButton.propTypes = {
53
- status: PropTypes.string.isRequired,
54
- onClick: PropTypes.func.isRequired,
55
- jobLink: PropTypes.string,
56
- };
57
- CloudConnectorButton.defaultProps = {
58
- jobLink: '',
59
- };
@@ -1,6 +0,0 @@
1
- export const CONFIGURE_CLOUD_CONNECTOR = 'CONFIGURE_CLOUD_CONNECTOR';
2
- export const CONNECTOR_STATUS = {
3
- PENDING: 'PENDING',
4
- RESOLVED: 'RESOLVED',
5
- NOT_RESOLVED: 'NOT_RESOLVED',
6
- };
@@ -1,19 +0,0 @@
1
- import { foremanUrl } from '../../../../../ForemanRhCloudHelpers';
2
- import { selectAccountsList } from '../../../AccountList/AccountListSelectors';
3
- import { CONNECTOR_STATUS } from './CloudConnectorConstants';
4
-
5
- export const SelectCloudConnectorStatus = state =>
6
- selectAccountsList(state).CloudConnectorStatus || {};
7
-
8
- export const selectStatus = state => {
9
- const { task } = SelectCloudConnectorStatus(state);
10
- if (!task) return CONNECTOR_STATUS.NOT_RESOLVED;
11
- if (task.result === 'pending') return CONNECTOR_STATUS.PENDING;
12
- if (task.result === 'success') return CONNECTOR_STATUS.RESOLVED;
13
- return CONNECTOR_STATUS.NOT_RESOLVED;
14
- };
15
-
16
- export const selectJobLink = state => {
17
- const { id } = SelectCloudConnectorStatus(state);
18
- return id ? foremanUrl(`/job_invocations/${id}`) : '';
19
- };
@@ -1,51 +0,0 @@
1
- import React from 'react';
2
- import { render, screen, fireEvent } from '@testing-library/react';
3
- import { CloudConnectorButton } from '../CloudConnectorButton';
4
- import { CONNECTOR_STATUS } from '../CloudConnectorConstants';
5
-
6
- describe('CloudConnectorButton', () => {
7
- it('renders "Configure cloud connector" when not resolved', () => {
8
- render(
9
- <CloudConnectorButton
10
- status={CONNECTOR_STATUS.NOT_RESOLVED}
11
- onClick={jest.fn()}
12
- />
13
- );
14
- expect(screen.getByRole('button', { name: /Configure cloud connector/ })).toBeTruthy();
15
- });
16
-
17
- it('renders "Reconfigure cloud connector" when resolved', () => {
18
- render(
19
- <CloudConnectorButton
20
- status={CONNECTOR_STATUS.RESOLVED}
21
- onClick={jest.fn()}
22
- />
23
- );
24
- expect(screen.getByRole('button', { name: /Reconfigure cloud connector/ })).toBeTruthy();
25
- });
26
-
27
- it('renders in-progress button when pending', () => {
28
- render(
29
- <CloudConnectorButton
30
- status={CONNECTOR_STATUS.PENDING}
31
- onClick={jest.fn()}
32
- jobLink="/job-link"
33
- />
34
- );
35
- expect(
36
- screen.getByText('Cloud Connector is in progress')
37
- ).toBeTruthy();
38
- });
39
-
40
- it('calls onClick when configure button is clicked', () => {
41
- const onClick = jest.fn();
42
- render(
43
- <CloudConnectorButton
44
- status={CONNECTOR_STATUS.NOT_RESOLVED}
45
- onClick={onClick}
46
- />
47
- );
48
- fireEvent.click(screen.getByRole('button', { name: /Configure cloud connector/ }));
49
- expect(onClick).toHaveBeenCalledTimes(1);
50
- });
51
- });
@@ -1,34 +0,0 @@
1
- import React from 'react';
2
- import { useSelector, useDispatch } from 'react-redux';
3
- import { openConfirmModal } from 'foremanReact/components/ConfirmModal';
4
- import { translate as __ } from 'foremanReact/common/I18n';
5
- import { CloudConnectorButton } from './CloudConnectorButton';
6
- import { configureCloudConnector } from './CloudConnectorActions';
7
- import { selectStatus, selectJobLink } from './CloudConnectorSelectors';
8
-
9
- const ConnectedCloudConnectorButton = () => {
10
- const status = useSelector(selectStatus);
11
- const jobLink = useSelector(selectJobLink);
12
- const dispatch = useDispatch();
13
-
14
- return (
15
- <CloudConnectorButton
16
- status={status}
17
- onClick={() =>
18
- dispatch(
19
- openConfirmModal({
20
- title: __('Notice'),
21
- message: __(
22
- 'This action will also enable automatic reports upload'
23
- ),
24
- isWarning: true,
25
- onConfirm: () => dispatch(configureCloudConnector()),
26
- })
27
- )
28
- }
29
- jobLink={jobLink}
30
- />
31
- );
32
- };
33
-
34
- export default ConnectedCloudConnectorButton;
@@ -1,66 +0,0 @@
1
- import React, { useState } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { Alert, AlertActionCloseButton } from '@patternfly/react-core';
4
- import { translate as __ } from 'foremanReact/common/I18n';
5
-
6
- export const SettingsWarning = ({
7
- autoUpload,
8
- hostObfuscation,
9
- isCloudConnector,
10
- }) => {
11
- const [showUploadWarning, setShowUploadWarning] = useState(true);
12
- const [showObfuscationWarning, setShowObfuscationWarning] = useState(true);
13
- if (!isCloudConnector || (!showUploadWarning && !showObfuscationWarning)) {
14
- return null;
15
- }
16
- if (autoUpload && !hostObfuscation) {
17
- return null;
18
- }
19
-
20
- const alerts = [];
21
- if (!autoUpload && showUploadWarning) {
22
- alerts.push(
23
- <Alert
24
- key="auto-upload"
25
- ouiaId="auto-upload"
26
- variant="warning"
27
- title={__(
28
- "Cloud Connector has been configured however the inventory auto-upload is disabled, it's recommended to enable it"
29
- )}
30
- actionClose={
31
- <AlertActionCloseButton onClose={() => setShowUploadWarning(false)} />
32
- }
33
- />
34
- );
35
- }
36
- if (hostObfuscation && showObfuscationWarning) {
37
- alerts.push(
38
- <Alert
39
- key="obfuscating-host"
40
- ouiaId="obfuscating-host"
41
- variant="warning"
42
- title={__(
43
- "Cloud Connector has been configured however obfuscating host names setting is enabled, it's recommended to disable it"
44
- )}
45
- actionClose={
46
- <AlertActionCloseButton
47
- onClose={() => setShowObfuscationWarning(false)}
48
- />
49
- }
50
- />
51
- );
52
- }
53
- return <div className="settings-alert">{alerts}</div>;
54
- };
55
-
56
- SettingsWarning.propTypes = {
57
- autoUpload: PropTypes.bool,
58
- hostObfuscation: PropTypes.bool,
59
- isCloudConnector: PropTypes.bool,
60
- };
61
-
62
- SettingsWarning.defaultProps = {
63
- autoUpload: false,
64
- hostObfuscation: false,
65
- isCloudConnector: false,
66
- };
@@ -1,61 +0,0 @@
1
- import React from 'react';
2
- import { render, screen } from '@testing-library/react';
3
- import { SettingsWarning } from './SettingsWarning';
4
-
5
- describe('SettingsWarning', () => {
6
- it('renders nothing when isCloudConnector is false', () => {
7
- render(
8
- <SettingsWarning autoUpload={false} isCloudConnector={false} />
9
- );
10
- expect(screen.queryByRole('alert')).toBeNull();
11
- });
12
-
13
- it('renders nothing when autoUpload is on and obfuscation is off', () => {
14
- render(
15
- <SettingsWarning
16
- autoUpload
17
- hostObfuscation={false}
18
- isCloudConnector
19
- />
20
- );
21
- expect(screen.queryByRole('alert')).toBeNull();
22
- });
23
-
24
- it('renders upload warning when autoUpload is disabled', () => {
25
- render(
26
- <SettingsWarning
27
- autoUpload={false}
28
- hostObfuscation={false}
29
- isCloudConnector
30
- />
31
- );
32
- expect(
33
- screen.getByText(/inventory auto-upload is disabled/)
34
- ).toBeTruthy();
35
- });
36
-
37
- it('renders obfuscation warning when hostObfuscation is enabled', () => {
38
- render(
39
- <SettingsWarning autoUpload hostObfuscation isCloudConnector />
40
- );
41
- expect(
42
- screen.getByText(/obfuscating host names setting is enabled/)
43
- ).toBeTruthy();
44
- });
45
-
46
- it('renders both warnings when both conditions met', () => {
47
- render(
48
- <SettingsWarning
49
- autoUpload={false}
50
- hostObfuscation
51
- isCloudConnector
52
- />
53
- );
54
- expect(
55
- screen.getByText(/inventory auto-upload is disabled/)
56
- ).toBeTruthy();
57
- expect(
58
- screen.getByText(/obfuscating host names setting is enabled/)
59
- ).toBeTruthy();
60
- });
61
- });
@@ -1,25 +0,0 @@
1
- import React from 'react';
2
- import { useSelector } from 'react-redux';
3
- import { SettingsWarning } from './SettingsWarning';
4
- import {
5
- selectAutoUploadEnabled,
6
- selectHostObfuscationEnabled,
7
- } from '../../../InventorySettings/InventorySettingsSelectors';
8
- import { CONNECTOR_STATUS } from '../CloudConnectorButton/CloudConnectorConstants';
9
- import { selectStatus } from '../CloudConnectorButton/CloudConnectorSelectors';
10
-
11
- const ConnectedSettingsWarning = () => {
12
- const autoUpload = useSelector(selectAutoUploadEnabled);
13
- const hostObfuscation = useSelector(selectHostObfuscationEnabled);
14
- const isCloudConnector =
15
- useSelector(selectStatus) === CONNECTOR_STATUS.RESOLVED;
16
- return (
17
- <SettingsWarning
18
- autoUpload={autoUpload}
19
- hostObfuscation={hostObfuscation}
20
- isCloudConnector={isCloudConnector}
21
- />
22
- );
23
- };
24
-
25
- export default ConnectedSettingsWarning;