@eeacms/volto-n2k 0.1.15 → 1.0.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/.coverage.babel.config.js +1 -1
- package/.i18n.babel.config.js +1 -0
- package/.project.eslintrc.js +46 -0
- package/CHANGELOG.md +20 -2
- package/README.md +1 -72
- package/RELEASE.md +74 -0
- package/babel.config.js +17 -0
- package/cypress.config.js +26 -0
- package/jest-addon.config.js +4 -4
- package/locales/volto.pot +69 -0
- package/package.json +21 -14
- package/src/components/index.js +3 -3
- package/src/components/manage/Blocks/CddaShape/View.jsx +14 -1
- package/src/components/manage/Blocks/ExploreHabitats/View.jsx +17 -5
- package/src/components/manage/Blocks/ExploreSites/View.jsx +15 -6
- package/src/components/manage/Blocks/ExploreSpecies/View.jsx +15 -5
- package/src/components/manage/Blocks/HabitatDistribution/View.jsx +14 -1
- package/src/components/manage/Blocks/HabitatProtectedSites/View.jsx +14 -1
- package/src/components/manage/Blocks/Landing/DefalutView.jsx +0 -16
- package/src/components/manage/Blocks/Landing/Edit.jsx +0 -16
- package/src/components/manage/Blocks/Landing/View.jsx +0 -16
- package/src/components/manage/Blocks/NavigationAnchors/View.jsx +1 -1
- package/src/components/manage/Blocks/SiteShape/View.jsx +14 -1
- package/src/components/manage/Blocks/SpeciesDistribution/View.jsx +14 -1
- package/src/components/manage/Blocks/SpeciesProtectedSites/View.jsx +14 -1
- package/src/components/theme/AppExtras/MultilingualRedirector/MultilingualRedirector.jsx +3 -3
- package/src/components/theme/Header/Header.jsx +58 -25
- package/src/components/theme/LanguageSelector/LanguageSelector.jsx +22 -14
- package/src/components/theme/Navigation/Navigation.jsx +37 -22
- package/src/components/theme/Sitemap/Sitemap.jsx +2 -2
- package/src/index.js +31 -29
- package/src/less/styles.less +10 -12
- package/src/static/global-line.svg +1 -0
- package/Jenkinsfile +0 -242
- package/cypress/fixtures/example.json +0 -5
- package/cypress/integration/block-basics.js +0 -32
- package/cypress/plugins/index.js +0 -26
- package/cypress/support/commands.js +0 -315
- package/cypress/support/index.js +0 -53
- package/cypress.json +0 -17
|
@@ -11,6 +11,7 @@ import './style.less';
|
|
|
11
11
|
const View = (props) => {
|
|
12
12
|
const [options, setOptions] = React.useState({});
|
|
13
13
|
const [vectorSource, setVectorSource] = useState(null);
|
|
14
|
+
const [tileWMSSources, setTileWMSSources] = useState([]);
|
|
14
15
|
const { extent, format, proj, style, source } = openlayers;
|
|
15
16
|
const provider_data = props.provider_data || {};
|
|
16
17
|
const { code_2000 = [] } = provider_data;
|
|
@@ -18,6 +19,17 @@ const View = (props) => {
|
|
|
18
19
|
useEffect(() => {
|
|
19
20
|
if (__SERVER__) return;
|
|
20
21
|
setVectorSource(new source.Vector());
|
|
22
|
+
setTileWMSSources([
|
|
23
|
+
new source.TileWMS({
|
|
24
|
+
url: 'https://gisco-services.ec.europa.eu/maps/service',
|
|
25
|
+
params: {
|
|
26
|
+
LAYERS: 'OSMPositronComposite',
|
|
27
|
+
TILED: true,
|
|
28
|
+
},
|
|
29
|
+
serverType: 'geoserver',
|
|
30
|
+
transition: 0,
|
|
31
|
+
}),
|
|
32
|
+
]);
|
|
21
33
|
/* eslint-disable-next-line */
|
|
22
34
|
}, []);
|
|
23
35
|
|
|
@@ -55,10 +67,11 @@ const View = (props) => {
|
|
|
55
67
|
showFullExtent: true,
|
|
56
68
|
zoom: 5,
|
|
57
69
|
}}
|
|
70
|
+
pixelRatio={1}
|
|
58
71
|
{...options}
|
|
59
72
|
>
|
|
60
73
|
<Layers>
|
|
61
|
-
<Layer.Tile zIndex={0} />
|
|
74
|
+
<Layer.Tile source={tileWMSSources[0]} zIndex={0} />
|
|
62
75
|
<Layer.Vector
|
|
63
76
|
source={vectorSource}
|
|
64
77
|
style={
|
|
@@ -11,6 +11,7 @@ import './style.less';
|
|
|
11
11
|
const View = (props) => {
|
|
12
12
|
const [options, setOptions] = React.useState({});
|
|
13
13
|
const [vectorSource, setVectorSource] = useState(null);
|
|
14
|
+
const [tileWMSSources, setTileWMSSources] = useState([]);
|
|
14
15
|
const { extent, format, proj, style, source } = openlayers;
|
|
15
16
|
const provider_data = props.provider_data || {};
|
|
16
17
|
const { code_2000 = [] } = provider_data;
|
|
@@ -18,6 +19,17 @@ const View = (props) => {
|
|
|
18
19
|
useEffect(() => {
|
|
19
20
|
if (__SERVER__) return;
|
|
20
21
|
setVectorSource(new source.Vector());
|
|
22
|
+
setTileWMSSources([
|
|
23
|
+
new source.TileWMS({
|
|
24
|
+
url: 'https://gisco-services.ec.europa.eu/maps/service',
|
|
25
|
+
params: {
|
|
26
|
+
LAYERS: 'OSMPositronComposite',
|
|
27
|
+
TILED: true,
|
|
28
|
+
},
|
|
29
|
+
serverType: 'geoserver',
|
|
30
|
+
transition: 0,
|
|
31
|
+
}),
|
|
32
|
+
]);
|
|
21
33
|
/* eslint-disable-next-line */
|
|
22
34
|
}, []);
|
|
23
35
|
|
|
@@ -55,10 +67,11 @@ const View = (props) => {
|
|
|
55
67
|
showFullExtent: true,
|
|
56
68
|
zoom: 5,
|
|
57
69
|
}}
|
|
70
|
+
pixelRatio={1}
|
|
58
71
|
{...options}
|
|
59
72
|
>
|
|
60
73
|
<Layers>
|
|
61
|
-
<Layer.Tile zIndex={0} />
|
|
74
|
+
<Layer.Tile source={tileWMSSources[0]} zIndex={0} />
|
|
62
75
|
<Layer.VectorImage
|
|
63
76
|
source={vectorSource}
|
|
64
77
|
style={
|
|
@@ -4,7 +4,6 @@ import { generatePath } from 'react-router';
|
|
|
4
4
|
import { Grid } from 'semantic-ui-react';
|
|
5
5
|
import { UniversalLink } from '@plone/volto/components';
|
|
6
6
|
import { withLocalStorage } from '@eeacms/volto-n2k/hocs';
|
|
7
|
-
import LanguageSelector from '@eeacms/volto-n2k/components/theme/LanguageSelector/LanguageSelector';
|
|
8
7
|
import hiker from './images/hiker.webp';
|
|
9
8
|
import { tiles, tileProps, getStyle } from './index';
|
|
10
9
|
|
|
@@ -19,21 +18,6 @@ const DefaultView = (props) => {
|
|
|
19
18
|
>
|
|
20
19
|
<Grid className="landing-page" container columns="12">
|
|
21
20
|
<Grid.Row>
|
|
22
|
-
<Grid.Column
|
|
23
|
-
{...{
|
|
24
|
-
mobile: 12,
|
|
25
|
-
tablet: 12,
|
|
26
|
-
computer: 12,
|
|
27
|
-
largeScreen: 12,
|
|
28
|
-
widescreen: 12,
|
|
29
|
-
}}
|
|
30
|
-
style={{ zIndex: 1, marginBottom: '1rem' }}
|
|
31
|
-
>
|
|
32
|
-
<LanguageSelector
|
|
33
|
-
navigation={props.navigation}
|
|
34
|
-
className="landingpage-variation"
|
|
35
|
-
/>
|
|
36
|
-
</Grid.Column>
|
|
37
21
|
<Grid.Column
|
|
38
22
|
className="landing-page-description"
|
|
39
23
|
widescreen="6"
|
|
@@ -9,7 +9,6 @@ import { SidebarPortal, UniversalLink } from '@plone/volto/components';
|
|
|
9
9
|
import InlineForm from '@plone/volto/components/manage/Form/InlineForm';
|
|
10
10
|
import config from '@plone/volto/registry';
|
|
11
11
|
import settingsSVG from '@plone/volto/icons/settings.svg';
|
|
12
|
-
import LanguageSelector from '@eeacms/volto-n2k/components/theme/LanguageSelector/LanguageSelector';
|
|
13
12
|
import DefaultView from './DefalutView';
|
|
14
13
|
import getSchema from './schema';
|
|
15
14
|
import hiker from './images/hiker.webp';
|
|
@@ -100,21 +99,6 @@ const Edit = (props) => {
|
|
|
100
99
|
>
|
|
101
100
|
<Grid className="landing-page" container columns="12">
|
|
102
101
|
<Grid.Row>
|
|
103
|
-
<Grid.Column
|
|
104
|
-
{...{
|
|
105
|
-
mobile: 12,
|
|
106
|
-
tablet: 12,
|
|
107
|
-
computer: 12,
|
|
108
|
-
largeScreen: 12,
|
|
109
|
-
widescreen: 12,
|
|
110
|
-
}}
|
|
111
|
-
style={{ zIndex: 1, marginBottom: '1rem' }}
|
|
112
|
-
>
|
|
113
|
-
<LanguageSelector
|
|
114
|
-
navigation={props.navigation}
|
|
115
|
-
className="landingpage-variation"
|
|
116
|
-
/>
|
|
117
|
-
</Grid.Column>
|
|
118
102
|
<Grid.Column
|
|
119
103
|
className="landing-page-description"
|
|
120
104
|
widescreen="6"
|
|
@@ -2,7 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import { connect } from 'react-redux';
|
|
3
3
|
import { Grid } from 'semantic-ui-react';
|
|
4
4
|
import { RenderBlocks, UniversalLink } from '@plone/volto/components';
|
|
5
|
-
import LanguageSelector from '@eeacms/volto-n2k/components/theme/LanguageSelector/LanguageSelector';
|
|
6
5
|
import DefaultView from './DefalutView';
|
|
7
6
|
import hiker from './images/hiker.webp';
|
|
8
7
|
import { tileProps, getStyle } from './index';
|
|
@@ -23,21 +22,6 @@ const View = (props) => {
|
|
|
23
22
|
>
|
|
24
23
|
<Grid className="landing-page" container columns="12">
|
|
25
24
|
<Grid.Row>
|
|
26
|
-
<Grid.Column
|
|
27
|
-
{...{
|
|
28
|
-
mobile: 12,
|
|
29
|
-
tablet: 12,
|
|
30
|
-
computer: 12,
|
|
31
|
-
largeScreen: 12,
|
|
32
|
-
widescreen: 12,
|
|
33
|
-
}}
|
|
34
|
-
style={{ zIndex: 1, marginBottom: '1rem' }}
|
|
35
|
-
>
|
|
36
|
-
<LanguageSelector
|
|
37
|
-
navigation={props.navigation}
|
|
38
|
-
className="landingpage-variation"
|
|
39
|
-
/>
|
|
40
|
-
</Grid.Column>
|
|
41
25
|
<Grid.Column
|
|
42
26
|
className="landing-page-description"
|
|
43
27
|
widescreen="6"
|
|
@@ -6,7 +6,7 @@ import qs from 'querystring';
|
|
|
6
6
|
import cx from 'classnames';
|
|
7
7
|
import { UniversalLink } from '@plone/volto/components';
|
|
8
8
|
import { withHashLink } from 'volto-slate/hooks';
|
|
9
|
-
import { StickyContext } from '
|
|
9
|
+
import { StickyContext } from '@eeacms/volto-bise/components';
|
|
10
10
|
import './styles.less';
|
|
11
11
|
|
|
12
12
|
const formatLink = (str, obj) => {
|
|
@@ -11,6 +11,7 @@ import './style.less';
|
|
|
11
11
|
const View = (props) => {
|
|
12
12
|
const [options, setOptions] = React.useState({});
|
|
13
13
|
const [vectorSource, setVectorSource] = useState(null);
|
|
14
|
+
const [tileWMSSources, setTileWMSSources] = useState([]);
|
|
14
15
|
const { extent, format, proj, style, source } = openlayers;
|
|
15
16
|
const provider_data = props.provider_data || {};
|
|
16
17
|
const { site_code = [] } = provider_data;
|
|
@@ -18,6 +19,17 @@ const View = (props) => {
|
|
|
18
19
|
useEffect(() => {
|
|
19
20
|
if (__SERVER__) return;
|
|
20
21
|
setVectorSource(new source.Vector());
|
|
22
|
+
setTileWMSSources([
|
|
23
|
+
new source.TileWMS({
|
|
24
|
+
url: 'https://gisco-services.ec.europa.eu/maps/service',
|
|
25
|
+
params: {
|
|
26
|
+
LAYERS: 'OSMPositronComposite',
|
|
27
|
+
TILED: true,
|
|
28
|
+
},
|
|
29
|
+
serverType: 'geoserver',
|
|
30
|
+
transition: 0,
|
|
31
|
+
}),
|
|
32
|
+
]);
|
|
21
33
|
/* eslint-disable-next-line */
|
|
22
34
|
}, []);
|
|
23
35
|
|
|
@@ -55,10 +67,11 @@ const View = (props) => {
|
|
|
55
67
|
showFullExtent: true,
|
|
56
68
|
zoom: 5,
|
|
57
69
|
}}
|
|
70
|
+
pixelRatio={1}
|
|
58
71
|
{...options}
|
|
59
72
|
>
|
|
60
73
|
<Layers>
|
|
61
|
-
<Layer.Tile zIndex={0} />
|
|
74
|
+
<Layer.Tile source={tileWMSSources[0]} zIndex={0} />
|
|
62
75
|
<Layer.Vector
|
|
63
76
|
source={vectorSource}
|
|
64
77
|
style={
|
|
@@ -11,6 +11,7 @@ import './style.less';
|
|
|
11
11
|
const View = (props) => {
|
|
12
12
|
const [options, setOptions] = React.useState({});
|
|
13
13
|
const [vectorSource, setVectorSource] = useState(null);
|
|
14
|
+
const [tileWMSSources, setTileWMSSources] = useState([]);
|
|
14
15
|
const { extent, format, proj, style, source } = openlayers;
|
|
15
16
|
const provider_data = props.provider_data || {};
|
|
16
17
|
const { code_2000 = [] } = provider_data;
|
|
@@ -18,6 +19,17 @@ const View = (props) => {
|
|
|
18
19
|
useEffect(() => {
|
|
19
20
|
if (__SERVER__) return;
|
|
20
21
|
setVectorSource(new source.Vector());
|
|
22
|
+
setTileWMSSources([
|
|
23
|
+
new source.TileWMS({
|
|
24
|
+
url: 'https://gisco-services.ec.europa.eu/maps/service',
|
|
25
|
+
params: {
|
|
26
|
+
LAYERS: 'OSMPositronComposite',
|
|
27
|
+
TILED: true,
|
|
28
|
+
},
|
|
29
|
+
serverType: 'geoserver',
|
|
30
|
+
transition: 0,
|
|
31
|
+
}),
|
|
32
|
+
]);
|
|
21
33
|
/* eslint-disable-next-line */
|
|
22
34
|
}, []);
|
|
23
35
|
|
|
@@ -55,10 +67,11 @@ const View = (props) => {
|
|
|
55
67
|
showFullExtent: true,
|
|
56
68
|
zoom: 5,
|
|
57
69
|
}}
|
|
70
|
+
pixelRatio={1}
|
|
58
71
|
{...options}
|
|
59
72
|
>
|
|
60
73
|
<Layers>
|
|
61
|
-
<Layer.Tile zIndex={0} />
|
|
74
|
+
<Layer.Tile source={tileWMSSources[0]} zIndex={0} />
|
|
62
75
|
<Layer.Vector
|
|
63
76
|
source={vectorSource}
|
|
64
77
|
style={
|
|
@@ -11,6 +11,7 @@ import './style.less';
|
|
|
11
11
|
const View = (props) => {
|
|
12
12
|
const [options, setOptions] = React.useState({});
|
|
13
13
|
const [vectorSource, setVectorSource] = useState(null);
|
|
14
|
+
const [tileWMSSources, setTileWMSSources] = useState([]);
|
|
14
15
|
const { extent, format, proj, style, source } = openlayers;
|
|
15
16
|
const provider_data = props.provider_data || {};
|
|
16
17
|
const { code_2000 = [] } = provider_data;
|
|
@@ -18,6 +19,17 @@ const View = (props) => {
|
|
|
18
19
|
useEffect(() => {
|
|
19
20
|
if (__SERVER__) return;
|
|
20
21
|
setVectorSource(new source.Vector());
|
|
22
|
+
setTileWMSSources([
|
|
23
|
+
new source.TileWMS({
|
|
24
|
+
url: 'https://gisco-services.ec.europa.eu/maps/service',
|
|
25
|
+
params: {
|
|
26
|
+
LAYERS: 'OSMPositronComposite',
|
|
27
|
+
TILED: true,
|
|
28
|
+
},
|
|
29
|
+
serverType: 'geoserver',
|
|
30
|
+
transition: 0,
|
|
31
|
+
}),
|
|
32
|
+
]);
|
|
21
33
|
/* eslint-disable-next-line */
|
|
22
34
|
}, []);
|
|
23
35
|
|
|
@@ -55,10 +67,11 @@ const View = (props) => {
|
|
|
55
67
|
showFullExtent: true,
|
|
56
68
|
zoom: 5,
|
|
57
69
|
}}
|
|
70
|
+
pixelRatio={1}
|
|
58
71
|
{...options}
|
|
59
72
|
>
|
|
60
73
|
<Layers>
|
|
61
|
-
<Layer.Tile zIndex={0} />
|
|
74
|
+
<Layer.Tile source={tileWMSSources[0]} zIndex={0} />
|
|
62
75
|
<Layer.VectorImage
|
|
63
76
|
source={vectorSource}
|
|
64
77
|
style={
|
|
@@ -9,12 +9,12 @@ const MultilingualRedirector = (props) => {
|
|
|
9
9
|
const { settings } = config;
|
|
10
10
|
const { pathname, children } = props;
|
|
11
11
|
const currentLanguage =
|
|
12
|
-
cookie.load('N2K_LANGUAGE') || settings.defaultLanguage;
|
|
13
|
-
const redirectToLanguage = settings.supportedLanguages.includes(
|
|
12
|
+
cookie.load('N2K_LANGUAGE') || settings.n2k.defaultLanguage;
|
|
13
|
+
const redirectToLanguage = settings.n2k.supportedLanguages.includes(
|
|
14
14
|
currentLanguage,
|
|
15
15
|
)
|
|
16
16
|
? currentLanguage
|
|
17
|
-
: settings.defaultLanguage;
|
|
17
|
+
: settings.n2k.defaultLanguage;
|
|
18
18
|
const dispatch = useDispatch();
|
|
19
19
|
|
|
20
20
|
React.useEffect(() => {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* @module components/theme/Header/Header
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import React, { useEffect, useContext } from 'react';
|
|
6
|
+
import React, { useEffect, useContext, useMemo } from 'react';
|
|
7
7
|
import { matchPath, withRouter } from 'react-router';
|
|
8
8
|
import { Container, Sticky } from 'semantic-ui-react';
|
|
9
9
|
import { connect } from 'react-redux';
|
|
@@ -12,7 +12,7 @@ import config from '@plone/volto/registry';
|
|
|
12
12
|
import { Anontools } from '@plone/volto/components';
|
|
13
13
|
import { withLocalStorage } from '@eeacms/volto-n2k/hocs';
|
|
14
14
|
import Navigation from '../Navigation/Navigation';
|
|
15
|
-
import { StickyContext } from '
|
|
15
|
+
import { StickyContext } from '@eeacms/volto-bise/components';
|
|
16
16
|
|
|
17
17
|
const Navbar = (props) => {
|
|
18
18
|
const currentLang = props.localStorage.get('N2K_LANGUAGE');
|
|
@@ -26,6 +26,8 @@ const Navbar = (props) => {
|
|
|
26
26
|
{currentLang ? (
|
|
27
27
|
<Navigation
|
|
28
28
|
isSticky={props.isSticky}
|
|
29
|
+
isRoot={props.isRoot}
|
|
30
|
+
isExplorer={props.isExplorer}
|
|
29
31
|
pathname={props.pathname}
|
|
30
32
|
/>
|
|
31
33
|
) : (
|
|
@@ -47,37 +49,68 @@ const Navbar = (props) => {
|
|
|
47
49
|
const Header = (props) => {
|
|
48
50
|
const [isSticky, setIsSticky] = React.useState(false);
|
|
49
51
|
const { stickyRef } = useContext(StickyContext);
|
|
50
|
-
const isRoot =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
const isRoot = useMemo(
|
|
53
|
+
() =>
|
|
54
|
+
matchPath(props.pathname, {
|
|
55
|
+
path: config.settings.n2k.multilingualRoot,
|
|
56
|
+
exact: true,
|
|
57
|
+
strict: false,
|
|
58
|
+
}),
|
|
59
|
+
[props.pathname],
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const isExplorer = useMemo(
|
|
63
|
+
() =>
|
|
64
|
+
(isRoot &&
|
|
65
|
+
!config.settings.n2k.supportedLanguages.includes(isRoot.params.lang)) ||
|
|
66
|
+
matchPath(props.pathname, {
|
|
67
|
+
path: '/natura2000/explore-natura2000/*',
|
|
68
|
+
exact: true,
|
|
69
|
+
strict: false,
|
|
70
|
+
}),
|
|
71
|
+
[props.pathname, isRoot],
|
|
72
|
+
);
|
|
55
73
|
|
|
56
74
|
useEffect(() => {
|
|
57
75
|
if (!props.localStorage.get('N2K_LANGUAGE')) {
|
|
58
|
-
props.localStorage.set(
|
|
76
|
+
props.localStorage.set(
|
|
77
|
+
'N2K_LANGUAGE',
|
|
78
|
+
config.settings.n2k.defaultLanguage,
|
|
79
|
+
);
|
|
59
80
|
}
|
|
60
81
|
/* eslint-disable-next-line */
|
|
61
82
|
}, []);
|
|
62
83
|
|
|
63
|
-
return isRoot ? (
|
|
64
|
-
|
|
84
|
+
return isRoot || isExplorer ? (
|
|
85
|
+
<div className="ui basic segment sticky-header-wrapper">
|
|
86
|
+
<div className="ui sticky">
|
|
87
|
+
<Navbar
|
|
88
|
+
{...props}
|
|
89
|
+
isSticky={false}
|
|
90
|
+
isRoot={isRoot}
|
|
91
|
+
isExplorer={isExplorer}
|
|
92
|
+
/>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
65
95
|
) : (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
96
|
+
<Sticky
|
|
97
|
+
context={stickyRef}
|
|
98
|
+
className="ui basic segment sticky-header-wrapper"
|
|
99
|
+
role="banner"
|
|
100
|
+
onStick={() => {
|
|
101
|
+
setIsSticky(true);
|
|
102
|
+
}}
|
|
103
|
+
onUnstick={() => {
|
|
104
|
+
setIsSticky(false);
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
<Navbar
|
|
108
|
+
{...props}
|
|
109
|
+
isSticky={isSticky}
|
|
110
|
+
isRoot={isRoot}
|
|
111
|
+
isExplorer={isExplorer}
|
|
112
|
+
/>
|
|
113
|
+
</Sticky>
|
|
81
114
|
);
|
|
82
115
|
};
|
|
83
116
|
|
|
@@ -9,12 +9,14 @@ import { useSelector } from 'react-redux';
|
|
|
9
9
|
import cx from 'classnames';
|
|
10
10
|
import { langmap } from '@plone/volto/helpers';
|
|
11
11
|
import { flattenToAppURL } from '@plone/volto/helpers';
|
|
12
|
-
import { Dropdown } from 'semantic-ui-react';
|
|
12
|
+
import { Dropdown, Image } from 'semantic-ui-react';
|
|
13
13
|
import config from '@plone/volto/registry';
|
|
14
14
|
import { withLocalStorage } from '@eeacms/volto-n2k/hocs';
|
|
15
15
|
import { getN2kItems, pathExists } from '@eeacms/volto-n2k/helpers';
|
|
16
16
|
import './styles.less';
|
|
17
17
|
|
|
18
|
+
import globeIcon from '@eeacms/volto-n2k/static/global-line.svg';
|
|
19
|
+
|
|
18
20
|
const LanguageSelector = (props) => {
|
|
19
21
|
const { settings } = config;
|
|
20
22
|
const content = useSelector((state) => state.content);
|
|
@@ -23,24 +25,24 @@ const LanguageSelector = (props) => {
|
|
|
23
25
|
const pathname = props.location.pathname;
|
|
24
26
|
const currentLang = localStorage.get('N2K_LANGUAGE');
|
|
25
27
|
const matchRoot = matchPath(pathname, {
|
|
26
|
-
path: settings.multilingualRoot,
|
|
28
|
+
path: settings.n2k.multilingualRoot,
|
|
27
29
|
exact: true,
|
|
28
30
|
strict: false,
|
|
29
31
|
});
|
|
30
32
|
const matchChild = matchPath(pathname, {
|
|
31
|
-
path: settings.multilingualPath,
|
|
33
|
+
path: settings.n2k.multilingualPath,
|
|
32
34
|
exact: true,
|
|
33
35
|
strict: false,
|
|
34
36
|
});
|
|
35
37
|
const match = matchRoot || matchChild;
|
|
36
38
|
const hasMultilingualSupport =
|
|
37
|
-
match && settings.supportedLanguages.includes(match.params.lang);
|
|
39
|
+
match && settings.n2k.supportedLanguages.includes(match.params.lang);
|
|
38
40
|
const translations = hasMultilingualSupport
|
|
39
|
-
? settings.supportedLanguages.map((lang) => {
|
|
41
|
+
? settings.n2k.supportedLanguages.map((lang) => {
|
|
40
42
|
return {
|
|
41
43
|
path: matchRoot
|
|
42
44
|
? `/natura2000/${lang}`
|
|
43
|
-
: generatePath(settings.multilingualPath, {
|
|
45
|
+
: generatePath(settings.n2k.multilingualPath, {
|
|
44
46
|
...match.params,
|
|
45
47
|
lang,
|
|
46
48
|
}),
|
|
@@ -48,11 +50,13 @@ const LanguageSelector = (props) => {
|
|
|
48
50
|
};
|
|
49
51
|
})
|
|
50
52
|
: [];
|
|
51
|
-
const supportedLanguagesOptions = settings.supportedLanguages.map(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
const supportedLanguagesOptions = settings.n2k.supportedLanguages.map(
|
|
54
|
+
(lang) => ({
|
|
55
|
+
key: lang,
|
|
56
|
+
value: lang,
|
|
57
|
+
text: langmap[lang].nativeName,
|
|
58
|
+
}),
|
|
59
|
+
);
|
|
56
60
|
|
|
57
61
|
return (
|
|
58
62
|
<div className={cx('language-selector', props.className)}>
|
|
@@ -60,10 +64,14 @@ const LanguageSelector = (props) => {
|
|
|
60
64
|
aria-label="Language selector"
|
|
61
65
|
disabled={content.get.loading}
|
|
62
66
|
placeholder="Select a language"
|
|
63
|
-
|
|
67
|
+
text={currentLang}
|
|
64
68
|
scrolling
|
|
69
|
+
icon={
|
|
70
|
+
<Image src={globeIcon} alt="language dropdown globe icon"></Image>
|
|
71
|
+
}
|
|
65
72
|
options={supportedLanguagesOptions}
|
|
66
|
-
|
|
73
|
+
value={currentLang}
|
|
74
|
+
onChange={(_, data) => {
|
|
67
75
|
const lang = data.value;
|
|
68
76
|
const translation = translations.filter(
|
|
69
77
|
(item) => item.lang === lang,
|
|
@@ -78,7 +86,7 @@ const LanguageSelector = (props) => {
|
|
|
78
86
|
}
|
|
79
87
|
}
|
|
80
88
|
|
|
81
|
-
if (config.settings.supportedLanguages.includes(lang)) {
|
|
89
|
+
if (config.settings.n2k.supportedLanguages.includes(lang)) {
|
|
82
90
|
localStorage.set('N2K_LANGUAGE', lang);
|
|
83
91
|
}
|
|
84
92
|
}}
|
|
@@ -12,7 +12,11 @@ import { Link } from 'react-router-dom';
|
|
|
12
12
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
13
13
|
import { Menu, Dropdown } from 'semantic-ui-react';
|
|
14
14
|
import cx from 'classnames';
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
getBaseUrl,
|
|
17
|
+
flattenToAppURL,
|
|
18
|
+
hasApiExpander,
|
|
19
|
+
} from '@plone/volto/helpers';
|
|
16
20
|
import { UniversalLink, Icon } from '@plone/volto/components';
|
|
17
21
|
import qs from 'querystring';
|
|
18
22
|
import { getNavigation } from '@plone/volto/actions';
|
|
@@ -89,6 +93,10 @@ class Navigation extends Component {
|
|
|
89
93
|
).isRequired,
|
|
90
94
|
};
|
|
91
95
|
|
|
96
|
+
static defaultProps = {
|
|
97
|
+
token: null,
|
|
98
|
+
};
|
|
99
|
+
|
|
92
100
|
/**
|
|
93
101
|
* Constructor
|
|
94
102
|
* @method constructor
|
|
@@ -102,7 +110,6 @@ class Navigation extends Component {
|
|
|
102
110
|
this.state = {
|
|
103
111
|
isMobileMenuOpen: false,
|
|
104
112
|
isSdf: false,
|
|
105
|
-
language: this.props.localStorage.get('N2K_LANGUAGE'),
|
|
106
113
|
};
|
|
107
114
|
this.container = React.createRef();
|
|
108
115
|
}
|
|
@@ -113,10 +120,13 @@ class Navigation extends Component {
|
|
|
113
120
|
* @returns {undefined}
|
|
114
121
|
*/
|
|
115
122
|
componentDidMount() {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
const { settings } = config;
|
|
124
|
+
if (!hasApiExpander('navigation', getBaseUrl(this.props.pathname))) {
|
|
125
|
+
this.props.getNavigation(
|
|
126
|
+
getBaseUrl(this.props.pathname),
|
|
127
|
+
settings.navDepth,
|
|
128
|
+
);
|
|
129
|
+
}
|
|
120
130
|
this.setState({
|
|
121
131
|
isSdf: this.isSdf(),
|
|
122
132
|
});
|
|
@@ -134,20 +144,23 @@ class Navigation extends Component {
|
|
|
134
144
|
};
|
|
135
145
|
|
|
136
146
|
/**
|
|
137
|
-
* Component
|
|
138
|
-
* @method
|
|
139
|
-
* @param {Object}
|
|
147
|
+
* Component will receive props
|
|
148
|
+
* @method componentWillReceiveProps
|
|
149
|
+
* @param {Object} nextProps Next properties
|
|
140
150
|
* @returns {undefined}
|
|
141
151
|
*/
|
|
142
|
-
|
|
152
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
153
|
+
const { settings } = config;
|
|
143
154
|
if (
|
|
144
|
-
|
|
145
|
-
|
|
155
|
+
nextProps.pathname !== this.props.pathname ||
|
|
156
|
+
nextProps.token !== this.props.token
|
|
146
157
|
) {
|
|
147
|
-
this.props.
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
158
|
+
if (!hasApiExpander('navigation', getBaseUrl(this.props.pathname))) {
|
|
159
|
+
this.props.getNavigation(
|
|
160
|
+
getBaseUrl(nextProps.pathname),
|
|
161
|
+
settings.navDepth,
|
|
162
|
+
);
|
|
163
|
+
}
|
|
151
164
|
this.closeMobileMenu();
|
|
152
165
|
}
|
|
153
166
|
|
|
@@ -227,6 +240,8 @@ class Navigation extends Component {
|
|
|
227
240
|
...(this.props.route_parameters || {}),
|
|
228
241
|
...qs.parse(this.props.location.search.replace('?', '')),
|
|
229
242
|
};
|
|
243
|
+
const currentLang = this.props.localStorage.get('N2K_LANGUAGE');
|
|
244
|
+
|
|
230
245
|
return (
|
|
231
246
|
<nav
|
|
232
247
|
className={cx('navigation', this.props.className || '')}
|
|
@@ -261,7 +276,7 @@ class Navigation extends Component {
|
|
|
261
276
|
/>
|
|
262
277
|
</div>
|
|
263
278
|
<Menu.Item className="home-button logo">
|
|
264
|
-
<Link title="Natura 2000" to={`/natura2000/${
|
|
279
|
+
<Link title="Natura 2000" to={`/natura2000/${currentLang}`}>
|
|
265
280
|
<Icon name={n2kLogo} size={44} />
|
|
266
281
|
</Link>
|
|
267
282
|
</Menu.Item>
|
|
@@ -298,7 +313,7 @@ class Navigation extends Component {
|
|
|
298
313
|
''
|
|
299
314
|
)}
|
|
300
315
|
|
|
301
|
-
{!this.state.isSdf
|
|
316
|
+
{!this.state.isSdf && !this.props.isRoot && !this.props.isExplorer
|
|
302
317
|
? this.props.items.map((item) => {
|
|
303
318
|
const flatUrl = flattenToAppURL(item.url);
|
|
304
319
|
const itemID = item.title.split(' ').join('-').toLowerCase();
|
|
@@ -391,7 +406,7 @@ class Navigation extends Component {
|
|
|
391
406
|
);
|
|
392
407
|
})
|
|
393
408
|
: ''}
|
|
394
|
-
{!this.state.isSdf ? (
|
|
409
|
+
{!this.state.isSdf && !this.props.isExplorer ? (
|
|
395
410
|
<Menu.Item className="firstLevel language-selector-wrapper">
|
|
396
411
|
<LanguageSelector navigation={this.props.navigation} />
|
|
397
412
|
</Menu.Item>
|
|
@@ -412,7 +427,7 @@ const getN2kItems = (items, localStorage) => {
|
|
|
412
427
|
items.filter((item) => item.url === '/natura2000')?.[0]?.items || [];
|
|
413
428
|
natura2000.forEach((item) => {
|
|
414
429
|
const languageFolder = matchPath(item.url, {
|
|
415
|
-
path: config.settings.multilingualRoot,
|
|
430
|
+
path: config.settings.n2k.multilingualRoot,
|
|
416
431
|
exact: true,
|
|
417
432
|
strict: false,
|
|
418
433
|
});
|
|
@@ -421,7 +436,7 @@ const getN2kItems = (items, localStorage) => {
|
|
|
421
436
|
}
|
|
422
437
|
if (
|
|
423
438
|
languageFolder &&
|
|
424
|
-
!config.settings.supportedLanguages.includes(
|
|
439
|
+
!config.settings.n2k.supportedLanguages.includes(
|
|
425
440
|
languageFolder.params.lang,
|
|
426
441
|
) &&
|
|
427
442
|
item.url !== '/natura2000/sites' &&
|
|
@@ -443,10 +458,10 @@ export default compose(
|
|
|
443
458
|
connect(
|
|
444
459
|
(state, props) => {
|
|
445
460
|
return {
|
|
461
|
+
token: state.userSession.token,
|
|
446
462
|
route_parameters: state.route_parameters,
|
|
447
463
|
navigation: state.navigation,
|
|
448
464
|
items: getN2kItems(state.navigation.items, props.localStorage),
|
|
449
|
-
userToken: state?.userSession?.token,
|
|
450
465
|
};
|
|
451
466
|
},
|
|
452
467
|
{ getNavigation },
|