@eeacms/volto-eea-website-theme 2.2.1 → 2.3.0
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 +20 -0
- package/package.json +1 -1
- package/src/components/theme/Widgets/DateWidget.jsx +32 -0
- package/src/components/theme/Widgets/DateWidget.test.js +67 -0
- package/src/components/theme/Widgets/DatetimeWidget.jsx +45 -0
- package/src/components/theme/Widgets/DatetimeWidget.test.js +63 -0
- package/src/config.js +1 -1
- package/src/index.js +17 -7
- package/src/index.test.js +2 -0
package/CHANGELOG.md
CHANGED
@@ -4,6 +4,26 @@ 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
|
+
### [2.3.0](https://github.com/eea/volto-eea-website-theme/compare/2.2.2...2.3.0) - 9 September 2024
|
8
|
+
|
9
|
+
#### :house: Internal changes
|
10
|
+
|
11
|
+
- style: Automated code fix [eea-jenkins - [`df350bf`](https://github.com/eea/volto-eea-website-theme/commit/df350bfff7b6e0ca4227a29d4fd6108293a55b04)]
|
12
|
+
|
13
|
+
#### :hammer_and_wrench: Others
|
14
|
+
|
15
|
+
- Bump package.json version to 2.3.0 [ichim-david - [`c81b67e`](https://github.com/eea/volto-eea-website-theme/commit/c81b67e70a826af43b3876d531778c4320f64add)]
|
16
|
+
- fix conflicts with develop [Teodor - [`801f4fc`](https://github.com/eea/volto-eea-website-theme/commit/801f4fc45fb9a3e985a7351bb8998dcb53e8fa19)]
|
17
|
+
- update both widgets and tests [Teodor - [`8d295f7`](https://github.com/eea/volto-eea-website-theme/commit/8d295f7bb736b48c02ad0aa1ea1f6071752ecf1c)]
|
18
|
+
- code cleanup [Teodor - [`8e27f48`](https://github.com/eea/volto-eea-website-theme/commit/8e27f48c6fde1f66e76d01e03e7001c620c4c585)]
|
19
|
+
- update test and add DateWidget in config too [Teodor - [`f14f9e4`](https://github.com/eea/volto-eea-website-theme/commit/f14f9e44c3779e40cf8d7bcc42efc5768a919250)]
|
20
|
+
- Fix test [Tiberiu Ichim - [`42012c6`](https://github.com/eea/volto-eea-website-theme/commit/42012c6bce80d0d6f13ae9d2a9c0deea8fa19eb0)]
|
21
|
+
- remake snapshots and fix import [Teodor - [`5bb47d6`](https://github.com/eea/volto-eea-website-theme/commit/5bb47d6e7bdb0cad7f1fd4c7055c7d8f7b06d9e6)]
|
22
|
+
- Fix test [Tiberiu Ichim - [`f73cf32`](https://github.com/eea/volto-eea-website-theme/commit/f73cf32ae50cd768d56a991d7c9177e89ae53599)]
|
23
|
+
- add test for the widget [Teodor - [`543c5bc`](https://github.com/eea/volto-eea-website-theme/commit/543c5bcf1246953e06ee79c5b559d0ba9e3307cf)]
|
24
|
+
- use formatDate from Volto [Teodor - [`24114b3`](https://github.com/eea/volto-eea-website-theme/commit/24114b3dac79418293d271bff06afd8d985d380d)]
|
25
|
+
### [2.2.2](https://github.com/eea/volto-eea-website-theme/compare/2.2.1...2.2.2) - 29 August 2024
|
26
|
+
|
7
27
|
### [2.2.1](https://github.com/eea/volto-eea-website-theme/compare/2.2.0...2.2.1) - 28 August 2024
|
8
28
|
|
9
29
|
#### :bug: Bug Fixes
|
package/package.json
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import cx from 'classnames';
|
3
|
+
import { useSelector } from 'react-redux';
|
4
|
+
import { toBackendLang } from '@plone/volto/helpers';
|
5
|
+
import { formatDate } from '@plone/volto/helpers/Utils/Date';
|
6
|
+
import config from '@plone/volto/registry';
|
7
|
+
|
8
|
+
export const DateWidget = ({ value, children, className }) => {
|
9
|
+
const lang = useSelector((state) => state.intl.locale);
|
10
|
+
const backendLang = toBackendLang(lang);
|
11
|
+
const locale =
|
12
|
+
backendLang === 'en' ? config.settings.dateLocale : backendLang;
|
13
|
+
const formatOptions = {
|
14
|
+
date: value,
|
15
|
+
format: {
|
16
|
+
year: 'numeric',
|
17
|
+
month: 'short',
|
18
|
+
day: '2-digit',
|
19
|
+
},
|
20
|
+
locale,
|
21
|
+
};
|
22
|
+
|
23
|
+
return value ? (
|
24
|
+
<span className={cx(className, 'date', 'widget')}>
|
25
|
+
{children
|
26
|
+
? children(formatDate(formatOptions))
|
27
|
+
: formatDate(formatOptions)}
|
28
|
+
</span>
|
29
|
+
) : (
|
30
|
+
''
|
31
|
+
);
|
32
|
+
};
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import renderer from 'react-test-renderer';
|
3
|
+
import { DateWidget } from './DateWidget';
|
4
|
+
import { Provider } from 'react-intl-redux';
|
5
|
+
import configureStore from 'redux-mock-store';
|
6
|
+
import thunk from 'redux-thunk';
|
7
|
+
|
8
|
+
const mockStore = configureStore([thunk]);
|
9
|
+
|
10
|
+
const store = mockStore({
|
11
|
+
intl: {
|
12
|
+
locale: 'en-gb',
|
13
|
+
messages: {},
|
14
|
+
},
|
15
|
+
});
|
16
|
+
|
17
|
+
describe('DateWidget', () => {
|
18
|
+
it('renders an empty date view widget component', () => {
|
19
|
+
const component = renderer.create(
|
20
|
+
<Provider store={store}>
|
21
|
+
<DateWidget />
|
22
|
+
</Provider>,
|
23
|
+
);
|
24
|
+
const json = component.toJSON();
|
25
|
+
expect(json).toMatchSnapshot();
|
26
|
+
});
|
27
|
+
|
28
|
+
it('renders a date view widget component', () => {
|
29
|
+
const component = renderer.create(
|
30
|
+
<Provider store={store}>
|
31
|
+
<DateWidget className="metadata" value="2020-08-04T09:00:00" />
|
32
|
+
</Provider>,
|
33
|
+
);
|
34
|
+
const json = component.toJSON();
|
35
|
+
expect(json).toMatchSnapshot();
|
36
|
+
});
|
37
|
+
|
38
|
+
it('renders a date view widget component with custom format', () => {
|
39
|
+
const component = renderer.create(
|
40
|
+
<Provider store={store}>
|
41
|
+
<DateWidget
|
42
|
+
className="metadata"
|
43
|
+
value="2020-08-04T09:00:00"
|
44
|
+
format={{
|
45
|
+
year: 'numeric',
|
46
|
+
month: 'short',
|
47
|
+
day: '2-digit',
|
48
|
+
}}
|
49
|
+
/>
|
50
|
+
</Provider>,
|
51
|
+
);
|
52
|
+
const json = component.toJSON();
|
53
|
+
expect(json).toMatchSnapshot();
|
54
|
+
});
|
55
|
+
|
56
|
+
it('renders a date view widget component with children', () => {
|
57
|
+
const component = renderer.create(
|
58
|
+
<Provider store={store}>
|
59
|
+
<DateWidget className="metadata" value="2020-08-04T09:00:00">
|
60
|
+
{(child) => <strong>{child}</strong>}
|
61
|
+
</DateWidget>
|
62
|
+
</Provider>,
|
63
|
+
);
|
64
|
+
const json = component.toJSON();
|
65
|
+
expect(json).toMatchSnapshot();
|
66
|
+
});
|
67
|
+
});
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import cx from 'classnames';
|
3
|
+
import { useSelector } from 'react-redux';
|
4
|
+
import { toBackendLang } from '@plone/volto/helpers';
|
5
|
+
import { formatDate } from '@plone/volto/helpers/Utils/Date';
|
6
|
+
import config from '@plone/volto/registry';
|
7
|
+
|
8
|
+
export const DatetimeWidget = ({ value, children, className }) => {
|
9
|
+
const lang = useSelector((state) => state.intl.locale);
|
10
|
+
const backendLang = toBackendLang(lang);
|
11
|
+
const locale =
|
12
|
+
backendLang === 'en' ? config.settings.dateLocale : backendLang;
|
13
|
+
const formatOptions = {
|
14
|
+
date: value,
|
15
|
+
format: {
|
16
|
+
year: 'numeric',
|
17
|
+
month: 'short',
|
18
|
+
day: '2-digit',
|
19
|
+
hour: '2-digit',
|
20
|
+
minute: '2-digit',
|
21
|
+
},
|
22
|
+
locale,
|
23
|
+
includeTime: true,
|
24
|
+
formatToParts: true,
|
25
|
+
};
|
26
|
+
|
27
|
+
let formattedParts = formatDate(formatOptions);
|
28
|
+
|
29
|
+
const formattedDate = formattedParts
|
30
|
+
.map((part) => {
|
31
|
+
if (part.type === 'literal' && part.value === ', ') {
|
32
|
+
return ' ';
|
33
|
+
}
|
34
|
+
return part.value;
|
35
|
+
})
|
36
|
+
.join('');
|
37
|
+
|
38
|
+
return value ? (
|
39
|
+
<span className={cx(className, 'datetime', 'widget')}>
|
40
|
+
{children ? children(formattedDate) : formattedDate}
|
41
|
+
</span>
|
42
|
+
) : (
|
43
|
+
''
|
44
|
+
);
|
45
|
+
};
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import renderer from 'react-test-renderer';
|
3
|
+
import { DatetimeWidget } from './DatetimeWidget';
|
4
|
+
import { Provider } from 'react-intl-redux';
|
5
|
+
import configureStore from 'redux-mock-store';
|
6
|
+
import thunk from 'redux-thunk';
|
7
|
+
|
8
|
+
const mockStore = configureStore([thunk]);
|
9
|
+
|
10
|
+
const store = mockStore({
|
11
|
+
intl: {
|
12
|
+
locale: 'en-gb',
|
13
|
+
messages: {},
|
14
|
+
},
|
15
|
+
});
|
16
|
+
|
17
|
+
describe('DatetimeWidget', () => {
|
18
|
+
it('renders an empty datetime view widget component', () => {
|
19
|
+
const component = renderer.create(
|
20
|
+
<Provider store={store}>
|
21
|
+
<DatetimeWidget />
|
22
|
+
</Provider>,
|
23
|
+
);
|
24
|
+
const json = component.toJSON();
|
25
|
+
expect(json).toMatchSnapshot();
|
26
|
+
});
|
27
|
+
|
28
|
+
it('renders a datetime view widget component with a date and time', () => {
|
29
|
+
const component = renderer.create(
|
30
|
+
<Provider store={store}>
|
31
|
+
<DatetimeWidget className="metadata" value="2024-09-05T15:34:00" />
|
32
|
+
</Provider>,
|
33
|
+
);
|
34
|
+
const json = component.toJSON();
|
35
|
+
expect(json).toMatchSnapshot();
|
36
|
+
});
|
37
|
+
|
38
|
+
it('renders a datetime view widget component with children formatting', () => {
|
39
|
+
const component = renderer.create(
|
40
|
+
<Provider store={store}>
|
41
|
+
<DatetimeWidget className="metadata" value="2024-09-05T15:34:00">
|
42
|
+
{(formattedDate) => <strong>{formattedDate}</strong>}
|
43
|
+
</DatetimeWidget>
|
44
|
+
</Provider>,
|
45
|
+
);
|
46
|
+
const json = component.toJSON();
|
47
|
+
expect(json).toMatchSnapshot();
|
48
|
+
});
|
49
|
+
|
50
|
+
it('removes the comma in the formatted date and shows correct time', () => {
|
51
|
+
const component = renderer.create(
|
52
|
+
<Provider store={store}>
|
53
|
+
<DatetimeWidget className="metadata" value="2024-09-05T15:34:00" />
|
54
|
+
</Provider>,
|
55
|
+
);
|
56
|
+
const json = component.toJSON();
|
57
|
+
expect(json).toMatchSnapshot();
|
58
|
+
|
59
|
+
const instance = component.root;
|
60
|
+
const span = instance.findByType('span');
|
61
|
+
expect(span.props.children).toContain('05 Sept 2024 15:34');
|
62
|
+
});
|
63
|
+
});
|
package/src/config.js
CHANGED
@@ -16,7 +16,7 @@ import climateLogo from '@eeacms/volto-eea-design-system/../theme/themes/eea/ass
|
|
16
16
|
// Footer.jsx config options
|
17
17
|
export const footerOpts = {
|
18
18
|
buttonName: 'Explore our environmental information systems',
|
19
|
-
hrefButton: 'https://www.eea.europa.eu/en/information-systems',
|
19
|
+
hrefButton: 'https://www.eea.europa.eu/en/information-systems#',
|
20
20
|
logosHeader: '',
|
21
21
|
contactHeader: 'Contact Us',
|
22
22
|
actions: [
|
package/src/index.js
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { v4 as uuid } from 'uuid';
|
3
|
+
import { Icon } from '@plone/volto/components';
|
4
|
+
import { default as TokenWidgetEdit } from '@plone/volto/components/manage/Widgets/TokenWidget';
|
5
|
+
import SelectAutoCompleteWidget from '@plone/volto/components/manage/Widgets/SelectAutoComplete';
|
6
|
+
import { serializeNodesToText } from '@plone/volto-slate/editor/render';
|
7
|
+
import { nanoid } from '@plone/volto-slate/utils';
|
8
|
+
|
1
9
|
import InpageNavigation from '@eeacms/volto-eea-design-system/ui/InpageNavigation/InpageNavigation';
|
2
10
|
import CustomCSS from '@eeacms/volto-eea-website-theme/components/theme/CustomCSS/CustomCSS';
|
3
11
|
import DraftBackground from '@eeacms/volto-eea-website-theme/components/theme/DraftBackground/DraftBackground';
|
@@ -6,11 +14,10 @@ import HomePageView from '@eeacms/volto-eea-website-theme/components/theme/Homep
|
|
6
14
|
import NotFound from '@eeacms/volto-eea-website-theme/components/theme/NotFound/NotFound';
|
7
15
|
import { TokenWidget } from '@eeacms/volto-eea-website-theme/components/theme/Widgets/TokenWidget';
|
8
16
|
import { TopicsWidget } from '@eeacms/volto-eea-website-theme/components/theme/Widgets/TopicsWidget';
|
17
|
+
import { DateWidget } from '@eeacms/volto-eea-website-theme/components/theme/Widgets/DateWidget';
|
18
|
+
import { DatetimeWidget } from '@eeacms/volto-eea-website-theme/components/theme/Widgets/DatetimeWidget';
|
9
19
|
import CreatableSelectWidget from '@eeacms/volto-eea-website-theme/components/theme/Widgets/CreatableSelectWidget';
|
10
20
|
|
11
|
-
import { Icon } from '@plone/volto/components';
|
12
|
-
import { default as TokenWidgetEdit } from '@plone/volto/components/manage/Widgets/TokenWidget';
|
13
|
-
import { serializeNodesToText } from '@plone/volto-slate/editor/render';
|
14
21
|
import Tag from '@eeacms/volto-eea-design-system/ui/Tag/Tag';
|
15
22
|
|
16
23
|
import {
|
@@ -30,11 +37,8 @@ import okMiddleware from './middleware/ok';
|
|
30
37
|
import voltoCustomMiddleware from './middleware/voltoCustom';
|
31
38
|
import installSlate from './slate';
|
32
39
|
import { print } from './reducers';
|
33
|
-
import { nanoid } from '@plone/volto-slate/utils';
|
34
|
-
import { v4 as uuid } from 'uuid';
|
35
40
|
|
36
41
|
import * as eea from './config';
|
37
|
-
import React from 'react';
|
38
42
|
|
39
43
|
const restrictedBlocks = ['imagesGrid', 'teaser', 'dataFigure', 'plotly_chart'];
|
40
44
|
|
@@ -330,11 +334,17 @@ const applyConfig = (config) => {
|
|
330
334
|
}
|
331
335
|
|
332
336
|
// Custom Widgets
|
333
|
-
config.widgets.id.other_organisations = TokenWidgetEdit;
|
337
|
+
// config.widgets.id.other_organisations = TokenWidgetEdit;
|
338
|
+
config.widgets.vocabulary['eea.coremetadata.other_organisations'] =
|
339
|
+
TokenWidgetEdit;
|
340
|
+
config.widgets.views.widget.datetime = DatetimeWidget;
|
341
|
+
config.widgets.views.widget.date = DateWidget;
|
334
342
|
config.widgets.views.id.topics = TopicsWidget;
|
335
343
|
config.widgets.views.id.subjects = TokenWidget;
|
336
344
|
config.widgets.views.widget.tags = TokenWidget;
|
337
345
|
config.widgets.widget.creatable_select = CreatableSelectWidget;
|
346
|
+
config.widgets.vocabulary['plone.app.vocabularies.Users'] =
|
347
|
+
SelectAutoCompleteWidget;
|
338
348
|
|
339
349
|
// /voltoCustom.css express-middleware
|
340
350
|
// /ok express-middleware - see also: https://github.com/plone/volto/pull/4432
|
package/src/index.test.js
CHANGED
@@ -92,6 +92,7 @@ describe('applyConfig', () => {
|
|
92
92
|
},
|
93
93
|
},
|
94
94
|
widget: {},
|
95
|
+
vocabulary: {},
|
95
96
|
id: {},
|
96
97
|
},
|
97
98
|
settings: {
|
@@ -247,6 +248,7 @@ describe('applyConfig', () => {
|
|
247
248
|
},
|
248
249
|
widget: {},
|
249
250
|
id: {},
|
251
|
+
vocabulary: {},
|
250
252
|
},
|
251
253
|
settings: {
|
252
254
|
eea: {},
|