@eeacms/volto-cca-policy 0.2.31 → 0.2.32

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,11 @@ 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
+ ### [0.2.32](https://github.com/eea/volto-cca-policy/compare/0.2.31...0.2.32) - 22 May 2024
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - Add test [Tiberiu Ichim - [`9248894`](https://github.com/eea/volto-cca-policy/commit/92488940bbff4ec4c5a8f5f7950d1841e9f92366)]
7
12
  ### [0.2.31](https://github.com/eea/volto-cca-policy/compare/0.2.30...0.2.31) - 22 May 2024
8
13
 
9
14
  #### :nail_care: Enhancements
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.2.31",
3
+ "version": "0.2.32",
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",
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+
3
+ import { BlockDataForm, SidebarPortal } from '@plone/volto/components';
4
+
5
+ import ASTNavigationView from './ASTNavigationView';
6
+ import schema from './schema';
7
+
8
+ export default function ASTNavigationEdit(props) {
9
+ const { block, data, onChangeBlock, selected, id } = props;
10
+
11
+ return (
12
+ <div>
13
+ <ASTNavigationView data={data} id={id} mode="edit" />
14
+ <SidebarPortal selected={selected}>
15
+ <BlockDataForm
16
+ block={block}
17
+ title={schema.title}
18
+ schema={schema}
19
+ onChangeField={(id, value) => {
20
+ onChangeBlock(block, {
21
+ ...data,
22
+ [id]: value,
23
+ });
24
+ }}
25
+ onChangeBlock={onChangeBlock}
26
+ formData={data}
27
+ />
28
+ </SidebarPortal>
29
+ </div>
30
+ );
31
+ }
@@ -0,0 +1,17 @@
1
+ import ASTLogoMap from '@eeacms/volto-cca-policy/components/theme/ASTNavigation/ASTLogoMap';
2
+ import UASTLogoMap from '@eeacms/volto-cca-policy/components/theme/ASTNavigation/UASTLogoMap';
3
+
4
+ export default function ASTNavigationView(props) {
5
+ const { data, path } = props;
6
+ const { items = [], image_type = 'ast' } = data;
7
+ if (items.length !== 6) return <div>Incomplete number of sources</div>;
8
+ const itemsMap = Object.assign(
9
+ {},
10
+ ...items.map((item, i) => ({ [`step-${i + 1}`]: item.href?.[0] })),
11
+ );
12
+ return image_type === 'ast' ? (
13
+ <ASTLogoMap items={itemsMap} pathname={path} />
14
+ ) : image_type === 'uast' ? (
15
+ <UASTLogoMap items={itemsMap} pathname={path} />
16
+ ) : null;
17
+ }
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ import '@testing-library/jest-dom/extend-expect';
3
+ import { MemoryRouter } from 'react-router-dom';
4
+ import configureStore from 'redux-mock-store';
5
+ import { render } from '@testing-library/react';
6
+ import { Provider } from 'react-intl-redux';
7
+ import ASTNavigationView from './ASTNavigationView';
8
+
9
+ const mockStore = configureStore();
10
+
11
+ describe('ASTLogoMap', () => {
12
+ it('should render the component', () => {
13
+ const data = {
14
+ items: {
15
+ 'step-0': {
16
+ '@id': '/en/knowledge/tools/adaptation-support-tool',
17
+ title: 'Preparing the ground for adaptation',
18
+ items: [
19
+ {
20
+ '@id': '/en/knowledge/tools/adaptation-support-tool/step-1-1',
21
+ title:
22
+ '1.1 Obtaining high-level political support for adaptation',
23
+ },
24
+ ],
25
+ },
26
+ },
27
+ pathname: '/en/knowledge/tools/adaptation-support-tool',
28
+ image_type: 'ast',
29
+ };
30
+
31
+ const store = mockStore({
32
+ userSession: { token: '1234' },
33
+ intl: {
34
+ locale: 'en',
35
+ messages: {},
36
+ },
37
+ });
38
+
39
+ const { container } = render(
40
+ <Provider store={store}>
41
+ <MemoryRouter>
42
+ <ASTNavigationView path="/en/ast-nav" data={data} />
43
+ </MemoryRouter>
44
+ </Provider>,
45
+ );
46
+ expect(container).toBeTruthy();
47
+ });
48
+ });
@@ -0,0 +1,28 @@
1
+ import contentSVG from '@plone/volto/icons/content.svg';
2
+ import { blockAvailableInMission } from '@eeacms/volto-cca-policy/utils';
3
+ import ASTNavigationView from './ASTNavigationView';
4
+ import ASTNavigationEdit from './ASTNavigationEdit';
5
+
6
+ export default function installBlock(config) {
7
+ const blocksConfig = config.blocks.blocksConfig;
8
+
9
+ blocksConfig.astNavigation = {
10
+ id: 'astNavigation',
11
+ title: 'AST Navigation',
12
+ icon: contentSVG,
13
+ group: 'site',
14
+ view: ASTNavigationView,
15
+ edit: ASTNavigationEdit,
16
+ sidebarTab: 1,
17
+ security: {
18
+ addPermission: [],
19
+ view: [],
20
+ },
21
+ variations: [],
22
+ restricted: ({ properties, block }) => {
23
+ return blockAvailableInMission(properties, block);
24
+ },
25
+ };
26
+
27
+ return config;
28
+ }
@@ -0,0 +1,56 @@
1
+ const Item = () => ({
2
+ title: 'Item',
3
+ fieldsets: [
4
+ {
5
+ id: 'default',
6
+ title: 'Default',
7
+ fields: ['href', 'title'],
8
+ },
9
+ ],
10
+ properties: {
11
+ href: {
12
+ widget: 'object_browser',
13
+ mode: 'link',
14
+ title: 'Source',
15
+ description: 'Choose an existing content as source',
16
+ },
17
+ title: {
18
+ type: 'string',
19
+ title: 'Title',
20
+ description: 'Overrides the source title',
21
+ },
22
+ },
23
+
24
+ required: ['href'],
25
+ });
26
+
27
+ export default {
28
+ title: 'AST Navigation',
29
+ fieldsets: [
30
+ {
31
+ id: 'default',
32
+ title: 'Default',
33
+ fields: ['title', 'image_type', 'items'],
34
+ },
35
+ ],
36
+ properties: {
37
+ items: {
38
+ widget: 'object_list',
39
+ title: 'Items',
40
+ description: 'Pick one item for each navigation step',
41
+ schema: Item(),
42
+ },
43
+ image_type: {
44
+ title: 'Image type',
45
+ choices: [
46
+ ['ast', 'AST'],
47
+ ['uast', 'UAST'],
48
+ ],
49
+ default: 'ast',
50
+ },
51
+ title: {
52
+ title: 'Block title',
53
+ },
54
+ },
55
+ required: [],
56
+ };
@@ -21,6 +21,7 @@ import installCollectionStats from './CollectionStatistics';
21
21
  import installTabsBlock from './TabsBlock';
22
22
  import installRedirectBlock from './RedirectBlock';
23
23
  import installContentLinks from './ContentLinks';
24
+ import installASTNavigation from './ASTNavigation';
24
25
 
25
26
  export default function installBlocks(config) {
26
27
  config.blocks.blocksConfig.title.restricted = false;
@@ -51,5 +52,6 @@ export default function installBlocks(config) {
51
52
  installListing,
52
53
  installRedirectBlock,
53
54
  installContentLinks,
55
+ installASTNavigation,
54
56
  )(config);
55
57
  }