foreman_rh_cloud 3.0.15 → 3.0.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (19) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_inventory_upload/accounts_controller.rb +8 -0
  3. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +0 -6
  4. data/app/services/foreman_rh_cloud/cloud_connector.rb +2 -1
  5. data/config/Gemfile.lock.gh_test +81 -66
  6. data/config/package-lock.json.gh_test +1261 -1455
  7. data/config/routes.rb +0 -1
  8. data/lib/foreman_rh_cloud/version.rb +1 -1
  9. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +6 -0
  10. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +2 -0
  11. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +6 -0
  12. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +6 -0
  13. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorActions.js +1 -7
  14. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js +16 -8
  15. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorSelectors.js +16 -11
  16. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorButton.test.js.snap +20 -12
  17. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/index.js +2 -8
  18. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/toolbarButtons.scss +4 -0
  19. metadata +2 -2
data/config/routes.rb CHANGED
@@ -11,7 +11,6 @@ Rails.application.routes.draw do
11
11
  post 'installed_packages_inclusion', to: 'uploads#installed_packages_inclusion'
12
12
  post 'ips_obfuscation', to: 'uploads#ips_obfuscation'
13
13
 
14
- get 'cloud_connector', to: 'uploads#cloud_connector_status'
15
14
  post 'cloud_connector', to: 'uploads#enable_cloud_connector'
16
15
 
17
16
  resources :tasks, only: [:create]
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '3.0.15'.freeze
2
+ VERSION = '3.0.16'.freeze
3
3
  end
@@ -42,6 +42,11 @@ export const cloudToken = 'some-cloud-token';
42
42
 
43
43
  export const excludePackages = false;
44
44
 
45
+ export const CloudConnectorStatus = {
46
+ id: 7,
47
+ task: { id: 11 },
48
+ };
49
+
45
50
  export const props = {
46
51
  accounts,
47
52
  fetchAccountsStatus: noop,
@@ -57,6 +62,7 @@ export const pollingResponse = {
57
62
  ipsObfuscationEnabled,
58
63
  cloudToken,
59
64
  excludePackages,
65
+ CloudConnectorStatus,
60
66
  };
61
67
 
62
68
  export const fetchAccountsStatusResponse = {
@@ -29,6 +29,7 @@ export default (state = initialState, action) => {
29
29
  ipsObfuscationEnabled,
30
30
  cloudToken,
31
31
  excludePackages,
32
+ CloudConnectorStatus,
32
33
  } = {},
33
34
  } = action;
34
35
 
@@ -42,6 +43,7 @@ export default (state = initialState, action) => {
42
43
  ipsObfuscationEnabled,
43
44
  cloudToken,
44
45
  excludePackages,
46
+ CloudConnectorStatus,
45
47
  error: null,
46
48
  });
47
49
  case INVENTORY_ACCOUNT_STATUS_POLLING_ERROR:
@@ -5,6 +5,12 @@ Array [
5
5
  Array [
6
6
  Object {
7
7
  "payload": Object {
8
+ "CloudConnectorStatus": Object {
9
+ "id": 7,
10
+ "task": Object {
11
+ "id": 11,
12
+ },
13
+ },
8
14
  "accounts": Object {
9
15
  "Account1": Object {
10
16
  "generate_report_status": "running",
@@ -20,6 +20,12 @@ Object {
20
20
 
21
21
  exports[`AccountList reducer should handle INVENTORY_ACCOUNT_STATUS_POLLING 1`] = `
22
22
  Object {
23
+ "CloudConnectorStatus": Object {
24
+ "id": 7,
25
+ "task": Object {
26
+ "id": 11,
27
+ },
28
+ },
23
29
  "accounts": Object {
24
30
  "Account1": Object {
25
31
  "generate_report_status": "running",
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { translate as __ } from 'foremanReact/common/I18n';
3
- import { get, post } from 'foremanReact/redux/API';
3
+ import { post } from 'foremanReact/redux/API';
4
4
  import { CONFIGURE_CLOUD_CONNECTOR } from './CloudConnectorConstants';
5
5
  import { inventoryUrl } from '../../../../ForemanInventoryHelpers';
6
6
  import { foremanUrl } from '../../../../../ForemanRhCloudHelpers';
@@ -19,9 +19,3 @@ export const configureCloudConnector = () =>
19
19
  ),
20
20
  errorToast: error => `${__('Cloud connector setup has failed: ')} ${error}`,
21
21
  });
22
-
23
- export const getCloudConnector = () =>
24
- get({
25
- key: CONFIGURE_CLOUD_CONNECTOR,
26
- url: inventoryUrl('cloud_connector'),
27
- });
@@ -1,35 +1,43 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { Spinner, Button, Popover } from '@patternfly/react-core';
4
4
  import { translate as __ } from 'foremanReact/common/I18n';
5
5
  import { CONNECTOR_STATUS } from './CloudConnectorConstants';
6
6
 
7
7
  export const CloudConnectorButton = ({ status, onClick, jobLink }) => {
8
+ const [isPopoverVisible, setIsPopoverVisible] = useState(false);
8
9
  if (status === CONNECTOR_STATUS.PENDING) {
9
10
  return (
10
11
  <Popover
12
+ isVisible={isPopoverVisible}
13
+ shouldClose={() => setIsPopoverVisible(false)}
11
14
  bodyContent={
12
15
  <div>
13
- {__('Cloud connector job is still running, you can view it here:')}
16
+ {__('Cloud connector setup has started: ')}
14
17
  <a href={jobLink} target="_blank" rel="noopener noreferrer">
15
- {__('Open job')}
18
+ {__('view the job in progress')}
16
19
  </a>
17
20
  </div>
18
21
  }
19
22
  aria-label="Popover with Link to cloud connector job"
20
23
  closeBtnAriaLabel="Close cloud connector Popover"
21
24
  >
22
- <Button variant="secondary">
23
- <Spinner size="sm" /> {__('Cloud Connector in progress')}
24
- </Button>
25
+ <div
26
+ className="cloud-connector-pending-button"
27
+ onMouseEnter={() => setIsPopoverVisible(true)}
28
+ >
29
+ <Button variant="secondary" isDisabled>
30
+ <Spinner size="sm" /> {__('Cloud Connector is in progress')}
31
+ </Button>
32
+ </div>
25
33
  </Popover>
26
34
  );
27
35
  }
28
36
 
29
37
  if (status === CONNECTOR_STATUS.RESOLVED) {
30
38
  return (
31
- <Button variant="secondary" isDisabled>
32
- {__('Cloud Connector is configured')}
39
+ <Button variant="secondary" onClick={onClick}>
40
+ {__('Reconfigure Cloud Connector')}
33
41
  </Button>
34
42
  );
35
43
  }
@@ -1,14 +1,19 @@
1
- import { selectAPIResponse } from 'foremanReact/redux/API/APISelectors';
1
+ import { foremanUrl } from '../../../../../ForemanRhCloudHelpers';
2
+ import { selectAccountsList } from '../../../AccountList/AccountListSelectors';
3
+ import { CONNECTOR_STATUS } from './CloudConnectorConstants';
2
4
 
3
- import {
4
- CONFIGURE_CLOUD_CONNECTOR,
5
- CONNECTOR_STATUS,
6
- } from './CloudConnectorConstants';
5
+ export const SelectCloudConnectorStatus = state =>
6
+ selectAccountsList(state).CloudConnectorStatus || {};
7
7
 
8
- export const selectStatus = state =>
9
- selectAPIResponse(state, CONFIGURE_CLOUD_CONNECTOR)?.result === 'success'
10
- ? CONNECTOR_STATUS.RESOLVED
11
- : CONNECTOR_STATUS.NOT_RESOLVED;
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
+ };
12
15
 
13
- export const selectJobLink = state =>
14
- selectAPIResponse(state, CONFIGURE_CLOUD_CONNECTOR).job_link || '';
16
+ export const selectJobLink = state => {
17
+ const { id } = SelectCloudConnectorStatus(state);
18
+ return id ? foremanUrl(`/job_invocations/${id}`) : '';
19
+ };
@@ -14,35 +14,43 @@ exports[`CloudConnectorButton render pending connector 1`] = `
14
14
  aria-label="Popover with Link to cloud connector job"
15
15
  bodyContent={
16
16
  <div>
17
- Cloud connector job is still running, you can view it here:
17
+ Cloud connector setup has started:
18
18
  <a
19
19
  href="/job-link"
20
20
  rel="noopener noreferrer"
21
21
  target="_blank"
22
22
  >
23
- Open job
23
+ view the job in progress
24
24
  </a>
25
25
  </div>
26
26
  }
27
27
  closeBtnAriaLabel="Close cloud connector Popover"
28
+ isVisible={false}
29
+ shouldClose={[Function]}
28
30
  >
29
- <Button
30
- variant="secondary"
31
+ <div
32
+ className="cloud-connector-pending-button"
33
+ onMouseEnter={[Function]}
31
34
  >
32
- <Spinner
33
- size="sm"
34
- />
35
-
36
- Cloud Connector in progress
37
- </Button>
35
+ <Button
36
+ isDisabled={true}
37
+ variant="secondary"
38
+ >
39
+ <Spinner
40
+ size="sm"
41
+ />
42
+
43
+ Cloud Connector is in progress
44
+ </Button>
45
+ </div>
38
46
  </Popover>
39
47
  `;
40
48
 
41
49
  exports[`CloudConnectorButton render resolved cloud connector 1`] = `
42
50
  <Button
43
- isDisabled={true}
51
+ onClick={[MockFunction]}
44
52
  variant="secondary"
45
53
  >
46
- Cloud Connector is configured
54
+ Reconfigure Cloud Connector
47
55
  </Button>
48
56
  `;
@@ -1,10 +1,7 @@
1
- import React, { useEffect } from 'react';
1
+ import React from 'react';
2
2
  import { useSelector, useDispatch } from 'react-redux';
3
3
  import { CloudConnectorButton } from './CloudConnectorButton';
4
- import {
5
- configureCloudConnector,
6
- getCloudConnector,
7
- } from './CloudConnectorActions';
4
+ import { configureCloudConnector } from './CloudConnectorActions';
8
5
  import { selectStatus, selectJobLink } from './CloudConnectorSelectors';
9
6
 
10
7
  const ConnectedCloudConnectorButton = () => {
@@ -12,9 +9,6 @@ const ConnectedCloudConnectorButton = () => {
12
9
  const jobLink = useSelector(selectJobLink);
13
10
  const dispatch = useDispatch();
14
11
 
15
- useEffect(() => {
16
- dispatch(getCloudConnector());
17
- }, [dispatch]);
18
12
  return (
19
13
  <CloudConnectorButton
20
14
  status={status}
@@ -8,4 +8,8 @@
8
8
  .sync_button .spinner {
9
9
  margin: 3px 5px 0 -3px;
10
10
  }
11
+
12
+ .cloud-connector-pending-button {
13
+ display: inline-block;
14
+ }
11
15
  }
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: 3.0.15
4
+ version: 3.0.16
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: 2021-02-02 00:00:00.000000000 Z
11
+ date: 2021-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: katello