@eeacms/volto-clms-theme 1.0.84 → 1.0.87

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,8 +4,37 @@ 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
+ #### [1.0.87](https://github.com/eea/volto-clms-theme/compare/1.0.86...1.0.87)
8
+
9
+ - images condition for lightGallery rendering [`728b2b3`](https://github.com/eea/volto-clms-theme/commit/728b2b32a1470d61a2eabf7d51ef59ea2b9adc33)
10
+
11
+ #### [1.0.86](https://github.com/eea/volto-clms-theme/compare/1.0.85...1.0.86)
12
+
13
+ > 23 March 2022
14
+
15
+ - Develop [`#243`](https://github.com/eea/volto-clms-theme/pull/243)
16
+ - News item view and blocks [`#242`](https://github.com/eea/volto-clms-theme/pull/242)
17
+ - NewsItem with blocks [`5320bd3`](https://github.com/eea/volto-clms-theme/commit/5320bd3073f7528d511d49b41755a5ebea05ba20)
18
+ - if a news item has blocks render them [`5795bd4`](https://github.com/eea/volto-clms-theme/commit/5795bd47a8215a575142bfe5a42713f2ed2b540b)
19
+
20
+ #### [1.0.85](https://github.com/eea/volto-clms-theme/compare/1.0.84...1.0.85)
21
+
22
+ > 22 March 2022
23
+
24
+ - Upgrade to Volto 15.2.1 [`#241`](https://github.com/eea/volto-clms-theme/pull/241)
25
+ - Volto 15 upgrade [`#240`](https://github.com/eea/volto-clms-theme/pull/240)
26
+ - jest config [`5e0723b`](https://github.com/eea/volto-clms-theme/commit/5e0723b1c1006609811a84d6fb9a3b6744c8d1be)
27
+ - sort downloads [`50cdd33`](https://github.com/eea/volto-clms-theme/commit/50cdd332f992e45a8745483bddaf25e01ecd5db5)
28
+ - condition valid Start date [`dce8883`](https://github.com/eea/volto-clms-theme/commit/dce8883f386676c682af2b5a68f7451d3ccd49dd)
29
+ - search block new features [`8e814cb`](https://github.com/eea/volto-clms-theme/commit/8e814cbd359782540c21fe37b37ef146d331f0d6)
30
+ - language selector cookie management [`1385ac9`](https://github.com/eea/volto-clms-theme/commit/1385ac95795702206d3623ba6e780faa43a89e0a)
31
+ - toolbar cookie management [`5c23200`](https://github.com/eea/volto-clms-theme/commit/5c23200790b20e1d4f1bc966463c37bf4c808f47)
32
+
7
33
  #### [1.0.84](https://github.com/eea/volto-clms-theme/compare/1.0.83...1.0.84)
8
34
 
35
+ > 18 March 2022
36
+
37
+ - Develop [`#239`](https://github.com/eea/volto-clms-theme/pull/239)
9
38
  - lightgallery style imports [`7b6c1a9`](https://github.com/eea/volto-clms-theme/commit/7b6c1a9d2b269a74d7c0ec699b078f41035c7e23)
10
39
  - lightGallery added for meeting view [`4047d5c`](https://github.com/eea/volto-clms-theme/commit/4047d5c18ce4c64b03fbcc3db761b3c0f4cd26d3)
11
40
 
package/Jenkinsfile CHANGED
@@ -4,9 +4,9 @@ pipeline {
4
4
  environment {
5
5
  GIT_NAME = "volto-clms-theme"
6
6
  NAMESPACE = "@eeacms"
7
- SONARQUBE_TAGS = "clms.land.copernicus.eu,volto.eea.europa.eu"
7
+ SONARQUBE_TAGS = "clms.land.copernicus.eu,volto.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu"
8
8
  DEPENDENCIES = ""
9
- VOLTO = "14.10.0"
9
+ VOLTO = "15.2.1"
10
10
  }
11
11
 
12
12
  stages {
@@ -1,5 +1,5 @@
1
1
  module.exports = {
2
- testMatch: ['**/src/addons/**/?(*.)+(spec|test).[jt]s?(x)'],
2
+ testMatch: ['**/src/addons/**/?(*.)+(spec|test).[jt]s(x)?'],
3
3
  collectCoverageFrom: [
4
4
  'src/addons/**/src/**/*.{js,jsx,ts,tsx}',
5
5
  '!src/**/*.d.ts',
@@ -15,6 +15,7 @@ module.exports = {
15
15
  '@eeacms/(.*?)/(.*)$': '<rootDir>/src/addons/$1/src/$2',
16
16
  'volto-clms-theme/(.*)$': '<rootDir>/src/addons/volto-clms-theme/src/$1',
17
17
  '~/(.*)$': '<rootDir>/src/$1',
18
+ '@root/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
18
19
  'load-volto-addons':
19
20
  '<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
20
21
  },
@@ -38,4 +39,7 @@ module.exports = {
38
39
  statements: 5,
39
40
  },
40
41
  },
42
+ roots: ['<rootDir>'],
43
+ modulePaths: ['<rootDir>'],
44
+ moduleDirectories: ['node_modules'],
41
45
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-clms-theme",
3
- "version": "1.0.84",
3
+ "version": "1.0.87",
4
4
  "description": "volto-clms-theme: Volto theme for CLMS site",
5
5
  "main": "src/index.js",
6
6
  "author": "CodeSyntax for the European Environment Agency",
@@ -1,5 +1,10 @@
1
1
  import { Checkbox } from 'semantic-ui-react';
2
2
  import React from 'react';
3
+ import {
4
+ selectFacetSchemaEnhancer,
5
+ selectFacetStateToValue,
6
+ selectFacetValueToQuery,
7
+ } from '@plone/volto/components/manage/Blocks/Search/components/base';
3
8
 
4
9
  const AccordionFacet = (props) => {
5
10
  const {
@@ -79,4 +84,7 @@ const AccordionFacet = (props) => {
79
84
  );
80
85
  };
81
86
 
87
+ AccordionFacet.schemaEnhancer = selectFacetSchemaEnhancer;
88
+ AccordionFacet.stateToValue = selectFacetStateToValue;
89
+ AccordionFacet.valueToQuery = selectFacetValueToQuery;
82
90
  export default AccordionFacet;
@@ -5,6 +5,12 @@ import React, { useState } from 'react';
5
5
  import { Checkbox, List } from 'semantic-ui-react';
6
6
  import { structure_taxonomy_terms } from '@eeacms/volto-clms-theme/components';
7
7
 
8
+ import {
9
+ selectFacetSchemaEnhancer,
10
+ selectFacetStateToValue,
11
+ selectFacetValueToQuery,
12
+ } from '@plone/volto/components/manage/Blocks/Search/components/base';
13
+
8
14
  const CheckboxTreeFacet = (props) => {
9
15
  const { facet, choices, onChange, value } = props;
10
16
  const facetValue = value;
@@ -120,4 +126,7 @@ const CheckboxListParent = ({ option, key, onChange, value, id }) => {
120
126
  );
121
127
  };
122
128
 
129
+ CheckboxTreeFacet.schemaEnhancer = selectFacetSchemaEnhancer;
130
+ CheckboxTreeFacet.stateToValue = selectFacetStateToValue;
131
+ CheckboxTreeFacet.valueToQuery = selectFacetValueToQuery;
123
132
  export default CheckboxTreeFacet;
@@ -5,6 +5,11 @@ import React, { useState } from 'react';
5
5
 
6
6
  import InputRange from 'react-input-range';
7
7
  import { Segment } from 'semantic-ui-react';
8
+ import {
9
+ selectFacetSchemaEnhancer,
10
+ selectFacetStateToValue,
11
+ selectFacetValueToQuery,
12
+ } from '@plone/volto/components/manage/Blocks/Search/components/base';
8
13
 
9
14
  const DoubleRangeFacet = (props) => {
10
15
  const { facet, choices, onChange, value } = props;
@@ -73,4 +78,7 @@ const DoubleRangeFacet = (props) => {
73
78
  );
74
79
  };
75
80
 
81
+ DoubleRangeFacet.schemaEnhancer = selectFacetSchemaEnhancer;
82
+ DoubleRangeFacet.stateToValue = selectFacetStateToValue;
83
+ DoubleRangeFacet.valueToQuery = selectFacetValueToQuery;
76
84
  export default DoubleRangeFacet;
@@ -6,6 +6,7 @@ import {
6
6
  CheckboxTreeFacet,
7
7
  rewriteOptions,
8
8
  } from '@eeacms/volto-clms-theme/components/Blocks/CustomTemplates/VoltoSearchBlock';
9
+ import { SelectFacetFilterListEntry } from '@plone/volto/components/manage/Blocks/Search/components';
9
10
  import {
10
11
  CclCarouselView,
11
12
  CclProductTabsView,
@@ -305,24 +306,40 @@ const customBlocks = (config) => ({
305
306
  title: 'Accordion Checkbox',
306
307
  view: WithType(AccordionFacet, 'checkbox'),
307
308
  isDefault: true,
309
+ schemaEnhancer: AccordionFacet.schemaEnhancer,
310
+ stateToValue: AccordionFacet.stateToValue,
311
+ valueToQuery: AccordionFacet.valueToQuery,
312
+ filterListComponent: SelectFacetFilterListEntry,
308
313
  },
309
314
  {
310
315
  id: 'accordionLabelFacet',
311
316
  title: 'Accordion Label',
312
317
  view: WithType(AccordionFacet, 'label'),
313
318
  isDefault: false,
319
+ schemaEnhancer: AccordionFacet.schemaEnhancer,
320
+ stateToValue: AccordionFacet.stateToValue,
321
+ valueToQuery: AccordionFacet.valueToQuery,
322
+ filterListComponent: SelectFacetFilterListEntry,
314
323
  },
315
324
  {
316
325
  id: 'doubleRangeFacet',
317
326
  title: 'Double Range',
318
327
  view: DoubleRangeFacet,
319
328
  isDefault: false,
329
+ schemaEnhancer: DoubleRangeFacet.schemaEnhancer,
330
+ stateToValue: DoubleRangeFacet.stateToValue,
331
+ valueToQuery: DoubleRangeFacet.valueToQuery,
332
+ filterListComponent: SelectFacetFilterListEntry,
320
333
  },
321
334
  {
322
335
  id: 'checkboxTreeFacet',
323
336
  title: 'Checkbox Tree',
324
337
  view: CheckboxTreeFacet,
325
338
  isDefault: false,
339
+ schemaEnhancer: CheckboxTreeFacet.schemaEnhancer,
340
+ stateToValue: CheckboxTreeFacet.stateToValue,
341
+ valueToQuery: CheckboxTreeFacet.valueToQuery,
342
+ filterListComponent: SelectFacetFilterListEntry,
326
343
  },
327
344
 
328
345
  ...config.blocks.blocksConfig.search.extensions.facetWidgets.types,
@@ -67,15 +67,23 @@ const CLMSDownloadTasks = (props) => {
67
67
  return (
68
68
  <Grid columns={2}>
69
69
  {tasks?.length > 0 &&
70
- tasks.map((item, key) => (
71
- <Grid.Column key={key}>
72
- <FileCard
73
- item={item}
74
- showDeleteTaskLoading={showDel}
75
- deleteTaskInProgress={delTask}
76
- />
77
- </Grid.Column>
78
- ))}
70
+ tasks
71
+ .map((item) => {
72
+ if (!item.RegistrationDateTime) {
73
+ item.RegistrationDateTime = '1970-01-01T00:00:00.000Z';
74
+ }
75
+ return item;
76
+ })
77
+ .sort(dynamicSort('-RegistrationDateTime'))
78
+ .map((item, key) => (
79
+ <Grid.Column key={key}>
80
+ <FileCard
81
+ item={item}
82
+ showDeleteTaskLoading={showDel}
83
+ deleteTaskInProgress={delTask}
84
+ />
85
+ </Grid.Column>
86
+ ))}
79
87
  </Grid>
80
88
  );
81
89
  };
@@ -108,6 +116,22 @@ const CLMSDownloadTasks = (props) => {
108
116
  setter(intermediate);
109
117
  }
110
118
 
119
+ const dynamicSort = (property) => {
120
+ var sortOrder = 1;
121
+ if (property[0] === '-') {
122
+ sortOrder = -1;
123
+ property = property.substr(1);
124
+ }
125
+ return function (a, b) {
126
+ /* next line works with strings and numbers,
127
+ * and you may want to customize it to your needs
128
+ */
129
+ var result =
130
+ a[property] < b[property] ? -1 : a[property] > b[property] ? 1 : 0;
131
+ return result * sortOrder;
132
+ };
133
+ };
134
+
111
135
  const deleteTaskInProgress = (task_id) => {
112
136
  setShowDeleteTaskLoading(task_id);
113
137
  dispatch(deleteDownloadtool(task_id));
@@ -220,7 +244,7 @@ const CLMSDownloadTasks = (props) => {
220
244
  <h2>
221
245
  <FormattedMessage id="Cancelled" defaultMessage="Cancelled" />
222
246
  </h2>
223
- {cancelled?.length !== 0 ? (
247
+ {cancelled?.length > 0 ? (
224
248
  <MapTasks tasks={cancelled} showDel={showDeleteTaskLoading} />
225
249
  ) : (
226
250
  <p>
@@ -125,18 +125,25 @@ const FileCard = (props) => {
125
125
  >
126
126
  <Header as="h3">{`Task ID: ${item?.TaskID}`}</Header>
127
127
  <Segment basic className="file-datetimes">
128
- Start date:{' '}
129
- {new Date(item?.RegistrationDateTime).toLocaleString('en-GB', {
130
- timeZone: 'UTC',
131
- })}{' '}
132
- <span
133
- className="info-icon"
134
- tooltip="Dates and times are in UTC"
135
- direction="up"
136
- >
137
- <FontAwesomeIcon icon={faInfoCircle} />
138
- </span>
139
- <br />
128
+ {item?.RegistrationDateTime && (
129
+ <>
130
+ Start date:
131
+ {new Date(item?.RegistrationDateTime).toLocaleString(
132
+ 'en-GB',
133
+ {
134
+ timeZone: 'UTC',
135
+ },
136
+ )}
137
+ <span
138
+ className="info-icon"
139
+ tooltip="Dates and times are in UTC"
140
+ direction="up"
141
+ >
142
+ <FontAwesomeIcon icon={faInfoCircle} />
143
+ </span>
144
+ <br />
145
+ </>
146
+ )}
140
147
  {item?.FinalizationDateTime && (
141
148
  <>
142
149
  End date:{' '}
@@ -4,8 +4,9 @@ import LightGallery from 'lightgallery/react';
4
4
  import lgZoom from 'lightgallery/plugins/zoom';
5
5
  import 'lightgallery/css/lightgallery.css';
6
6
  import 'lightgallery/css/lg-zoom.css';
7
- import { Image } from 'semantic-ui-react';
8
7
  import './styles.less';
8
+
9
+ import { Image } from 'semantic-ui-react';
9
10
  import { flattenToAppURL } from '@plone/volto/helpers';
10
11
  import { useDispatch, useSelector } from 'react-redux';
11
12
  import { searchContent } from '@plone/volto/actions';
@@ -23,7 +24,6 @@ export const LightGalleryListing = () => {
23
24
  {
24
25
  'path.depth': 1,
25
26
  portal_type: 'Image',
26
- fullobjects: true,
27
27
  },
28
28
  'images',
29
29
  ),
@@ -32,27 +32,32 @@ export const LightGalleryListing = () => {
32
32
  dispatch(searchContent([]));
33
33
  };
34
34
  }, [dispatch]);
35
-
36
35
  return (
37
36
  <>
38
37
  <div>
39
- <LightGallery plugins={[lgZoom]} mode="lg-fade">
40
- {images?.map((item, index) => (
41
- <a
42
- key={index}
43
- className="gallery-item"
44
- href={flattenToAppURL(item?.image?.download)}
45
- data-sub-html={item.description}
46
- data-src={flattenToAppURL(item?.image?.scales?.huge?.download)}
47
- >
48
- <Image
49
- src={flattenToAppURL(item?.image?.scales?.large?.download)}
50
- className="img-responsive"
51
- alt={item.description}
52
- />
53
- </a>
54
- ))}
55
- </LightGallery>
38
+ {images?.length > 0 && (
39
+ <LightGallery plugins={[lgZoom]} mode="lg-fade">
40
+ {images?.map((item, index) => (
41
+ <a
42
+ key={index}
43
+ className="gallery-item"
44
+ href={flattenToAppURL(
45
+ `${item['@id']}/@@images/${item?.image_field}/huge`,
46
+ )}
47
+ data-sub-html={item?.description}
48
+ data-src={flattenToAppURL(
49
+ `${item['@id']}/@@images/${item?.image_field}/huge`,
50
+ )}
51
+ >
52
+ <Image
53
+ src={`${item['@id']}/@@images/${item?.image_field}/large`}
54
+ className="img-responsive"
55
+ alt={item?.description}
56
+ />
57
+ </a>
58
+ ))}
59
+ </LightGallery>
60
+ )}
56
61
  </div>
57
62
  </>
58
63
  );
@@ -1,32 +1,42 @@
1
1
  import React from 'react';
2
2
  import { StringToHTML } from '@eeacms/volto-clms-theme/components/CclUtils';
3
+ import { hasBlocksData } from '@plone/volto/helpers';
4
+ import RenderBlocks from '@plone/volto/components/theme/View/RenderBlocks';
3
5
 
4
6
  const CLMSNewsItemView = (props) => {
5
7
  const { content } = props;
6
8
  return (
7
9
  <div className="ccl-container">
8
- <h1 className="page-title">{content.title}</h1>
9
- <div className="news-detail">
10
- <div className="news-detail-date">
11
- {new Date(content?.effective).toLocaleString()}
12
- </div>
13
- {content?.image && (
14
- <figure className="news-detail-image">
15
- <img
16
- src={
17
- content?.image
18
- ? content?.image?.download
19
- : 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg'
20
- }
21
- alt={content?.image ? content?.image?.filename : 'Placeholder'}
22
- />
23
- <figcaption>{content?.image_caption}</figcaption>
24
- </figure>
25
- )}
26
- <div className="news-detail-content">
27
- <StringToHTML string={content.text?.data || ''} />
28
- </div>
29
- </div>
10
+ {hasBlocksData(content) && content.blocks_layout?.items?.length > 1 ? (
11
+ <RenderBlocks {...props} />
12
+ ) : (
13
+ <>
14
+ <h1 className="page-title">{content.title}</h1>
15
+ <div className="news-detail">
16
+ <div className="news-detail-date">
17
+ {new Date(content?.effective).toLocaleDateString()}
18
+ </div>
19
+ {content?.image && (
20
+ <figure className="news-detail-image">
21
+ <img
22
+ src={
23
+ content?.image
24
+ ? content?.image?.download
25
+ : 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg'
26
+ }
27
+ alt={
28
+ content?.image ? content?.image?.filename : 'Placeholder'
29
+ }
30
+ />
31
+ <figcaption>{content?.image_caption}</figcaption>
32
+ </figure>
33
+ )}
34
+ <div className="news-detail-content">
35
+ <StringToHTML string={content.text?.data || ''} />
36
+ </div>
37
+ </div>
38
+ </>
39
+ )}
30
40
  </div>
31
41
  );
32
42
  };
@@ -4,21 +4,26 @@
4
4
  */
5
5
 
6
6
  import { Helmet, flattenToAppURL, langmap } from '@plone/volto/helpers';
7
- import { useDispatch, useSelector } from 'react-redux';
7
+ import { useSelector } from 'react-redux';
8
8
 
9
9
  import CclModal from '@eeacms/volto-clms-theme/components/CclModal/CclModal';
10
- import { FormattedMessage } from 'react-intl';
10
+ import { defineMessages, useIntl, FormattedMessage } from 'react-intl';
11
11
  import { Link } from 'react-router-dom';
12
12
  import PropTypes from 'prop-types';
13
13
  import React from 'react';
14
14
  import config from '@plone/volto/registry';
15
- import cookie from 'react-cookie';
16
15
  import cx from 'classnames';
17
16
  import { find } from 'lodash';
18
- import { updateIntl } from 'react-intl-redux';
19
17
 
20
18
  let locales = {};
21
19
 
20
+ const messages = defineMessages({
21
+ switchLanguageTo: {
22
+ id: 'Switch to',
23
+ defaultMessage: 'Switch to',
24
+ },
25
+ });
26
+
22
27
  if (config.settings) {
23
28
  config.settings.supportedLanguages.forEach((lang) => {
24
29
  import('~/../locales/' + lang + '.json').then((locale) => {
@@ -31,12 +36,9 @@ function Capitalize(str) {
31
36
  return str.charAt(0).toUpperCase() + str.slice(1);
32
37
  }
33
38
 
34
- const ModalContent = ({
35
- translations,
36
- currentLang,
37
- onClickAction,
38
- changeLanguage,
39
- }) => {
39
+ const ModalContent = (props) => {
40
+ const intl = useIntl();
41
+ const { translations, currentLang, onClickAction } = props;
40
42
  return (
41
43
  <div className="ccl-container">
42
44
  <div className="modal-language-header">
@@ -64,6 +66,9 @@ const ModalContent = ({
64
66
  <span className="language-link" lang-code={lang}>
65
67
  {lang !== currentLang ? (
66
68
  <Link
69
+ aria-label={`${intl.formatMessage(
70
+ messages.switchLanguageTo,
71
+ )} ${langmap[lang].nativeName.toLowerCase()}`}
67
72
  to={
68
73
  translation
69
74
  ? flattenToAppURL(translation['@id'])
@@ -72,7 +77,6 @@ const ModalContent = ({
72
77
  title={langmap[lang].nativeName}
73
78
  onClick={() => {
74
79
  onClickAction();
75
- changeLanguage(lang);
76
80
  }}
77
81
  key={`language-selector-${lang}`}
78
82
  >
@@ -92,26 +96,11 @@ const ModalContent = ({
92
96
  };
93
97
 
94
98
  function CclLanguageSelector(props) {
95
- const dispatch = useDispatch();
96
99
  const currentLang = useSelector((state) => state.intl.locale);
97
100
  const translations = useSelector(
98
101
  (state) => state.content.data?.['@components']?.translations?.items,
99
102
  );
100
103
 
101
- function changeLanguage(language) {
102
- cookie.save('I18N_LANGUAGE', language, {
103
- expires: new Date((2 ** 31 - 1) * 1000),
104
- path: '/',
105
- });
106
-
107
- dispatch(
108
- updateIntl({
109
- locale: language,
110
- messages: locales[language],
111
- }),
112
- );
113
- }
114
-
115
104
  return config.settings.isMultilingual ? (
116
105
  <div className="ccl-header-lang">
117
106
  <CclModal
@@ -129,7 +118,6 @@ function CclLanguageSelector(props) {
129
118
  translations={translations}
130
119
  currentLang={currentLang}
131
120
  onClickAction={props.onClickAction}
132
- changeLanguage={changeLanguage}
133
121
  />
134
122
  </CclModal>
135
123
 
@@ -142,7 +130,6 @@ function CclLanguageSelector(props) {
142
130
  translations={translations}
143
131
  currentLang={currentLang}
144
132
  onClickAction={props.onClickAction}
145
- changeLanguage={changeLanguage}
146
133
  />
147
134
  </CclModal>
148
135
  </div>
@@ -3,41 +3,44 @@
3
3
  * @module components/manage/Toolbar/Toolbar
4
4
  */
5
5
 
6
- import { BodyClass, getBaseUrl } from '@plone/volto/helpers';
7
6
  import React, { Component } from 'react';
8
7
  import { defineMessages, injectIntl } from 'react-intl';
8
+ import PropTypes from 'prop-types';
9
+ import { Link } from 'react-router-dom';
10
+ import jwtDecode from 'jwt-decode';
11
+ import { connect } from 'react-redux';
12
+ import { compose } from 'redux';
13
+ import { doesNodeContainClick } from 'semantic-ui-react/dist/commonjs/lib';
14
+ import { withCookies } from 'react-cookie';
9
15
  import { filter, find } from 'lodash';
16
+ import cx from 'classnames';
17
+ import config from '@plone/volto/registry';
18
+
19
+ import More from '@plone/volto/components/manage/Toolbar/More';
20
+ import PersonalTools from '@plone/volto/components/manage/Toolbar/PersonalTools';
21
+ import Types from '@plone/volto/components/manage/Toolbar/Types';
22
+ import PersonalInformation from '@plone/volto/components/manage/Preferences/PersonalInformation';
23
+ import PersonalPreferences from '@plone/volto/components/manage/Preferences/PersonalPreferences';
24
+ import StandardWrapper from '@plone/volto/components/manage/Toolbar/StandardWrapper';
10
25
  import {
11
26
  getTypes,
12
27
  listActions,
13
28
  setExpandedToolbar,
14
29
  unlockContent,
15
30
  } from '@plone/volto/actions';
16
-
17
31
  import { Icon } from '@plone/volto/components';
18
- import { Link } from 'react-router-dom';
19
- import More from '@plone/volto/components/manage/Toolbar/More';
20
- import PersonalInformation from '@plone/volto/components/manage/Preferences/PersonalInformation';
21
- import PersonalPreferences from '@plone/volto/components/manage/Preferences/PersonalPreferences';
22
- import PersonalTools from '@plone/volto/components/manage/Toolbar/PersonalTools';
32
+ import { BodyClass, getBaseUrl } from '@plone/volto/helpers';
23
33
  import { Pluggable } from '@plone/volto/components/manage/Pluggable';
24
- import PropTypes from 'prop-types';
25
- import StandardWrapper from '@plone/volto/components/manage/Toolbar/StandardWrapper';
26
- import Types from '@plone/volto/components/manage/Toolbar/Types';
27
- import addSVG from '@plone/volto/icons/add-document.svg';
28
- import clearSVG from '@plone/volto/icons/clear.svg';
29
- import { compose } from 'redux';
30
- import config from '@plone/volto/registry';
31
- import { connect } from 'react-redux';
32
- import cookie from 'react-cookie';
33
- import cx from 'classnames';
34
- import { doesNodeContainClick } from 'semantic-ui-react/dist/commonjs/lib';
35
- import folderSVG from '@plone/volto/icons/folder.svg';
36
- import jwtDecode from 'jwt-decode';
37
- import moreSVG from '@plone/volto/icons/more.svg';
34
+
38
35
  import penSVG from '@plone/volto/icons/pen.svg';
39
36
  import unlockSVG from '@plone/volto/icons/unlock.svg';
37
+ import folderSVG from '@plone/volto/icons/folder.svg';
38
+ import addSVG from '@plone/volto/icons/add-document.svg';
39
+ import moreSVG from '@plone/volto/icons/more.svg';
40
40
  import userSVG from '@plone/volto/icons/user.svg';
41
+ import clearSVG from '@plone/volto/icons/clear.svg';
42
+
43
+ // import cookie from 'react-cookie';
41
44
 
42
45
  const messages = defineMessages({
43
46
  edit: {
@@ -174,17 +177,21 @@ class Toolbar extends Component {
174
177
  types: [],
175
178
  };
176
179
 
177
- state = {
178
- expanded: cookie.load('toolbar_expanded') !== 'false',
179
- showMenu: false,
180
- menuStyle: {},
181
- menuComponents: [],
182
- loadedComponents: [],
183
- hideToolbarBody: false,
184
- };
185
-
186
180
  toolbarWindow = React.createRef();
187
181
 
182
+ constructor(props) {
183
+ super(props);
184
+ const { cookies } = props;
185
+ this.state = {
186
+ expanded: cookies.get('toolbar_expanded') !== 'false',
187
+ showMenu: false,
188
+ menuStyle: {},
189
+ menuComponents: [],
190
+ loadedComponents: [],
191
+ hideToolbarBody: false,
192
+ };
193
+ }
194
+
188
195
  /**
189
196
  * Component will mount
190
197
  * @method componentDidMount
@@ -225,8 +232,11 @@ class Toolbar extends Component {
225
232
  }
226
233
 
227
234
  handleShrink = () => {
228
- cookie.save('toolbar_expanded', !this.state.expanded, {
229
- expires: new Date((2 ** 31 - 1) * 1000),
235
+ const { cookies } = this.props;
236
+ cookies.set('toolbar_expanded', !this.state.expanded, {
237
+ expires: new Date(
238
+ new Date().getTime() + config.settings.cookieExpires * 1000,
239
+ ),
230
240
  path: '/',
231
241
  });
232
242
  this.setState(
@@ -303,6 +313,7 @@ class Toolbar extends Component {
303
313
  id: 'folderContents',
304
314
  });
305
315
  const { expanded } = this.state;
316
+
306
317
  if (this.props.roles && this.props.roles?.includes('Manager')) {
307
318
  return (
308
319
  this.props.token && (
@@ -583,6 +594,7 @@ class Toolbar extends Component {
583
594
 
584
595
  export default compose(
585
596
  injectIntl,
597
+ withCookies,
586
598
  connect(
587
599
  (state, props) => ({
588
600
  actions: state.actions.actions,