@eeacms/volto-embed 8.0.0 → 9.0.1
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 -3
- package/locales/de/LC_MESSAGES/volto.po +7 -40
- package/locales/en/LC_MESSAGES/volto.po +7 -40
- package/locales/it/LC_MESSAGES/volto.po +7 -40
- package/locales/ro/LC_MESSAGES/volto.po +7 -40
- package/locales/volto.pot +8 -41
- package/package.json +2 -3
- package/src/Blocks/EmbedMaps/Edit.test.js +75 -0
- package/src/Blocks/EmbedMaps/View.jsx +22 -27
- package/src/Blocks/EmbedMaps/View.test.js +60 -0
- package/src/Blocks/EmbedMaps/index.js +3 -3
- 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/{Map/Map.jsx → EmbedMap/EmbedMap.jsx} +15 -6
- package/src/EmbedMap/EmbedMap.test.js +66 -0
- package/src/PrivacyProtection/PrivacyProtection.jsx +2 -0
- package/src/Toolbar/FigureNote.jsx +2 -3
- package/src/Toolbar/Toolbar.test.js +96 -0
- package/src/Views/MapView.jsx +17 -3
- package/src/Views/MapView.test.js +68 -0
- package/src/Widgets/MapsViewWidget.jsx +18 -3
- package/src/Widgets/MapsWidget.jsx +3 -3
- package/src/helpers.js +16 -0
- package/src/Blocks/Maps/Edit.test.jsx +0 -119
- /package/src/{Map → EmbedMap}/style.less +0 -0
|
@@ -1,5 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { connect } from 'react-redux';
|
|
2
|
+
import { pickMetadata } from '@eeacms/volto-embed/helpers';
|
|
3
|
+
import EmbedMap from '@eeacms/volto-embed/EmbedMap/EmbedMap';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
return
|
|
5
|
+
function MapsViewWidget({ id, value, content }) {
|
|
6
|
+
return (
|
|
7
|
+
<EmbedMap
|
|
8
|
+
data={{
|
|
9
|
+
...(value || {}),
|
|
10
|
+
...pickMetadata(content),
|
|
11
|
+
with_share: true,
|
|
12
|
+
}}
|
|
13
|
+
id={id}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
5
16
|
}
|
|
17
|
+
|
|
18
|
+
export default connect((state) => ({ content: state.content.data }))(
|
|
19
|
+
MapsViewWidget,
|
|
20
|
+
);
|
|
@@ -5,7 +5,7 @@ import { Button, Modal, Grid, Label, Input, Message } from 'semantic-ui-react';
|
|
|
5
5
|
import { map } from 'lodash';
|
|
6
6
|
import { FormFieldWrapper, InlineForm } from '@plone/volto/components';
|
|
7
7
|
import { addPrivacyProtectionToSchema } from '@eeacms/volto-embed';
|
|
8
|
-
import
|
|
8
|
+
import EmbedMap from '@eeacms/volto-embed/EmbedMap/EmbedMap';
|
|
9
9
|
import { MapsSchema } from '@eeacms/volto-embed/Blocks/Maps/schema';
|
|
10
10
|
|
|
11
11
|
import clearSVG from '@plone/volto/icons/clear.svg';
|
|
@@ -103,7 +103,7 @@ function MapEditorModal({ id, onClose, onChange, ...rest }) {
|
|
|
103
103
|
computer={8}
|
|
104
104
|
className="tableau-visualization-column"
|
|
105
105
|
>
|
|
106
|
-
<
|
|
106
|
+
<EmbedMap data={value} id={id} />
|
|
107
107
|
</Grid.Column>
|
|
108
108
|
</Grid>
|
|
109
109
|
)}
|
|
@@ -204,7 +204,7 @@ export default function MapsWidget(props) {
|
|
|
204
204
|
</Button>
|
|
205
205
|
</div>
|
|
206
206
|
{description && <p className="help">{description}</p>}
|
|
207
|
-
{value.url && <
|
|
207
|
+
{value.url && <EmbedMap {...props} data={value} />}
|
|
208
208
|
{mapEditor && (
|
|
209
209
|
<MapEditorModal
|
|
210
210
|
id={id}
|
package/src/helpers.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { pick } from 'lodash';
|
|
2
|
+
|
|
3
|
+
export function pickMetadata(content) {
|
|
4
|
+
return {
|
|
5
|
+
...pick(content, [
|
|
6
|
+
'@id',
|
|
7
|
+
'title',
|
|
8
|
+
'data_provenance',
|
|
9
|
+
'figure_note',
|
|
10
|
+
'other_organisations',
|
|
11
|
+
'temporan_coverage',
|
|
12
|
+
'publisher',
|
|
13
|
+
'geo_coverage',
|
|
14
|
+
]),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-unused-vars */
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import config from '@plone/volto/registry';
|
|
4
|
-
import { render, fireEvent, screen } from '@testing-library/react';
|
|
5
|
-
import { Provider } from 'react-intl-redux';
|
|
6
|
-
import configureStore from 'redux-mock-store';
|
|
7
|
-
import Edit from './Edit';
|
|
8
|
-
import '@testing-library/jest-dom/extend-expect';
|
|
9
|
-
|
|
10
|
-
const mockStore = configureStore();
|
|
11
|
-
|
|
12
|
-
const store = mockStore(() => ({
|
|
13
|
-
connected_data_parameters: {},
|
|
14
|
-
router: {
|
|
15
|
-
location: {
|
|
16
|
-
pathname: '',
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
intl: {
|
|
20
|
-
locale: 'en',
|
|
21
|
-
messages: {},
|
|
22
|
-
},
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
config.blocks.blocksConfig = {
|
|
26
|
-
...config.blocks.blocksConfig,
|
|
27
|
-
maps: {
|
|
28
|
-
id: 'maps',
|
|
29
|
-
title: 'Maps',
|
|
30
|
-
group: 'media',
|
|
31
|
-
extensions: {},
|
|
32
|
-
variations: [],
|
|
33
|
-
restricted: false,
|
|
34
|
-
mostUsed: true,
|
|
35
|
-
sidebarTab: 1,
|
|
36
|
-
security: {
|
|
37
|
-
addPermission: [],
|
|
38
|
-
view: [],
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
jest.mock(
|
|
44
|
-
'@eeacms/volto-embed/PrivacyProtection/PrivacyProtection',
|
|
45
|
-
() => ({ children }) => children,
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
describe('Edit', () => {
|
|
49
|
-
it('renders without crashing', () => {
|
|
50
|
-
render(
|
|
51
|
-
<Provider store={store}>
|
|
52
|
-
<Edit
|
|
53
|
-
selected={false}
|
|
54
|
-
block="block"
|
|
55
|
-
index={1}
|
|
56
|
-
data={{
|
|
57
|
-
'@type': 'maps',
|
|
58
|
-
url:
|
|
59
|
-
'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',
|
|
60
|
-
}}
|
|
61
|
-
pathname="/"
|
|
62
|
-
onChangeBlock={() => {}}
|
|
63
|
-
onSelectBlock={() => {}}
|
|
64
|
-
onDeleteBlock={() => {}}
|
|
65
|
-
onFocusPreviousBlock={() => {}}
|
|
66
|
-
onFocusNextBlock={() => {}}
|
|
67
|
-
handleKeyDown={() => {}}
|
|
68
|
-
/>
|
|
69
|
-
</Provider>,
|
|
70
|
-
);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('submits url when button is clicked', async () => {
|
|
74
|
-
const url =
|
|
75
|
-
'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';
|
|
76
|
-
|
|
77
|
-
const { container, getByPlaceholderText } = render(
|
|
78
|
-
<Provider store={store}>
|
|
79
|
-
<Edit
|
|
80
|
-
selected={false}
|
|
81
|
-
block="block"
|
|
82
|
-
index={1}
|
|
83
|
-
data={{
|
|
84
|
-
'@type': 'maps',
|
|
85
|
-
dataprotection: {
|
|
86
|
-
privacy_statement: 'test',
|
|
87
|
-
},
|
|
88
|
-
}}
|
|
89
|
-
pathname="/"
|
|
90
|
-
onChangeBlock={() => {}}
|
|
91
|
-
onSelectBlock={() => {}}
|
|
92
|
-
onDeleteBlock={() => {}}
|
|
93
|
-
onFocusPreviousBlock={() => {}}
|
|
94
|
-
onFocusNextBlock={() => {}}
|
|
95
|
-
handleKeyDown={() => {}}
|
|
96
|
-
/>
|
|
97
|
-
</Provider>,
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
const input = getByPlaceholderText('Enter map Embed Code');
|
|
101
|
-
|
|
102
|
-
fireEvent.click(input);
|
|
103
|
-
fireEvent.change(input, { target: { value: url } });
|
|
104
|
-
// screen.debug();
|
|
105
|
-
// expect(input.value).toBe(url);
|
|
106
|
-
|
|
107
|
-
// fireEvent.click(container.querySelector('button.cancel'));
|
|
108
|
-
|
|
109
|
-
// fireEvent.keyDown(input, { key: 'Enter', code: 'Enter' });
|
|
110
|
-
// fireEvent.keyDown(input, { key: 'Escape', code: 'Escape' });
|
|
111
|
-
// fireEvent.keyDown(input, { key: 'KeyA', code: 'KeyA' });
|
|
112
|
-
|
|
113
|
-
// fireEvent.change(input, { target: { value: '<iframe src="test"/>' } });
|
|
114
|
-
// fireEvent.keyDown(input, { key: 'Enter', code: 'Enter' });
|
|
115
|
-
|
|
116
|
-
// const button = container.querySelector('button.ui.basic.primary.button');
|
|
117
|
-
// fireEvent.click(button);
|
|
118
|
-
});
|
|
119
|
-
});
|
|
File without changes
|