foreman_rh_cloud 14.7.1 → 15.0.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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/app/services/foreman_rh_cloud/tags_auth.rb +28 -13
  3. data/config/routes.rb +10 -0
  4. data/lib/foreman_rh_cloud/plugin.rb +14 -0
  5. data/lib/foreman_rh_cloud/version.rb +1 -1
  6. data/package.json +1 -1
  7. data/test/unit/services/foreman_rh_cloud/tags_auth_test.rb +26 -0
  8. data/webpack/ComplianceHostDetailsTab/ComplianceHostDetailsTab.js +36 -0
  9. data/webpack/ComplianceHostDetailsTab/ComplianceHostDetailsTab.scss +3 -0
  10. data/webpack/ComplianceHostDetailsTab/__tests__/ComplianceHostDetailsTab.test.js +159 -0
  11. data/webpack/ComplianceHostDetailsTab/index.js +3 -0
  12. data/webpack/ForemanRhCloudFills.js +11 -0
  13. data/webpack/ForemanRhCloudPages.js +7 -0
  14. data/webpack/InsightsCompliance/ComplianceIframe.js +34 -0
  15. data/webpack/InsightsCompliance/ComplianceIframe.scss +12 -0
  16. data/webpack/InsightsCompliance/InsightsCompliancePage.js +11 -0
  17. data/webpack/InsightsCompliance/InsightsCompliancePage.test.js +35 -0
  18. data/webpack/InsightsCompliance/complianceIframeConstants.js +7 -0
  19. data/webpack/InsightsCompliance/complianceIframeHelpers.js +23 -0
  20. data/webpack/InsightsCompliance/complianceIframeHelpers.test.js +50 -0
  21. data/webpack/common/Hooks/PermissionsHooks.js +10 -0
  22. data/webpack/common/IopIframe/IopAppIframe.js +74 -0
  23. data/webpack/common/IopIframe/IopHostDetailsIframe.js +66 -0
  24. data/webpack/common/IopIframe/IopHostDetailsIframe.scss +6 -0
  25. data/webpack/common/IopIframe/IopHostDetailsIframeTab.js +81 -0
  26. data/webpack/common/IopIframe/__tests__/IopAppIframe.test.js +92 -0
  27. data/webpack/common/IopIframe/__tests__/IopHostDetailsIframeTab.test.js +93 -0
  28. data/webpack/common/IopIframe/__tests__/iopIframeHelpers.test.js +63 -0
  29. data/webpack/common/IopIframe/__tests__/postIopChromeToIframe.test.js +60 -0
  30. data/webpack/common/IopIframe/__tests__/useIopIframeHeight.test.js +37 -0
  31. data/webpack/common/IopIframe/iopIframeConstants.js +5 -0
  32. data/webpack/common/IopIframe/iopIframeHelpers.js +49 -0
  33. data/webpack/common/IopIframe/postIopChromeToIframe.js +35 -0
  34. data/webpack/common/IopIframe/useIopIframeChrome.js +54 -0
  35. data/webpack/common/IopIframe/useIopIframeHeight.js +35 -0
  36. data/webpack/common/IopIframe/useIopIframeNavigate.js +40 -0
  37. metadata +27 -1
@@ -0,0 +1,54 @@
1
+ import { useCallback, useEffect } from 'react';
2
+ import { postIopChromeToIframe } from './postIopChromeToIframe';
3
+
4
+ /**
5
+ * Posts IOP chrome context into an iframe and re-posts when the child signals READY.
6
+ *
7
+ * @param {Object} options
8
+ * @param {React.RefObject} options.iframeRef
9
+ * @param {Array} options.permissions
10
+ * @param {string} options.appRoute
11
+ * @param {string} [options.pathname]
12
+ * @param {string} [options.embedded]
13
+ * @param {string} options.readyMessageType postMessage type from the child (e.g. IOP_COMPLIANCE_READY)
14
+ * @returns {Function} sendChromeContext — also pass to iframe onLoad
15
+ */
16
+ export const useIopIframeChrome = ({
17
+ iframeRef,
18
+ permissions,
19
+ appRoute,
20
+ pathname = '',
21
+ embedded,
22
+ readyMessageType,
23
+ }) => {
24
+ const sendChromeContext = useCallback(() => {
25
+ postIopChromeToIframe(iframeRef.current, {
26
+ permissions,
27
+ appRoute,
28
+ pathname,
29
+ embedded,
30
+ });
31
+ }, [appRoute, embedded, iframeRef, pathname, permissions]);
32
+
33
+ useEffect(() => {
34
+ sendChromeContext();
35
+ }, [sendChromeContext]);
36
+
37
+ useEffect(() => {
38
+ const handleMessage = event => {
39
+ if (event.origin !== window.location.origin) {
40
+ return;
41
+ }
42
+
43
+ if (event.data?.type === readyMessageType) {
44
+ sendChromeContext();
45
+ }
46
+ };
47
+
48
+ window.addEventListener('message', handleMessage);
49
+
50
+ return () => window.removeEventListener('message', handleMessage);
51
+ }, [readyMessageType, sendChromeContext]);
52
+
53
+ return sendChromeContext;
54
+ };
@@ -0,0 +1,35 @@
1
+ import { useEffect } from 'react';
2
+ import { IOP_IFRAME_HEIGHT } from './iopIframeConstants';
3
+
4
+ /**
5
+ * Sizes a host-details iframe from IOP_IFRAME_HEIGHT messages sent by the child.
6
+ *
7
+ * @param {Object} options
8
+ * @param {React.RefObject} options.iframeRef
9
+ */
10
+ export const useIopIframeHeight = ({ iframeRef }) => {
11
+ useEffect(() => {
12
+ const handleMessage = event => {
13
+ if (event.origin !== window.location.origin) {
14
+ return;
15
+ }
16
+
17
+ if (event.data?.type !== IOP_IFRAME_HEIGHT) {
18
+ return;
19
+ }
20
+
21
+ const iframe = iframeRef.current;
22
+ const height = event.data.payload?.height;
23
+
24
+ if (!iframe || !height) {
25
+ return;
26
+ }
27
+
28
+ iframe.style.height = `${height}px`;
29
+ };
30
+
31
+ window.addEventListener('message', handleMessage);
32
+
33
+ return () => window.removeEventListener('message', handleMessage);
34
+ }, [iframeRef]);
35
+ };
@@ -0,0 +1,40 @@
1
+ import { useEffect } from 'react';
2
+
3
+ /**
4
+ * Listens for iframe NAVIGATE messages and pushes matching Foreman paths.
5
+ *
6
+ * @param {Object} options
7
+ * @param {Object} options.history react-router v5 history
8
+ * @param {string} options.navigateMessageType
9
+ * @param {(appRoute: string) => string} options.getForemanPath
10
+ * @param {string} options.defaultAppRoute fallback when payload.appRoute is missing
11
+ */
12
+ export const useIopIframeNavigate = ({
13
+ history,
14
+ navigateMessageType,
15
+ getForemanPath,
16
+ defaultAppRoute,
17
+ }) => {
18
+ useEffect(() => {
19
+ const handleMessage = event => {
20
+ if (event.origin !== window.location.origin) {
21
+ return;
22
+ }
23
+
24
+ if (event.data?.type !== navigateMessageType) {
25
+ return;
26
+ }
27
+
28
+ const appRoute = event.data.payload?.appRoute || defaultAppRoute;
29
+ const nextPath = getForemanPath(appRoute);
30
+
31
+ if (window.location.pathname !== nextPath) {
32
+ history.push(nextPath);
33
+ }
34
+ };
35
+
36
+ window.addEventListener('message', handleMessage);
37
+
38
+ return () => window.removeEventListener('message', handleMessage);
39
+ }, [defaultAppRoute, getForemanPath, history, navigateMessageType]);
40
+ };
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.7.1
4
+ version: 15.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Red Hat Cloud team
@@ -282,6 +282,10 @@ files:
282
282
  - webpack/CVEsHostDetailsTab/CVEsHostDetailsTab.scss
283
283
  - webpack/CVEsHostDetailsTab/__tests__/CVEsHostDetailsTab.test.js
284
284
  - webpack/CVEsHostDetailsTab/index.js
285
+ - webpack/ComplianceHostDetailsTab/ComplianceHostDetailsTab.js
286
+ - webpack/ComplianceHostDetailsTab/ComplianceHostDetailsTab.scss
287
+ - webpack/ComplianceHostDetailsTab/__tests__/ComplianceHostDetailsTab.test.js
288
+ - webpack/ComplianceHostDetailsTab/index.js
285
289
  - webpack/CveDetailsPage/CveDetailsPage.js
286
290
  - webpack/CveDetailsPage/CveDetailsPage.test.js
287
291
  - webpack/CveDetailsPage/index.js
@@ -447,6 +451,13 @@ files:
447
451
  - webpack/InsightsCloudSync/InsightsCloudSyncReducers.js
448
452
  - webpack/InsightsCloudSync/__tests__/InsightsCloudSyncActions.test.js
449
453
  - webpack/InsightsCloudSync/index.js
454
+ - webpack/InsightsCompliance/ComplianceIframe.js
455
+ - webpack/InsightsCompliance/ComplianceIframe.scss
456
+ - webpack/InsightsCompliance/InsightsCompliancePage.js
457
+ - webpack/InsightsCompliance/InsightsCompliancePage.test.js
458
+ - webpack/InsightsCompliance/complianceIframeConstants.js
459
+ - webpack/InsightsCompliance/complianceIframeHelpers.js
460
+ - webpack/InsightsCompliance/complianceIframeHelpers.test.js
450
461
  - webpack/InsightsHostDetailsTab/InsightsTab.js
451
462
  - webpack/InsightsHostDetailsTab/InsightsTab.scss
452
463
  - webpack/InsightsHostDetailsTab/InsightsTabActions.js
@@ -494,6 +505,21 @@ files:
494
505
  - webpack/common/ForemanTasks/index.js
495
506
  - webpack/common/Hooks/ConfigHooks.js
496
507
  - webpack/common/Hooks/PermissionsHooks.js
508
+ - webpack/common/IopIframe/IopAppIframe.js
509
+ - webpack/common/IopIframe/IopHostDetailsIframe.js
510
+ - webpack/common/IopIframe/IopHostDetailsIframe.scss
511
+ - webpack/common/IopIframe/IopHostDetailsIframeTab.js
512
+ - webpack/common/IopIframe/__tests__/IopAppIframe.test.js
513
+ - webpack/common/IopIframe/__tests__/IopHostDetailsIframeTab.test.js
514
+ - webpack/common/IopIframe/__tests__/iopIframeHelpers.test.js
515
+ - webpack/common/IopIframe/__tests__/postIopChromeToIframe.test.js
516
+ - webpack/common/IopIframe/__tests__/useIopIframeHeight.test.js
517
+ - webpack/common/IopIframe/iopIframeConstants.js
518
+ - webpack/common/IopIframe/iopIframeHelpers.js
519
+ - webpack/common/IopIframe/postIopChromeToIframe.js
520
+ - webpack/common/IopIframe/useIopIframeChrome.js
521
+ - webpack/common/IopIframe/useIopIframeHeight.js
522
+ - webpack/common/IopIframe/useIopIframeNavigate.js
497
523
  - webpack/common/ScalprumModule/ScalprumContext.js
498
524
  - webpack/common/ScalprumModule/__tests__/ScalprumContext.test.js
499
525
  - webpack/common/Switcher/HelpLabel.js