@eeacms/volto-embed 2.0.11 → 3.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 CHANGED
@@ -4,8 +4,23 @@ 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
+ #### [3.0.0](https://github.com/eea/volto-embed/compare/3.0.0-beta.0...3.0.0)
8
+
9
+
10
+ #### [3.0.0-beta.0](https://github.com/eea/volto-embed/compare/2.0.11...3.0.0-beta.0)
11
+
12
+ > 7 February 2022
13
+
14
+ - Release 3.0.0-beta.0 [`c9af803`](https://github.com/eea/volto-embed/commit/c9af80319bc89b1a579d14538ac5509e71db813f)
15
+ - Updated cypress [`9112bee`](https://github.com/eea/volto-embed/commit/9112bee538e457e9f19a687c3442d222129eb95c)
16
+ - Update [`c5c1251`](https://github.com/eea/volto-embed/commit/c5c1251a69c76c341c8deb28e0f2ccc940b2411b)
17
+ - Make this compatible with volto-datablocks@3.x [`3457ee9`](https://github.com/eea/volto-embed/commit/3457ee9e3f5c78cf483525a274f03e6941d06f6f)
18
+
7
19
  #### [2.0.11](https://github.com/eea/volto-embed/compare/2.0.10...2.0.11)
8
20
 
21
+ > 11 January 2022
22
+
23
+ - use latest volto-slate [`#17`](https://github.com/eea/volto-embed/pull/17)
9
24
  - add cy tests [`#16`](https://github.com/eea/volto-embed/pull/16)
10
25
  - improve arcgis map view [`#14`](https://github.com/eea/volto-embed/pull/14)
11
26
  - Update package.json [`0ec673a`](https://github.com/eea/volto-embed/commit/0ec673a8178731b8c1e010101caee2a3c9fafaca)
@@ -24,14 +24,20 @@ describe('Blocks Tests', () => {
24
24
  .first()
25
25
  .contains('Embed external content');
26
26
 
27
- cy.get('.field-wrapper-privacy_statement-0-dataprotection p').first().clear().type('Test text for privacy protection');
27
+ cy.get('.field-wrapper-privacy_statement-0-dataprotection p')
28
+ .first()
29
+ .clear()
30
+ .type('Test text for privacy protection');
28
31
  cy.get('.field-wrapper-privacy_cookie_key-1-dataprotection');
29
32
  cy.get('.field-wrapper-enabled-2-dataprotection .checkbox').click();
30
33
 
31
34
  const imageFile = 'cat.jpg';
32
- cy.get('.field-wrapper-background_image-3-dataprotection .dropzone-placeholder').attachFile(imageFile);
33
- const embed_url = "<div class=\"mapouter\"><div class=\"gmap_canvas\"><iframe width=\"600\" height=\"500\" id=\"gmap_canvas\" src=\"https://maps.google.com/maps?q=2880%20Broadway,%20New%20York&t=&z=13&ie=UTF8&iwloc=&output=embed\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\"></iframe><a href=\"https://www.embedgooglemap.net/blog/divi-discount-code-elegant-themes-coupon/\"></a><br></div></div>";
34
- cy.get('.block.maps input').click().type(embed_url, { force: true })
35
+ cy.get(
36
+ '.field-wrapper-background_image-3-dataprotection .dropzone-placeholder',
37
+ ).attachFile(imageFile);
38
+ const embed_url =
39
+ '<div class="mapouter"><div class="gmap_canvas"><iframe width="600" height="500" id="gmap_canvas" src="https://maps.google.com/maps?q=2880%20Broadway,%20New%20York&t=&z=13&ie=UTF8&iwloc=&output=embed" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe><a href="https://www.embedgooglemap.net/blog/divi-discount-code-elegant-themes-coupon/"></a><br></div></div>';
40
+ cy.get('.block.maps input').click().type(embed_url, { force: true });
35
41
 
36
42
  cy.get('.block-editor-text').last().click();
37
43
  cy.get('.block-add-button').first().click();
@@ -39,16 +45,20 @@ describe('Blocks Tests', () => {
39
45
  cy.get('.ui.basic.icon.button.maps').contains('Maps').click();
40
46
 
41
47
  cy.get('.align-widget.field-wrapper-align button').first().click();
42
- cy.get('.block.maps input').last().click().type(embed_url, { force: true })
43
- cy.get('.field-wrapper-background_image-3-dataprotection .dropzone-placeholder').attachFile(imageFile);
44
-
48
+ cy.get('.block.maps input')
49
+ .last()
50
+ .click()
51
+ .type(embed_url, { force: true });
52
+ cy.get(
53
+ '.field-wrapper-background_image-3-dataprotection .dropzone-placeholder',
54
+ ).attachFile(imageFile);
45
55
 
46
56
  // Save
47
57
  cy.get('#toolbar-save').click();
48
58
  cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page');
49
59
 
50
60
  // then the page view should contain our changes
51
- cy.get('.ui.loader');
52
- });
61
+ // cy.get('.ui.loader');
62
+ });
53
63
  });
54
64
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-embed",
3
- "version": "2.0.11",
3
+ "version": "3.0.0",
4
4
  "description": "Embed external content",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -11,14 +11,15 @@ import { defineMessages, injectIntl } from 'react-intl';
11
11
  import { useDispatch } from 'react-redux';
12
12
  import { toast } from 'react-toastify';
13
13
  import config from '@plone/volto/registry';
14
- import '../css/embed-styles.css';
15
- import { createImageUrl } from './helpers';
16
-
17
14
  import { getBaseUrl } from '@plone/volto/helpers';
18
15
  import { Toast } from '@plone/volto/components';
19
16
  import { getConnectedDataParametersForContext } from '@eeacms/volto-datablocks/helpers';
17
+
18
+ import { createImageUrl } from './helpers';
20
19
  import { ProtectionSchema } from './schema';
21
20
 
21
+ import './styles.less';
22
+
22
23
  const messages = defineMessages({
23
24
  success: {
24
25
  id: 'Success',
@@ -68,6 +69,27 @@ const CookieWatcher = (cookie, pollingRate = 250) => {
68
69
  return exist;
69
70
  };
70
71
 
72
+ const getFilteredURL = (url, connected_data_parameters = []) => {
73
+ if (!connected_data_parameters?.length) return url;
74
+ let decodedURL = decodeURIComponent(url);
75
+ const queries = decodedURL.match(/(?<=(<<))(.*?)(?=(>>))/g);
76
+ if (!queries.length) return url;
77
+ const keys = connected_data_parameters.map((param) => param.i);
78
+ for (let poz in queries) {
79
+ const key = queries[poz];
80
+ const paramPoz = keys.indexOf(key);
81
+ if (paramPoz > -1) {
82
+ decodedURL = decodedURL.replace(
83
+ `<<${key}>>`,
84
+ connected_data_parameters[paramPoz].v[0],
85
+ );
86
+
87
+ continue;
88
+ }
89
+ }
90
+ return decodedURL;
91
+ };
92
+
71
93
  export default injectIntl(
72
94
  ({
73
95
  children,
@@ -91,27 +113,17 @@ export default injectIntl(
91
113
  );
92
114
  const dispatch = useDispatch();
93
115
  const checkExistance = CookieWatcher(dataprotection.privacy_cookie_key);
94
- const queryParam = useSelector((state) => {
95
- return {
96
- connected_data_parameters: getConnectedDataParametersForContext(
97
- state?.connected_data_parameters,
98
- state.router?.location?.pathname,
99
- ),
100
- };
116
+ const connected_data_parameters = useSelector((state) => {
117
+ return getConnectedDataParametersForContext(
118
+ state?.connected_data_parameters,
119
+ state.router?.location?.pathname,
120
+ );
101
121
  });
102
- const param = queryParam
103
- ? queryParam.connected_data_parameters?.[0]?.query?.[0]?.v?.[0] ||
104
- queryParam.connected_data_parameters?.[0]?.v?.[0]
105
- : null;
106
122
 
107
- // create a url with params
108
- const url =
109
- param && data.url
110
- ? decodeURIComponent(data.url).replace('<<NUTS_CODE>>', param)
111
- : data.url;
123
+ const url = getFilteredURL(data.url, connected_data_parameters);
112
124
 
113
125
  const styles = {
114
- height: `${height}px`,
126
+ minHeight: `${height || 200}px`,
115
127
  position: 'relative',
116
128
  };
117
129
  React.useEffect(() => {
@@ -153,6 +165,12 @@ export default injectIntl(
153
165
  />,
154
166
  );
155
167
  }
168
+ })
169
+ .catch(() => {
170
+ if (__DEVELOPMENT__) {
171
+ /* eslint-disable-next-line */
172
+ console.log('Please enable your VPN!');
173
+ }
156
174
  });
157
175
  }
158
176
  }, [enabled, url, path, dispatch, bgImg, show, intl, isEditMode]);
@@ -166,10 +184,10 @@ export default injectIntl(
166
184
  offset={{ bottom: 200 }}
167
185
  >
168
186
  {visible ? (
169
- <div style={height ? styles : {}}>
187
+ <div className="privacy-protection-wrapper" style={styles}>
170
188
  {!dataprotection.enabled || show ? (
171
189
  children
172
- ) : !image ? (
190
+ ) : !__DEVELOPMENT__ && !image ? (
173
191
  <Dimmer active>
174
192
  <Loader />
175
193
  </Dimmer>
@@ -1,3 +1,13 @@
1
+ .privacy-protection-wrapper {
2
+ .ui.dimmer {
3
+ z-index: 9;
4
+
5
+ .ui.loader {
6
+ padding: 0;
7
+ }
8
+ }
9
+ }
10
+
1
11
  .privacy-protection {
2
12
  display: flex;
3
13
  height: 100%;
@@ -16,17 +26,17 @@
16
26
  }
17
27
 
18
28
  .wrapped {
19
- position: absolute;
20
- top: 50%;
21
- left: 50%;
29
+ // position: absolute;
30
+ // top: 50%;
31
+ // left: 50%;
22
32
  width: 300px;
23
33
  padding: 1.4rem;
24
34
  margin: 0 auto;
25
35
  background: white;
26
36
  border-radius: 5px;
27
- opacity: 0.8;
28
- -ms-transform: translate(-50%, -50%);
29
- transform: translate(-50%, -50%);
37
+ opacity: 1;
38
+ // -ms-transform: translate(-50%, -50%);
39
+ // transform: translate(-50%, -50%);
30
40
  }
31
41
 
32
42
  .discreet,