@eeacms/volto-cca-policy 0.1.35 → 0.1.36
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 +7 -0
- package/package.json +1 -1
- package/src/components/manage/Blocks/CaseStudyExplorer/index.js +9 -0
- package/src/components/manage/Blocks/CountryMapHeatIndex/index.js +9 -0
- package/src/components/manage/Blocks/CountryMapObservatory/index.js +9 -0
- package/src/components/manage/Blocks/CountryMapProfile/index.js +9 -0
- package/src/components/manage/Blocks/ECDEIndicators/index.js +9 -0
- package/src/components/manage/Blocks/FilterAceContent/index.js +4 -1
- package/src/components/manage/Blocks/MKHMap/index.js +10 -1
- package/src/components/manage/Blocks/RASTBlock/index.js +7 -1
- package/src/components/manage/Blocks/RelevantAceContent/index.js +4 -0
- package/src/components/manage/Blocks/SearchAceContent/index.js +4 -0
- package/src/components/manage/Blocks/TransRegionSelect/index.js +4 -0
- package/src/components/theme/Header.jsx +282 -0
- package/src/customizations/volto/components/theme/Header/Header.jsx +2 -281
- package/src/index.js +9 -0
- package/src/utils.js +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@ 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.36](https://github.com/eea/volto-cca-policy/compare/0.1.35...0.1.36) - 11 August 2023
|
|
8
|
+
|
|
9
|
+
#### :hammer_and_wrench: Others
|
|
10
|
+
|
|
11
|
+
- Move Header code from customizations [Tiberiu Ichim - [`7af45f3`](https://github.com/eea/volto-cca-policy/commit/7af45f36a279e5a0d857363e48b1ff34cb8bb951)]
|
|
12
|
+
- Restrict mission blocks on CCA [kreafox - [`d3ee731`](https://github.com/eea/volto-cca-policy/commit/d3ee7312c256b316362249f4ad8bf3fd0d1f2371)]
|
|
13
|
+
- Restrict blocks on mission [kreafox - [`ed28366`](https://github.com/eea/volto-cca-policy/commit/ed28366e879139b138b1bb3d6ba059a46614de1d)]
|
|
7
14
|
### [0.1.35](https://github.com/eea/volto-cca-policy/compare/0.1.34...0.1.35) - 7 August 2023
|
|
8
15
|
|
|
9
16
|
#### :hammer_and_wrench: Others
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import worldSVG from '@plone/volto/icons/world.svg';
|
|
2
2
|
import CaseStudyExplorerEdit from './CaseStudyExplorerEdit';
|
|
3
3
|
import CaseStudyExplorerView from './CaseStudyExplorerView';
|
|
4
|
+
import { blockAvailableInMission } from '@eeacms/volto-cca-policy/utils';
|
|
4
5
|
|
|
5
6
|
export default function installCaseStudyExplorerBlock(config) {
|
|
6
7
|
config.blocks.blocksConfig.caseStudyExplorer = {
|
|
@@ -10,6 +11,14 @@ export default function installCaseStudyExplorerBlock(config) {
|
|
|
10
11
|
group: 'site',
|
|
11
12
|
edit: CaseStudyExplorerEdit,
|
|
12
13
|
view: CaseStudyExplorerView,
|
|
14
|
+
sidebarTab: 1,
|
|
15
|
+
security: {
|
|
16
|
+
addPermission: [],
|
|
17
|
+
view: [],
|
|
18
|
+
},
|
|
19
|
+
restricted: ({ properties, block }) => {
|
|
20
|
+
return blockAvailableInMission(properties, block);
|
|
21
|
+
},
|
|
13
22
|
};
|
|
14
23
|
|
|
15
24
|
return config;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import worldSVG from '@plone/volto/icons/world.svg';
|
|
2
2
|
import Edit from './Edit';
|
|
3
3
|
import View from './View';
|
|
4
|
+
import { blockAvailableInMission } from '@eeacms/volto-cca-policy/utils';
|
|
4
5
|
|
|
5
6
|
export default function installCountryMapHeatIndex(config) {
|
|
6
7
|
config.blocks.blocksConfig.countryMapHeatIndex = {
|
|
@@ -10,6 +11,14 @@ export default function installCountryMapHeatIndex(config) {
|
|
|
10
11
|
group: 'site',
|
|
11
12
|
edit: Edit,
|
|
12
13
|
view: View,
|
|
14
|
+
sidebarTab: 1,
|
|
15
|
+
security: {
|
|
16
|
+
addPermission: [],
|
|
17
|
+
view: [],
|
|
18
|
+
},
|
|
19
|
+
restricted: ({ properties, block }) => {
|
|
20
|
+
return blockAvailableInMission(properties, block);
|
|
21
|
+
},
|
|
13
22
|
};
|
|
14
23
|
|
|
15
24
|
return config;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import worldSVG from '@plone/volto/icons/world.svg';
|
|
2
2
|
import CountryMapObservatoryEdit from './CountryMapObservatoryEdit';
|
|
3
3
|
import CountryMapObservatoryView from './CountryMapObservatoryView';
|
|
4
|
+
import { blockAvailableInMission } from '@eeacms/volto-cca-policy/utils';
|
|
4
5
|
|
|
5
6
|
export default function installCountryMapObservatoryBlock(config) {
|
|
6
7
|
config.blocks.blocksConfig.countryMapObservatory = {
|
|
@@ -10,6 +11,14 @@ export default function installCountryMapObservatoryBlock(config) {
|
|
|
10
11
|
group: 'site',
|
|
11
12
|
edit: CountryMapObservatoryEdit,
|
|
12
13
|
view: CountryMapObservatoryView,
|
|
14
|
+
sidebarTab: 1,
|
|
15
|
+
security: {
|
|
16
|
+
addPermission: [],
|
|
17
|
+
view: [],
|
|
18
|
+
},
|
|
19
|
+
restricted: ({ properties, block }) => {
|
|
20
|
+
return blockAvailableInMission(properties, block);
|
|
21
|
+
},
|
|
13
22
|
};
|
|
14
23
|
|
|
15
24
|
return config;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import worldSVG from '@plone/volto/icons/world.svg';
|
|
2
2
|
import Edit from './Edit';
|
|
3
3
|
import View from './View';
|
|
4
|
+
import { blockAvailableInMission } from '@eeacms/volto-cca-policy/utils';
|
|
4
5
|
|
|
5
6
|
export default function installCountryMapProfile(config) {
|
|
6
7
|
config.blocks.blocksConfig.countryMapProfile = {
|
|
@@ -10,6 +11,14 @@ export default function installCountryMapProfile(config) {
|
|
|
10
11
|
group: 'site',
|
|
11
12
|
edit: Edit,
|
|
12
13
|
view: View,
|
|
14
|
+
sidebarTab: 1,
|
|
15
|
+
security: {
|
|
16
|
+
addPermission: [],
|
|
17
|
+
view: [],
|
|
18
|
+
},
|
|
19
|
+
restricted: ({ properties, block }) => {
|
|
20
|
+
return blockAvailableInMission(properties, block);
|
|
21
|
+
},
|
|
13
22
|
};
|
|
14
23
|
|
|
15
24
|
return config;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import worldSVG from '@plone/volto/icons/world.svg';
|
|
2
2
|
import ECDEIndicatorsEdit from './ECDEIndicatorsEdit';
|
|
3
3
|
import ECDEIndicatorsView from './ECDEIndicatorsView';
|
|
4
|
+
import { blockAvailableInMission } from '@eeacms/volto-cca-policy/utils';
|
|
4
5
|
|
|
5
6
|
export default function installECDEIndicatorsBlock(config) {
|
|
6
7
|
config.blocks.blocksConfig.ecdeIndicators = {
|
|
@@ -10,6 +11,14 @@ export default function installECDEIndicatorsBlock(config) {
|
|
|
10
11
|
group: 'site',
|
|
11
12
|
edit: ECDEIndicatorsEdit,
|
|
12
13
|
view: ECDEIndicatorsView,
|
|
14
|
+
sidebarTab: 1,
|
|
15
|
+
security: {
|
|
16
|
+
addPermission: [],
|
|
17
|
+
view: [],
|
|
18
|
+
},
|
|
19
|
+
restricted: ({ properties, block }) => {
|
|
20
|
+
return blockAvailableInMission(properties, block);
|
|
21
|
+
},
|
|
13
22
|
};
|
|
14
23
|
|
|
15
24
|
return config;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import zoomSVG from '@plone/volto/icons/zoom.svg';
|
|
2
2
|
import FilterAceContentEdit from './FilterAceContentEdit';
|
|
3
3
|
import FilterAceContentView from './FilterAceContentView';
|
|
4
|
+
import { blockAvailableInMission } from '@eeacms/volto-cca-policy/utils';
|
|
4
5
|
|
|
5
6
|
export default function installBlock(config) {
|
|
6
7
|
config.blocks.blocksConfig.filterAceContent = {
|
|
@@ -15,7 +16,9 @@ export default function installBlock(config) {
|
|
|
15
16
|
addPermission: [],
|
|
16
17
|
view: [],
|
|
17
18
|
},
|
|
18
|
-
|
|
19
|
+
restricted: ({ properties, block }) => {
|
|
20
|
+
return blockAvailableInMission(properties, block);
|
|
21
|
+
},
|
|
19
22
|
};
|
|
20
23
|
|
|
21
24
|
return config;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import MapBlockEdit from './Edit';
|
|
2
2
|
import MapBlockView from './View';
|
|
3
|
-
|
|
4
3
|
import worldSVG from '@plone/volto/icons/world.svg';
|
|
4
|
+
import { blockAvailableInMission } from '@eeacms/volto-cca-policy/utils';
|
|
5
5
|
|
|
6
6
|
export default (config) => {
|
|
7
7
|
config.blocks.blocksConfig.mkh_map = {
|
|
@@ -11,6 +11,15 @@ export default (config) => {
|
|
|
11
11
|
group: 'site',
|
|
12
12
|
edit: MapBlockEdit,
|
|
13
13
|
view: MapBlockView,
|
|
14
|
+
sidebarTab: 1,
|
|
15
|
+
security: {
|
|
16
|
+
addPermission: [],
|
|
17
|
+
view: [],
|
|
18
|
+
},
|
|
19
|
+
restricted: ({ properties, block }) => {
|
|
20
|
+
return blockAvailableInMission(properties, block);
|
|
21
|
+
},
|
|
14
22
|
};
|
|
23
|
+
|
|
15
24
|
return config;
|
|
16
25
|
};
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import zoomSVG from '@plone/volto/icons/zoom.svg';
|
|
2
2
|
import RASTEdit from './RASTEdit';
|
|
3
3
|
import RASTView from './RASTView';
|
|
4
|
+
import { blockAvailableInMission } from '@eeacms/volto-cca-policy/utils';
|
|
4
5
|
|
|
5
6
|
export default function installBlock(config) {
|
|
6
|
-
config.blocks.blocksConfig
|
|
7
|
+
const blocksConfig = config.blocks.blocksConfig;
|
|
8
|
+
|
|
9
|
+
blocksConfig.rastBlock = {
|
|
7
10
|
id: 'rastBlock',
|
|
8
11
|
title: 'RAST',
|
|
9
12
|
icon: zoomSVG,
|
|
@@ -16,6 +19,9 @@ export default function installBlock(config) {
|
|
|
16
19
|
view: [],
|
|
17
20
|
},
|
|
18
21
|
variations: [],
|
|
22
|
+
restricted: ({ properties, block }) => {
|
|
23
|
+
return blockAvailableInMission(properties, block);
|
|
24
|
+
},
|
|
19
25
|
};
|
|
20
26
|
|
|
21
27
|
return config;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import zoomSVG from '@plone/volto/icons/zoom.svg';
|
|
2
2
|
import RelevantAceContentEdit from './RelevantAceContentEdit';
|
|
3
3
|
import RelevantAceContentView from './RelevantAceContentView';
|
|
4
|
+
import { blockAvailableInMission } from '@eeacms/volto-cca-policy/utils';
|
|
4
5
|
|
|
5
6
|
export default function installBlock(config) {
|
|
6
7
|
config.blocks.blocksConfig.relevantAceContent = {
|
|
@@ -16,6 +17,9 @@ export default function installBlock(config) {
|
|
|
16
17
|
view: [],
|
|
17
18
|
},
|
|
18
19
|
variations: [],
|
|
20
|
+
restricted: ({ properties, block }) => {
|
|
21
|
+
return blockAvailableInMission(properties, block);
|
|
22
|
+
},
|
|
19
23
|
};
|
|
20
24
|
|
|
21
25
|
return config;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import zoomSVG from '@plone/volto/icons/zoom.svg';
|
|
2
2
|
import SearchAceContentEdit from './SearchAceContentEdit';
|
|
3
3
|
import SearchAceContentView from './SearchAceContentView';
|
|
4
|
+
import { blockAvailableInMission } from '@eeacms/volto-cca-policy/utils';
|
|
4
5
|
|
|
5
6
|
export default function installBlock(config) {
|
|
6
7
|
config.blocks.blocksConfig.searchAceContent = {
|
|
@@ -16,6 +17,9 @@ export default function installBlock(config) {
|
|
|
16
17
|
view: [],
|
|
17
18
|
},
|
|
18
19
|
variations: [],
|
|
20
|
+
restricted: ({ properties, block }) => {
|
|
21
|
+
return blockAvailableInMission(properties, block);
|
|
22
|
+
},
|
|
19
23
|
};
|
|
20
24
|
|
|
21
25
|
return config;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import zoomSVG from '@plone/volto/icons/zoom.svg';
|
|
2
2
|
import TransRegionSelectEdit from './TransRegionSelectEdit';
|
|
3
3
|
import TransRegionSelectView from './TransRegionSelectView';
|
|
4
|
+
import { blockAvailableInMission } from '@eeacms/volto-cca-policy/utils';
|
|
4
5
|
|
|
5
6
|
export default function installBlock(config) {
|
|
6
7
|
config.blocks.blocksConfig.transRegionSelect = {
|
|
@@ -16,6 +17,9 @@ export default function installBlock(config) {
|
|
|
16
17
|
view: [],
|
|
17
18
|
},
|
|
18
19
|
variations: [],
|
|
20
|
+
restricted: ({ properties, block }) => {
|
|
21
|
+
return blockAvailableInMission(properties, block);
|
|
22
|
+
},
|
|
19
23
|
};
|
|
20
24
|
|
|
21
25
|
return config;
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Header component.
|
|
3
|
+
* @module components/theme/Header/Header
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { Dropdown, Image } from 'semantic-ui-react';
|
|
8
|
+
import { connect, useDispatch, useSelector } from 'react-redux';
|
|
9
|
+
|
|
10
|
+
import { withRouter } from 'react-router-dom';
|
|
11
|
+
import { UniversalLink } from '@plone/volto/components';
|
|
12
|
+
import {
|
|
13
|
+
getBaseUrl,
|
|
14
|
+
hasApiExpander,
|
|
15
|
+
flattenToAppURL,
|
|
16
|
+
} from '@plone/volto/helpers';
|
|
17
|
+
import { getNavigation } from '@plone/volto/actions';
|
|
18
|
+
import { Header, Logo } from '@eeacms/volto-eea-design-system/ui';
|
|
19
|
+
import { usePrevious } from '@eeacms/volto-eea-design-system/helpers';
|
|
20
|
+
import { find } from 'lodash';
|
|
21
|
+
import globeIcon from '@eeacms/volto-eea-design-system/../theme/themes/eea/assets/images/Header/global-line.svg';
|
|
22
|
+
import eeaFlag from '@eeacms/volto-eea-design-system/../theme/themes/eea/assets/images/Header/eea.png';
|
|
23
|
+
|
|
24
|
+
import config from '@plone/volto/registry';
|
|
25
|
+
import { compose } from 'recompose';
|
|
26
|
+
import { BodyClass } from '@plone/volto/helpers';
|
|
27
|
+
|
|
28
|
+
import cx from 'classnames';
|
|
29
|
+
|
|
30
|
+
function removeTrailingSlash(path) {
|
|
31
|
+
return path.replace(/\/+$/, '');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* EEA Specific Header component.
|
|
36
|
+
*/
|
|
37
|
+
const EEAHeader = ({ pathname, token, items, history, subsite }) => {
|
|
38
|
+
const currentLang = useSelector((state) => state.intl.locale);
|
|
39
|
+
const translations = useSelector(
|
|
40
|
+
(state) => state.content.data?.['@components']?.translations?.items,
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const router_pathname = useSelector((state) => {
|
|
44
|
+
return removeTrailingSlash(state.router?.location?.pathname) || '';
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const isSubsite = subsite?.['@type'] === 'Subsite';
|
|
48
|
+
|
|
49
|
+
const isHomePageInverse = useSelector((state) => {
|
|
50
|
+
const layout = state.content?.data?.layout;
|
|
51
|
+
const has_home_layout =
|
|
52
|
+
layout === 'homepage_inverse_view' ||
|
|
53
|
+
(__CLIENT__ && document.body.classList.contains('homepage-inverse'));
|
|
54
|
+
return (
|
|
55
|
+
has_home_layout &&
|
|
56
|
+
(removeTrailingSlash(pathname) === router_pathname ||
|
|
57
|
+
router_pathname.endsWith('/edit'))
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const { eea } = config.settings;
|
|
62
|
+
const headerOpts = eea.headerOpts || {};
|
|
63
|
+
const headerSearchBox = eea.headerSearchBox || [];
|
|
64
|
+
const { logo, logoWhite } = headerOpts || {};
|
|
65
|
+
const width = useSelector((state) => state.screen?.width);
|
|
66
|
+
const dispatch = useDispatch();
|
|
67
|
+
const previousToken = usePrevious(token);
|
|
68
|
+
const [language, setLanguage] = React.useState(
|
|
69
|
+
currentLang || eea.defaultLanguage,
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
React.useEffect(() => {
|
|
73
|
+
const { settings } = config;
|
|
74
|
+
const base_url = getBaseUrl(pathname);
|
|
75
|
+
if (!hasApiExpander('navigation', base_url)) {
|
|
76
|
+
dispatch(getNavigation(base_url, settings.navDepth));
|
|
77
|
+
}
|
|
78
|
+
}, [pathname, dispatch]);
|
|
79
|
+
|
|
80
|
+
React.useEffect(() => {
|
|
81
|
+
if (token !== previousToken) {
|
|
82
|
+
const { settings } = config;
|
|
83
|
+
const base = getBaseUrl(pathname);
|
|
84
|
+
if (!hasApiExpander('navigation', base)) {
|
|
85
|
+
dispatch(getNavigation(base, settings.navDepth));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}, [token, dispatch, pathname, previousToken]);
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<Header menuItems={items}>
|
|
92
|
+
{isHomePageInverse && <BodyClass className="homepage" />}
|
|
93
|
+
<Header.TopHeader>
|
|
94
|
+
<Header.TopItem className="official-union">
|
|
95
|
+
<Image src={eeaFlag} alt="eea flag"></Image>
|
|
96
|
+
<Header.TopDropdownMenu
|
|
97
|
+
text="An official website of the European Union | How do you know?"
|
|
98
|
+
tabletText="EEA information systems"
|
|
99
|
+
mobileText=" "
|
|
100
|
+
icon="chevron down"
|
|
101
|
+
aria-label="dropdown"
|
|
102
|
+
className=""
|
|
103
|
+
viewportWidth={width}
|
|
104
|
+
>
|
|
105
|
+
{/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}
|
|
106
|
+
<div
|
|
107
|
+
className="content"
|
|
108
|
+
onClick={(evt) => evt.stopPropagation()}
|
|
109
|
+
onKeyDown={(evt) => evt.stopPropagation()}
|
|
110
|
+
>
|
|
111
|
+
<p>
|
|
112
|
+
All official European Union website addresses are in the{' '}
|
|
113
|
+
<b>europa.eu</b> domain.
|
|
114
|
+
</p>
|
|
115
|
+
<a
|
|
116
|
+
href="https://europa.eu/european-union/contact/institutions-bodies_en"
|
|
117
|
+
target="_blank"
|
|
118
|
+
rel="noreferrer"
|
|
119
|
+
onKeyDown={(evt) => evt.stopPropagation()}
|
|
120
|
+
>
|
|
121
|
+
See all EU institutions and bodies
|
|
122
|
+
</a>
|
|
123
|
+
</div>
|
|
124
|
+
</Header.TopDropdownMenu>
|
|
125
|
+
</Header.TopItem>
|
|
126
|
+
|
|
127
|
+
{!!headerOpts.partnerLinks && (
|
|
128
|
+
<Header.TopItem>
|
|
129
|
+
<Header.TopDropdownMenu
|
|
130
|
+
id="theme-sites"
|
|
131
|
+
text={headerOpts.partnerLinks.title}
|
|
132
|
+
viewportWidth={width}
|
|
133
|
+
>
|
|
134
|
+
<div className="wrapper">
|
|
135
|
+
{headerOpts.partnerLinks.links.map((item, index) => (
|
|
136
|
+
<Dropdown.Item key={index}>
|
|
137
|
+
<a
|
|
138
|
+
href={item.href}
|
|
139
|
+
className="site"
|
|
140
|
+
target="_blank"
|
|
141
|
+
rel="noreferrer"
|
|
142
|
+
onKeyDown={(evt) => evt.stopPropagation()}
|
|
143
|
+
>
|
|
144
|
+
{item.title}
|
|
145
|
+
</a>
|
|
146
|
+
</Dropdown.Item>
|
|
147
|
+
))}
|
|
148
|
+
</div>
|
|
149
|
+
</Header.TopDropdownMenu>
|
|
150
|
+
</Header.TopItem>
|
|
151
|
+
)}
|
|
152
|
+
|
|
153
|
+
{config.settings.isMultilingual && (
|
|
154
|
+
<Header.TopDropdownMenu
|
|
155
|
+
id="language-switcher"
|
|
156
|
+
className="item"
|
|
157
|
+
hasLanguageDropdown={
|
|
158
|
+
config.settings.supportedLanguages.length > 1 &&
|
|
159
|
+
config.settings.hasLanguageDropdown
|
|
160
|
+
}
|
|
161
|
+
text={`${language.toUpperCase()}`}
|
|
162
|
+
mobileText={`${language.toUpperCase()}`}
|
|
163
|
+
icon={
|
|
164
|
+
<Image src={globeIcon} alt="language dropdown globe icon"></Image>
|
|
165
|
+
}
|
|
166
|
+
viewportWidth={width}
|
|
167
|
+
>
|
|
168
|
+
<ul
|
|
169
|
+
className="wrapper language-list"
|
|
170
|
+
role="listbox"
|
|
171
|
+
aria-label="language switcher"
|
|
172
|
+
>
|
|
173
|
+
{eea.languages.map((item, index) => (
|
|
174
|
+
<Dropdown.Item
|
|
175
|
+
as="li"
|
|
176
|
+
key={index}
|
|
177
|
+
text={
|
|
178
|
+
<span>
|
|
179
|
+
{item.name}
|
|
180
|
+
<span className="country-code">
|
|
181
|
+
{item.code.toUpperCase()}
|
|
182
|
+
</span>
|
|
183
|
+
</span>
|
|
184
|
+
}
|
|
185
|
+
onClick={() => {
|
|
186
|
+
const translation = find(translations, {
|
|
187
|
+
language: item.code,
|
|
188
|
+
});
|
|
189
|
+
const to = translation
|
|
190
|
+
? flattenToAppURL(translation['@id'])
|
|
191
|
+
: `/${item.code}`;
|
|
192
|
+
setLanguage(item.code);
|
|
193
|
+
history.push(to);
|
|
194
|
+
}}
|
|
195
|
+
></Dropdown.Item>
|
|
196
|
+
))}
|
|
197
|
+
</ul>
|
|
198
|
+
</Header.TopDropdownMenu>
|
|
199
|
+
)}
|
|
200
|
+
</Header.TopHeader>
|
|
201
|
+
<Header.Main
|
|
202
|
+
pathname={pathname}
|
|
203
|
+
isMultilingual={config.settings.isMultilingual}
|
|
204
|
+
headerSearchBox={headerSearchBox}
|
|
205
|
+
inverted={isHomePageInverse ? true : false}
|
|
206
|
+
transparency={isHomePageInverse ? true : false}
|
|
207
|
+
logo={
|
|
208
|
+
<div {...(isSubsite ? { className: 'logo-wrapper' } : {})}>
|
|
209
|
+
{!!subsite && subsite.title ? (
|
|
210
|
+
<>
|
|
211
|
+
{subsite.subsite_logo ? (
|
|
212
|
+
<Logo
|
|
213
|
+
src={subsite.subsite_logo?.scales.preview.download}
|
|
214
|
+
title={subsite.title}
|
|
215
|
+
alt={subsite.title}
|
|
216
|
+
url={flattenToAppURL(subsite['@id'])}
|
|
217
|
+
/>
|
|
218
|
+
) : (
|
|
219
|
+
subsite.title
|
|
220
|
+
)}
|
|
221
|
+
<div className="subsite-logo">
|
|
222
|
+
<Logo
|
|
223
|
+
src={isHomePageInverse ? logoWhite : logo}
|
|
224
|
+
title={eea.websiteTitle}
|
|
225
|
+
alt={eea.organisationName}
|
|
226
|
+
url={eea.logoTargetUrl}
|
|
227
|
+
/>
|
|
228
|
+
</div>
|
|
229
|
+
</>
|
|
230
|
+
) : (
|
|
231
|
+
<Logo
|
|
232
|
+
src={isHomePageInverse ? logoWhite : logo}
|
|
233
|
+
title={eea.websiteTitle}
|
|
234
|
+
alt={eea.organisationName}
|
|
235
|
+
url={eea.logoTargetUrl}
|
|
236
|
+
/>
|
|
237
|
+
)}
|
|
238
|
+
</div>
|
|
239
|
+
}
|
|
240
|
+
menuItems={items}
|
|
241
|
+
renderGlobalMenuItem={(item, { onClick }) => (
|
|
242
|
+
<a
|
|
243
|
+
href={item.url || '/'}
|
|
244
|
+
title={item.title}
|
|
245
|
+
onClick={(e) => {
|
|
246
|
+
e.preventDefault();
|
|
247
|
+
onClick(e, item);
|
|
248
|
+
}}
|
|
249
|
+
>
|
|
250
|
+
{item.title}
|
|
251
|
+
</a>
|
|
252
|
+
)}
|
|
253
|
+
renderMenuItem={(item, options, props) => (
|
|
254
|
+
<UniversalLink
|
|
255
|
+
href={item.url || '/'}
|
|
256
|
+
title={item.nav_title || item.title}
|
|
257
|
+
{...(options || {})}
|
|
258
|
+
className={cx(options?.className, {
|
|
259
|
+
active: item.url === router_pathname,
|
|
260
|
+
})}
|
|
261
|
+
>
|
|
262
|
+
{props?.iconPosition !== 'right' && props?.children}
|
|
263
|
+
<span>{item.nav_title || item.title}</span>
|
|
264
|
+
{props?.iconPosition === 'right' && props?.children}
|
|
265
|
+
</UniversalLink>
|
|
266
|
+
)}
|
|
267
|
+
></Header.Main>
|
|
268
|
+
</Header>
|
|
269
|
+
);
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
export default compose(
|
|
273
|
+
withRouter,
|
|
274
|
+
connect(
|
|
275
|
+
(state) => ({
|
|
276
|
+
token: state.userSession.token,
|
|
277
|
+
items: state.navigation.items,
|
|
278
|
+
subsite: state.content.data?.['@components']?.subsite,
|
|
279
|
+
}),
|
|
280
|
+
{ getNavigation },
|
|
281
|
+
),
|
|
282
|
+
)(EEAHeader);
|
|
@@ -1,282 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
* Header component.
|
|
3
|
-
* @module components/theme/Header/Header
|
|
4
|
-
*/
|
|
1
|
+
import Header from '@eeacms/volto-cca-policy/components/theme/Header';
|
|
5
2
|
|
|
6
|
-
|
|
7
|
-
import { Dropdown, Image } from 'semantic-ui-react';
|
|
8
|
-
import { connect, useDispatch, useSelector } from 'react-redux';
|
|
9
|
-
|
|
10
|
-
import { withRouter } from 'react-router-dom';
|
|
11
|
-
import { UniversalLink } from '@plone/volto/components';
|
|
12
|
-
import {
|
|
13
|
-
getBaseUrl,
|
|
14
|
-
hasApiExpander,
|
|
15
|
-
flattenToAppURL,
|
|
16
|
-
} from '@plone/volto/helpers';
|
|
17
|
-
import { getNavigation } from '@plone/volto/actions';
|
|
18
|
-
import { Header, Logo } from '@eeacms/volto-eea-design-system/ui';
|
|
19
|
-
import { usePrevious } from '@eeacms/volto-eea-design-system/helpers';
|
|
20
|
-
import { find } from 'lodash';
|
|
21
|
-
import globeIcon from '@eeacms/volto-eea-design-system/../theme/themes/eea/assets/images/Header/global-line.svg';
|
|
22
|
-
import eeaFlag from '@eeacms/volto-eea-design-system/../theme/themes/eea/assets/images/Header/eea.png';
|
|
23
|
-
|
|
24
|
-
import config from '@plone/volto/registry';
|
|
25
|
-
import { compose } from 'recompose';
|
|
26
|
-
import { BodyClass } from '@plone/volto/helpers';
|
|
27
|
-
|
|
28
|
-
import cx from 'classnames';
|
|
29
|
-
|
|
30
|
-
function removeTrailingSlash(path) {
|
|
31
|
-
return path.replace(/\/+$/, '');
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* EEA Specific Header component.
|
|
36
|
-
*/
|
|
37
|
-
const EEAHeader = ({ pathname, token, items, history, subsite }) => {
|
|
38
|
-
const currentLang = useSelector((state) => state.intl.locale);
|
|
39
|
-
const translations = useSelector(
|
|
40
|
-
(state) => state.content.data?.['@components']?.translations?.items,
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
const router_pathname = useSelector((state) => {
|
|
44
|
-
return removeTrailingSlash(state.router?.location?.pathname) || '';
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const isSubsite = subsite?.['@type'] === 'Subsite';
|
|
48
|
-
|
|
49
|
-
const isHomePageInverse = useSelector((state) => {
|
|
50
|
-
const layout = state.content?.data?.layout;
|
|
51
|
-
const has_home_layout =
|
|
52
|
-
layout === 'homepage_inverse_view' ||
|
|
53
|
-
(__CLIENT__ && document.body.classList.contains('homepage-inverse'));
|
|
54
|
-
return (
|
|
55
|
-
has_home_layout &&
|
|
56
|
-
(removeTrailingSlash(pathname) === router_pathname ||
|
|
57
|
-
router_pathname.endsWith('/edit'))
|
|
58
|
-
);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const { eea } = config.settings;
|
|
62
|
-
const headerOpts = eea.headerOpts || {};
|
|
63
|
-
const headerSearchBox = eea.headerSearchBox || [];
|
|
64
|
-
const { logo, logoWhite } = headerOpts || {};
|
|
65
|
-
const width = useSelector((state) => state.screen?.width);
|
|
66
|
-
const dispatch = useDispatch();
|
|
67
|
-
const previousToken = usePrevious(token);
|
|
68
|
-
const [language, setLanguage] = React.useState(
|
|
69
|
-
currentLang || eea.defaultLanguage,
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
React.useEffect(() => {
|
|
73
|
-
const { settings } = config;
|
|
74
|
-
const base_url = getBaseUrl(pathname);
|
|
75
|
-
if (!hasApiExpander('navigation', base_url)) {
|
|
76
|
-
dispatch(getNavigation(base_url, settings.navDepth));
|
|
77
|
-
}
|
|
78
|
-
}, [pathname, dispatch]);
|
|
79
|
-
|
|
80
|
-
React.useEffect(() => {
|
|
81
|
-
if (token !== previousToken) {
|
|
82
|
-
const { settings } = config;
|
|
83
|
-
const base = getBaseUrl(pathname);
|
|
84
|
-
if (!hasApiExpander('navigation', base)) {
|
|
85
|
-
dispatch(getNavigation(base, settings.navDepth));
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}, [token, dispatch, pathname, previousToken]);
|
|
89
|
-
|
|
90
|
-
return (
|
|
91
|
-
<Header menuItems={items}>
|
|
92
|
-
{isHomePageInverse && <BodyClass className="homepage" />}
|
|
93
|
-
<Header.TopHeader>
|
|
94
|
-
<Header.TopItem className="official-union">
|
|
95
|
-
<Image src={eeaFlag} alt="eea flag"></Image>
|
|
96
|
-
<Header.TopDropdownMenu
|
|
97
|
-
text="An official website of the European Union | How do you know?"
|
|
98
|
-
tabletText="EEA information systems"
|
|
99
|
-
mobileText=" "
|
|
100
|
-
icon="chevron down"
|
|
101
|
-
aria-label="dropdown"
|
|
102
|
-
className=""
|
|
103
|
-
viewportWidth={width}
|
|
104
|
-
>
|
|
105
|
-
{/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}
|
|
106
|
-
<div
|
|
107
|
-
className="content"
|
|
108
|
-
onClick={(evt) => evt.stopPropagation()}
|
|
109
|
-
onKeyDown={(evt) => evt.stopPropagation()}
|
|
110
|
-
>
|
|
111
|
-
<p>
|
|
112
|
-
All official European Union website addresses are in the{' '}
|
|
113
|
-
<b>europa.eu</b> domain.
|
|
114
|
-
</p>
|
|
115
|
-
<a
|
|
116
|
-
href="https://europa.eu/european-union/contact/institutions-bodies_en"
|
|
117
|
-
target="_blank"
|
|
118
|
-
rel="noreferrer"
|
|
119
|
-
onKeyDown={(evt) => evt.stopPropagation()}
|
|
120
|
-
>
|
|
121
|
-
See all EU institutions and bodies
|
|
122
|
-
</a>
|
|
123
|
-
</div>
|
|
124
|
-
</Header.TopDropdownMenu>
|
|
125
|
-
</Header.TopItem>
|
|
126
|
-
|
|
127
|
-
{!!headerOpts.partnerLinks && (
|
|
128
|
-
<Header.TopItem>
|
|
129
|
-
<Header.TopDropdownMenu
|
|
130
|
-
id="theme-sites"
|
|
131
|
-
text={headerOpts.partnerLinks.title}
|
|
132
|
-
viewportWidth={width}
|
|
133
|
-
>
|
|
134
|
-
<div className="wrapper">
|
|
135
|
-
{headerOpts.partnerLinks.links.map((item, index) => (
|
|
136
|
-
<Dropdown.Item key={index}>
|
|
137
|
-
<a
|
|
138
|
-
href={item.href}
|
|
139
|
-
className="site"
|
|
140
|
-
target="_blank"
|
|
141
|
-
rel="noreferrer"
|
|
142
|
-
onKeyDown={(evt) => evt.stopPropagation()}
|
|
143
|
-
>
|
|
144
|
-
{item.title}
|
|
145
|
-
</a>
|
|
146
|
-
</Dropdown.Item>
|
|
147
|
-
))}
|
|
148
|
-
</div>
|
|
149
|
-
</Header.TopDropdownMenu>
|
|
150
|
-
</Header.TopItem>
|
|
151
|
-
)}
|
|
152
|
-
|
|
153
|
-
{config.settings.isMultilingual && (
|
|
154
|
-
<Header.TopDropdownMenu
|
|
155
|
-
id="language-switcher"
|
|
156
|
-
className="item"
|
|
157
|
-
hasLanguageDropdown={
|
|
158
|
-
config.settings.supportedLanguages.length > 1 &&
|
|
159
|
-
config.settings.hasLanguageDropdown
|
|
160
|
-
}
|
|
161
|
-
text={`${language.toUpperCase()}`}
|
|
162
|
-
mobileText={`${language.toUpperCase()}`}
|
|
163
|
-
icon={
|
|
164
|
-
<Image src={globeIcon} alt="language dropdown globe icon"></Image>
|
|
165
|
-
}
|
|
166
|
-
viewportWidth={width}
|
|
167
|
-
>
|
|
168
|
-
<ul
|
|
169
|
-
className="wrapper language-list"
|
|
170
|
-
role="listbox"
|
|
171
|
-
aria-label="language switcher"
|
|
172
|
-
>
|
|
173
|
-
{eea.languages.map((item, index) => (
|
|
174
|
-
<Dropdown.Item
|
|
175
|
-
as="li"
|
|
176
|
-
key={index}
|
|
177
|
-
text={
|
|
178
|
-
<span>
|
|
179
|
-
{item.name}
|
|
180
|
-
<span className="country-code">
|
|
181
|
-
{item.code.toUpperCase()}
|
|
182
|
-
</span>
|
|
183
|
-
</span>
|
|
184
|
-
}
|
|
185
|
-
onClick={() => {
|
|
186
|
-
const translation = find(translations, {
|
|
187
|
-
language: item.code,
|
|
188
|
-
});
|
|
189
|
-
const to = translation
|
|
190
|
-
? flattenToAppURL(translation['@id'])
|
|
191
|
-
: `/${item.code}`;
|
|
192
|
-
setLanguage(item.code);
|
|
193
|
-
history.push(to);
|
|
194
|
-
}}
|
|
195
|
-
></Dropdown.Item>
|
|
196
|
-
))}
|
|
197
|
-
</ul>
|
|
198
|
-
</Header.TopDropdownMenu>
|
|
199
|
-
)}
|
|
200
|
-
</Header.TopHeader>
|
|
201
|
-
<Header.Main
|
|
202
|
-
pathname={pathname}
|
|
203
|
-
isMultilingual={config.settings.isMultilingual}
|
|
204
|
-
headerSearchBox={headerSearchBox}
|
|
205
|
-
inverted={isHomePageInverse ? true : false}
|
|
206
|
-
transparency={isHomePageInverse ? true : false}
|
|
207
|
-
logo={
|
|
208
|
-
<div {...(isSubsite ? { className: 'logo-wrapper' } : {})}>
|
|
209
|
-
{!!subsite && subsite.title ? (
|
|
210
|
-
<>
|
|
211
|
-
{subsite.subsite_logo ? (
|
|
212
|
-
<Logo
|
|
213
|
-
src={subsite.subsite_logo?.scales.preview.download}
|
|
214
|
-
title={subsite.title}
|
|
215
|
-
alt={subsite.title}
|
|
216
|
-
url={flattenToAppURL(subsite['@id'])}
|
|
217
|
-
/>
|
|
218
|
-
) : (
|
|
219
|
-
subsite.title
|
|
220
|
-
)}
|
|
221
|
-
<div className="subsite-logo">
|
|
222
|
-
<Logo
|
|
223
|
-
src={isHomePageInverse ? logoWhite : logo}
|
|
224
|
-
title={eea.websiteTitle}
|
|
225
|
-
alt={eea.organisationName}
|
|
226
|
-
url={eea.logoTargetUrl}
|
|
227
|
-
/>
|
|
228
|
-
</div>
|
|
229
|
-
</>
|
|
230
|
-
) : (
|
|
231
|
-
<Logo
|
|
232
|
-
src={isHomePageInverse ? logoWhite : logo}
|
|
233
|
-
title={eea.websiteTitle}
|
|
234
|
-
alt={eea.organisationName}
|
|
235
|
-
url={eea.logoTargetUrl}
|
|
236
|
-
/>
|
|
237
|
-
)}
|
|
238
|
-
</div>
|
|
239
|
-
}
|
|
240
|
-
menuItems={items}
|
|
241
|
-
renderGlobalMenuItem={(item, { onClick }) => (
|
|
242
|
-
<a
|
|
243
|
-
href={item.url || '/'}
|
|
244
|
-
title={item.title}
|
|
245
|
-
onClick={(e) => {
|
|
246
|
-
e.preventDefault();
|
|
247
|
-
onClick(e, item);
|
|
248
|
-
}}
|
|
249
|
-
>
|
|
250
|
-
{item.title}
|
|
251
|
-
</a>
|
|
252
|
-
)}
|
|
253
|
-
renderMenuItem={(item, options, props) => (
|
|
254
|
-
<UniversalLink
|
|
255
|
-
href={item.url || '/'}
|
|
256
|
-
title={item.nav_title || item.title}
|
|
257
|
-
{...(options || {})}
|
|
258
|
-
className={cx(options?.className, {
|
|
259
|
-
active: item.url === router_pathname,
|
|
260
|
-
})}
|
|
261
|
-
>
|
|
262
|
-
{props?.iconPosition !== 'right' && props?.children}
|
|
263
|
-
<span>{item.nav_title || item.title}</span>
|
|
264
|
-
{props?.iconPosition === 'right' && props?.children}
|
|
265
|
-
</UniversalLink>
|
|
266
|
-
)}
|
|
267
|
-
></Header.Main>
|
|
268
|
-
</Header>
|
|
269
|
-
);
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
export default compose(
|
|
273
|
-
withRouter,
|
|
274
|
-
connect(
|
|
275
|
-
(state) => ({
|
|
276
|
-
token: state.userSession.token,
|
|
277
|
-
items: state.navigation.items,
|
|
278
|
-
subsite: state.content.data?.['@components']?.subsite,
|
|
279
|
-
}),
|
|
280
|
-
{ getNavigation },
|
|
281
|
-
),
|
|
282
|
-
)(EEAHeader);
|
|
3
|
+
export default Header;
|
package/src/index.js
CHANGED
|
@@ -26,6 +26,8 @@ import GeolocationWidget from './components/theme/Widgets/GeolocationWidget';
|
|
|
26
26
|
|
|
27
27
|
const getEnv = () => (typeof window !== 'undefined' ? window.env : process.env);
|
|
28
28
|
|
|
29
|
+
const restrictedBlocks = ['countryFlag'];
|
|
30
|
+
|
|
29
31
|
const applyConfig = (config) => {
|
|
30
32
|
const notInEnMission = /^(?!(\/en\/mission)).*$/;
|
|
31
33
|
const env = getEnv();
|
|
@@ -164,6 +166,13 @@ const applyConfig = (config) => {
|
|
|
164
166
|
config.blocks.blocksConfig.video.restricted = false;
|
|
165
167
|
}
|
|
166
168
|
|
|
169
|
+
// Disable blocks
|
|
170
|
+
restrictedBlocks.forEach((block) => {
|
|
171
|
+
if (config.blocks.blocksConfig[block]) {
|
|
172
|
+
config.blocks.blocksConfig[block].restricted = true;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
167
176
|
// Move blocks to Site group
|
|
168
177
|
const move_to_site = [
|
|
169
178
|
'countryFlag',
|
package/src/utils.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const blockAvailableInMission = (properties, block) => {
|
|
2
|
+
const missionBlocks = ['mkh_map', 'rastBlock'];
|
|
3
|
+
const isMission = properties['@id'].includes('/en/mission');
|
|
4
|
+
|
|
5
|
+
if (isMission) {
|
|
6
|
+
return missionBlocks.includes(block.id) ? false : true;
|
|
7
|
+
} else {
|
|
8
|
+
return missionBlocks.includes(block.id) ? true : false;
|
|
9
|
+
}
|
|
10
|
+
};
|