@eeacms/volto-eea-website-policy 0.2.3 → 0.2.6
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 +28 -1
- package/package.json +1 -1
- package/src/components/Blocks/Teaser/Card.jsx +79 -0
- package/src/components/Blocks/Teaser/Schema.js +70 -0
- package/src/components/Blocks/Teaser/index.js +26 -0
- package/src/components/Blocks/Teaser/utils.js +18 -0
- package/src/customizations/volto/components/manage/Toolbar/Toolbar.jsx +589 -0
- package/src/index.js +15 -4
- package/src/components/Blocks/Teaser/Edit.jsx +0 -0
- package/src/components/Blocks/Teaser/View.jsx +0 -0
- package/src/components/Blocks/TeaserGrid/Edit.jsx +0 -0
- package/src/components/Blocks/TeaserGrid/View.jsx +0 -0
- package/src/components/index.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,8 +4,36 @@ 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.2.6](https://github.com/eea/volto-eea-website-policy/compare/0.2.5...0.2.6)
|
|
8
|
+
|
|
9
|
+
- Fix Cannot read properties of undefined (reading 'translations') [`8e7b8b8`](https://github.com/eea/volto-eea-website-policy/commit/8e7b8b8533b14f173d77783fe2d0b517c29c5937)
|
|
10
|
+
- Customize Toolbar.jsx - copied unchanged from @plone/volto 16.0.0.alpha.11 [`b7add4f`](https://github.com/eea/volto-eea-website-policy/commit/b7add4faa8ef2dde7d77489fc8bc431cbb023314)
|
|
11
|
+
|
|
12
|
+
#### [0.2.5](https://github.com/eea/volto-eea-website-policy/compare/0.2.4...0.2.5)
|
|
13
|
+
|
|
14
|
+
> 23 June 2022
|
|
15
|
+
|
|
16
|
+
- Rounded Card variation and disable ImageCards block [`#11`](https://github.com/eea/volto-eea-website-policy/pull/11)
|
|
17
|
+
- Rounded card via style wrapper [`6728684`](https://github.com/eea/volto-eea-website-policy/commit/67286844b00902aa4c6b316b50be35db95c531f0)
|
|
18
|
+
- Revert "Rounded Card variation - refs #148723" [`0168a86`](https://github.com/eea/volto-eea-website-policy/commit/0168a86fa644a9b848e37c7f5054eb4308c36784)
|
|
19
|
+
- Disable Image Cards block [`3ed8dc3`](https://github.com/eea/volto-eea-website-policy/commit/3ed8dc311cad8e30a8c918ecec7b21cc99260c50)
|
|
20
|
+
- Rounded Card variation - refs #148723 [`4b46731`](https://github.com/eea/volto-eea-website-policy/commit/4b46731e25962bbb6e7159d0db8a9a642a95eb53)
|
|
21
|
+
|
|
22
|
+
#### [0.2.4](https://github.com/eea/volto-eea-website-policy/compare/0.2.3...0.2.4)
|
|
23
|
+
|
|
24
|
+
> 13 June 2022
|
|
25
|
+
|
|
26
|
+
- Release [`#10`](https://github.com/eea/volto-eea-website-policy/pull/10)
|
|
27
|
+
- Fix listing block title: Listing (Content) [`cec2760`](https://github.com/eea/volto-eea-website-policy/commit/cec276082c3fc1b5486c996c3746a6958fb3a1a9)
|
|
28
|
+
- Add theme to teaser stylewrapper [`60eeb28`](https://github.com/eea/volto-eea-website-policy/commit/60eeb28b7793708c59d0af73ffb09895e8f2c87d)
|
|
29
|
+
- Fix className vs class warning [`fea1603`](https://github.com/eea/volto-eea-website-policy/commit/fea1603eefd628d57640a6b94ddbbb7edfb0d841)
|
|
30
|
+
- Custom card view for teaser [`c8eded0`](https://github.com/eea/volto-eea-website-policy/commit/c8eded011b8317cce9f842526f5d86771f54797b)
|
|
31
|
+
|
|
7
32
|
#### [0.2.3](https://github.com/eea/volto-eea-website-policy/compare/0.2.2...0.2.3)
|
|
8
33
|
|
|
34
|
+
> 10 June 2022
|
|
35
|
+
|
|
36
|
+
- Add Item block [`#9`](https://github.com/eea/volto-eea-website-policy/pull/9)
|
|
9
37
|
- prettier fix [`c2a6d2d`](https://github.com/eea/volto-eea-website-policy/commit/c2a6d2d3b12ce771b9b4413c5a6db157ccd9d1fc)
|
|
10
38
|
- Update index.js [`fb73895`](https://github.com/eea/volto-eea-website-policy/commit/fb7389509bc7e207942762c5e02a93d0168a6fba)
|
|
11
39
|
- removed change from commit 719e3778 [`29e636b`](https://github.com/eea/volto-eea-website-policy/commit/29e636b34ab02992c67cc5960f4dc6b21b1b4e71)
|
|
@@ -14,7 +42,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
|
14
42
|
- Move Item block un components folder [`9fb6ab2`](https://github.com/eea/volto-eea-website-policy/commit/9fb6ab2fb02cc5c1a7e25367de5ebe7109bd3dc4)
|
|
15
43
|
- Set default sizes for image & icon in Item block [`af22ec7`](https://github.com/eea/volto-eea-website-policy/commit/af22ec78b2c6fd1d033dc1acfec5e64f8926cd77)
|
|
16
44
|
- Add helpers functions [`353581c`](https://github.com/eea/volto-eea-website-policy/commit/353581cc6602b5e573eee93c74a67656203c0968)
|
|
17
|
-
- Add Item block [`617bfe2`](https://github.com/eea/volto-eea-website-policy/commit/617bfe2b827708ddb2c5eecd8fe1cc6fee37f60a)
|
|
18
45
|
- Add Teaser block folder's structure [`9457dd4`](https://github.com/eea/volto-eea-website-policy/commit/9457dd4ffaa2631eceb46bfd1ec2d201e8b3d7a8)
|
|
19
46
|
|
|
20
47
|
#### [0.2.2](https://github.com/eea/volto-eea-website-policy/compare/0.2.1...0.2.2)
|
package/package.json
CHANGED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { Message } from 'semantic-ui-react';
|
|
4
|
+
import { defineMessages, useIntl } from 'react-intl';
|
|
5
|
+
import imageBlockSVG from '@plone/volto/components/manage/Blocks/Image/block-image.svg';
|
|
6
|
+
import { flattenToAppURL } from '@plone/volto/helpers';
|
|
7
|
+
import { getTeaserImageURL } from './utils';
|
|
8
|
+
import { MaybeWrap } from '@plone/volto/components';
|
|
9
|
+
import { UniversalLink } from '@plone/volto/components';
|
|
10
|
+
import cx from 'classnames';
|
|
11
|
+
|
|
12
|
+
const messages = defineMessages({
|
|
13
|
+
PleaseChooseContent: {
|
|
14
|
+
id: 'Please choose an existing content as source for this element',
|
|
15
|
+
defaultMessage:
|
|
16
|
+
'Please choose an existing content as source for this element',
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const TeaserCardTemplate = (props) => {
|
|
21
|
+
const { data, isEditMode } = props;
|
|
22
|
+
const intl = useIntl();
|
|
23
|
+
const href = data.href?.[0];
|
|
24
|
+
const image = data.preview_image?.[0];
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<>
|
|
28
|
+
{!href && isEditMode && (
|
|
29
|
+
<Message>
|
|
30
|
+
<div className="grid-teaser-item placeholder">
|
|
31
|
+
<img src={imageBlockSVG} alt="" />
|
|
32
|
+
<p>{intl.formatMessage(messages.PleaseChooseContent)}</p>
|
|
33
|
+
</div>
|
|
34
|
+
</Message>
|
|
35
|
+
)}
|
|
36
|
+
{href && (
|
|
37
|
+
<MaybeWrap
|
|
38
|
+
condition={!isEditMode}
|
|
39
|
+
as={UniversalLink}
|
|
40
|
+
href={href['@id']}
|
|
41
|
+
target={data.openLinkInNewTab ? '_blank' : null}
|
|
42
|
+
>
|
|
43
|
+
<div
|
|
44
|
+
className={cx(
|
|
45
|
+
'ui fluid card',
|
|
46
|
+
data?.styles?.theme,
|
|
47
|
+
data?.styles?.rounded ? 'rounded big' : '',
|
|
48
|
+
)}
|
|
49
|
+
>
|
|
50
|
+
{(href.hasPreviewImage || href.image_field || image) && (
|
|
51
|
+
<div className="image">
|
|
52
|
+
<img
|
|
53
|
+
src={flattenToAppURL(getTeaserImageURL(href, image))}
|
|
54
|
+
alt="a"
|
|
55
|
+
/>
|
|
56
|
+
</div>
|
|
57
|
+
)}
|
|
58
|
+
<div className="content">
|
|
59
|
+
{data?.head_title && (
|
|
60
|
+
<div className="meta">{data?.head_title}</div>
|
|
61
|
+
)}
|
|
62
|
+
<div className="header">{data?.title}</div>
|
|
63
|
+
{!data.hide_description && (
|
|
64
|
+
<p className="description">{data?.description}</p>
|
|
65
|
+
)}
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
</MaybeWrap>
|
|
69
|
+
)}
|
|
70
|
+
</>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
TeaserCardTemplate.propTypes = {
|
|
75
|
+
data: PropTypes.objectOf(PropTypes.any).isRequired,
|
|
76
|
+
isEditMode: PropTypes.bool,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export default TeaserCardTemplate;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl';
|
|
2
|
+
|
|
3
|
+
const messages = defineMessages({
|
|
4
|
+
Type: {
|
|
5
|
+
id: 'Teaser',
|
|
6
|
+
defaultMessage: 'Teaser',
|
|
7
|
+
},
|
|
8
|
+
Theme: {
|
|
9
|
+
id: 'Theme',
|
|
10
|
+
defaultMessage: 'Theme',
|
|
11
|
+
},
|
|
12
|
+
ThemeHelp: {
|
|
13
|
+
id: 'Theme',
|
|
14
|
+
defaultMessage: 'Theme',
|
|
15
|
+
},
|
|
16
|
+
ThemeDefault: {
|
|
17
|
+
id: 'Default',
|
|
18
|
+
defaultMessage: 'Default',
|
|
19
|
+
},
|
|
20
|
+
ThemePrimary: {
|
|
21
|
+
id: 'Primary',
|
|
22
|
+
defaultMessage: 'Primary',
|
|
23
|
+
},
|
|
24
|
+
ThemeSecondary: {
|
|
25
|
+
id: 'Secondary',
|
|
26
|
+
defaultMessage: 'Secondary',
|
|
27
|
+
},
|
|
28
|
+
ThemeTertiary: {
|
|
29
|
+
id: 'Tertiary',
|
|
30
|
+
defaultMessage: 'Tertiary',
|
|
31
|
+
},
|
|
32
|
+
Rounded: {
|
|
33
|
+
id: 'Rounded',
|
|
34
|
+
defaultMessage: 'Rounded',
|
|
35
|
+
},
|
|
36
|
+
RoundedHelp: {
|
|
37
|
+
id: 'Rounded Image',
|
|
38
|
+
defaultMessage: 'Rounded Image',
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export const StylingSchema = ({ intl }) => ({
|
|
43
|
+
title: intl.formatMessage(messages.Type),
|
|
44
|
+
block: 'teaserGrid',
|
|
45
|
+
fieldsets: [
|
|
46
|
+
{
|
|
47
|
+
id: 'default',
|
|
48
|
+
title: 'Default',
|
|
49
|
+
fields: ['theme', 'rounded'],
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
properties: {
|
|
53
|
+
theme: {
|
|
54
|
+
title: intl.formatMessage(messages.Theme),
|
|
55
|
+
description: intl.formatMessage(messages.ThemeHelp),
|
|
56
|
+
choices: [
|
|
57
|
+
['', intl.formatMessage(messages.ThemeDefault)],
|
|
58
|
+
['primary', intl.formatMessage(messages.ThemePrimary)],
|
|
59
|
+
['secondary', intl.formatMessage(messages.ThemeSecondary)],
|
|
60
|
+
['tertiary', intl.formatMessage(messages.ThemeTertiary)],
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
rounded: {
|
|
64
|
+
title: intl.formatMessage(messages.Rounded),
|
|
65
|
+
description: intl.formatMessage(messages.RoundedHelp),
|
|
66
|
+
type: 'boolean',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
required: [],
|
|
70
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import TeaserCardTemplate from './Card';
|
|
2
|
+
import { StylingSchema } from './Schema';
|
|
3
|
+
|
|
4
|
+
export default (config) => {
|
|
5
|
+
// Teaser
|
|
6
|
+
if (config.blocks.blocksConfig.teaser) {
|
|
7
|
+
config.blocks.blocksConfig.teaser.variations = [
|
|
8
|
+
...(config.blocks.blocksConfig.teaser.variations || []),
|
|
9
|
+
{
|
|
10
|
+
id: 'card',
|
|
11
|
+
isDefault: true,
|
|
12
|
+
title: 'Card (top image)',
|
|
13
|
+
template: TeaserCardTemplate,
|
|
14
|
+
},
|
|
15
|
+
];
|
|
16
|
+
config.blocks.blocksConfig.teaser.enableStyling = true;
|
|
17
|
+
config.blocks.blocksConfig.teaser.stylesSchema = StylingSchema;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Teaser Grid
|
|
21
|
+
if (config.blocks.blocksConfig.teaserGrid) {
|
|
22
|
+
config.blocks.blocksConfig.teaserGrid.title = 'Teaser (Cards)';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return config;
|
|
26
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { isInternalURL } from '@plone/volto/helpers';
|
|
2
|
+
import config from '@plone/volto/registry';
|
|
3
|
+
|
|
4
|
+
export function getTeaserImageURL(href, image) {
|
|
5
|
+
const imageScale =
|
|
6
|
+
config.blocks.blocksConfig['teaser'].imageScale || 'preview';
|
|
7
|
+
if (image) {
|
|
8
|
+
if (isInternalURL(image['@id'])) {
|
|
9
|
+
return `${image['@id']}/@@images/image/${imageScale}`;
|
|
10
|
+
} else {
|
|
11
|
+
return image['@id'];
|
|
12
|
+
}
|
|
13
|
+
} else {
|
|
14
|
+
return `${href['@id']}/@@images/${
|
|
15
|
+
href.image_field || 'preview_image'
|
|
16
|
+
}/${imageScale}`;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,589 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Toolbar component.
|
|
3
|
+
* @module components/manage/Toolbar/Toolbar
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React, { Component } from 'react';
|
|
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';
|
|
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';
|
|
25
|
+
import {
|
|
26
|
+
getTypes,
|
|
27
|
+
listActions,
|
|
28
|
+
setExpandedToolbar,
|
|
29
|
+
unlockContent,
|
|
30
|
+
} from '@plone/volto/actions';
|
|
31
|
+
import { Icon } from '@plone/volto/components';
|
|
32
|
+
import { BodyClass, getBaseUrl, getCookieOptions } from '@plone/volto/helpers';
|
|
33
|
+
import { Pluggable } from '@plone/volto/components/manage/Pluggable';
|
|
34
|
+
|
|
35
|
+
import penSVG from '@plone/volto/icons/pen.svg';
|
|
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
|
+
import userSVG from '@plone/volto/icons/user.svg';
|
|
41
|
+
import clearSVG from '@plone/volto/icons/clear.svg';
|
|
42
|
+
|
|
43
|
+
const messages = defineMessages({
|
|
44
|
+
edit: {
|
|
45
|
+
id: 'Edit',
|
|
46
|
+
defaultMessage: 'Edit',
|
|
47
|
+
},
|
|
48
|
+
contents: {
|
|
49
|
+
id: 'Contents',
|
|
50
|
+
defaultMessage: 'Contents',
|
|
51
|
+
},
|
|
52
|
+
add: {
|
|
53
|
+
id: 'Add',
|
|
54
|
+
defaultMessage: 'Add',
|
|
55
|
+
},
|
|
56
|
+
more: {
|
|
57
|
+
id: 'More',
|
|
58
|
+
defaultMessage: 'More',
|
|
59
|
+
},
|
|
60
|
+
personalTools: {
|
|
61
|
+
id: 'Personal tools',
|
|
62
|
+
defaultMessage: 'Personal tools',
|
|
63
|
+
},
|
|
64
|
+
shrinkToolbar: {
|
|
65
|
+
id: 'Shrink toolbar',
|
|
66
|
+
defaultMessage: 'Shrink toolbar',
|
|
67
|
+
},
|
|
68
|
+
personalInformation: {
|
|
69
|
+
id: 'Personal Information',
|
|
70
|
+
defaultMessage: 'Personal Information',
|
|
71
|
+
},
|
|
72
|
+
personalPreferences: {
|
|
73
|
+
id: 'Personal Preferences',
|
|
74
|
+
defaultMessage: 'Personal Preferences',
|
|
75
|
+
},
|
|
76
|
+
collection: {
|
|
77
|
+
id: 'Collection',
|
|
78
|
+
defaultMessage: 'Collection',
|
|
79
|
+
},
|
|
80
|
+
file: {
|
|
81
|
+
id: 'File',
|
|
82
|
+
defaultMessage: 'File',
|
|
83
|
+
},
|
|
84
|
+
link: {
|
|
85
|
+
id: 'Link',
|
|
86
|
+
defaultMessage: 'Link',
|
|
87
|
+
},
|
|
88
|
+
newsItem: {
|
|
89
|
+
id: 'News Item',
|
|
90
|
+
defaultMessage: 'News Item',
|
|
91
|
+
},
|
|
92
|
+
page: {
|
|
93
|
+
id: 'Page',
|
|
94
|
+
defaultMessage: 'Page',
|
|
95
|
+
},
|
|
96
|
+
back: {
|
|
97
|
+
id: 'Back',
|
|
98
|
+
defaultMessage: 'Back',
|
|
99
|
+
},
|
|
100
|
+
unlock: {
|
|
101
|
+
id: 'Unlock',
|
|
102
|
+
defaultMessage: 'Unlock',
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
const toolbarComponents = {
|
|
107
|
+
personalTools: { component: PersonalTools, wrapper: null },
|
|
108
|
+
more: { component: More, wrapper: null },
|
|
109
|
+
types: { component: Types, wrapper: null, contentAsProps: true },
|
|
110
|
+
profile: {
|
|
111
|
+
component: PersonalInformation,
|
|
112
|
+
wrapper: StandardWrapper,
|
|
113
|
+
wrapperTitle: messages.personalInformation,
|
|
114
|
+
hideToolbarBody: true,
|
|
115
|
+
},
|
|
116
|
+
preferences: {
|
|
117
|
+
component: PersonalPreferences,
|
|
118
|
+
wrapper: StandardWrapper,
|
|
119
|
+
wrapperTitle: messages.personalPreferences,
|
|
120
|
+
hideToolbarBody: true,
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Toolbar container class.
|
|
126
|
+
* @class Toolbar
|
|
127
|
+
* @extends Component
|
|
128
|
+
*/
|
|
129
|
+
class Toolbar extends Component {
|
|
130
|
+
/**
|
|
131
|
+
* Property types.
|
|
132
|
+
* @property {Object} propTypes Property types.
|
|
133
|
+
* @static
|
|
134
|
+
*/
|
|
135
|
+
static propTypes = {
|
|
136
|
+
actions: PropTypes.shape({
|
|
137
|
+
object: PropTypes.arrayOf(PropTypes.object),
|
|
138
|
+
object_buttons: PropTypes.arrayOf(PropTypes.object),
|
|
139
|
+
user: PropTypes.arrayOf(PropTypes.object),
|
|
140
|
+
}),
|
|
141
|
+
token: PropTypes.string,
|
|
142
|
+
userId: PropTypes.string,
|
|
143
|
+
pathname: PropTypes.string.isRequired,
|
|
144
|
+
content: PropTypes.shape({
|
|
145
|
+
'@type': PropTypes.string,
|
|
146
|
+
is_folderish: PropTypes.bool,
|
|
147
|
+
review_state: PropTypes.string,
|
|
148
|
+
}),
|
|
149
|
+
getTypes: PropTypes.func.isRequired,
|
|
150
|
+
types: PropTypes.arrayOf(
|
|
151
|
+
PropTypes.shape({
|
|
152
|
+
'@id': PropTypes.string,
|
|
153
|
+
addable: PropTypes.bool,
|
|
154
|
+
title: PropTypes.string,
|
|
155
|
+
}),
|
|
156
|
+
),
|
|
157
|
+
listActions: PropTypes.func.isRequired,
|
|
158
|
+
unlockContent: PropTypes.func,
|
|
159
|
+
unlockRequest: PropTypes.objectOf(PropTypes.any),
|
|
160
|
+
inner: PropTypes.element.isRequired,
|
|
161
|
+
hideDefaultViewButtons: PropTypes.bool,
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Default properties.
|
|
166
|
+
* @property {Object} defaultProps Default properties.
|
|
167
|
+
* @static
|
|
168
|
+
*/
|
|
169
|
+
static defaultProps = {
|
|
170
|
+
actions: null,
|
|
171
|
+
token: null,
|
|
172
|
+
userId: null,
|
|
173
|
+
content: null,
|
|
174
|
+
hideDefaultViewButtons: false,
|
|
175
|
+
types: [],
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
toolbarWindow = React.createRef();
|
|
179
|
+
|
|
180
|
+
constructor(props) {
|
|
181
|
+
super(props);
|
|
182
|
+
const { cookies } = props;
|
|
183
|
+
this.state = {
|
|
184
|
+
expanded: cookies.get('toolbar_expanded') !== 'false',
|
|
185
|
+
showMenu: false,
|
|
186
|
+
menuStyle: {},
|
|
187
|
+
menuComponents: [],
|
|
188
|
+
loadedComponents: [],
|
|
189
|
+
hideToolbarBody: false,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Component will mount
|
|
195
|
+
* @method componentDidMount
|
|
196
|
+
* @returns {undefined}
|
|
197
|
+
*/
|
|
198
|
+
componentDidMount() {
|
|
199
|
+
this.props.listActions(getBaseUrl(this.props.pathname));
|
|
200
|
+
this.props.getTypes(getBaseUrl(this.props.pathname));
|
|
201
|
+
this.props.setExpandedToolbar(this.state.expanded);
|
|
202
|
+
document.addEventListener('mousedown', this.handleClickOutside, false);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Component will receive props
|
|
207
|
+
* @method componentWillReceiveProps
|
|
208
|
+
* @param {Object} nextProps Next properties
|
|
209
|
+
* @returns {undefined}
|
|
210
|
+
*/
|
|
211
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
212
|
+
if (nextProps.pathname !== this.props.pathname) {
|
|
213
|
+
this.props.listActions(getBaseUrl(nextProps.pathname));
|
|
214
|
+
this.props.getTypes(getBaseUrl(nextProps.pathname));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Unlock
|
|
218
|
+
if (this.props.unlockRequest.loading && nextProps.unlockRequest.loaded) {
|
|
219
|
+
this.props.listActions(getBaseUrl(nextProps.pathname));
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Component will receive props
|
|
225
|
+
* @method componentWillUnmount
|
|
226
|
+
* @returns {undefined}
|
|
227
|
+
*/
|
|
228
|
+
componentWillUnmount() {
|
|
229
|
+
document.removeEventListener('mousedown', this.handleClickOutside, false);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
handleShrink = () => {
|
|
233
|
+
const { cookies } = this.props;
|
|
234
|
+
cookies.set('toolbar_expanded', !this.state.expanded, getCookieOptions());
|
|
235
|
+
this.setState(
|
|
236
|
+
(state) => ({ expanded: !state.expanded }),
|
|
237
|
+
() => this.props.setExpandedToolbar(this.state.expanded),
|
|
238
|
+
);
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
closeMenu = () =>
|
|
242
|
+
this.setState(() => ({ showMenu: false, loadedComponents: [] }));
|
|
243
|
+
|
|
244
|
+
loadComponent = (type) => {
|
|
245
|
+
const { loadedComponents } = this.state;
|
|
246
|
+
if (!this.state.loadedComponents.includes(type)) {
|
|
247
|
+
this.setState({
|
|
248
|
+
loadedComponents: [...loadedComponents, type],
|
|
249
|
+
hideToolbarBody: toolbarComponents[type].hideToolbarBody || false,
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
unloadComponent = () => {
|
|
255
|
+
this.setState((state) => ({
|
|
256
|
+
loadedComponents: state.loadedComponents.slice(0, -1),
|
|
257
|
+
hideToolbarBody:
|
|
258
|
+
toolbarComponents[
|
|
259
|
+
state.loadedComponents[state.loadedComponents.length - 2]
|
|
260
|
+
].hideToolbarBody || false,
|
|
261
|
+
}));
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
toggleMenu = (e, selector) => {
|
|
265
|
+
if (this.state.showMenu) {
|
|
266
|
+
this.closeMenu();
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
// PersonalTools always shows at bottom
|
|
270
|
+
if (selector === 'personalTools') {
|
|
271
|
+
this.setState((state) => ({
|
|
272
|
+
showMenu: !state.showMenu,
|
|
273
|
+
menuStyle: { bottom: 0 },
|
|
274
|
+
}));
|
|
275
|
+
} else {
|
|
276
|
+
this.setState((state) => ({
|
|
277
|
+
showMenu: !state.showMenu,
|
|
278
|
+
menuStyle: { top: 0 },
|
|
279
|
+
}));
|
|
280
|
+
}
|
|
281
|
+
this.loadComponent(selector);
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
handleClickOutside = (e) => {
|
|
285
|
+
if (this.pusher && doesNodeContainClick(this.pusher, e)) return;
|
|
286
|
+
this.closeMenu();
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
unlock = (e) => {
|
|
290
|
+
this.props.unlockContent(getBaseUrl(this.props.pathname), true);
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Render method.
|
|
295
|
+
* @method render
|
|
296
|
+
* @returns {string} Markup for the component.
|
|
297
|
+
*/
|
|
298
|
+
render() {
|
|
299
|
+
const path = getBaseUrl(this.props.pathname);
|
|
300
|
+
const lock = this.props.content?.lock;
|
|
301
|
+
const unlockAction =
|
|
302
|
+
lock?.locked && lock?.stealable && lock?.creator !== this.props.userId;
|
|
303
|
+
const editAction =
|
|
304
|
+
!unlockAction && find(this.props.actions.object, { id: 'edit' });
|
|
305
|
+
const folderContentsAction = find(this.props.actions.object, {
|
|
306
|
+
id: 'folderContents',
|
|
307
|
+
});
|
|
308
|
+
const { expanded } = this.state;
|
|
309
|
+
|
|
310
|
+
return (
|
|
311
|
+
this.props.token && (
|
|
312
|
+
<>
|
|
313
|
+
<BodyClass
|
|
314
|
+
className={expanded ? 'has-toolbar' : 'has-toolbar-collapsed'}
|
|
315
|
+
/>
|
|
316
|
+
<div
|
|
317
|
+
style={this.state.menuStyle}
|
|
318
|
+
className={
|
|
319
|
+
this.state.showMenu ? 'toolbar-content show' : 'toolbar-content'
|
|
320
|
+
}
|
|
321
|
+
ref={this.toolbarWindow}
|
|
322
|
+
>
|
|
323
|
+
{this.state.showMenu && (
|
|
324
|
+
// This sets the scroll locker in the body tag in mobile
|
|
325
|
+
<BodyClass className="has-toolbar-menu-open" />
|
|
326
|
+
)}
|
|
327
|
+
<div
|
|
328
|
+
className="pusher-puller"
|
|
329
|
+
ref={(node) => (this.pusher = node)}
|
|
330
|
+
style={{
|
|
331
|
+
transform: this.toolbarWindow.current
|
|
332
|
+
? `translateX(-${
|
|
333
|
+
(this.state.loadedComponents.length - 1) *
|
|
334
|
+
this.toolbarWindow.current.getBoundingClientRect().width
|
|
335
|
+
}px)`
|
|
336
|
+
: null,
|
|
337
|
+
}}
|
|
338
|
+
>
|
|
339
|
+
{this.state.loadedComponents.map((component, index) =>
|
|
340
|
+
(() => {
|
|
341
|
+
const ToolbarComponent =
|
|
342
|
+
toolbarComponents[component].component;
|
|
343
|
+
const WrapperComponent = toolbarComponents[component].wrapper;
|
|
344
|
+
const haveActions =
|
|
345
|
+
toolbarComponents[component].hideToolbarBody;
|
|
346
|
+
const title =
|
|
347
|
+
toolbarComponents[component].wrapperTitle &&
|
|
348
|
+
this.props.intl.formatMessage(
|
|
349
|
+
toolbarComponents[component].wrapperTitle,
|
|
350
|
+
);
|
|
351
|
+
if (WrapperComponent) {
|
|
352
|
+
return (
|
|
353
|
+
<WrapperComponent
|
|
354
|
+
componentName={component}
|
|
355
|
+
componentTitle={title}
|
|
356
|
+
pathname={this.props.pathname}
|
|
357
|
+
loadComponent={this.loadComponent}
|
|
358
|
+
unloadComponent={this.unloadComponent}
|
|
359
|
+
componentIndex={index}
|
|
360
|
+
theToolbar={this.toolbarWindow}
|
|
361
|
+
key={`personalToolsComponent-${index}`}
|
|
362
|
+
closeMenu={this.closeMenu}
|
|
363
|
+
hasActions={haveActions}
|
|
364
|
+
>
|
|
365
|
+
<ToolbarComponent
|
|
366
|
+
pathname={this.props.pathname}
|
|
367
|
+
loadComponent={this.loadComponent}
|
|
368
|
+
unloadComponent={this.unloadComponent}
|
|
369
|
+
componentIndex={index}
|
|
370
|
+
theToolbar={this.toolbarWindow}
|
|
371
|
+
closeMenu={this.closeMenu}
|
|
372
|
+
isToolbarEmbedded
|
|
373
|
+
/>
|
|
374
|
+
</WrapperComponent>
|
|
375
|
+
);
|
|
376
|
+
} else {
|
|
377
|
+
return (
|
|
378
|
+
<ToolbarComponent
|
|
379
|
+
pathname={this.props.pathname}
|
|
380
|
+
loadComponent={this.loadComponent}
|
|
381
|
+
unloadComponent={this.unloadComponent}
|
|
382
|
+
componentIndex={index}
|
|
383
|
+
theToolbar={this.toolbarWindow}
|
|
384
|
+
key={`personalToolsComponent-${index}`}
|
|
385
|
+
closeMenu={this.closeMenu}
|
|
386
|
+
content={
|
|
387
|
+
toolbarComponents[component].contentAsProps
|
|
388
|
+
? this.props.content
|
|
389
|
+
: null
|
|
390
|
+
}
|
|
391
|
+
/>
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
})(),
|
|
395
|
+
)}
|
|
396
|
+
</div>
|
|
397
|
+
</div>
|
|
398
|
+
<div className={this.state.expanded ? 'toolbar expanded' : 'toolbar'}>
|
|
399
|
+
<div className="toolbar-body">
|
|
400
|
+
<div className="toolbar-actions">
|
|
401
|
+
{this.props.hideDefaultViewButtons && this.props.inner && (
|
|
402
|
+
<>{this.props.inner}</>
|
|
403
|
+
)}
|
|
404
|
+
{!this.props.hideDefaultViewButtons && (
|
|
405
|
+
<>
|
|
406
|
+
{unlockAction && (
|
|
407
|
+
<button
|
|
408
|
+
aria-label={this.props.intl.formatMessage(
|
|
409
|
+
messages.unlock,
|
|
410
|
+
)}
|
|
411
|
+
className="unlock"
|
|
412
|
+
onClick={(e) => this.unlock(e)}
|
|
413
|
+
tabIndex={0}
|
|
414
|
+
>
|
|
415
|
+
<Icon
|
|
416
|
+
name={unlockSVG}
|
|
417
|
+
size="30px"
|
|
418
|
+
className="unlock"
|
|
419
|
+
title={this.props.intl.formatMessage(messages.unlock)}
|
|
420
|
+
/>
|
|
421
|
+
</button>
|
|
422
|
+
)}
|
|
423
|
+
|
|
424
|
+
{editAction && (
|
|
425
|
+
<Link
|
|
426
|
+
aria-label={this.props.intl.formatMessage(
|
|
427
|
+
messages.edit,
|
|
428
|
+
)}
|
|
429
|
+
className="edit"
|
|
430
|
+
to={`${path}/edit`}
|
|
431
|
+
>
|
|
432
|
+
<Icon
|
|
433
|
+
name={penSVG}
|
|
434
|
+
size="30px"
|
|
435
|
+
className="circled"
|
|
436
|
+
title={this.props.intl.formatMessage(messages.edit)}
|
|
437
|
+
/>
|
|
438
|
+
</Link>
|
|
439
|
+
)}
|
|
440
|
+
{this.props.content &&
|
|
441
|
+
this.props.content.is_folderish &&
|
|
442
|
+
folderContentsAction &&
|
|
443
|
+
!this.props.pathname.endsWith('/contents') && (
|
|
444
|
+
<Link
|
|
445
|
+
aria-label={this.props.intl.formatMessage(
|
|
446
|
+
messages.contents,
|
|
447
|
+
)}
|
|
448
|
+
to={`${path}/contents`}
|
|
449
|
+
>
|
|
450
|
+
<Icon
|
|
451
|
+
name={folderSVG}
|
|
452
|
+
size="30px"
|
|
453
|
+
title={this.props.intl.formatMessage(
|
|
454
|
+
messages.contents,
|
|
455
|
+
)}
|
|
456
|
+
/>
|
|
457
|
+
</Link>
|
|
458
|
+
)}
|
|
459
|
+
{this.props.content &&
|
|
460
|
+
this.props.content.is_folderish &&
|
|
461
|
+
folderContentsAction &&
|
|
462
|
+
this.props.pathname.endsWith('/contents') && (
|
|
463
|
+
<Link
|
|
464
|
+
to={`${path}`}
|
|
465
|
+
aria-label={this.props.intl.formatMessage(
|
|
466
|
+
messages.back,
|
|
467
|
+
)}
|
|
468
|
+
>
|
|
469
|
+
<Icon
|
|
470
|
+
name={clearSVG}
|
|
471
|
+
className="contents circled"
|
|
472
|
+
size="30px"
|
|
473
|
+
title={this.props.intl.formatMessage(messages.back)}
|
|
474
|
+
/>
|
|
475
|
+
</Link>
|
|
476
|
+
)}
|
|
477
|
+
{this.props.content &&
|
|
478
|
+
((this.props.content.is_folderish &&
|
|
479
|
+
this.props.types.length > 0) ||
|
|
480
|
+
(config.settings.isMultilingual &&
|
|
481
|
+
this.props.content['@components']?.translations)) && (
|
|
482
|
+
<button
|
|
483
|
+
className="add"
|
|
484
|
+
aria-label={this.props.intl.formatMessage(
|
|
485
|
+
messages.add,
|
|
486
|
+
)}
|
|
487
|
+
onClick={(e) => this.toggleMenu(e, 'types')}
|
|
488
|
+
tabIndex={0}
|
|
489
|
+
id="toolbar-add"
|
|
490
|
+
>
|
|
491
|
+
<Icon
|
|
492
|
+
name={addSVG}
|
|
493
|
+
size="30px"
|
|
494
|
+
title={this.props.intl.formatMessage(messages.add)}
|
|
495
|
+
/>
|
|
496
|
+
</button>
|
|
497
|
+
)}
|
|
498
|
+
<div className="toolbar-button-spacer" />
|
|
499
|
+
<button
|
|
500
|
+
className="more"
|
|
501
|
+
aria-label={this.props.intl.formatMessage(messages.more)}
|
|
502
|
+
onClick={(e) => this.toggleMenu(e, 'more')}
|
|
503
|
+
tabIndex={0}
|
|
504
|
+
id="toolbar-more"
|
|
505
|
+
>
|
|
506
|
+
<Icon
|
|
507
|
+
className="mobile hidden"
|
|
508
|
+
name={moreSVG}
|
|
509
|
+
size="30px"
|
|
510
|
+
title={this.props.intl.formatMessage(messages.more)}
|
|
511
|
+
/>
|
|
512
|
+
{this.state.showMenu ? (
|
|
513
|
+
<Icon
|
|
514
|
+
className="mobile only"
|
|
515
|
+
name={clearSVG}
|
|
516
|
+
size="30px"
|
|
517
|
+
/>
|
|
518
|
+
) : (
|
|
519
|
+
<Icon
|
|
520
|
+
className="mobile only"
|
|
521
|
+
name={moreSVG}
|
|
522
|
+
size="30px"
|
|
523
|
+
/>
|
|
524
|
+
)}
|
|
525
|
+
</button>
|
|
526
|
+
</>
|
|
527
|
+
)}
|
|
528
|
+
</div>
|
|
529
|
+
<div className="toolbar-bottom">
|
|
530
|
+
<Pluggable name="main.toolbar.bottom" />
|
|
531
|
+
{!this.props.hideDefaultViewButtons && (
|
|
532
|
+
<button
|
|
533
|
+
className="user"
|
|
534
|
+
aria-label={this.props.intl.formatMessage(
|
|
535
|
+
messages.personalTools,
|
|
536
|
+
)}
|
|
537
|
+
onClick={(e) => this.toggleMenu(e, 'personalTools')}
|
|
538
|
+
tabIndex={0}
|
|
539
|
+
id="toolbar-personal"
|
|
540
|
+
>
|
|
541
|
+
<Icon
|
|
542
|
+
name={userSVG}
|
|
543
|
+
size="30px"
|
|
544
|
+
title={this.props.intl.formatMessage(
|
|
545
|
+
messages.personalTools,
|
|
546
|
+
)}
|
|
547
|
+
/>
|
|
548
|
+
</button>
|
|
549
|
+
)}
|
|
550
|
+
</div>
|
|
551
|
+
</div>
|
|
552
|
+
<div className="toolbar-handler">
|
|
553
|
+
<button
|
|
554
|
+
aria-label={this.props.intl.formatMessage(
|
|
555
|
+
messages.shrinkToolbar,
|
|
556
|
+
)}
|
|
557
|
+
className={cx({
|
|
558
|
+
[this.props.content?.review_state]: this.props.content
|
|
559
|
+
?.review_state,
|
|
560
|
+
})}
|
|
561
|
+
onClick={this.handleShrink}
|
|
562
|
+
/>
|
|
563
|
+
</div>
|
|
564
|
+
</div>
|
|
565
|
+
<div className="pusher" />
|
|
566
|
+
</>
|
|
567
|
+
)
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
export default compose(
|
|
573
|
+
injectIntl,
|
|
574
|
+
withCookies,
|
|
575
|
+
connect(
|
|
576
|
+
(state, props) => ({
|
|
577
|
+
actions: state.actions.actions,
|
|
578
|
+
token: state.userSession.token,
|
|
579
|
+
userId: state.userSession.token
|
|
580
|
+
? jwtDecode(state.userSession.token).sub
|
|
581
|
+
: '',
|
|
582
|
+
content: state.content.data,
|
|
583
|
+
pathname: props.pathname,
|
|
584
|
+
types: filter(state.types.types, 'addable'),
|
|
585
|
+
unlockRequest: state.content.unlock,
|
|
586
|
+
}),
|
|
587
|
+
{ getTypes, listActions, setExpandedToolbar, unlockContent },
|
|
588
|
+
),
|
|
589
|
+
)(Toolbar);
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { runtimeConfig } from '@plone/volto/runtime_config';
|
|
2
2
|
import installCallout from 'volto-slate/editor/plugins/Callout';
|
|
3
3
|
import installItemBlock from '@eeacms/volto-eea-website-policy/components/Blocks/Item';
|
|
4
|
+
import customizeTeaserBlock from '@eeacms/volto-eea-website-policy/components/Blocks/Teaser';
|
|
4
5
|
|
|
5
6
|
const applyConfig = (config) => {
|
|
6
7
|
// if (process.env.NODE_ENV === 'production') {
|
|
@@ -76,9 +77,6 @@ const applyConfig = (config) => {
|
|
|
76
77
|
if (config.blocks.blocksConfig.teaser) {
|
|
77
78
|
config.blocks.blocksConfig.teaser.restricted = true;
|
|
78
79
|
}
|
|
79
|
-
if (config.blocks.blocksConfig.teaserGrid) {
|
|
80
|
-
config.blocks.blocksConfig.teaserGrid.title = 'Teaser (Cards)';
|
|
81
|
-
}
|
|
82
80
|
|
|
83
81
|
// Divider
|
|
84
82
|
if (config.blocks.blocksConfig.dividerBlock) {
|
|
@@ -95,10 +93,23 @@ const applyConfig = (config) => {
|
|
|
95
93
|
config.blocks.blocksConfig.columnsBlock.mostUsed = true;
|
|
96
94
|
}
|
|
97
95
|
|
|
96
|
+
// Listing
|
|
97
|
+
if (config.blocks.blocksConfig.listing) {
|
|
98
|
+
config.blocks.blocksConfig.listing.title = 'Listing (Content)';
|
|
99
|
+
}
|
|
100
|
+
|
|
98
101
|
// Custom blocks
|
|
99
|
-
config = [installItemBlock].reduce(
|
|
102
|
+
config = [installItemBlock, customizeTeaserBlock].reduce(
|
|
103
|
+
(acc, apply) => apply(acc),
|
|
104
|
+
config,
|
|
105
|
+
);
|
|
100
106
|
config.blocks.blocksConfig.item.mostUsed = true;
|
|
101
107
|
|
|
108
|
+
// Disable some blocks
|
|
109
|
+
if (config.blocks.blocksConfig.imagecards) {
|
|
110
|
+
config.blocks.blocksConfig.imagecards.restricted = true;
|
|
111
|
+
}
|
|
112
|
+
|
|
102
113
|
// Done
|
|
103
114
|
return config;
|
|
104
115
|
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/src/components/index.js
DELETED
|
File without changes
|