@eeacms/volto-cca-policy 1.0.15 → 1.0.16

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.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,8 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ ### [1.0.16](https://github.com/eea/volto-cca-policy/compare/1.0.15...1.0.16) - 4 September 2026
8
+
7
9
  ### [1.0.15](https://github.com/eea/volto-cca-policy/compare/1.0.14...1.0.15) - 4 September 2026
8
10
 
9
11
  #### :rocket: New Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "description": "@eeacms/volto-cca-policy: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -1,4 +1,6 @@
1
+ import React from 'react';
1
2
  import { ChatWindow } from '@eeacms/volto-eea-chatbot/ChatBlock/chat';
3
+ import { CompareToolsPanel } from '../../../theme/CompareTools/CompareToolsPanel';
2
4
 
3
5
  import { CcaDocCard } from './DocumentCard';
4
6
  import { remarkCcaDocCards } from './docCards';
@@ -31,17 +33,24 @@ const extraRemarkPlugins = [remarkCcaDocCards, remarkCcaNextSteps];
31
33
  * turned into inline Navigator-style catalogue cards (`CcaDocCard`),
32
34
  * and "Suggested next steps" sections are turned into styled callout boxes.
33
35
  *
36
+ * It also renders `<CompareToolsPanel />` so that when users activate the
37
+ * "Compare" checkbox on any document card, the floating comparison panel
38
+ * appears and allows navigating to the side-by-side comparison view.
39
+ *
34
40
  * `ChatBlockView` renders this as `<Presentation persona {...blockData} />`,
35
41
  * so all block fields arrive as top-level props and are forwarded unchanged.
36
42
  */
37
43
  function CatalogueChatView(props) {
38
44
  return (
39
- <ChatWindow
40
- {...props}
41
- hideSourcesTab
42
- extraRemarkPlugins={extraRemarkPlugins}
43
- extraMarkdownComponents={extraMarkdownComponents}
44
- />
45
+ <>
46
+ <ChatWindow
47
+ {...props}
48
+ hideSourcesTab
49
+ extraRemarkPlugins={extraRemarkPlugins}
50
+ extraMarkdownComponents={extraMarkdownComponents}
51
+ />
52
+ <CompareToolsPanel />
53
+ </>
45
54
  );
46
55
  }
47
56
 
@@ -17,6 +17,10 @@ jest.mock('@eeacms/volto-eea-chatbot/ChatBlock/chat', () => ({
17
17
  )),
18
18
  }));
19
19
 
20
+ jest.mock('../../../theme/CompareTools/CompareToolsPanel', () => ({
21
+ CompareToolsPanel: jest.fn(() => <div data-testid="compare-tools-panel" />),
22
+ }));
23
+
20
24
  describe('CatalogueChatView', () => {
21
25
  beforeEach(() => {
22
26
  ChatWindow.mockClear();
@@ -70,4 +74,9 @@ describe('CatalogueChatView', () => {
70
74
  expect(secondMd).toBe(firstMd);
71
75
  expect(secondPlugins).toBe(firstPlugins);
72
76
  });
77
+
78
+ it('renders the CompareToolsPanel alongside the chat window', () => {
79
+ const { getByTestId } = render(<CatalogueChatView persona={{}} />);
80
+ expect(getByTestId('compare-tools-panel')).toBeInTheDocument();
81
+ });
73
82
  });
@@ -1,8 +1,18 @@
1
1
  import CatalogueChatView from './CatalogueChatView';
2
2
 
3
+ const ALLOWED_ROLES = ['Manager', 'Site Administrator', 'Editor'];
4
+
5
+ export const isChatbotRestricted = ({ user }) => {
6
+ if (user?.roles) {
7
+ return !user.roles.some((role) => ALLOWED_ROLES.includes(role));
8
+ }
9
+ return false;
10
+ };
11
+
3
12
  /**
4
13
  * Registers the CCA "catalogue" presentation variation on the AI Chatbot
5
- * block (from @eeacms/volto-eea-chatbot).
14
+ * block (from @eeacms/volto-eea-chatbot) and loosens the role restriction
15
+ * to allow Managers, Site Administrators, and Editors.
6
16
  *
7
17
  * Pattern: cross-addon variation push, same as ./TabsBlock pushing the
8
18
  * "spotlight" variation onto the tabs block.
@@ -19,6 +29,13 @@ export default function applyConfig(config) {
19
29
  view: CatalogueChatView,
20
30
  });
21
31
  }
32
+ block.restricted = isChatbotRestricted;
22
33
  }
34
+
35
+ const danswer = config.blocks.blocksConfig.danswerChat;
36
+ if (danswer) {
37
+ danswer.restricted = isChatbotRestricted;
38
+ }
39
+
23
40
  return config;
24
41
  }
@@ -41,4 +41,33 @@ describe('ChatbotCatalogue applyConfig', () => {
41
41
  const config = { blocks: { blocksConfig: {} } };
42
42
  expect(applyConfig(config)).toEqual(config);
43
43
  });
44
+
45
+ it('loosens the restricted check to allow Manager, Site Administrator, and Editor', () => {
46
+ const config = applyConfig(makeConfig());
47
+ const isRestricted = config.blocks.blocksConfig.eeaChatbot.restricted;
48
+
49
+ expect(isRestricted({ user: { roles: ['Manager'] } })).toBe(false);
50
+ expect(isRestricted({ user: { roles: ['Site Administrator'] } })).toBe(
51
+ false,
52
+ );
53
+ expect(isRestricted({ user: { roles: ['Editor'] } })).toBe(false);
54
+ expect(isRestricted({ user: { roles: ['Contributor'] } })).toBe(true);
55
+ expect(isRestricted({ user: { roles: ['Reader'] } })).toBe(true);
56
+ expect(isRestricted({ user: null })).toBe(false);
57
+ });
58
+
59
+ it('also updates danswerChat restricted if present', () => {
60
+ const baseConfig = {
61
+ blocks: {
62
+ blocksConfig: {
63
+ eeaChatbot: {},
64
+ danswerChat: {},
65
+ },
66
+ },
67
+ };
68
+ const config = applyConfig(baseConfig);
69
+ const isRestricted = config.blocks.blocksConfig.danswerChat.restricted;
70
+ expect(isRestricted({ user: { roles: ['Editor'] } })).toBe(false);
71
+ expect(isRestricted({ user: { roles: ['Contributor'] } })).toBe(true);
72
+ });
44
73
  });