@eeacms/volto-embed 7.0.2 → 9.0.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 -17
- package/cypress.config.js +15 -5
- package/locales/de/LC_MESSAGES/volto.po +65 -9
- package/locales/en/LC_MESSAGES/volto.po +65 -9
- package/locales/it/LC_MESSAGES/volto.po +65 -9
- package/locales/ro/LC_MESSAGES/volto.po +65 -9
- package/locales/volto.pot +66 -10
- package/package.json +3 -4
- package/src/Blocks/EmbedMaps/Edit.jsx +31 -0
- package/src/Blocks/EmbedMaps/Edit.test.js +75 -0
- package/src/Blocks/EmbedMaps/View.jsx +71 -0
- package/src/Blocks/EmbedMaps/View.test.js +60 -0
- package/src/Blocks/EmbedMaps/index.js +22 -0
- package/src/Blocks/EmbedMaps/schema.js +62 -0
- package/src/Blocks/Maps/Edit.jsx +1 -0
- package/src/Blocks/Maps/Edit.test.js +79 -0
- package/src/Blocks/Maps/View.jsx +5 -1
- package/src/Blocks/Maps/View.test.js +67 -0
- package/src/Blocks/Maps/schema.js +40 -54
- package/src/Blocks/index.js +5 -1
- package/src/EmbedMap/EmbedMap.jsx +106 -0
- package/src/EmbedMap/EmbedMap.test.js +66 -0
- package/src/EmbedMap/style.less +16 -0
- package/src/PrivacyProtection/PrivacyProtection.jsx +86 -84
- package/src/Toolbar/Enlarge.jsx +28 -15
- package/src/Toolbar/FigureNote.jsx +2 -3
- package/src/Toolbar/Toolbar.test.js +96 -0
- package/src/Toolbar/styles.less +1 -2
- package/src/Views/MapView.jsx +13 -0
- package/src/Views/MapView.test.js +68 -0
- package/src/Widgets/MapsViewWidget.jsx +5 -0
- package/src/Widgets/MapsWidget.jsx +223 -0
- package/src/helpers.js +16 -0
- package/src/index.js +7 -0
- package/src/Blocks/Maps/Edit.test.jsx +0 -119
package/locales/volto.pot
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
msgid ""
|
|
2
2
|
msgstr ""
|
|
3
3
|
"Project-Id-Version: Plone\n"
|
|
4
|
-
"POT-Creation-Date: 2023-
|
|
4
|
+
"POT-Creation-Date: 2023-11-15T18:20:32.637Z\n"
|
|
5
5
|
"Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
|
|
6
6
|
"Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
|
|
7
7
|
"MIME-Version: 1.0\n"
|
|
@@ -13,37 +13,70 @@ msgstr ""
|
|
|
13
13
|
"Preferred-Encodings: utf-8\n"
|
|
14
14
|
"Domain: volto\n"
|
|
15
15
|
|
|
16
|
-
#:
|
|
16
|
+
#: Blocks/EmbedMaps/schema
|
|
17
|
+
#: Blocks/Maps/schema
|
|
18
|
+
# defaultMessage: Alignment
|
|
19
|
+
msgid "Alignment"
|
|
20
|
+
msgstr ""
|
|
21
|
+
|
|
22
|
+
#: Blocks/EmbedMaps/schema
|
|
23
|
+
#: Blocks/Maps/schema
|
|
24
|
+
# defaultMessage: Alt text
|
|
25
|
+
msgid "Alt text"
|
|
26
|
+
msgstr ""
|
|
27
|
+
|
|
28
|
+
#: Blocks/EmbedMaps/schema
|
|
29
|
+
#: Blocks/Maps/schema
|
|
30
|
+
# defaultMessage: undefined
|
|
31
|
+
msgid "CSSHeight"
|
|
32
|
+
msgstr ""
|
|
33
|
+
|
|
34
|
+
#: Blocks/EmbedMaps/schema
|
|
35
|
+
#: Blocks/Maps/schema
|
|
36
|
+
# defaultMessage: undefined
|
|
37
|
+
msgid "CSSHeightDescription"
|
|
38
|
+
msgstr ""
|
|
39
|
+
|
|
40
|
+
#: Blocks/EmbedMaps/Edit
|
|
41
|
+
#: Blocks/Maps/Edit
|
|
17
42
|
# defaultMessage: Center
|
|
18
43
|
msgid "Center"
|
|
19
44
|
msgstr ""
|
|
20
45
|
|
|
21
|
-
#:
|
|
46
|
+
#: Blocks/EmbedMaps/Edit
|
|
47
|
+
#: Blocks/Maps/Edit
|
|
48
|
+
#: Widgets/MapsWidget
|
|
22
49
|
# defaultMessage: Embed code error, please follow the instructions and try again.
|
|
23
50
|
msgid "Embed code error, please follow the instructions and try again."
|
|
24
51
|
msgstr ""
|
|
25
52
|
|
|
26
|
-
#:
|
|
53
|
+
#: Blocks/EmbedMaps/View
|
|
54
|
+
#: Blocks/Maps/View
|
|
55
|
+
#: Map/Map
|
|
27
56
|
# defaultMessage: Embeded Google Maps
|
|
28
57
|
msgid "Embeded Google Maps"
|
|
29
58
|
msgstr ""
|
|
30
59
|
|
|
31
|
-
#:
|
|
60
|
+
#: Blocks/EmbedMaps/Edit
|
|
61
|
+
#: Blocks/Maps/Edit
|
|
32
62
|
# defaultMessage: Enter map Embed Code
|
|
33
63
|
msgid "Enter map Embed Code"
|
|
34
64
|
msgstr ""
|
|
35
65
|
|
|
36
|
-
#:
|
|
66
|
+
#: Blocks/EmbedMaps/Edit
|
|
67
|
+
#: Blocks/Maps/Edit
|
|
37
68
|
# defaultMessage: Full
|
|
38
69
|
msgid "Full"
|
|
39
70
|
msgstr ""
|
|
40
71
|
|
|
41
|
-
#:
|
|
72
|
+
#: Blocks/EmbedMaps/Edit
|
|
73
|
+
#: Blocks/Maps/Edit
|
|
42
74
|
# defaultMessage: Google Maps Embedded Block
|
|
43
75
|
msgid "Google Maps Embedded Block"
|
|
44
76
|
msgstr ""
|
|
45
77
|
|
|
46
|
-
#:
|
|
78
|
+
#: Blocks/EmbedMaps/Edit
|
|
79
|
+
#: Blocks/Maps/Edit
|
|
47
80
|
# defaultMessage: Left
|
|
48
81
|
msgid "Left"
|
|
49
82
|
msgstr ""
|
|
@@ -53,12 +86,35 @@ msgstr ""
|
|
|
53
86
|
msgid "Live image generated"
|
|
54
87
|
msgstr ""
|
|
55
88
|
|
|
56
|
-
#:
|
|
89
|
+
#: Blocks/EmbedMaps/MapsSidebar
|
|
90
|
+
#: Blocks/EmbedMaps/schema
|
|
91
|
+
#: Blocks/Maps/MapsSidebar
|
|
92
|
+
#: Blocks/Maps/schema
|
|
93
|
+
# defaultMessage: Maps
|
|
94
|
+
msgid "Maps"
|
|
95
|
+
msgstr ""
|
|
96
|
+
|
|
97
|
+
#: Blocks/EmbedMaps/schema
|
|
98
|
+
#: Blocks/Maps/schema
|
|
99
|
+
# defaultMessage: Maps URL
|
|
100
|
+
msgid "Maps URL"
|
|
101
|
+
msgstr ""
|
|
102
|
+
|
|
103
|
+
#: Blocks/EmbedMaps/MapsSidebar
|
|
104
|
+
#: Blocks/Maps/MapsSidebar
|
|
105
|
+
# defaultMessage: No map selected
|
|
106
|
+
msgid "No map selected"
|
|
107
|
+
msgstr ""
|
|
108
|
+
|
|
109
|
+
#: Blocks/EmbedMaps/Edit
|
|
110
|
+
#: Blocks/Maps/Edit
|
|
111
|
+
#: Widgets/MapsWidget
|
|
57
112
|
# defaultMessage: Please enter the Embed Code provided by Google Maps -> Share -> Embed map. It should contain the <iframe> code on it.
|
|
58
113
|
msgid "Please enter the Embed Code provided by Google Maps -> Share -> Embed map. It should contain the <iframe> code on it."
|
|
59
114
|
msgstr ""
|
|
60
115
|
|
|
61
|
-
#:
|
|
116
|
+
#: Blocks/EmbedMaps/Edit
|
|
117
|
+
#: Blocks/Maps/Edit
|
|
62
118
|
# defaultMessage: Right
|
|
63
119
|
msgid "Right"
|
|
64
120
|
msgstr ""
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-embed",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0",
|
|
4
4
|
"description": "Embed external content",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "European Environment Agency: IDM2 A-Team",
|
|
@@ -20,8 +20,7 @@
|
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@eeacms/volto-corsproxy": "*",
|
|
23
|
-
"@eeacms/volto-datablocks": "*"
|
|
24
|
-
"react-visibility-sensor": "5.1.1"
|
|
23
|
+
"@eeacms/volto-datablocks": "*"
|
|
25
24
|
},
|
|
26
25
|
"devDependencies": {
|
|
27
26
|
"@cypress/code-coverage": "^3.10.0",
|
|
@@ -72,4 +71,4 @@
|
|
|
72
71
|
"cypress:open": "make cypress-open",
|
|
73
72
|
"prepare": "husky install"
|
|
74
73
|
}
|
|
75
|
-
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';
|
|
3
|
+
import { SidebarPortal } from '@plone/volto/components';
|
|
4
|
+
import View from './View';
|
|
5
|
+
import getSchema from './schema';
|
|
6
|
+
|
|
7
|
+
const Edit = (props) => {
|
|
8
|
+
const schema = React.useMemo(() => getSchema(props), [props]);
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<React.Fragment>
|
|
12
|
+
<View {...props} mode="edit" />
|
|
13
|
+
<SidebarPortal selected={props.selected}>
|
|
14
|
+
<BlockDataForm
|
|
15
|
+
block={props.block}
|
|
16
|
+
schema={schema}
|
|
17
|
+
title={schema.title}
|
|
18
|
+
onChangeField={(id, value) => {
|
|
19
|
+
props.onChangeBlock(props.block, {
|
|
20
|
+
...props.data,
|
|
21
|
+
[id]: value,
|
|
22
|
+
});
|
|
23
|
+
}}
|
|
24
|
+
formData={props.data}
|
|
25
|
+
/>
|
|
26
|
+
</SidebarPortal>
|
|
27
|
+
</React.Fragment>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default Edit;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer from 'react-test-renderer';
|
|
3
|
+
import configureStore from 'redux-mock-store';
|
|
4
|
+
import { Provider } from 'react-intl-redux';
|
|
5
|
+
import config from '@plone/volto/registry';
|
|
6
|
+
|
|
7
|
+
import Edit from './Edit';
|
|
8
|
+
import installEmbedMaps from '.';
|
|
9
|
+
|
|
10
|
+
installEmbedMaps(config);
|
|
11
|
+
|
|
12
|
+
const mockStore = configureStore();
|
|
13
|
+
|
|
14
|
+
jest.mock('@plone/volto/components', () => ({
|
|
15
|
+
__esModule: true,
|
|
16
|
+
SidebarPortal: jest.requireActual(
|
|
17
|
+
'@plone/volto/components/manage/Sidebar/SidebarPortal',
|
|
18
|
+
).default,
|
|
19
|
+
UniversalLink: ({ children, href }) => {
|
|
20
|
+
return <a href={href}>{children}</a>;
|
|
21
|
+
},
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
const store = mockStore({
|
|
25
|
+
intl: {
|
|
26
|
+
locale: 'en',
|
|
27
|
+
messages: {},
|
|
28
|
+
},
|
|
29
|
+
content: {
|
|
30
|
+
create: {},
|
|
31
|
+
},
|
|
32
|
+
connected_data_parameters: {},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('renders an edit embed map block component', () => {
|
|
36
|
+
const component = renderer.create(
|
|
37
|
+
<Provider store={store}>
|
|
38
|
+
<Edit
|
|
39
|
+
id="my-map"
|
|
40
|
+
data={{
|
|
41
|
+
'@type': 'embed_maps',
|
|
42
|
+
with_notes: false,
|
|
43
|
+
with_sources: false,
|
|
44
|
+
with_more_info: true,
|
|
45
|
+
with_share: true,
|
|
46
|
+
with_enlarge: true,
|
|
47
|
+
url: '/path/to/map',
|
|
48
|
+
maps: {
|
|
49
|
+
'@id': '/path/to/map',
|
|
50
|
+
title: 'My map',
|
|
51
|
+
url:
|
|
52
|
+
'https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3027.7835278268726!2d14.38842915203974!3d40.634655679238854!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x133b994881d943cb%3A0x6ab93db57d3272f0!2sHotel+Mediterraneo+Sorrento!5e0!3m2!1sen!2ses!4v1550168740166',
|
|
53
|
+
},
|
|
54
|
+
dataprotection: {
|
|
55
|
+
enabled: false,
|
|
56
|
+
},
|
|
57
|
+
useVisibilitySensor: false,
|
|
58
|
+
}}
|
|
59
|
+
pathname="/news"
|
|
60
|
+
selected={false}
|
|
61
|
+
block="1234"
|
|
62
|
+
index={1}
|
|
63
|
+
onChangeBlock={() => {}}
|
|
64
|
+
onSelectBlock={() => {}}
|
|
65
|
+
onDeleteBlock={() => {}}
|
|
66
|
+
onFocusPreviousBlock={() => {}}
|
|
67
|
+
onFocusNextBlock={() => {}}
|
|
68
|
+
handleKeyDown={() => {}}
|
|
69
|
+
content={{}}
|
|
70
|
+
/>
|
|
71
|
+
</Provider>,
|
|
72
|
+
);
|
|
73
|
+
const json = component.toJSON();
|
|
74
|
+
expect(json).toMatchSnapshot();
|
|
75
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React, { useEffect, useMemo } from 'react';
|
|
2
|
+
import { connect } from 'react-redux';
|
|
3
|
+
import { Message } from 'semantic-ui-react';
|
|
4
|
+
import { getContent } from '@plone/volto/actions';
|
|
5
|
+
import { flattenToAppURL } from '@plone/volto/helpers';
|
|
6
|
+
import EmbedMap from '@eeacms/volto-embed/EmbedMap/EmbedMap';
|
|
7
|
+
import { pickMetadata } from '@eeacms/volto-embed/helpers';
|
|
8
|
+
|
|
9
|
+
function getMaps(props) {
|
|
10
|
+
const content = props.mapsContent || {};
|
|
11
|
+
const maps = content.maps || props.data?.maps || {};
|
|
12
|
+
return {
|
|
13
|
+
...pickMetadata(content),
|
|
14
|
+
...maps,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function View(props) {
|
|
19
|
+
const { id, getContent, mode } = props;
|
|
20
|
+
const {
|
|
21
|
+
useVisibilitySensor = true,
|
|
22
|
+
with_notes = true,
|
|
23
|
+
with_sources = true,
|
|
24
|
+
with_more_info = true,
|
|
25
|
+
with_share = true,
|
|
26
|
+
with_enlarge = true,
|
|
27
|
+
} = props.data;
|
|
28
|
+
|
|
29
|
+
const url = flattenToAppURL(props.data.url || '');
|
|
30
|
+
|
|
31
|
+
const maps = useMemo(() => getMaps(props), [props]);
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const mapsId = maps['@id'] ? flattenToAppURL(maps['@id']) : undefined;
|
|
35
|
+
if (mode === 'edit' && url && url !== mapsId) {
|
|
36
|
+
getContent(url, null, id);
|
|
37
|
+
}
|
|
38
|
+
}, [id, getContent, mode, url, maps]);
|
|
39
|
+
|
|
40
|
+
if (props.mode === 'edit' && !url) {
|
|
41
|
+
return <Message>Please select a map from block editor.</Message>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (!maps) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div className="embed-map">
|
|
50
|
+
<EmbedMap
|
|
51
|
+
data={{
|
|
52
|
+
...maps,
|
|
53
|
+
useVisibilitySensor,
|
|
54
|
+
with_notes,
|
|
55
|
+
with_sources,
|
|
56
|
+
with_more_info,
|
|
57
|
+
with_share,
|
|
58
|
+
with_enlarge,
|
|
59
|
+
}}
|
|
60
|
+
id={props.id}
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default connect(
|
|
67
|
+
(state, props) => ({
|
|
68
|
+
mapsContent: state.content.subrequests?.[props.id]?.data,
|
|
69
|
+
}),
|
|
70
|
+
{ getContent },
|
|
71
|
+
)(View);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer from 'react-test-renderer';
|
|
3
|
+
import configureStore from 'redux-mock-store';
|
|
4
|
+
import { Provider } from 'react-intl-redux';
|
|
5
|
+
import config from '@plone/volto/registry';
|
|
6
|
+
|
|
7
|
+
import View from './View';
|
|
8
|
+
import installEmbedMaps from '.';
|
|
9
|
+
|
|
10
|
+
installEmbedMaps(config);
|
|
11
|
+
|
|
12
|
+
const mockStore = configureStore();
|
|
13
|
+
|
|
14
|
+
jest.mock('@plone/volto/components', () => ({
|
|
15
|
+
__esModule: true,
|
|
16
|
+
UniversalLink: ({ children, href }) => {
|
|
17
|
+
return <a href={href}>{children}</a>;
|
|
18
|
+
},
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
test('renders a view embed map block component', () => {
|
|
22
|
+
const store = mockStore({
|
|
23
|
+
intl: {
|
|
24
|
+
locale: 'en',
|
|
25
|
+
messages: {},
|
|
26
|
+
},
|
|
27
|
+
content: {
|
|
28
|
+
create: {},
|
|
29
|
+
},
|
|
30
|
+
connected_data_parameters: {},
|
|
31
|
+
});
|
|
32
|
+
const component = renderer.create(
|
|
33
|
+
<Provider store={store}>
|
|
34
|
+
<View
|
|
35
|
+
id="my-map"
|
|
36
|
+
data={{
|
|
37
|
+
'@type': 'embed_maps',
|
|
38
|
+
with_notes: false,
|
|
39
|
+
with_sources: false,
|
|
40
|
+
with_more_info: true,
|
|
41
|
+
with_share: true,
|
|
42
|
+
with_enlarge: true,
|
|
43
|
+
url: '/path/to/map',
|
|
44
|
+
maps: {
|
|
45
|
+
'@id': '/path/to/map',
|
|
46
|
+
title: 'My map',
|
|
47
|
+
url:
|
|
48
|
+
'https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3027.7835278268726!2d14.38842915203974!3d40.634655679238854!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x133b994881d943cb%3A0x6ab93db57d3272f0!2sHotel+Mediterraneo+Sorrento!5e0!3m2!1sen!2ses!4v1550168740166',
|
|
49
|
+
},
|
|
50
|
+
dataprotection: {
|
|
51
|
+
enabled: false,
|
|
52
|
+
},
|
|
53
|
+
useVisibilitySensor: false,
|
|
54
|
+
}}
|
|
55
|
+
/>
|
|
56
|
+
</Provider>,
|
|
57
|
+
);
|
|
58
|
+
const json = component.toJSON();
|
|
59
|
+
expect(json).toMatchSnapshot();
|
|
60
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import EmbedMap from './Edit';
|
|
2
|
+
import EmbedView from './View';
|
|
3
|
+
|
|
4
|
+
import sliderSVG from '@plone/volto/icons/slider.svg';
|
|
5
|
+
|
|
6
|
+
const applyConfig = (config) => {
|
|
7
|
+
config.blocks.blocksConfig.embed_maps = {
|
|
8
|
+
id: 'embed_maps',
|
|
9
|
+
title: 'Embed Map',
|
|
10
|
+
icon: sliderSVG,
|
|
11
|
+
group: 'common',
|
|
12
|
+
edit: EmbedMap,
|
|
13
|
+
view: EmbedView,
|
|
14
|
+
restricted: false,
|
|
15
|
+
mostUsed: false,
|
|
16
|
+
sidebarTab: 1,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return config;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default applyConfig;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export default () => {
|
|
2
|
+
return {
|
|
3
|
+
title: 'Embed Map',
|
|
4
|
+
fieldsets: [
|
|
5
|
+
{
|
|
6
|
+
id: 'default',
|
|
7
|
+
title: 'Default',
|
|
8
|
+
fields: ['url'],
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
id: 'toolbar',
|
|
12
|
+
title: 'Toolbar',
|
|
13
|
+
fields: [
|
|
14
|
+
'with_notes',
|
|
15
|
+
'with_sources',
|
|
16
|
+
'with_more_info',
|
|
17
|
+
'with_share',
|
|
18
|
+
'with_enlarge',
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
properties: {
|
|
23
|
+
url: {
|
|
24
|
+
title: 'Map url',
|
|
25
|
+
widget: 'url',
|
|
26
|
+
},
|
|
27
|
+
with_notes: {
|
|
28
|
+
title: 'Show note',
|
|
29
|
+
type: 'boolean',
|
|
30
|
+
defaultValue: true,
|
|
31
|
+
},
|
|
32
|
+
with_sources: {
|
|
33
|
+
title: 'Show sources',
|
|
34
|
+
description: 'Will show sources set in this page Data provenance',
|
|
35
|
+
type: 'boolean',
|
|
36
|
+
defaultValue: true,
|
|
37
|
+
},
|
|
38
|
+
with_more_info: {
|
|
39
|
+
title: 'Show more info',
|
|
40
|
+
type: 'boolean',
|
|
41
|
+
defaultValue: true,
|
|
42
|
+
},
|
|
43
|
+
with_enlarge: {
|
|
44
|
+
title: 'Show enlarge button',
|
|
45
|
+
type: 'boolean',
|
|
46
|
+
defaultValue: true,
|
|
47
|
+
},
|
|
48
|
+
with_share: {
|
|
49
|
+
title: 'Show share button',
|
|
50
|
+
type: 'boolean',
|
|
51
|
+
defaultValue: true,
|
|
52
|
+
},
|
|
53
|
+
tableau_height: {
|
|
54
|
+
title: 'Height',
|
|
55
|
+
type: 'text',
|
|
56
|
+
defaultValue: '700',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
required: ['tableau_vis_url'],
|
|
61
|
+
};
|
|
62
|
+
};
|
package/src/Blocks/Maps/Edit.jsx
CHANGED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer from 'react-test-renderer';
|
|
3
|
+
import configureStore from 'redux-mock-store';
|
|
4
|
+
import { Provider } from 'react-intl-redux';
|
|
5
|
+
import config from '@plone/volto/registry';
|
|
6
|
+
|
|
7
|
+
import Edit from './Edit';
|
|
8
|
+
|
|
9
|
+
const mockStore = configureStore();
|
|
10
|
+
|
|
11
|
+
jest.mock('@plone/volto/components', () => ({
|
|
12
|
+
__esModule: true,
|
|
13
|
+
SidebarPortal: jest.requireActual(
|
|
14
|
+
'@plone/volto/components/manage/Sidebar/SidebarPortal',
|
|
15
|
+
).default,
|
|
16
|
+
UniversalLink: ({ children, href }) => {
|
|
17
|
+
return <a href={href}>{children}</a>;
|
|
18
|
+
},
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
const store = mockStore({
|
|
22
|
+
intl: {
|
|
23
|
+
locale: 'en',
|
|
24
|
+
messages: {},
|
|
25
|
+
},
|
|
26
|
+
content: {
|
|
27
|
+
create: {},
|
|
28
|
+
},
|
|
29
|
+
connected_data_parameters: {},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
config.blocks.blocksConfig = {
|
|
33
|
+
...config.blocks.blocksConfig,
|
|
34
|
+
maps: {
|
|
35
|
+
id: 'maps',
|
|
36
|
+
title: 'Maps',
|
|
37
|
+
group: 'media',
|
|
38
|
+
extensions: {},
|
|
39
|
+
variations: [],
|
|
40
|
+
restricted: false,
|
|
41
|
+
mostUsed: true,
|
|
42
|
+
sidebarTab: 1,
|
|
43
|
+
security: {
|
|
44
|
+
addPermission: [],
|
|
45
|
+
view: [],
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
test('renders an edit map block component', () => {
|
|
51
|
+
const component = renderer.create(
|
|
52
|
+
<Provider store={store}>
|
|
53
|
+
<Edit
|
|
54
|
+
data={{
|
|
55
|
+
'@type': 'maps',
|
|
56
|
+
url:
|
|
57
|
+
'https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3027.7835278268726!2d14.38842915203974!3d40.634655679238854!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x133b994881d943cb%3A0x6ab93db57d3272f0!2sHotel+Mediterraneo+Sorrento!5e0!3m2!1sen!2ses!4v1550168740166',
|
|
58
|
+
dataprotection: {
|
|
59
|
+
enabled: false,
|
|
60
|
+
},
|
|
61
|
+
useVisibilitySensor: false,
|
|
62
|
+
}}
|
|
63
|
+
pathname="/news"
|
|
64
|
+
selected={false}
|
|
65
|
+
block="1234"
|
|
66
|
+
index={1}
|
|
67
|
+
onChangeBlock={() => {}}
|
|
68
|
+
onSelectBlock={() => {}}
|
|
69
|
+
onDeleteBlock={() => {}}
|
|
70
|
+
onFocusPreviousBlock={() => {}}
|
|
71
|
+
onFocusNextBlock={() => {}}
|
|
72
|
+
handleKeyDown={() => {}}
|
|
73
|
+
content={{}}
|
|
74
|
+
/>
|
|
75
|
+
</Provider>,
|
|
76
|
+
);
|
|
77
|
+
const json = component.toJSON();
|
|
78
|
+
expect(json).toMatchSnapshot();
|
|
79
|
+
});
|
package/src/Blocks/Maps/View.jsx
CHANGED
|
@@ -40,7 +40,11 @@ const View = ({ data, intl, id }) => {
|
|
|
40
40
|
'full-width': data.align === 'full',
|
|
41
41
|
})}
|
|
42
42
|
>
|
|
43
|
-
<PrivacyProtection
|
|
43
|
+
<PrivacyProtection
|
|
44
|
+
data={data}
|
|
45
|
+
id={id}
|
|
46
|
+
useVisibilitySensor={data.useVisibilitySensor}
|
|
47
|
+
>
|
|
44
48
|
<iframe
|
|
45
49
|
title={intl.formatMessage(messages.EmbededGoogleMaps)}
|
|
46
50
|
src={data.url}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderer from 'react-test-renderer';
|
|
3
|
+
import configureStore from 'redux-mock-store';
|
|
4
|
+
import { Provider } from 'react-intl-redux';
|
|
5
|
+
import config from '@plone/volto/registry';
|
|
6
|
+
|
|
7
|
+
import View from './View';
|
|
8
|
+
import installEmbedMaps from '.';
|
|
9
|
+
|
|
10
|
+
installEmbedMaps(config);
|
|
11
|
+
|
|
12
|
+
const mockStore = configureStore();
|
|
13
|
+
|
|
14
|
+
jest.mock('@plone/volto/components', () => ({
|
|
15
|
+
__esModule: true,
|
|
16
|
+
UniversalLink: ({ children, href }) => {
|
|
17
|
+
return <a href={href}>{children}</a>;
|
|
18
|
+
},
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
config.blocks.blocksConfig = {
|
|
22
|
+
...config.blocks.blocksConfig,
|
|
23
|
+
maps: {
|
|
24
|
+
id: 'maps',
|
|
25
|
+
title: 'Maps',
|
|
26
|
+
group: 'media',
|
|
27
|
+
extensions: {},
|
|
28
|
+
variations: [],
|
|
29
|
+
restricted: false,
|
|
30
|
+
mostUsed: true,
|
|
31
|
+
sidebarTab: 1,
|
|
32
|
+
security: {
|
|
33
|
+
addPermission: [],
|
|
34
|
+
view: [],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
test('renders a view map block component', () => {
|
|
40
|
+
const store = mockStore({
|
|
41
|
+
intl: {
|
|
42
|
+
locale: 'en',
|
|
43
|
+
messages: {},
|
|
44
|
+
},
|
|
45
|
+
content: {
|
|
46
|
+
create: {},
|
|
47
|
+
},
|
|
48
|
+
connected_data_parameters: {},
|
|
49
|
+
});
|
|
50
|
+
const component = renderer.create(
|
|
51
|
+
<Provider store={store}>
|
|
52
|
+
<View
|
|
53
|
+
data={{
|
|
54
|
+
'@type': 'maps',
|
|
55
|
+
url:
|
|
56
|
+
'https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3027.7835278268726!2d14.38842915203974!3d40.634655679238854!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x133b994881d943cb%3A0x6ab93db57d3272f0!2sHotel+Mediterraneo+Sorrento!5e0!3m2!1sen!2ses!4v1550168740166',
|
|
57
|
+
useVisibilitySensor: false,
|
|
58
|
+
dataprotection: {
|
|
59
|
+
enabled: false,
|
|
60
|
+
},
|
|
61
|
+
}}
|
|
62
|
+
/>
|
|
63
|
+
</Provider>,
|
|
64
|
+
);
|
|
65
|
+
const json = component.toJSON();
|
|
66
|
+
expect(json).toMatchSnapshot();
|
|
67
|
+
});
|