foreman_rh_cloud 11.0.3 → 11.1.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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/app/controllers/api/v2/advisor_engine/advisor_engine_controller.rb +98 -0
  4. data/app/controllers/api/v2/rh_cloud/advisor_engine_config_controller.rb +16 -0
  5. data/app/models/concerns/rh_cloud_host.rb +5 -0
  6. data/app/services/foreman_rh_cloud/cloud_connector.rb +1 -1
  7. data/app/services/foreman_rh_cloud/cloud_request.rb +1 -1
  8. data/app/services/foreman_rh_cloud/hits_uploader.rb +55 -0
  9. data/app/views/api/v2/advisor_engine/host_details.json.rabl +9 -0
  10. data/app/views/api/v2/hosts/insights/base.rabl +5 -0
  11. data/app/views/api/v2/hosts/insights/insights.rabl +3 -0
  12. data/config/routes.rb +6 -1
  13. data/db/migrate/20241217190624_add_unique_index_to_rule_id_and_host_id_in_insights_hits.rb +5 -0
  14. data/db/migrate/20241220184900_change_sync_insights_recommendations_to_true.rb +5 -0
  15. data/lib/foreman_inventory_upload/async/generate_all_reports_job.rb +21 -13
  16. data/lib/foreman_inventory_upload/async/upload_report_job.rb +1 -1
  17. data/lib/foreman_inventory_upload/generators/slice.rb +1 -1
  18. data/lib/foreman_rh_cloud/engine.rb +24 -5
  19. data/lib/foreman_rh_cloud/version.rb +1 -1
  20. data/lib/foreman_rh_cloud.rb +21 -31
  21. data/lib/insights_cloud/async/insights_scheduled_sync.rb +10 -2
  22. data/lib/inventory_sync/async/inventory_full_sync.rb +0 -10
  23. data/lib/inventory_sync/async/inventory_scheduled_sync.rb +15 -7
  24. data/package.json +1 -1
  25. data/test/controllers/insights_cloud/api/advisor_engine_controller_test.rb +48 -0
  26. data/test/controllers/insights_sync/settings_controller_test.rb +3 -0
  27. data/test/factories/insights_factories.rb +1 -1
  28. data/test/jobs/inventory_scheduled_sync_test.rb +10 -0
  29. data/test/unit/rh_cloud_http_proxy_test.rb +1 -26
  30. data/test/unit/services/foreman_rh_cloud/hits_uploader_test.rb +120 -0
  31. data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap +1 -1
  32. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/CloudConnectorButton.js +2 -2
  33. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudConnectorButton/__tests__/__snapshots__/CloudConnectorButton.test.js.snap +2 -2
  34. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js +3 -1
  35. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/__snapshots__/PageDescription.test.js.snap +1 -1
  36. data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/SyncButton.test.js.snap +1 -1
  37. data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.js +1 -1
  38. data/webpack/ForemanInventoryUpload/ForemanInventoryConstants.js +1 -1
  39. data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +1 -1
  40. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettings.js +26 -22
  41. data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettingsActions.js +2 -1
  42. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTable.js +10 -1
  43. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableConstants.js +8 -1
  44. data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js +3 -1
  45. data/webpack/InsightsCloudSync/Components/ToolbarDropdown.js +5 -0
  46. data/webpack/InsightsCloudSync/InsightsCloudSync.js +1 -2
  47. data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +1 -1
  48. data/webpack/InsightsHostDetailsTab/NewHostDetailsTab.js +3 -1
  49. data/webpack/__mocks__/foremanReact/common/hooks/API/APIHooks.js +3 -0
  50. data/webpack/common/Hooks/ConfigHooks.js +19 -0
  51. metadata +17 -9
  52. data/webpack/InsightsCloudSync/Components/InsightsHeader/InsightsHeader.scss +0 -8
  53. data/webpack/InsightsCloudSync/Components/InsightsHeader/index.js +0 -16
  54. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/InsightsSettings.test.js +0 -18
  55. data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettings.test.js.snap +0 -15
  56. data/webpack/InsightsCloudSync/Components/__tests__/InsightsHeader.test.js +0 -10
  57. data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/InsightsHeader.test.js.snap +0 -13
@@ -2,6 +2,9 @@ require 'test_plugin_helper'
2
2
 
3
3
  class SettingsControllerTest < ActionController::TestCase
4
4
  tests InsightsCloud::SettingsController
5
+ def setup
6
+ ForemanRhCloud.stubs(:with_local_advisor_engine?).returns(false)
7
+ end
5
8
 
6
9
  test 'should return allow_auto_insights_sync setting' do
7
10
  Setting[:allow_auto_insights_sync] = false
@@ -1,6 +1,6 @@
1
1
  FactoryBot.define do
2
2
  factory :insights_facet do
3
- # sequence(:uuid) { |n| "uuid-#{n}" }
3
+ sequence(:uuid) { |n| "uuid-#{n}" }
4
4
 
5
5
  trait :with_hits do
6
6
  hits do
@@ -14,6 +14,16 @@ class InventoryScheduledSyncTest < ActiveSupport::TestCase
14
14
  ForemanTasks.sync_task(InventorySync::Async::InventoryScheduledSync)
15
15
  end
16
16
 
17
+ test 'Skips execution if with_local_advisor_engine? is true' do
18
+ ForemanRhCloud.stubs(:with_local_advisor_engine?).returns(true)
19
+
20
+ InventorySync::Async::InventoryScheduledSync.any_instance.expects(:plan_org_sync).never
21
+
22
+ task = ForemanTasks.sync_task(InventorySync::Async::InventoryScheduledSync)
23
+ status = task.output[:status].to_s
24
+ assert_match(/Foreman is configured with the use_local_advisor_engine option/, status)
25
+ end
26
+
17
27
  test 'Skips execution if auto upload is disabled' do
18
28
  Setting[:allow_auto_inventory_upload] = false
19
29
 
@@ -4,29 +4,12 @@ class RhCloudHttpProxyTest < ActiveSupport::TestCase
4
4
  setup do
5
5
  @global_content_proxy_mock = 'http://global:content@localhost:80'
6
6
  @global_foreman_proxy_mock = 'http://global:foreman@localhost:80'
7
- @katello_cdn_proxy_mock = {
8
- host: 'localhost',
9
- port: '80',
10
- user: 'katello',
11
- password: 'cdn',
12
- scheme: 'http',
13
- }
14
- @katello_cdn_proxy_string_mock = 'http://katello:cdn@localhost:80'
15
7
  end
16
8
 
17
9
  test 'selects global content proxy' do
18
10
  setup_global_content_proxy
19
11
  setup_global_foreman_proxy
20
- setup_cdn_proxy do
21
- assert_equal @global_content_proxy_mock, ForemanRhCloud.proxy_setting
22
- end
23
- end
24
-
25
- test 'selects cdn proxy' do
26
- setup_global_foreman_proxy
27
- setup_cdn_proxy do
28
- assert_equal @katello_cdn_proxy_string_mock, ForemanRhCloud.proxy_setting
29
- end
12
+ assert_equal @global_content_proxy_mock, ForemanRhCloud.proxy_setting
30
13
  end
31
14
 
32
15
  test 'selects global foreman proxy' do
@@ -44,14 +27,6 @@ class RhCloudHttpProxyTest < ActiveSupport::TestCase
44
27
  Setting[:http_proxy] = @global_foreman_proxy_mock
45
28
  end
46
29
 
47
- def setup_cdn_proxy
48
- old_cdn_setting = SETTINGS[:katello][:cdn_proxy]
49
- SETTINGS[:katello][:cdn_proxy] = @katello_cdn_proxy_mock
50
- yield
51
- ensure
52
- SETTINGS[:katello][:cdn_proxy] = old_cdn_setting
53
- end
54
-
55
30
  test 'transform proxy scheme test' do
56
31
  mock_http_proxy = 'http://user:password@localhost:8888'
57
32
  mock_https_proxy = 'https://user:password@localhost:8888'
@@ -0,0 +1,120 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class HitsUploaderTest < ActiveSupport::TestCase
4
+ PAYLOAD = {
5
+ resolutions: [
6
+ {
7
+ rule_id: "R123",
8
+ description: "Apply security patch to fix vulnerability CVE-2025-0001.",
9
+ needs_reboot: true,
10
+ resolution_risk: "Medium",
11
+ resolution_type: "fix",
12
+ },
13
+ {
14
+ rule_id: "R124",
15
+ description: "Update configuration file to improve system stability.",
16
+ needs_reboot: false,
17
+ resolution_risk: "Low",
18
+ resolution_type: "fix",
19
+ },
20
+ ],
21
+ rules: [
22
+ {
23
+ rule_id: "R123",
24
+ description: "Security patch for CVE-2025-0001.",
25
+ category_name: "Security",
26
+ impact_name: "High",
27
+ summary: "Fixes critical vulnerability.",
28
+ generic: "Security updates are mandatory.",
29
+ reason: "Vulnerability exposed in external audit.",
30
+ total_risk: 5,
31
+ reboot_required: true,
32
+ more_info: "https://example.com/security-update",
33
+ rating: 4.8,
34
+ },
35
+ {
36
+ rule_id: "R124",
37
+ description: "Configuration update to improve performance.",
38
+ category_name: "Availability",
39
+ impact_name: "Medium",
40
+ summary: "Improves application stability and reduces crashes.",
41
+ generic: "Periodic updates recommended.",
42
+ reason: "Frequent crashes observed in logs.",
43
+ total_risk: 3,
44
+ reboot_required: false,
45
+ more_info: "https://example.com/config-update",
46
+ rating: 4.0,
47
+ },
48
+ ],
49
+ hits: [
50
+ {
51
+ rule_id: "R123",
52
+ title: "Critical Vulnerability Patch",
53
+ solution_url: "https://example.com/solution",
54
+ total_risk: 5,
55
+ likelihood: 4,
56
+ publish_date: "2025-01-01",
57
+ results_url: "https://example.com/results",
58
+ },
59
+ {
60
+ rule_id: "R124",
61
+ title: "Configuration Update",
62
+ solution_url: "https://example.com/config-solution",
63
+ total_risk: 3,
64
+ likelihood: 3,
65
+ publish_date: "2025-01-02",
66
+ results_url: "https://example.com/config-results",
67
+ },
68
+ ],
69
+ details: "{\"summary\": \"Detected issues and resolutions applied successfully.\"}",
70
+ }.freeze
71
+
72
+ setup do
73
+ @host = FactoryBot.create(:host)
74
+ @uuid = SecureRandom.uuid
75
+ uploader = ForemanRhCloud::HitsUploader.new(host: @host, payload: PAYLOAD, uuid: @uuid)
76
+ uploader.upload!
77
+ @host.reload
78
+ end
79
+
80
+ test 'facets' do
81
+ assert_equal @uuid, @host.insights_facet.uuid
82
+ end
83
+
84
+ test 'hits' do
85
+ assert_equal PAYLOAD[:hits].count, @host.insights_facet.hits_count
86
+ assert_includes @host.insights_facet.hits.pluck(:rule_id), "R124"
87
+ end
88
+
89
+ test "resolutions" do
90
+ assert_equal 2, InsightsResolution.where(rule_id: ["R123", "R124"]).count
91
+ end
92
+
93
+ test "details" do
94
+ fact_name = FactName.where(name: "insights::hit_details").first
95
+ fact_value = @host.fact_values.where(fact_name: fact_name).first
96
+ refute_nil fact_value
97
+ assert_equal PAYLOAD[:details], fact_value.value
98
+ end
99
+
100
+ test "empty payload" do
101
+ payload = {
102
+ resolutions: [],
103
+ rules: [],
104
+ hits: [],
105
+ details: "",
106
+ }
107
+
108
+ @host = FactoryBot.create(:host)
109
+ @uuid = SecureRandom.uuid
110
+ uploader = ForemanRhCloud::HitsUploader.new(host: @host, payload: payload, uuid: @uuid)
111
+ uploader.upload!
112
+ @host.reload
113
+ assert_equal @uuid, @host.insights_facet.uuid
114
+ assert_empty @host.insights_facet.hits
115
+ assert_equal 0, @host.insights_facet.hits_count
116
+ fact_name = FactName.where(name: "insights::hit_details").first
117
+ fact_value = @host.fact_values.where(fact_name: fact_name).first
118
+ assert_nil fact_value
119
+ end
120
+ end
@@ -24,7 +24,7 @@ exports[`PageTitle rendering render without Props 1`] = `
24
24
  dropdownItems={
25
25
  Array [
26
26
  <DropdownItem
27
- href="/foreman_tasks/tasks?search=action++%3D++ForemanInventoryUpload%3A%3AAsync%3A%3AGenerateReportJob+or+action++%3D++ForemanInventoryUpload%3A%3AAsync%3A%3AGenerateAllReportsJob&page=1"
27
+ href="/foreman_tasks/tasks?search=label+%3D+ForemanInventoryUpload%3A%3AAsync%3A%3AGenerateReportJob+or+label+%3D+ForemanInventoryUpload%3A%3AAsync%3A%3AGenerateAllReportsJob&page=1"
28
28
  rel="noopener noreferrer"
29
29
  target="_blank"
30
30
  >
@@ -37,14 +37,14 @@ export const CloudConnectorButton = ({ status, onClick, jobLink }) => {
37
37
  if (status === CONNECTOR_STATUS.RESOLVED) {
38
38
  return (
39
39
  <Button variant="secondary" onClick={onClick}>
40
- {__('Reconfigure Cloud Connector')}
40
+ {__('Reconfigure cloud connector')}
41
41
  </Button>
42
42
  );
43
43
  }
44
44
 
45
45
  return (
46
46
  <Button variant="secondary" onClick={onClick}>
47
- {__('Configure Cloud Connector')}
47
+ {__('Configure cloud connector')}
48
48
  </Button>
49
49
  );
50
50
  };
@@ -5,7 +5,7 @@ exports[`CloudConnectorButton render no cloud connector 1`] = `
5
5
  onClick={[MockFunction]}
6
6
  variant="secondary"
7
7
  >
8
- Configure Cloud Connector
8
+ Configure cloud connector
9
9
  </Button>
10
10
  `;
11
11
 
@@ -51,6 +51,6 @@ exports[`CloudConnectorButton render resolved cloud connector 1`] = `
51
51
  onClick={[MockFunction]}
52
52
  variant="secondary"
53
53
  >
54
- Reconfigure Cloud Connector
54
+ Reconfigure cloud connector
55
55
  </Button>
56
56
  `;
@@ -34,7 +34,9 @@ export const PageDescription = () => (
34
34
  'To manually upload the data for a specific organization, select an organization and click {restartButtonName}.'
35
35
  )}
36
36
  values={{
37
- restartButtonName: <strong>{__('Restart')}</strong>,
37
+ restartButtonName: (
38
+ <strong>{__('Generate and upload report')}</strong>
39
+ ),
38
40
  }}
39
41
  />
40
42
  </Text>
@@ -30,7 +30,7 @@ exports[`PageDescription rendering render without Props 1`] = `
30
30
  values={
31
31
  Object {
32
32
  "restartButtonName": <strong>
33
- Restart
33
+ Generate and upload report
34
34
  </strong>,
35
35
  }
36
36
  }
@@ -9,7 +9,7 @@ exports[`SyncButton rendering render with Props 1`] = `
9
9
  size="lg"
10
10
  variant="secondary"
11
11
  >
12
- Sync inventory status
12
+ Sync all inventory status
13
13
  </Button>
14
14
  </Fragment>
15
15
  `;
@@ -19,7 +19,7 @@ const TabHeader = ({ exitCode, onRestart, onDownload, toggleFullScreen }) => (
19
19
  onClick={onRestart}
20
20
  disabled={isExitCodeLoading(exitCode)}
21
21
  >
22
- {__('Restart')}
22
+ {__('Generate and upload report')}
23
23
  </Button>
24
24
  ) : null}
25
25
  {onDownload ? (
@@ -6,6 +6,6 @@ export const DOCS_BUTTON_TEXT = __('Documentation');
6
6
 
7
7
  export const ACTIONS_HISTORY_BUTTON_TEXT = __('Actions history');
8
8
 
9
- export const SYNC_BUTTON_TEXT = __(' Sync inventory status');
9
+ export const SYNC_BUTTON_TEXT = __(' Sync all inventory status');
10
10
 
11
11
  export const CLOUD_PING_TITLE = __('Connectivity test');
@@ -13,7 +13,7 @@ export const getInventoryDocsUrl = () =>
13
13
 
14
14
  export const getActionsHistoryUrl = () =>
15
15
  foremanUrl(
16
- '/foreman_tasks/tasks?search=action++%3D++ForemanInventoryUpload%3A%3AAsync%3A%3AGenerateReportJob+or+action++%3D++ForemanInventoryUpload%3A%3AAsync%3A%3AGenerateAllReportsJob&page=1'
16
+ '/foreman_tasks/tasks?search=label+%3D+ForemanInventoryUpload%3A%3AAsync%3A%3AGenerateReportJob+or+label+%3D+ForemanInventoryUpload%3A%3AAsync%3A%3AGenerateAllReportsJob&page=1'
17
17
  );
18
18
 
19
19
  export const isExitCodeLoading = exitCode => {
@@ -1,32 +1,36 @@
1
- import React, { Component } from 'react';
1
+ import React, { useEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { translate as __ } from 'foremanReact/common/I18n';
4
4
  import SwitcherPF4 from '../../../common/Switcher/SwitcherPF4';
5
5
  import './insightsSettings.scss';
6
+ import { useAdvisorEngineConfig } from '../../../common/Hooks/ConfigHooks';
6
7
 
7
- class InsightsSettings extends Component {
8
- componentDidMount() {
9
- const { getInsightsSyncSettings } = this.props;
8
+ const InsightsSettings = ({
9
+ insightsSyncEnabled,
10
+ getInsightsSyncSettings,
11
+ setInsightsSyncEnabled,
12
+ }) => {
13
+ const isLocalAdvisorEngine = useAdvisorEngineConfig();
14
+ useEffect(() => {
10
15
  getInsightsSyncSettings();
11
- }
16
+ }, [getInsightsSyncSettings]);
12
17
 
13
- render() {
14
- const { insightsSyncEnabled, setInsightsSyncEnabled } = this.props;
15
- return (
16
- <div className="insights_settings">
17
- <SwitcherPF4
18
- id="insights_sync_switcher"
19
- label={__('Sync automatically')}
20
- tooltip={__(
21
- 'Enable automatic synchronization of Insights recommendations from the Red Hat cloud'
22
- )}
23
- isChecked={insightsSyncEnabled}
24
- onChange={() => setInsightsSyncEnabled(!insightsSyncEnabled)}
25
- />
26
- </div>
27
- );
28
- }
29
- }
18
+ if (isLocalAdvisorEngine) return null;
19
+
20
+ return (
21
+ <div className="insights_settings">
22
+ <SwitcherPF4
23
+ id="insights_sync_switcher"
24
+ label={__('Sync automatically')}
25
+ tooltip={__(
26
+ 'Enable automatic synchronization of Insights recommendations from the Red Hat cloud'
27
+ )}
28
+ isChecked={insightsSyncEnabled}
29
+ onChange={() => setInsightsSyncEnabled(!insightsSyncEnabled)}
30
+ />
31
+ </div>
32
+ );
33
+ };
30
34
 
31
35
  InsightsSettings.propTypes = {
32
36
  insightsSyncEnabled: PropTypes.bool.isRequired,
@@ -19,7 +19,8 @@ export const getInsightsSyncSettings = () => async dispatch => {
19
19
  },
20
20
  },
21
21
  });
22
- } catch ({ message }) {
22
+ } catch (err) {
23
+ const { message } = err;
23
24
  dispatch(
24
25
  addToast({
25
26
  sticky: true,
@@ -12,6 +12,7 @@ import TableEmptyState from '../../../common/table/EmptyState';
12
12
  import { modifySelectedRows, getSortColumnIndex } from './InsightsTableHelpers';
13
13
  import Pagination from './Pagination';
14
14
  import './table.scss';
15
+ import { useAdvisorEngineConfig } from '../../../common/Hooks/ConfigHooks';
15
16
 
16
17
  const InsightsTable = ({
17
18
  page,
@@ -43,9 +44,17 @@ const InsightsTable = ({
43
44
  fetchInsights({ page, perPage, query, sortBy, sortOrder });
44
45
  }, [hostname]);
45
46
 
47
+ const isLocalAdvisorEngine = useAdvisorEngineConfig();
48
+
46
49
  useEffect(() => {
47
50
  setRows(
48
- modifySelectedRows(hits, selectedIds, showSelectAllAlert, hideHost)
51
+ modifySelectedRows(
52
+ hits,
53
+ selectedIds,
54
+ showSelectAllAlert,
55
+ hideHost,
56
+ isLocalAdvisorEngine
57
+ )
49
58
  );
50
59
 
51
60
  if (hideHost) setColumns(getColumnsWithoutHostname());
@@ -31,10 +31,11 @@ export const hasPlaybookFormatter = ({ title: hasPlaybook }) => ({
31
31
  });
32
32
 
33
33
  export const actionsFormatter = (props, { rowData = {} }) => {
34
- const { recommendationUrl, accessRHUrl } = rowData;
34
+ const { recommendationUrl, accessRHUrl, isLocalAdvisorEngine } = rowData;
35
35
  const dropdownItems = [];
36
36
 
37
37
  recommendationUrl &&
38
+ !isLocalAdvisorEngine &&
38
39
  dropdownItems.push(
39
40
  <DropdownItem key="recommendation-url">
40
41
  <a href={recommendationUrl} target="_blank" rel="noopener noreferrer">
@@ -121,4 +122,10 @@ export const INSIGHTS_SET_SELECT_ALL_ALERT = 'INSIGHTS_SET_SELECT_ALL_ALERT';
121
122
 
122
123
  export const INSIGHTS_SET_SELECT_ALL = 'INSIGHTS_SET_SELECT_ALL';
123
124
 
125
+ export const ADVISOR_ENGINE_CONFIG_KEY = 'ADVISOR_ENGINE_CONFIG';
126
+
127
+ export const ADVISOR_ENGINE_CONFIG_PATH = foremanUrl(
128
+ '/api/v2/rh_cloud/advisor_engine_config'
129
+ );
130
+
124
131
  export const NEW_HOST_PATH = '/new/hosts/';
@@ -6,7 +6,8 @@ export const modifySelectedRows = (
6
6
  hits,
7
7
  selectedIds,
8
8
  showSelectAllAlert,
9
- hideHost
9
+ hideHost,
10
+ isLocalAdvisorEngine
10
11
  ) => {
11
12
  if (hits.length === 0) return [];
12
13
 
@@ -34,6 +35,7 @@ export const modifySelectedRows = (
34
35
  selected: selectedIds[id] || (disableCheckbox && showSelectAllAlert),
35
36
  recommendationUrl: results_url,
36
37
  accessRHUrl: solution_url,
38
+ isLocalAdvisorEngine,
37
39
  };
38
40
  }
39
41
  );
@@ -4,9 +4,14 @@ import { translate as __ } from 'foremanReact/common/I18n';
4
4
  import { Dropdown, DropdownItem, KebabToggle } from '@patternfly/react-core';
5
5
  import { ExternalLinkAltIcon } from '@patternfly/react-icons';
6
6
  import { redHatAdvisorSystems } from '../InsightsCloudSyncHelpers';
7
+ import { useAdvisorEngineConfig } from '../../common/Hooks/ConfigHooks';
7
8
 
8
9
  const ToolbarDropdown = ({ onRecommendationSync }) => {
9
10
  const [isDropdownOpen, setIsDropdownOpen] = useState(false);
11
+ const isLocalAdvisorEngine = useAdvisorEngineConfig();
12
+ if (isLocalAdvisorEngine) {
13
+ return null;
14
+ }
10
15
  const dropdownItems = [
11
16
  <DropdownItem
12
17
  key="recommendation-manual-sync"
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import PageLayout from 'foremanReact/routes/common/PageLayout/PageLayout';
4
- import InsightsHeader from './Components/InsightsHeader';
5
4
  import InsightsTable from './Components/InsightsTable';
6
5
  import RemediationModal from './Components/RemediationModal';
7
6
  import {
@@ -37,7 +36,7 @@ const InsightsCloudSync = ({ syncInsights, query, fetchInsights }) => {
37
36
  header={INSIGHTS_SYNC_PAGE_TITLE}
38
37
  toolbarButtons={toolbarButtons}
39
38
  searchQuery={query}
40
- beforeToolbarComponent={<InsightsHeader />}
39
+ beforeToolbarComponent={null}
41
40
  >
42
41
  <InsightsTable />
43
42
  </PageLayout>
@@ -6,7 +6,7 @@ exports[`InsightsCloudSync render 1`] = `
6
6
  >
7
7
  <Connect(InsightsSettings) />
8
8
  <PageLayout
9
- beforeToolbarComponent={<InsightsHeader />}
9
+ beforeToolbarComponent={null}
10
10
  header="Red Hat Insights"
11
11
  onSearch={[Function]}
12
12
  searchProps={
@@ -21,11 +21,13 @@ import {
21
21
  selectHits,
22
22
  } from '../InsightsCloudSync/Components/InsightsTable/InsightsTableSelectors';
23
23
  import { redHatAdvisorSystems } from '../InsightsCloudSync/InsightsCloudSyncHelpers';
24
+ import { useAdvisorEngineConfig } from '../common/Hooks/ConfigHooks';
24
25
 
25
26
  const NewHostDetailsTab = ({ hostName, router }) => {
26
27
  const dispatch = useDispatch();
27
28
  const query = useSelector(selectSearch);
28
29
  const hits = useSelector(selectHits);
30
+ const isLocalAdvisorEngine = useAdvisorEngineConfig();
29
31
 
30
32
  useEffect(() => () => router.replace({ search: null }), [router]);
31
33
 
@@ -41,7 +43,7 @@ const NewHostDetailsTab = ({ hostName, router }) => {
41
43
  </DropdownItem>,
42
44
  ];
43
45
 
44
- if (hits.length) {
46
+ if (hits.length && !isLocalAdvisorEngine) {
45
47
  const { host_uuid: uuid } = hits[0];
46
48
  dropdownItems.push(
47
49
  <DropdownItem key="insights-advisor-link" ouiaId="insights-advisor-link">
@@ -0,0 +1,3 @@
1
+ export const useAPI = jest.fn(() => ({
2
+ response: {},
3
+ }));
@@ -0,0 +1,19 @@
1
+ import { useAPI } from 'foremanReact/common/hooks/API/APIHooks';
2
+ import {
3
+ ADVISOR_ENGINE_CONFIG_KEY,
4
+ ADVISOR_ENGINE_CONFIG_PATH,
5
+ } from '../../InsightsCloudSync/Components/InsightsTable/InsightsTableConstants';
6
+
7
+ export const useAdvisorEngineConfig = () => {
8
+ const { response: advisorEngineConfig } = useAPI(
9
+ 'get',
10
+ ADVISOR_ENGINE_CONFIG_PATH,
11
+ {
12
+ key: ADVISOR_ENGINE_CONFIG_KEY,
13
+ }
14
+ );
15
+
16
+ // eslint-disable-next-line camelcase
17
+ const isLocalAdvisorEngine = advisorEngineConfig?.use_local_advisor_engine;
18
+ return isLocalAdvisorEngine;
19
+ };