@eeacms/volto-cca-policy 0.2.20 → 0.2.21
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 +12 -0
- package/package.json +1 -1
- package/src/components/manage/Blocks/CollectionStatistics/index.js +2 -2
- package/src/components/manage/Blocks/ContentLinks/ContentLinksEdit.jsx +45 -0
- package/src/components/manage/Blocks/ContentLinks/ContentLinksView.jsx +42 -0
- package/src/components/manage/Blocks/ContentLinks/ContentLinksView.test.jsx +70 -0
- package/src/components/manage/Blocks/ContentLinks/index.js +35 -0
- package/src/components/manage/Blocks/ContentLinks/schema.js +47 -0
- package/src/components/manage/Blocks/ContentLinks/style.less +33 -0
- package/src/components/manage/Blocks/RASTBlock/index.js +2 -2
- package/src/components/manage/Blocks/RedirectBlock/index.js +2 -2
- package/src/components/manage/Blocks/index.js +2 -0
- package/src/components/theme/ShareInfoButton/ShareInfoButton.jsx +1 -1
- package/src/index.js +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,18 @@ 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.21](https://github.com/eea/volto-cca-policy/compare/0.2.20...0.2.21) - 9 May 2024
|
|
8
|
+
|
|
9
|
+
#### :rocket: New Features
|
|
10
|
+
|
|
11
|
+
- feat(block): add ContentLinks block [kreafox - [`4e7aaab`](https://github.com/eea/volto-cca-policy/commit/4e7aaab744ebc72dd98936a333a6df3e3315e945)]
|
|
12
|
+
|
|
13
|
+
#### :nail_care: Enhancements
|
|
14
|
+
|
|
15
|
+
- change: remove no needed info button [kreafox - [`6771435`](https://github.com/eea/volto-cca-policy/commit/677143541d515514a3b9541cce625319ab30425a)]
|
|
16
|
+
- change: blocks icon [kreafox - [`100bab4`](https://github.com/eea/volto-cca-policy/commit/100bab435aa72b20d2fade206dfeb7b53dec76ab)]
|
|
17
|
+
- change: share info button icon [kreafox - [`8ef908e`](https://github.com/eea/volto-cca-policy/commit/8ef908e3c26f2b80405c8cf480b73017e221d003)]
|
|
18
|
+
|
|
7
19
|
### [0.2.20](https://github.com/eea/volto-cca-policy/compare/0.2.19...0.2.20) - 8 May 2024
|
|
8
20
|
|
|
9
21
|
#### :bug: Bug Fixes
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import CollectionStatsView, {
|
|
|
4
4
|
RemixIcon,
|
|
5
5
|
} from './CollectionStatsView';
|
|
6
6
|
|
|
7
|
-
import
|
|
7
|
+
import dotsSVG from '@plone/volto/icons/dots.svg';
|
|
8
8
|
import airPollutionSvg from '@eeacms/volto-cca-policy/icons/air_pollution_and_aero-allergens.svg';
|
|
9
9
|
import heatSvg from '@eeacms/volto-cca-policy/icons/heat.svg';
|
|
10
10
|
import climateSensitiveSvg from '@eeacms/volto-cca-policy/icons/climate-sensitive_diseases.svg';
|
|
@@ -57,7 +57,7 @@ export default function installCollectionStatsBlock(config) {
|
|
|
57
57
|
config.blocks.blocksConfig.collectionStats = {
|
|
58
58
|
id: 'collectionStats',
|
|
59
59
|
title: 'Collection Statistics',
|
|
60
|
-
icon:
|
|
60
|
+
icon: dotsSVG,
|
|
61
61
|
group: 'site',
|
|
62
62
|
edit: CollectionStatsEdit,
|
|
63
63
|
view: CollectionStatsView,
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { SidebarPortal } from '@plone/volto/components';
|
|
4
|
+
import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
|
|
5
|
+
|
|
6
|
+
import schema from './schema';
|
|
7
|
+
import ContentLinksView from './ContentLinksView';
|
|
8
|
+
|
|
9
|
+
export default function ContentLinksEdit(props) {
|
|
10
|
+
const { block, data, onChangeBlock, selected, id } = props;
|
|
11
|
+
|
|
12
|
+
const { items = [] } = data;
|
|
13
|
+
const [refresh, forceRefresh] = React.useState(0);
|
|
14
|
+
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
items.forEach((item, index) => {
|
|
17
|
+
if (item.source?.length && !item.item_title) {
|
|
18
|
+
item.item_title = item.source[0].title;
|
|
19
|
+
item.link = item.source['@id'];
|
|
20
|
+
forceRefresh(refresh + 1);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}, [items, refresh]);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div>
|
|
27
|
+
<ContentLinksView data={data} id={id} mode="edit" />
|
|
28
|
+
<SidebarPortal selected={selected}>
|
|
29
|
+
<BlockDataForm
|
|
30
|
+
block={block}
|
|
31
|
+
title={schema.title}
|
|
32
|
+
schema={schema}
|
|
33
|
+
onChangeField={(id, value) => {
|
|
34
|
+
onChangeBlock(block, {
|
|
35
|
+
...data,
|
|
36
|
+
[id]: value,
|
|
37
|
+
});
|
|
38
|
+
}}
|
|
39
|
+
onChangeBlock={onChangeBlock}
|
|
40
|
+
formData={data}
|
|
41
|
+
/>
|
|
42
|
+
</SidebarPortal>
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { List } from 'semantic-ui-react';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
import { useLocation } from 'react-router-dom';
|
|
5
|
+
import { flattenToAppURL } from '@plone/volto/helpers';
|
|
6
|
+
import cx from 'classnames';
|
|
7
|
+
|
|
8
|
+
import './style.less';
|
|
9
|
+
|
|
10
|
+
const ContentLinksView = (props) => {
|
|
11
|
+
const location = useLocation();
|
|
12
|
+
const { data, mode = 'view' } = props;
|
|
13
|
+
const { title, items = [], variation } = data;
|
|
14
|
+
const isEdit = mode === 'edit';
|
|
15
|
+
|
|
16
|
+
return items && items.length > 0 ? (
|
|
17
|
+
<div className={`block content-links ${variation}-view`}>
|
|
18
|
+
{title && <h4>{title}</h4>}
|
|
19
|
+
|
|
20
|
+
<List className="content-items">
|
|
21
|
+
{items.map((item, index) => {
|
|
22
|
+
const link = item?.source?.[0]?.['@id'];
|
|
23
|
+
const active = location.pathname === link;
|
|
24
|
+
return (
|
|
25
|
+
<List.Item
|
|
26
|
+
key={index}
|
|
27
|
+
className={cx({
|
|
28
|
+
active: active,
|
|
29
|
+
})}
|
|
30
|
+
>
|
|
31
|
+
<Link to={flattenToAppURL(link)}>{item.item_title}</Link>
|
|
32
|
+
</List.Item>
|
|
33
|
+
);
|
|
34
|
+
})}
|
|
35
|
+
</List>
|
|
36
|
+
</div>
|
|
37
|
+
) : (
|
|
38
|
+
<>{isEdit && <div>No items</div>}</>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default ContentLinksView;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
3
|
+
import configureStore from 'redux-mock-store';
|
|
4
|
+
import renderer from 'react-test-renderer';
|
|
5
|
+
|
|
6
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
7
|
+
import { Provider } from 'react-intl-redux';
|
|
8
|
+
import ContentLinksView from './ContentLinksView';
|
|
9
|
+
|
|
10
|
+
const mockStore = configureStore();
|
|
11
|
+
|
|
12
|
+
jest.mock('semantic-ui-react', () => ({
|
|
13
|
+
...jest.requireActual('semantic-ui-react'),
|
|
14
|
+
Icon: () => <div>Icon</div>,
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
jest.mock('react-router-dom', () => ({
|
|
18
|
+
...jest.requireActual('react-router-dom'),
|
|
19
|
+
Link: () => <div>Link</div>,
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
describe('ContentLinksView', () => {
|
|
23
|
+
it('should render the component', () => {
|
|
24
|
+
const data = {
|
|
25
|
+
'@type': 'contentLinks',
|
|
26
|
+
items: [
|
|
27
|
+
{
|
|
28
|
+
item_title: 'Item 1',
|
|
29
|
+
source: [
|
|
30
|
+
{
|
|
31
|
+
'@id': '/item-1',
|
|
32
|
+
title: 'Item 1',
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
'@id': '7e2af23d-3905-404c-895f-0d31ea5878ef',
|
|
38
|
+
item_title: 'Item 2',
|
|
39
|
+
source: [
|
|
40
|
+
{
|
|
41
|
+
'@id': '/item-2',
|
|
42
|
+
title: 'Item 2',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
show_share_btn: false,
|
|
48
|
+
title: 'Navigation',
|
|
49
|
+
variation: 'default',
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const store = mockStore({
|
|
53
|
+
userSession: { token: '1234' },
|
|
54
|
+
intl: {
|
|
55
|
+
locale: 'en',
|
|
56
|
+
messages: {},
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const component = renderer.create(
|
|
61
|
+
<Provider store={store}>
|
|
62
|
+
<MemoryRouter>
|
|
63
|
+
<ContentLinksView data={data} />
|
|
64
|
+
</MemoryRouter>
|
|
65
|
+
</Provider>,
|
|
66
|
+
);
|
|
67
|
+
const json = component.toJSON();
|
|
68
|
+
expect(json).toMatchSnapshot();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import listSVG from '@plone/volto/icons/list-bullet.svg';
|
|
2
|
+
import ContentLinksEdit from './ContentLinksEdit';
|
|
3
|
+
import ContentLinksView from './ContentLinksView';
|
|
4
|
+
|
|
5
|
+
export default function installBlock(config) {
|
|
6
|
+
config.blocks.blocksConfig.contentLinks = {
|
|
7
|
+
id: 'contentLinks',
|
|
8
|
+
title: 'Content links',
|
|
9
|
+
icon: listSVG,
|
|
10
|
+
group: 'site',
|
|
11
|
+
view: ContentLinksView,
|
|
12
|
+
edit: ContentLinksEdit,
|
|
13
|
+
sidebarTab: 1,
|
|
14
|
+
security: {
|
|
15
|
+
addPermission: [],
|
|
16
|
+
view: [],
|
|
17
|
+
},
|
|
18
|
+
variations: [
|
|
19
|
+
{
|
|
20
|
+
id: 'default',
|
|
21
|
+
title: 'Simple list (default)',
|
|
22
|
+
isDefault: true,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: 'navigationList',
|
|
26
|
+
title: 'Navigation list',
|
|
27
|
+
isDefault: false,
|
|
28
|
+
fullobjects: true,
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
restricted: false,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return config;
|
|
35
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const Item = () => ({
|
|
2
|
+
title: 'Item',
|
|
3
|
+
fieldsets: [
|
|
4
|
+
{
|
|
5
|
+
id: 'default',
|
|
6
|
+
title: 'Default',
|
|
7
|
+
fields: ['source', 'item_title'],
|
|
8
|
+
},
|
|
9
|
+
],
|
|
10
|
+
properties: {
|
|
11
|
+
source: {
|
|
12
|
+
widget: 'object_browser',
|
|
13
|
+
mode: 'link',
|
|
14
|
+
title: 'Source',
|
|
15
|
+
description: 'Choose an existing content as source',
|
|
16
|
+
},
|
|
17
|
+
item_title: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
title: 'Title',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
required: ['title'],
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export default {
|
|
27
|
+
title: 'Content links',
|
|
28
|
+
fieldsets: [
|
|
29
|
+
{
|
|
30
|
+
id: 'default',
|
|
31
|
+
title: 'Default',
|
|
32
|
+
fields: ['title', 'items'],
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
properties: {
|
|
36
|
+
items: {
|
|
37
|
+
widget: 'object_list',
|
|
38
|
+
title: 'Items',
|
|
39
|
+
description: 'Add a list of items',
|
|
40
|
+
schema: Item(),
|
|
41
|
+
},
|
|
42
|
+
title: {
|
|
43
|
+
title: 'Block title',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
required: [],
|
|
47
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
@type: 'extra';
|
|
2
|
+
@element: 'custom';
|
|
3
|
+
|
|
4
|
+
@import (multiple, reference, optional) '../../theme.config';
|
|
5
|
+
|
|
6
|
+
.content-items {
|
|
7
|
+
margin-bottom: 1em;
|
|
8
|
+
|
|
9
|
+
.item:hover,
|
|
10
|
+
.item.active {
|
|
11
|
+
color: @primaryColor;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
a,
|
|
15
|
+
a:visited {
|
|
16
|
+
color: inherit;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.navigationList-view {
|
|
21
|
+
.item {
|
|
22
|
+
padding: 0.75rem 0 0.75rem 0.75rem !important;
|
|
23
|
+
|
|
24
|
+
&:hover {
|
|
25
|
+
color: @primaryColor;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&.active {
|
|
29
|
+
background: @primaryColor;
|
|
30
|
+
color: @white;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import contentSVG from '@plone/volto/icons/content.svg';
|
|
2
2
|
import RASTEdit from './RASTEdit';
|
|
3
3
|
import RASTView from './RASTView';
|
|
4
4
|
import { blockAvailableInMission } from '@eeacms/volto-cca-policy/utils';
|
|
@@ -9,7 +9,7 @@ export default function installBlock(config) {
|
|
|
9
9
|
blocksConfig.rastBlock = {
|
|
10
10
|
id: 'rastBlock',
|
|
11
11
|
title: 'RAST',
|
|
12
|
-
icon:
|
|
12
|
+
icon: contentSVG,
|
|
13
13
|
group: 'site',
|
|
14
14
|
view: RASTView,
|
|
15
15
|
edit: RASTEdit,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import redoSVG from '@plone/volto/icons/redo.svg';
|
|
2
2
|
import RedirectBlockEdit from './RedirectBlockEdit';
|
|
3
3
|
import RedirectBlockView from './RedirectBlockView';
|
|
4
4
|
// import { blockAvailableInMission } from '@eeacms/volto-cca-policy/utils';
|
|
@@ -7,7 +7,7 @@ export default function installBlock(config) {
|
|
|
7
7
|
config.blocks.blocksConfig.redirectBlock = {
|
|
8
8
|
id: 'redirectBlock',
|
|
9
9
|
title: 'Redirection Block',
|
|
10
|
-
icon:
|
|
10
|
+
icon: redoSVG,
|
|
11
11
|
group: 'site',
|
|
12
12
|
view: RedirectBlockView,
|
|
13
13
|
edit: RedirectBlockEdit,
|
|
@@ -20,6 +20,7 @@ import installReadMore from './ReadMore';
|
|
|
20
20
|
import installCollectionStats from './CollectionStatistics';
|
|
21
21
|
import installTabsBlock from './TabsBlock';
|
|
22
22
|
import installRedirectBlock from './RedirectBlock';
|
|
23
|
+
import installContentLinks from './ContentLinks';
|
|
23
24
|
|
|
24
25
|
export default function installBlocks(config) {
|
|
25
26
|
config.blocks.blocksConfig.title.restricted = false;
|
|
@@ -49,5 +50,6 @@ export default function installBlocks(config) {
|
|
|
49
50
|
installTabsBlock,
|
|
50
51
|
installListing,
|
|
51
52
|
installRedirectBlock,
|
|
53
|
+
installContentLinks,
|
|
52
54
|
)(config);
|
|
53
55
|
}
|
package/src/index.js
CHANGED
|
@@ -313,12 +313,6 @@ const applyConfig = (config) => {
|
|
|
313
313
|
bottomLevel: 2,
|
|
314
314
|
rootPath: 'countries-regions/transnational-regions/carpathian-mountains',
|
|
315
315
|
},
|
|
316
|
-
{
|
|
317
|
-
title: 'Share your info',
|
|
318
|
-
topLevel: 2,
|
|
319
|
-
bottomLevel: 2,
|
|
320
|
-
rootPath: 'help/share-your-info',
|
|
321
|
-
},
|
|
322
316
|
];
|
|
323
317
|
|
|
324
318
|
config.settings.astNavigations = [
|