@eeacms/volto-cca-policy 0.1.35 → 0.1.37

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 CHANGED
@@ -4,6 +4,15 @@ 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.37](https://github.com/eea/volto-cca-policy/compare/0.1.36...0.1.37) - 11 August 2023
8
+
9
+ ### [0.1.36](https://github.com/eea/volto-cca-policy/compare/0.1.35...0.1.36) - 11 August 2023
10
+
11
+ #### :hammer_and_wrench: Others
12
+
13
+ - Move Header code from customizations [Tiberiu Ichim - [`7af45f3`](https://github.com/eea/volto-cca-policy/commit/7af45f36a279e5a0d857363e48b1ff34cb8bb951)]
14
+ - Restrict mission blocks on CCA [kreafox - [`d3ee731`](https://github.com/eea/volto-cca-policy/commit/d3ee7312c256b316362249f4ad8bf3fd0d1f2371)]
15
+ - Restrict blocks on mission [kreafox - [`ed28366`](https://github.com/eea/volto-cca-policy/commit/ed28366e879139b138b1bb3d6ba059a46614de1d)]
7
16
  ### [0.1.35](https://github.com/eea/volto-cca-policy/compare/0.1.34...0.1.35) - 7 August 2023
8
17
 
9
18
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.1.35",
3
+ "version": "0.1.37",
4
4
  "description": "@eeacms/volto-cca-policy: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -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
- variations: [],
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.rastBlock = {
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,310 @@
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
+ * Logo component class.
36
+ * @function Logo
37
+ * @param {Object} intl Intl object
38
+ * @returns {string} Markup of the component.
39
+ */
40
+ const DirectLinkLogo = ({
41
+ src,
42
+ invertedSrc,
43
+ id,
44
+ url,
45
+ alt,
46
+ title,
47
+ inverted,
48
+ }) => {
49
+ return (
50
+ <a href={url} title={title} className={'logo'}>
51
+ <Image
52
+ src={inverted ? invertedSrc : src}
53
+ alt={alt}
54
+ title={title}
55
+ className="eea-logo"
56
+ id={id}
57
+ />
58
+ </a>
59
+ );
60
+ };
61
+
62
+ /**
63
+ * EEA Specific Header component.
64
+ */
65
+ const EEAHeader = ({ pathname, token, items, history, subsite }) => {
66
+ const currentLang = useSelector((state) => state.intl.locale);
67
+ const translations = useSelector(
68
+ (state) => state.content.data?.['@components']?.translations?.items,
69
+ );
70
+
71
+ const router_pathname = useSelector((state) => {
72
+ return removeTrailingSlash(state.router?.location?.pathname) || '';
73
+ });
74
+
75
+ const isSubsite = subsite?.['@type'] === 'Subsite';
76
+
77
+ const isHomePageInverse = useSelector((state) => {
78
+ const layout = state.content?.data?.layout;
79
+ const has_home_layout =
80
+ layout === 'homepage_inverse_view' ||
81
+ (__CLIENT__ && document.body.classList.contains('homepage-inverse'));
82
+ return (
83
+ has_home_layout &&
84
+ (removeTrailingSlash(pathname) === router_pathname ||
85
+ router_pathname.endsWith('/edit'))
86
+ );
87
+ });
88
+
89
+ const { eea } = config.settings;
90
+ const headerOpts = eea.headerOpts || {};
91
+ const headerSearchBox = eea.headerSearchBox || [];
92
+ const { logo, logoWhite } = headerOpts || {};
93
+ const width = useSelector((state) => state.screen?.width);
94
+ const dispatch = useDispatch();
95
+ const previousToken = usePrevious(token);
96
+ const [language, setLanguage] = React.useState(
97
+ currentLang || eea.defaultLanguage,
98
+ );
99
+
100
+ React.useEffect(() => {
101
+ const { settings } = config;
102
+ const base_url = getBaseUrl(pathname);
103
+ if (!hasApiExpander('navigation', base_url)) {
104
+ dispatch(getNavigation(base_url, settings.navDepth));
105
+ }
106
+ }, [pathname, dispatch]);
107
+
108
+ React.useEffect(() => {
109
+ if (token !== previousToken) {
110
+ const { settings } = config;
111
+ const base = getBaseUrl(pathname);
112
+ if (!hasApiExpander('navigation', base)) {
113
+ dispatch(getNavigation(base, settings.navDepth));
114
+ }
115
+ }
116
+ }, [token, dispatch, pathname, previousToken]);
117
+
118
+ return (
119
+ <Header menuItems={items}>
120
+ {isHomePageInverse && <BodyClass className="homepage" />}
121
+ <Header.TopHeader>
122
+ <Header.TopItem className="official-union">
123
+ <Image src={eeaFlag} alt="eea flag"></Image>
124
+ <Header.TopDropdownMenu
125
+ text="An official website of the European Union | How do you know?"
126
+ tabletText="EEA information systems"
127
+ mobileText=" "
128
+ icon="chevron down"
129
+ aria-label="dropdown"
130
+ className=""
131
+ viewportWidth={width}
132
+ >
133
+ {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}
134
+ <div
135
+ className="content"
136
+ onClick={(evt) => evt.stopPropagation()}
137
+ onKeyDown={(evt) => evt.stopPropagation()}
138
+ >
139
+ <p>
140
+ All official European Union website addresses are in the{' '}
141
+ <b>europa.eu</b> domain.
142
+ </p>
143
+ <a
144
+ href="https://europa.eu/european-union/contact/institutions-bodies_en"
145
+ target="_blank"
146
+ rel="noreferrer"
147
+ onKeyDown={(evt) => evt.stopPropagation()}
148
+ >
149
+ See all EU institutions and bodies
150
+ </a>
151
+ </div>
152
+ </Header.TopDropdownMenu>
153
+ </Header.TopItem>
154
+
155
+ {!!headerOpts.partnerLinks && (
156
+ <Header.TopItem>
157
+ <Header.TopDropdownMenu
158
+ id="theme-sites"
159
+ text={headerOpts.partnerLinks.title}
160
+ viewportWidth={width}
161
+ >
162
+ <div className="wrapper">
163
+ {headerOpts.partnerLinks.links.map((item, index) => (
164
+ <Dropdown.Item key={index}>
165
+ <a
166
+ href={item.href}
167
+ className="site"
168
+ target="_blank"
169
+ rel="noreferrer"
170
+ onKeyDown={(evt) => evt.stopPropagation()}
171
+ >
172
+ {item.title}
173
+ </a>
174
+ </Dropdown.Item>
175
+ ))}
176
+ </div>
177
+ </Header.TopDropdownMenu>
178
+ </Header.TopItem>
179
+ )}
180
+
181
+ {config.settings.isMultilingual && (
182
+ <Header.TopDropdownMenu
183
+ id="language-switcher"
184
+ className="item"
185
+ hasLanguageDropdown={
186
+ config.settings.supportedLanguages.length > 1 &&
187
+ config.settings.hasLanguageDropdown
188
+ }
189
+ text={`${language.toUpperCase()}`}
190
+ mobileText={`${language.toUpperCase()}`}
191
+ icon={
192
+ <Image src={globeIcon} alt="language dropdown globe icon"></Image>
193
+ }
194
+ viewportWidth={width}
195
+ >
196
+ <ul
197
+ className="wrapper language-list"
198
+ role="listbox"
199
+ aria-label="language switcher"
200
+ >
201
+ {eea.languages.map((item, index) => (
202
+ <Dropdown.Item
203
+ as="li"
204
+ key={index}
205
+ text={
206
+ <span>
207
+ {item.name}
208
+ <span className="country-code">
209
+ {item.code.toUpperCase()}
210
+ </span>
211
+ </span>
212
+ }
213
+ onClick={() => {
214
+ const translation = find(translations, {
215
+ language: item.code,
216
+ });
217
+ const to = translation
218
+ ? flattenToAppURL(translation['@id'])
219
+ : `/${item.code}`;
220
+ setLanguage(item.code);
221
+ history.push(to);
222
+ }}
223
+ ></Dropdown.Item>
224
+ ))}
225
+ </ul>
226
+ </Header.TopDropdownMenu>
227
+ )}
228
+ </Header.TopHeader>
229
+ <Header.Main
230
+ pathname={pathname}
231
+ isMultilingual={config.settings.isMultilingual}
232
+ headerSearchBox={headerSearchBox}
233
+ inverted={isHomePageInverse ? true : false}
234
+ transparency={isHomePageInverse ? true : false}
235
+ logo={
236
+ <div {...(isSubsite ? { className: 'logo-wrapper' } : {})}>
237
+ {!!subsite && subsite.title ? (
238
+ <>
239
+ {subsite.subsite_logo ? (
240
+ <Logo
241
+ src={subsite.subsite_logo?.scales.preview.download}
242
+ title={subsite.title}
243
+ alt={subsite.title}
244
+ url={flattenToAppURL(subsite['@id'])}
245
+ />
246
+ ) : (
247
+ subsite.title
248
+ )}
249
+ <div className="subsite-logo">
250
+ <DirectLinkLogo
251
+ src={isHomePageInverse ? logoWhite : logo}
252
+ title={eea.websiteTitle}
253
+ alt={eea.organisationName}
254
+ url={eea.logoTargetUrl}
255
+ />
256
+ </div>
257
+ </>
258
+ ) : (
259
+ <Logo
260
+ src={isHomePageInverse ? logoWhite : logo}
261
+ title={eea.websiteTitle}
262
+ alt={eea.organisationName}
263
+ url={eea.logoTargetUrl}
264
+ />
265
+ )}
266
+ </div>
267
+ }
268
+ menuItems={items}
269
+ renderGlobalMenuItem={(item, { onClick }) => (
270
+ <a
271
+ href={item.url || '/'}
272
+ title={item.title}
273
+ onClick={(e) => {
274
+ e.preventDefault();
275
+ onClick(e, item);
276
+ }}
277
+ >
278
+ {item.title}
279
+ </a>
280
+ )}
281
+ renderMenuItem={(item, options, props) => (
282
+ <UniversalLink
283
+ href={item.url || '/'}
284
+ title={item.nav_title || item.title}
285
+ {...(options || {})}
286
+ className={cx(options?.className, {
287
+ active: item.url === router_pathname,
288
+ })}
289
+ >
290
+ {props?.iconPosition !== 'right' && props?.children}
291
+ <span>{item.nav_title || item.title}</span>
292
+ {props?.iconPosition === 'right' && props?.children}
293
+ </UniversalLink>
294
+ )}
295
+ ></Header.Main>
296
+ </Header>
297
+ );
298
+ };
299
+
300
+ export default compose(
301
+ withRouter,
302
+ connect(
303
+ (state) => ({
304
+ token: state.userSession.token,
305
+ items: state.navigation.items,
306
+ subsite: state.content.data?.['@components']?.subsite,
307
+ }),
308
+ { getNavigation },
309
+ ),
310
+ )(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
- 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);
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
+ };