@eeacms/volto-marine-policy 1.0.0 → 1.1.1
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/.eslintrc.js +1 -1
- package/CHANGELOG.md +39 -3
- package/jest-addon.config.js +23 -8
- package/package.json +3 -2
- package/razzle.extend.js +1 -1
- package/src/components/Blocks/ContextNavigation/Accordion.jsx +83 -0
- package/src/components/Blocks/ContextNavigation/Accordion.test.jsx +47 -0
- package/src/components/Blocks/ContextNavigation/AccordionContent.jsx +57 -0
- package/src/components/Blocks/ContextNavigation/ContextNavigation.jsx +41 -0
- package/src/components/Blocks/ContextNavigation/Edit.jsx +41 -0
- package/src/components/Blocks/ContextNavigation/Edit.test.jsx +71 -0
- package/src/components/Blocks/ContextNavigation/View.jsx +42 -0
- package/src/components/Blocks/ContextNavigation/View.test.jsx +71 -0
- package/src/components/Blocks/ContextNavigation/index.js +25 -0
- package/src/components/Blocks/ContextNavigation/schema.js +41 -0
- package/src/components/Blocks/ContextNavigation/styles.less +65 -0
- package/src/index.js +38 -7
- package/src/search/config.js +7 -12
- package/theme/assets/images/Header/wise-marine-logo-white.svg +143 -0
- package/theme/assets/images/Header/wise-marine-logo.svg +143 -0
- package/theme/globals/site.overrides +3 -3
- package/DEVELOP.md.tpl +0 -106
- package/Jenkinsfile.tpl +0 -416
- package/Makefile.tpl +0 -165
- package/README.md.tpl +0 -93
- package/jest-addon.config.js.tpl +0 -51
- package/package.json.tpl +0 -70
package/.eslintrc.js
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
|
-
|
|
1
|
+
### Changelog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
All notable changes to this project will be documented in this file. Dates are displayed in UTC.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
|
+
|
|
7
|
+
### [1.1.1](https://github.com/eea/volto-marine-policy/compare/1.1.0...1.1.1) - 18 April 2024
|
|
8
|
+
|
|
9
|
+
#### :rocket: New Features
|
|
10
|
+
|
|
11
|
+
- feat:install contextNavigation block,fix toc block [nileshgulia1 - [`46bf29c`](https://github.com/eea/volto-marine-policy/commit/46bf29cee029a343e87d8b2a3e0adeba61ec04d9)]
|
|
12
|
+
|
|
13
|
+
#### :bug: Bug Fixes
|
|
14
|
+
|
|
15
|
+
- fix: add tests [nileshgulia1 - [`6ea02e3`](https://github.com/eea/volto-marine-policy/commit/6ea02e300fdc45b9921aeccf34ce746b11390005)]
|
|
16
|
+
|
|
17
|
+
#### :hammer_and_wrench: Others
|
|
18
|
+
|
|
19
|
+
- update [nileshgulia1 - [`33ee2a0`](https://github.com/eea/volto-marine-policy/commit/33ee2a00edaf2dadc088e5cc16f5d565484ce357)]
|
|
20
|
+
- eslint . [nileshgulia1 - [`dba2fc6`](https://github.com/eea/volto-marine-policy/commit/dba2fc6697b36506d3b86b9647cd7fd5d9d0d17d)]
|
|
21
|
+
- update tests [nileshgulia1 - [`b668e15`](https://github.com/eea/volto-marine-policy/commit/b668e15bd5aa2b0b9a419fcfa8a9ab6bfe6a5fb6)]
|
|
22
|
+
- remove comment [nileshgulia1 - [`6deadba`](https://github.com/eea/volto-marine-policy/commit/6deadbabbe99cf5a1f7e1b480076bdcaad333921)]
|
|
23
|
+
- fix tests [nileshgulia1 - [`2db4819`](https://github.com/eea/volto-marine-policy/commit/2db4819596c8a1727cdb37f0fc33ba53ea757aef)]
|
|
24
|
+
### [1.1.0](https://github.com/eea/volto-marine-policy/compare/1.0.0...1.1.0) - 15 April 2024
|
|
25
|
+
|
|
26
|
+
#### :hammer_and_wrench: Others
|
|
27
|
+
|
|
28
|
+
- fix cypress [nileshgulia1 - [`9d588e7`](https://github.com/eea/volto-marine-policy/commit/9d588e7e9ba1cf258c4356a3d25bcc6f1ae98356)]
|
|
29
|
+
- add policy customizations [nileshgulia1 - [`8355128`](https://github.com/eea/volto-marine-policy/commit/8355128ef8c713d86261ce57d709250a38213ef6)]
|
|
30
|
+
- delete tpl files [nileshgulia1 - [`d21afd0`](https://github.com/eea/volto-marine-policy/commit/d21afd0ae83ad54240bea00e68656c1b87630d8e)]
|
|
31
|
+
## [1.0.0](https://github.com/eea/volto-marine-policy/compare/0.1.20...1.0.0) - 14 April 2024
|
|
32
|
+
|
|
33
|
+
### 0.1.20 - 15 April 2024
|
|
34
|
+
|
|
35
|
+
#### :hammer_and_wrench: Others
|
|
36
|
+
|
|
37
|
+
- add policy customizations [nileshgulia1 - [`8355128`](https://github.com/eea/volto-marine-policy/commit/8355128ef8c713d86261ce57d709250a38213ef6)]
|
|
38
|
+
- delete tpl files [nileshgulia1 - [`d21afd0`](https://github.com/eea/volto-marine-policy/commit/d21afd0ae83ad54240bea00e68656c1b87630d8e)]
|
|
39
|
+
- initialized volto-marine-policy [nileshgulia1 - [`9e6cf2f`](https://github.com/eea/volto-marine-policy/commit/9e6cf2f41e7c4c95571f5368d4da1411b73a3f90)]
|
|
40
|
+
- Initialize develop [Nilesh - [`d4cfba5`](https://github.com/eea/volto-marine-policy/commit/d4cfba54fc713b546fc68b8e253bfdb9c92e64cc)]
|
|
41
|
+
- Initial commit [Nilesh - [`ba76f13`](https://github.com/eea/volto-marine-policy/commit/ba76f134700e64d583e4c7d31857a2f715b64edf)]
|
package/jest-addon.config.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require('dotenv').config({ path: __dirname + '/.env' });
|
|
2
|
+
|
|
1
3
|
module.exports = {
|
|
2
4
|
testMatch: ['**/src/addons/**/?(*.)+(spec|test).[jt]s?(x)'],
|
|
3
5
|
collectCoverageFrom: [
|
|
@@ -5,19 +7,27 @@ module.exports = {
|
|
|
5
7
|
'!src/**/*.d.ts',
|
|
6
8
|
],
|
|
7
9
|
moduleNameMapper: {
|
|
10
|
+
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
|
|
8
11
|
'@plone/volto/cypress': '<rootDir>/node_modules/@plone/volto/cypress',
|
|
9
12
|
'@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
|
|
10
13
|
'@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
|
|
11
|
-
'@package/(.*)$': '<rootDir>/src/$1',
|
|
14
|
+
'@package/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
|
|
15
|
+
'@root/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
|
|
12
16
|
'@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
|
|
13
|
-
'@eeacms/
|
|
14
|
-
'@
|
|
17
|
+
'@eeacms/search/(.*)$': '<rootDir>/src/addons/volto-searchlib/searchlib/$1',
|
|
18
|
+
'@eeacms/search': '<rootDir>/src/addons/volto-searchlib/searchlib',
|
|
19
|
+
'@eeacms/(.*?)/(.*)$': '<rootDir>/node_modules/@eeacms/$1/src/$2',
|
|
20
|
+
'@plone/volto-slate$':
|
|
15
21
|
'<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
|
|
22
|
+
'@plone/volto-slate/(.*)$':
|
|
23
|
+
'<rootDir>/node_modules/@plone/volto/packages/volto-slate/src/$1',
|
|
16
24
|
'~/(.*)$': '<rootDir>/src/$1',
|
|
17
25
|
'load-volto-addons':
|
|
18
26
|
'<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
|
|
19
|
-
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
|
|
20
27
|
},
|
|
28
|
+
transformIgnorePatterns: [
|
|
29
|
+
'/node_modules/(?!(@plone|@root|@package|@eeacms)/).*/',
|
|
30
|
+
],
|
|
21
31
|
transform: {
|
|
22
32
|
'^.+\\.js(x)?$': 'babel-jest',
|
|
23
33
|
'^.+\\.(png)$': 'jest-file',
|
|
@@ -26,10 +36,15 @@ module.exports = {
|
|
|
26
36
|
},
|
|
27
37
|
coverageThreshold: {
|
|
28
38
|
global: {
|
|
29
|
-
branches:
|
|
30
|
-
functions:
|
|
31
|
-
lines:
|
|
32
|
-
statements:
|
|
39
|
+
branches: 1,
|
|
40
|
+
functions: 1,
|
|
41
|
+
lines: 1,
|
|
42
|
+
statements: 1,
|
|
33
43
|
},
|
|
34
44
|
},
|
|
45
|
+
...(process.env.JEST_USE_SETUP === 'ON' && {
|
|
46
|
+
setupFilesAfterEnv: [
|
|
47
|
+
'<rootDir>/node_modules/@eeacms/volto-marine-policy/jest.setup.js',
|
|
48
|
+
],
|
|
49
|
+
}),
|
|
35
50
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-marine-policy",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "@eeacms/volto-marine-policy: Volto add-on",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "European Environment Agency: IDM2 A-Team",
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
"@babel/plugin-proposal-nullish-coalescing-operator": "7.18.6",
|
|
49
49
|
"@cypress/code-coverage": "^3.9.5",
|
|
50
50
|
"@plone/scripts": "2.1.1",
|
|
51
|
-
"babel-plugin-transform-class-properties": "^6.24.1"
|
|
51
|
+
"babel-plugin-transform-class-properties": "^6.24.1",
|
|
52
|
+
"dotenv": "^16.3.2"
|
|
52
53
|
},
|
|
53
54
|
"scripts": {
|
|
54
55
|
"release": "release-it",
|
package/razzle.extend.js
CHANGED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Accordion as SemanticAccordion, Icon } from 'semantic-ui-react';
|
|
3
|
+
|
|
4
|
+
import AccordionContent from './AccordionContent';
|
|
5
|
+
import { useHistory } from 'react-router-dom';
|
|
6
|
+
|
|
7
|
+
const Accordion = (props) => {
|
|
8
|
+
const { items = {}, curent_location, activeMenu, data = {} } = props;
|
|
9
|
+
const [currentIndex, setIndex] = React.useState(activeMenu ?? 0);
|
|
10
|
+
const history = useHistory();
|
|
11
|
+
|
|
12
|
+
const handleClick = (e, item) => {
|
|
13
|
+
let itemUrl = '/' + item['@id'].split('/').slice(3).join('/');
|
|
14
|
+
history.push(itemUrl);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const handleIconClick = (e, index) => {
|
|
18
|
+
e.stopPropagation();
|
|
19
|
+
const newIndex = currentIndex === index ? -1 : index;
|
|
20
|
+
setIndex(newIndex);
|
|
21
|
+
};
|
|
22
|
+
return (
|
|
23
|
+
<>
|
|
24
|
+
<div className="context-navigation-header">{data?.title}</div>
|
|
25
|
+
{items.map((item, index) => {
|
|
26
|
+
const { id } = item;
|
|
27
|
+
const active = currentIndex === index;
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<SemanticAccordion id={id} key={index} className="secondary">
|
|
31
|
+
<SemanticAccordion.Title
|
|
32
|
+
role="button"
|
|
33
|
+
tabIndex={0}
|
|
34
|
+
active={activeMenu === index}
|
|
35
|
+
aria-expanded={activeMenu === index}
|
|
36
|
+
index={index}
|
|
37
|
+
onClick={(e) => {
|
|
38
|
+
handleClick(e, item);
|
|
39
|
+
}}
|
|
40
|
+
onKeyDown={(e) => {
|
|
41
|
+
if (e.keyCode === 13 || e.keyCode === 32) {
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
handleClick(e, item);
|
|
44
|
+
}
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
<span className="item-title">{item.title}</span>
|
|
48
|
+
{active ? (
|
|
49
|
+
<Icon
|
|
50
|
+
className="ri-arrow-up-s-line"
|
|
51
|
+
onClick={(e) => {
|
|
52
|
+
handleIconClick(e, index);
|
|
53
|
+
}}
|
|
54
|
+
/>
|
|
55
|
+
) : (
|
|
56
|
+
<Icon
|
|
57
|
+
className="ri-arrow-down-s-line"
|
|
58
|
+
onClick={(e) => {
|
|
59
|
+
handleIconClick(e, index);
|
|
60
|
+
}}
|
|
61
|
+
/>
|
|
62
|
+
)}
|
|
63
|
+
</SemanticAccordion.Title>
|
|
64
|
+
<SemanticAccordion.Content active={active}>
|
|
65
|
+
<AccordionContent
|
|
66
|
+
curent_location={curent_location}
|
|
67
|
+
key={index}
|
|
68
|
+
main={{
|
|
69
|
+
title: item.title,
|
|
70
|
+
href: item['@id'],
|
|
71
|
+
url: item.url,
|
|
72
|
+
}}
|
|
73
|
+
data={data}
|
|
74
|
+
/>
|
|
75
|
+
</SemanticAccordion.Content>
|
|
76
|
+
</SemanticAccordion>
|
|
77
|
+
);
|
|
78
|
+
})}
|
|
79
|
+
</>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export default Accordion;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
3
|
+
import configureStore from 'redux-mock-store';
|
|
4
|
+
import { render } from '@testing-library/react';
|
|
5
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
6
|
+
import { Provider } from 'react-intl-redux';
|
|
7
|
+
import Accordion from './Accordion';
|
|
8
|
+
|
|
9
|
+
const mockStore = configureStore();
|
|
10
|
+
|
|
11
|
+
describe('RASTAccordion', () => {
|
|
12
|
+
it('should render the component', () => {
|
|
13
|
+
const data = {
|
|
14
|
+
items: [
|
|
15
|
+
{
|
|
16
|
+
id: 'my-item',
|
|
17
|
+
title: 'Hello',
|
|
18
|
+
'@id': '/my-item',
|
|
19
|
+
'@type': 'Folder',
|
|
20
|
+
href: '/my-item-href',
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
activeMenu: 1,
|
|
24
|
+
curent_location: '/my-item-href',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const store = mockStore({
|
|
28
|
+
userSession: { token: '1234' },
|
|
29
|
+
intl: {
|
|
30
|
+
locale: 'en',
|
|
31
|
+
messages: {},
|
|
32
|
+
},
|
|
33
|
+
content: {
|
|
34
|
+
subrequests: {},
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const { container } = render(
|
|
39
|
+
<Provider store={store}>
|
|
40
|
+
<MemoryRouter>
|
|
41
|
+
<Accordion {...data} />
|
|
42
|
+
</MemoryRouter>
|
|
43
|
+
</Provider>,
|
|
44
|
+
);
|
|
45
|
+
expect(container.querySelector('.accordion')).toBeInTheDocument();
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { List } from 'semantic-ui-react';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
import { compose } from 'redux';
|
|
5
|
+
import { flattenToAppURL, getBaseUrl } from '@plone/volto/helpers';
|
|
6
|
+
import { useChildren } from './View';
|
|
7
|
+
|
|
8
|
+
const AccordionContent = (props) => {
|
|
9
|
+
const {
|
|
10
|
+
main,
|
|
11
|
+
curent_location,
|
|
12
|
+
data: { types = [] },
|
|
13
|
+
} = props;
|
|
14
|
+
const location = main.url;
|
|
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);
|
|
25
|
+
return (
|
|
26
|
+
<div className="dataset-content">
|
|
27
|
+
<div>
|
|
28
|
+
{items.length
|
|
29
|
+
? items
|
|
30
|
+
.filter((item) =>
|
|
31
|
+
types.length ? types.includes(item['@type']) : item,
|
|
32
|
+
)
|
|
33
|
+
.map((item) => (
|
|
34
|
+
<List.Item
|
|
35
|
+
key={item.id}
|
|
36
|
+
className={`${
|
|
37
|
+
item['@id'].endsWith(curent_location.pathname)
|
|
38
|
+
? 'active'
|
|
39
|
+
: ''
|
|
40
|
+
}`}
|
|
41
|
+
>
|
|
42
|
+
<List.Content>
|
|
43
|
+
<div className="dataset-item">
|
|
44
|
+
<Link to={flattenToAppURL(getBaseUrl(item['@id']))}>
|
|
45
|
+
{item.title}
|
|
46
|
+
</Link>
|
|
47
|
+
</div>
|
|
48
|
+
</List.Content>
|
|
49
|
+
</List.Item>
|
|
50
|
+
))
|
|
51
|
+
: null}
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default compose()(AccordionContent);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { compose } from 'redux';
|
|
3
|
+
|
|
4
|
+
import Accordion from './Accordion';
|
|
5
|
+
import { useLocation } from 'react-router-dom';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A navigation slot implementation, similar to the classic Plone navigation
|
|
9
|
+
* portlet. It uses the same API, so the options are similar to
|
|
10
|
+
* INavigationPortlet
|
|
11
|
+
*/
|
|
12
|
+
export function ContextNavigationComponent(props) {
|
|
13
|
+
const { items, data } = props;
|
|
14
|
+
let activeMenu = null;
|
|
15
|
+
|
|
16
|
+
const curent_location = useLocation();
|
|
17
|
+
for (let i = 0; i < items.length; i++) {
|
|
18
|
+
let itemUrl = '/' + items[i]['@id'].split('/').slice(3).join('/');
|
|
19
|
+
items[i].is_active = false;
|
|
20
|
+
if (curent_location.pathname.includes(itemUrl)) {
|
|
21
|
+
activeMenu = i;
|
|
22
|
+
items[i].is_active = true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<>
|
|
28
|
+
{items.length ? (
|
|
29
|
+
<Accordion
|
|
30
|
+
items={items}
|
|
31
|
+
curent_location={curent_location}
|
|
32
|
+
activeMenu={activeMenu}
|
|
33
|
+
data={data}
|
|
34
|
+
/>
|
|
35
|
+
) : null}
|
|
36
|
+
</>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// withContentNavigation
|
|
41
|
+
export default compose()(ContextNavigationComponent);
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useSelector } from 'react-redux';
|
|
3
|
+
import { SidebarPortal } from '@plone/volto/components';
|
|
4
|
+
import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
|
|
5
|
+
|
|
6
|
+
import View from './View';
|
|
7
|
+
import schema from './schema';
|
|
8
|
+
|
|
9
|
+
export default function Edit(props) {
|
|
10
|
+
const {
|
|
11
|
+
block,
|
|
12
|
+
data = {},
|
|
13
|
+
onChangeBlock,
|
|
14
|
+
selected,
|
|
15
|
+
id,
|
|
16
|
+
formData = {},
|
|
17
|
+
} = props;
|
|
18
|
+
const contentTypes = useSelector((state) => state?.types.types);
|
|
19
|
+
const blockSchema = schema({ formData, data, contentTypes });
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div>
|
|
23
|
+
<View data={data} id={id} mode="edit" />
|
|
24
|
+
<SidebarPortal selected={selected}>
|
|
25
|
+
<BlockDataForm
|
|
26
|
+
block={block}
|
|
27
|
+
title={blockSchema.title}
|
|
28
|
+
schema={blockSchema}
|
|
29
|
+
onChangeField={(id, value) => {
|
|
30
|
+
onChangeBlock(block, {
|
|
31
|
+
...data,
|
|
32
|
+
[id]: value,
|
|
33
|
+
});
|
|
34
|
+
}}
|
|
35
|
+
onChangeBlock={onChangeBlock}
|
|
36
|
+
formData={data}
|
|
37
|
+
/>
|
|
38
|
+
</SidebarPortal>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import { Provider } from 'react-intl-redux';
|
|
4
|
+
import configureStore from 'redux-mock-store';
|
|
5
|
+
import ContextNavigationEdit from './Edit';
|
|
6
|
+
import { Router } from 'react-router-dom';
|
|
7
|
+
import { createMemoryHistory } from 'history';
|
|
8
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
9
|
+
|
|
10
|
+
const mockStore = configureStore();
|
|
11
|
+
|
|
12
|
+
jest.mock('@plone/volto/components', () => ({
|
|
13
|
+
SidebarPortal: ({ children }) => (
|
|
14
|
+
<div>
|
|
15
|
+
<div>SidebarPortal</div>
|
|
16
|
+
{children}
|
|
17
|
+
</div>
|
|
18
|
+
),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
jest.mock('@plone/volto/components/manage/Form/BlockDataForm', () => {
|
|
22
|
+
return {
|
|
23
|
+
__esModule: true,
|
|
24
|
+
default: ({ params }) => {
|
|
25
|
+
return <div>BlockDataForm {params}</div>;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const store = mockStore({
|
|
31
|
+
userSession: { token: '1234' },
|
|
32
|
+
intl: {
|
|
33
|
+
locale: 'en',
|
|
34
|
+
messages: {},
|
|
35
|
+
},
|
|
36
|
+
content: {
|
|
37
|
+
subrequests: {},
|
|
38
|
+
},
|
|
39
|
+
types: {
|
|
40
|
+
types: [],
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('ContextNavigationEdit', () => {
|
|
45
|
+
it('renders corectly', () => {
|
|
46
|
+
const history = createMemoryHistory();
|
|
47
|
+
const { getByText } = render(
|
|
48
|
+
<Provider store={store}>
|
|
49
|
+
<Router history={history}>
|
|
50
|
+
<ContextNavigationEdit />
|
|
51
|
+
</Router>
|
|
52
|
+
</Provider>,
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
expect(getByText('SidebarPortal')).toBeInTheDocument();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('renders corectly', () => {
|
|
59
|
+
const history = createMemoryHistory();
|
|
60
|
+
const { getByText } = render(
|
|
61
|
+
<Provider store={store}>
|
|
62
|
+
<Router history={history}>
|
|
63
|
+
<ContextNavigationEdit selected={true} onChangeBlock={() => {}} />
|
|
64
|
+
</Router>
|
|
65
|
+
</Provider>,
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
// expect(getByText('InlineForm')).toBeInTheDocument();
|
|
69
|
+
expect(getByText('SidebarPortal')).toBeInTheDocument();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './styles.less';
|
|
3
|
+
import ContextNavigation from './ContextNavigation';
|
|
4
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
5
|
+
import { getContent } from '@plone/volto/actions';
|
|
6
|
+
|
|
7
|
+
export 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
|
+
}
|
|
19
|
+
|
|
20
|
+
export default function View(props) {
|
|
21
|
+
const { data } = props;
|
|
22
|
+
let root_path = data?.root_path;
|
|
23
|
+
if (typeof root_path === 'undefined') {
|
|
24
|
+
root_path = '/';
|
|
25
|
+
}
|
|
26
|
+
let items = useChildren(root_path);
|
|
27
|
+
if (root_path === '/') {
|
|
28
|
+
items = [];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div className="block rast-block">
|
|
33
|
+
<ContextNavigation
|
|
34
|
+
items={items}
|
|
35
|
+
location={{
|
|
36
|
+
pathname: root_path,
|
|
37
|
+
}}
|
|
38
|
+
data={data}
|
|
39
|
+
/>
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import ContextNavigationView from './View';
|
|
4
|
+
import { Router } from 'react-router-dom';
|
|
5
|
+
import { Provider } from 'react-intl-redux';
|
|
6
|
+
import configureStore from 'redux-mock-store';
|
|
7
|
+
import { createMemoryHistory } from 'history';
|
|
8
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
9
|
+
|
|
10
|
+
const mockStore = configureStore();
|
|
11
|
+
|
|
12
|
+
const store = mockStore({
|
|
13
|
+
userSession: { token: '1234' },
|
|
14
|
+
intl: {
|
|
15
|
+
locale: 'en',
|
|
16
|
+
messages: {},
|
|
17
|
+
},
|
|
18
|
+
content: {
|
|
19
|
+
subrequests: {},
|
|
20
|
+
},
|
|
21
|
+
types: {
|
|
22
|
+
types: {},
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
jest.mock(
|
|
27
|
+
'@eeacms/volto-marine-policy/components/Blocks/ContextNavigation/ContextNavigation',
|
|
28
|
+
() => {
|
|
29
|
+
return {
|
|
30
|
+
__esModule: true,
|
|
31
|
+
default: ({ params }) => {
|
|
32
|
+
return <div>ContextNavigation {params}</div>;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
describe('ContextNavigationView', () => {
|
|
39
|
+
let history;
|
|
40
|
+
beforeEach(() => {
|
|
41
|
+
history = createMemoryHistory();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('renders corectly', () => {
|
|
45
|
+
const { container } = render(
|
|
46
|
+
<Provider store={store}>
|
|
47
|
+
<Router history={history}>
|
|
48
|
+
<ContextNavigationView />
|
|
49
|
+
</Router>
|
|
50
|
+
</Provider>,
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
expect(container.firstChild).toHaveTextContent('ContextNavigation');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('renders corectly', () => {
|
|
57
|
+
const { container } = render(
|
|
58
|
+
<Provider store={store}>
|
|
59
|
+
<Router history={history}>
|
|
60
|
+
<ContextNavigationView
|
|
61
|
+
data={{
|
|
62
|
+
navProps: { root_path: 'https://localhost:3000/test' },
|
|
63
|
+
root_node: [{ '@id': 'root_node' }],
|
|
64
|
+
}}
|
|
65
|
+
/>
|
|
66
|
+
</Router>
|
|
67
|
+
</Provider>,
|
|
68
|
+
);
|
|
69
|
+
expect(container.firstChild).toHaveTextContent('ContextNavigation');
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import zoomSVG from '@plone/volto/icons/zoom.svg';
|
|
2
|
+
import Edit from './Edit';
|
|
3
|
+
import View from './View';
|
|
4
|
+
|
|
5
|
+
export default function installBlock(config) {
|
|
6
|
+
const blocksConfig = config.blocks.blocksConfig;
|
|
7
|
+
|
|
8
|
+
blocksConfig.contextNavigation = {
|
|
9
|
+
id: 'contextNavigation',
|
|
10
|
+
title: 'Context Navigation',
|
|
11
|
+
icon: zoomSVG,
|
|
12
|
+
group: 'site',
|
|
13
|
+
view: View,
|
|
14
|
+
edit: Edit,
|
|
15
|
+
sidebarTab: 1,
|
|
16
|
+
security: {
|
|
17
|
+
addPermission: [],
|
|
18
|
+
view: [],
|
|
19
|
+
},
|
|
20
|
+
variations: [],
|
|
21
|
+
restricted: false,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return config;
|
|
25
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const fields = ['root_path', 'title', 'types'];
|
|
2
|
+
|
|
3
|
+
export default ({ contentTypes }) => {
|
|
4
|
+
const availableTypes = contentTypes.map((type) => [
|
|
5
|
+
type.id,
|
|
6
|
+
type.title || type.name,
|
|
7
|
+
]);
|
|
8
|
+
return {
|
|
9
|
+
title: 'RAST',
|
|
10
|
+
|
|
11
|
+
fieldsets: [
|
|
12
|
+
{
|
|
13
|
+
id: 'default',
|
|
14
|
+
title: 'Default',
|
|
15
|
+
fields,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
|
|
19
|
+
properties: {
|
|
20
|
+
root_path: {
|
|
21
|
+
title: 'Rooth path',
|
|
22
|
+
type: 'string',
|
|
23
|
+
description:
|
|
24
|
+
'Ex: /en/knowledge-and-data/regional-adaptation-support-tool',
|
|
25
|
+
required: true,
|
|
26
|
+
noValueOption: false,
|
|
27
|
+
},
|
|
28
|
+
title: {
|
|
29
|
+
title: 'Title',
|
|
30
|
+
},
|
|
31
|
+
types: {
|
|
32
|
+
title: 'Display content types',
|
|
33
|
+
description: 'Choose content types displayed as children',
|
|
34
|
+
choices: availableTypes,
|
|
35
|
+
isMulti: true,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
required: [],
|
|
40
|
+
};
|
|
41
|
+
};
|