@eeacms/volto-cca-policy 0.1.52 → 0.1.53
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 +10 -0
- package/package.json +1 -1
- package/src/components/manage/Blocks/RASTBlock/ContextNavigation.jsx +5 -7
- package/src/components/manage/Blocks/RASTBlock/RASTAccordion.jsx +10 -17
- package/src/components/manage/Blocks/RASTBlock/RASTAccordion.test.jsx +4 -4
- package/src/components/manage/Blocks/RASTBlock/RASTAccordionContent.jsx +30 -18
- package/src/components/manage/Blocks/RASTBlock/RASTView.jsx +18 -10
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,16 @@ 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.1.53](https://github.com/eea/volto-cca-policy/compare/0.1.52...0.1.53) - 19 December 2023
|
|
8
|
+
|
|
9
|
+
#### :hammer_and_wrench: Others
|
|
10
|
+
|
|
11
|
+
- Refs #260715 - switch browse folder to getContent test subrequests [Tripon Eugen - [`7744481`](https://github.com/eea/volto-cca-policy/commit/7744481bbebe3a0eedd3d440d58ae3b9adf43a18)]
|
|
12
|
+
- Refs #260715 - switch browse folder to getContent test [Tripon Eugen - [`ca17c9c`](https://github.com/eea/volto-cca-policy/commit/ca17c9c9a2972129fdbcef1d7dcceb2af1062cf2)]
|
|
13
|
+
- Refs #260715 - switch browse folder to getContent jenkins [Tripon Eugen - [`866118c`](https://github.com/eea/volto-cca-policy/commit/866118c4d5537d00c7bb7ffed272c16cd9516194)]
|
|
14
|
+
- Refs #260715 - switch browse folder to getContent [Tripon Eugen - [`4c6cb1b`](https://github.com/eea/volto-cca-policy/commit/4c6cb1b74812c020f670b1e660fae74eca7bbd8d)]
|
|
15
|
+
- WIP [Tiberiu Ichim - [`baef385`](https://github.com/eea/volto-cca-policy/commit/baef385bc65818b1a7b294fd6fcbbe65aef731f2)]
|
|
16
|
+
- WIP [Tiberiu Ichim - [`d64813d`](https://github.com/eea/volto-cca-policy/commit/d64813d66b32c785124adfa4e1e2d95bab512592)]
|
|
7
17
|
### [0.1.52](https://github.com/eea/volto-cca-policy/compare/0.1.51...0.1.52) - 15 December 2023
|
|
8
18
|
|
|
9
19
|
#### :rocket: New Features
|
package/package.json
CHANGED
|
@@ -5,21 +5,18 @@ import RASTMap from './RASTMap';
|
|
|
5
5
|
import RASTAccordion from './RASTAccordion';
|
|
6
6
|
import { useLocation } from 'react-router-dom';
|
|
7
7
|
|
|
8
|
-
import { withContentNavigation } from '@plone/volto/components/theme/Navigation/withContentNavigation';
|
|
9
|
-
|
|
10
8
|
/**
|
|
11
9
|
* A navigation slot implementation, similar to the classic Plone navigation
|
|
12
10
|
* portlet. It uses the same API, so the options are similar to
|
|
13
11
|
* INavigationPortlet
|
|
14
12
|
*/
|
|
15
13
|
export function ContextNavigationComponent(props) {
|
|
16
|
-
const {
|
|
17
|
-
const { items = [] } = navigation;
|
|
14
|
+
const { location, items } = props;
|
|
18
15
|
let activeMenu = null;
|
|
19
16
|
|
|
20
17
|
const curent_location = useLocation();
|
|
21
18
|
for (let i = 0; i < items.length; i++) {
|
|
22
|
-
let itemUrl = '/' + items[i].
|
|
19
|
+
let itemUrl = '/' + items[i]['@id'].split('/').slice(3).join('/');
|
|
23
20
|
items[i].is_active = false;
|
|
24
21
|
if (curent_location.pathname.includes(itemUrl)) {
|
|
25
22
|
activeMenu = i;
|
|
@@ -35,10 +32,11 @@ export function ContextNavigationComponent(props) {
|
|
|
35
32
|
activeMenu={activeMenu}
|
|
36
33
|
/>
|
|
37
34
|
{items.length ? (
|
|
38
|
-
<RASTAccordion
|
|
35
|
+
<RASTAccordion items={items} activeMenu={activeMenu} />
|
|
39
36
|
) : null}
|
|
40
37
|
</>
|
|
41
38
|
);
|
|
42
39
|
}
|
|
43
40
|
|
|
44
|
-
|
|
41
|
+
// withContentNavigation
|
|
42
|
+
export default compose()(ContextNavigationComponent);
|
|
@@ -3,7 +3,7 @@ import { Accordion, Icon } from 'semantic-ui-react';
|
|
|
3
3
|
import RASTAccordionContent from './RASTAccordionContent';
|
|
4
4
|
|
|
5
5
|
const RASTAccordion = (props) => {
|
|
6
|
-
const {
|
|
6
|
+
const { items = {}, activeMenu } = props;
|
|
7
7
|
|
|
8
8
|
const [activeIndex, setActiveIndex] = React.useState([activeMenu]);
|
|
9
9
|
|
|
@@ -25,10 +25,9 @@ const RASTAccordion = (props) => {
|
|
|
25
25
|
};
|
|
26
26
|
return (
|
|
27
27
|
<>
|
|
28
|
-
{
|
|
29
|
-
const { id } =
|
|
28
|
+
{items.map((item, index) => {
|
|
29
|
+
const { id } = item;
|
|
30
30
|
const active = isActive(index);
|
|
31
|
-
let datasetPath = '/' + dataset.href.split('/').slice(3).join('/');
|
|
32
31
|
|
|
33
32
|
return (
|
|
34
33
|
<Accordion id={id} key={index} className="secondary">
|
|
@@ -38,15 +37,15 @@ const RASTAccordion = (props) => {
|
|
|
38
37
|
active={active}
|
|
39
38
|
aria-expanded={active}
|
|
40
39
|
index={index}
|
|
41
|
-
onClick={(e) => handleClick(e, { index, id,
|
|
40
|
+
onClick={(e) => handleClick(e, { index, id, item })}
|
|
42
41
|
onKeyDown={(e) => {
|
|
43
42
|
if (e.keyCode === 13 || e.keyCode === 32) {
|
|
44
43
|
e.preventDefault();
|
|
45
|
-
handleClick(e, { index, id,
|
|
44
|
+
handleClick(e, { index, id, item });
|
|
46
45
|
}
|
|
47
46
|
}}
|
|
48
47
|
>
|
|
49
|
-
<span className="
|
|
48
|
+
<span className="item-title">{item.title}</span>
|
|
50
49
|
{active ? (
|
|
51
50
|
<Icon className="ri-arrow-up-s-line" />
|
|
52
51
|
) : (
|
|
@@ -56,17 +55,11 @@ const RASTAccordion = (props) => {
|
|
|
56
55
|
<Accordion.Content active={active}>
|
|
57
56
|
<RASTAccordionContent
|
|
58
57
|
key={index}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
topLevel: 3,
|
|
64
|
-
bottomLevel: 6,
|
|
65
|
-
rootPath: datasetPath,
|
|
66
|
-
title: dataset.title,
|
|
58
|
+
main={{
|
|
59
|
+
title: item.title,
|
|
60
|
+
href: item['@id'],
|
|
61
|
+
url: item.url,
|
|
67
62
|
}}
|
|
68
|
-
location={{ pathname: datasetPath }}
|
|
69
|
-
main={{ title: dataset.title, href: dataset['@id'] }}
|
|
70
63
|
/>
|
|
71
64
|
</Accordion.Content>
|
|
72
65
|
</Accordion>
|
|
@@ -11,12 +11,12 @@ const mockStore = configureStore();
|
|
|
11
11
|
describe('RASTAccordion', () => {
|
|
12
12
|
it('should render the component', () => {
|
|
13
13
|
const data = {
|
|
14
|
-
|
|
14
|
+
items: [
|
|
15
15
|
{
|
|
16
|
-
id: 'my-
|
|
16
|
+
id: 'my-item',
|
|
17
17
|
title: 'Hello',
|
|
18
|
-
'@id': '/my-
|
|
19
|
-
href: '/my-
|
|
18
|
+
'@id': '/my-item',
|
|
19
|
+
href: '/my-item-href',
|
|
20
20
|
},
|
|
21
21
|
],
|
|
22
22
|
activeMenu: 1,
|
|
@@ -1,13 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { List } from 'semantic-ui-react';
|
|
2
3
|
import { Link } from 'react-router-dom';
|
|
3
4
|
import { compose } from 'redux';
|
|
4
5
|
import { flattenToAppURL, getBaseUrl } from '@plone/volto/helpers';
|
|
5
|
-
|
|
6
|
-
import {
|
|
6
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
7
|
+
import { getContent } from '@plone/volto/actions';
|
|
8
|
+
// import useChildren from './RASTView';
|
|
7
9
|
|
|
8
10
|
const RASTAccordionContent = (props) => {
|
|
9
11
|
const { main } = props;
|
|
10
|
-
const
|
|
12
|
+
const dispatch = useDispatch();
|
|
13
|
+
const location = main.url;
|
|
14
|
+
let items = [];
|
|
15
|
+
|
|
16
|
+
React.useEffect(() => {
|
|
17
|
+
const action = getContent(location, null, location);
|
|
18
|
+
dispatch(action);
|
|
19
|
+
}, [location, dispatch]);
|
|
20
|
+
|
|
21
|
+
items = useSelector(
|
|
22
|
+
(state) => state.content?.subrequests?.[location]?.data?.items || [],
|
|
23
|
+
);
|
|
24
|
+
// const items = useChildren(location);
|
|
11
25
|
|
|
12
26
|
return (
|
|
13
27
|
<div className="dataset-content">
|
|
@@ -21,24 +35,22 @@ const RASTAccordionContent = (props) => {
|
|
|
21
35
|
</div>
|
|
22
36
|
</List.Content>
|
|
23
37
|
</List.Item>
|
|
24
|
-
{items
|
|
25
|
-
? items.map((item
|
|
26
|
-
|
|
27
|
-
<List.
|
|
28
|
-
<
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
);
|
|
37
|
-
})
|
|
38
|
+
{items.length
|
|
39
|
+
? items.map((item) => (
|
|
40
|
+
<List.Item key={item.id}>
|
|
41
|
+
<List.Content>
|
|
42
|
+
<div className="dataset-item">
|
|
43
|
+
<Link to={flattenToAppURL(getBaseUrl(item['@id']))}>
|
|
44
|
+
{item.title}
|
|
45
|
+
</Link>
|
|
46
|
+
</div>
|
|
47
|
+
</List.Content>
|
|
48
|
+
</List.Item>
|
|
49
|
+
))
|
|
38
50
|
: null}
|
|
39
51
|
</div>
|
|
40
52
|
</div>
|
|
41
53
|
);
|
|
42
54
|
};
|
|
43
55
|
|
|
44
|
-
export default compose(
|
|
56
|
+
export default compose()(RASTAccordionContent);
|
|
@@ -1,27 +1,35 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './styles.less';
|
|
3
3
|
import ContextNavigation from './ContextNavigation';
|
|
4
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
5
|
+
import { getContent } from '@plone/volto/actions';
|
|
6
|
+
|
|
7
|
+
function useChildren(location) {
|
|
8
|
+
const dispatch = useDispatch();
|
|
9
|
+
React.useEffect(() => {
|
|
10
|
+
const action = getContent(location, null, location);
|
|
11
|
+
dispatch(action);
|
|
12
|
+
}, [location, dispatch]);
|
|
13
|
+
|
|
14
|
+
const items = useSelector(
|
|
15
|
+
(state) => state.content.subrequests?.[location]?.data?.items || [],
|
|
16
|
+
);
|
|
17
|
+
return items;
|
|
18
|
+
}
|
|
4
19
|
|
|
5
20
|
export default function RASTView(props) {
|
|
6
21
|
const { data } = props;
|
|
7
22
|
let root_path = data?.root_path;
|
|
8
|
-
let top_level = 1;
|
|
9
23
|
if (typeof root_path === 'undefined') {
|
|
10
24
|
root_path = '/';
|
|
11
25
|
}
|
|
12
|
-
|
|
26
|
+
|
|
27
|
+
const items = useChildren(root_path);
|
|
13
28
|
|
|
14
29
|
return (
|
|
15
30
|
<div className="block rast-block">
|
|
16
31
|
<ContextNavigation
|
|
17
|
-
|
|
18
|
-
// name: 'CurrentTitle',
|
|
19
|
-
// includeTop: false,
|
|
20
|
-
// currentFolderOnly: false,
|
|
21
|
-
topLevel: top_level,
|
|
22
|
-
// topLevel: 2,
|
|
23
|
-
// rootPath: '/en/about/test-rast/',
|
|
24
|
-
}}
|
|
32
|
+
items={items}
|
|
25
33
|
location={{
|
|
26
34
|
pathname: root_path,
|
|
27
35
|
}}
|