@eeacms/volto-flourish 0.1.2 → 0.1.3

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,6 +4,24 @@ 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.1.3](https://github.com/eea/volto-flourish/compare/0.1.2...0.1.3) - 13 February 2025
8
+
9
+ #### :bug: Bug Fixes
10
+
11
+ - fix: remove unused field from schema - refs #273385 [kreafox - [`8f475ef`](https://github.com/eea/volto-flourish/commit/8f475ef512089960e4207d277393803458bed5a4)]
12
+
13
+ #### :hammer_and_wrench: Others
14
+
15
+ - test: increase coverage [kreafox - [`830d81a`](https://github.com/eea/volto-flourish/commit/830d81ae67286d65b1ba80d3c190b21af18340e9)]
16
+ - test: increase coverage [kreafox - [`4b72dd7`](https://github.com/eea/volto-flourish/commit/4b72dd75e4d4cdf8270f76fa15357800fbdee36e)]
17
+ - test: increase coverage [kreafox - [`bf01b2c`](https://github.com/eea/volto-flourish/commit/bf01b2c280f699f620f1c8ee71b11921c9da7e55)]
18
+ - test: increase coverage [kreafox - [`18b4b24`](https://github.com/eea/volto-flourish/commit/18b4b24fa5758f797ef16dbf8f801dbdf7e941da)]
19
+ - Embed [Tiberiu Ichim - [`65a99d6`](https://github.com/eea/volto-flourish/commit/65a99d6a3cbf69a33e0b3a485a92afc53a2835b8)]
20
+ - Embed [Tiberiu Ichim - [`0bd365b`](https://github.com/eea/volto-flourish/commit/0bd365b91802227f921b3d7127a2722f56d33e97)]
21
+ - Embed [Tiberiu Ichim - [`1bc7ee6`](https://github.com/eea/volto-flourish/commit/1bc7ee667a6168a15f50a51b2263e216ffbecc52)]
22
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`9c0d692`](https://github.com/eea/volto-flourish/commit/9c0d692ee158e264bc33fe7d05eafcee1ccb6066)]
23
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`aae3813`](https://github.com/eea/volto-flourish/commit/aae3813cf0f792b7cdaedb9f7b4ebc9d4bb6cd53)]
24
+ - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`5ca27c2`](https://github.com/eea/volto-flourish/commit/5ca27c29e49291471d6cd2585922c39e87d46a84)]
7
25
  ### [0.1.2](https://github.com/eea/volto-flourish/compare/0.1.1...0.1.2) - 16 September 2024
8
26
 
9
27
  #### :house: Internal changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-flourish",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "@eeacms/volto-flourish: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import { MemoryRouter } from 'react-router-dom';
3
+ import configureStore from 'redux-mock-store';
4
+ import { render } from '@testing-library/react';
5
+ import '@testing-library/jest-dom/extend-expect';
6
+ import { Provider } from 'react-intl-redux';
7
+ import Edit from './Edit';
8
+
9
+ const mockStore = configureStore();
10
+
11
+ describe('Edit', () => {
12
+ it('should render the component with correct mode and child components', () => {
13
+ const data = {
14
+ with_sources: false,
15
+ with_notes: false,
16
+ with_share: false,
17
+ with_enlarge: false,
18
+ with_more_info: false,
19
+ flourish_item_url: undefined,
20
+ };
21
+
22
+ const block = { blockId: '1' };
23
+ const selected = false;
24
+ const onChangeBlock = jest.fn();
25
+
26
+ const store = mockStore({
27
+ userSession: { token: '1234' },
28
+ intl: {
29
+ locale: 'en',
30
+ messages: {},
31
+ },
32
+ });
33
+
34
+ const { container } = render(
35
+ <Provider store={store}>
36
+ <MemoryRouter>
37
+ <Edit
38
+ block={block}
39
+ data={data}
40
+ selected={selected}
41
+ onChangeBlock={onChangeBlock}
42
+ />
43
+ </MemoryRouter>
44
+ </Provider>,
45
+ );
46
+
47
+ expect(container.querySelector('.embed-flourish')).toBeInTheDocument();
48
+ });
49
+ });
@@ -2,6 +2,7 @@ import { useEffect } from 'react';
2
2
  import { useSelector, useDispatch } from 'react-redux';
3
3
  import { getContent } from '@plone/volto/actions';
4
4
  import { flattenToAppURL } from '@plone/volto/helpers';
5
+ import { default as Flourish } from '@eeacms/volto-flourish/components/Flourish';
5
6
  // import { Sources } from '@eeacms/volto-embed/Toolbar';
6
7
 
7
8
  import {
@@ -23,10 +24,9 @@ export default function View(props) {
23
24
  with_enlarge,
24
25
  with_more_info,
25
26
  flourish_item_url,
26
- flourish_iframe_height = '600px',
27
+ // flourish_iframe_height = '600px',
27
28
  } = data;
28
29
 
29
- const flourish_url = flourish_item_url + '/@@flourish/index.html';
30
30
  const vis_url = flattenToAppURL(flourish_item_url || '');
31
31
  const dispatch = useDispatch();
32
32
 
@@ -45,15 +45,7 @@ export default function View(props) {
45
45
  <div className="embed-flourish">
46
46
  {flourish_item_url ? (
47
47
  <div>
48
- <iframe
49
- src={flourish_url}
50
- width="100%"
51
- title={flourishItemContent?.title}
52
- style={{
53
- border: '0px',
54
- height: flourish_iframe_height,
55
- }}
56
- ></iframe>
48
+ <Flourish baseUrl={flourish_item_url} />
57
49
  {flourishItemContent && (
58
50
  <div className="visualization-toolbar">
59
51
  <div className="left-col">
@@ -1,15 +1,14 @@
1
- import { defineMessages } from 'react-intl';
2
-
3
- const messages = defineMessages({
4
- CSSHeight: {
5
- id: 'CSS height',
6
- defaultMessage: 'CSS height',
7
- },
8
- CSSFlourishHeightDescription: {
9
- id: 'Iframe height',
10
- defaultMessage: 'Flourish iframe height',
11
- },
12
- });
1
+ // import { defineMessages } from 'react-intl';
2
+ // const messages = defineMessages({
3
+ // CSSHeight: {
4
+ // id: 'CSS height',
5
+ // defaultMessage: 'CSS height',
6
+ // },
7
+ // CSSFlourishHeightDescription: {
8
+ // id: 'Iframe height',
9
+ // defaultMessage: 'Flourish iframe height',
10
+ // },
11
+ // });
13
12
 
14
13
  const schema = (props) => {
15
14
  return {
@@ -19,9 +18,8 @@ const schema = (props) => {
19
18
  id: 'default',
20
19
  title: 'Default',
21
20
  fields: [
22
- 'flourish_test_url',
23
21
  'flourish_item_url',
24
- 'flourish_iframe_height',
22
+ // 'flourish_iframe_height',
25
23
  ],
26
24
  },
27
25
  {
@@ -47,21 +45,21 @@ const schema = (props) => {
47
45
  </div>
48
46
  ),
49
47
  },
50
- flourish_iframe_height: {
51
- title: (
52
- <a
53
- rel="noopener noreferrer"
54
- target="_blank"
55
- href="https://developer.mozilla.org/en-US/docs/Web/CSS/height"
56
- >
57
- {props.intl.formatMessage(messages.CSSHeight)}
58
- </a>
59
- ),
60
- default: '600px',
61
- description: props.intl.formatMessage(
62
- messages.CSSFlourishHeightDescription,
63
- ),
64
- },
48
+ // flourish_iframe_height: {
49
+ // title: (
50
+ // <a
51
+ // rel="noopener noreferrer"
52
+ // target="_blank"
53
+ // href="https://developer.mozilla.org/en-US/docs/Web/CSS/height"
54
+ // >
55
+ // {props.intl.formatMessage(messages.CSSHeight)}
56
+ // </a>
57
+ // ),
58
+ // default: '600px',
59
+ // description: props.intl.formatMessage(
60
+ // messages.CSSFlourishHeightDescription,
61
+ // ),
62
+ // },
65
63
  with_notes: {
66
64
  title: 'Show note',
67
65
  type: 'boolean',
@@ -0,0 +1,30 @@
1
+ import { useEffect, useRef } from 'react';
2
+
3
+ export default function Flourish({ baseUrl }) {
4
+ const containerRef = useRef(null);
5
+ const flourishUrl = `${baseUrl}/@@flourish/index.html`;
6
+ const scriptUrl = `${baseUrl}/@@flourish/flourish.embed.js`;
7
+
8
+ useEffect(() => {
9
+ if (!baseUrl || !containerRef.current) return;
10
+
11
+ const script = document.createElement('script');
12
+ script.src = scriptUrl;
13
+ script.async = true;
14
+ script.onload = () => {};
15
+
16
+ document.body.appendChild(script);
17
+
18
+ return () => {
19
+ document.body.removeChild(script);
20
+ };
21
+ }, [baseUrl, scriptUrl]);
22
+
23
+ return (
24
+ <div
25
+ ref={containerRef}
26
+ className="flourish-embed"
27
+ data-src={flourishUrl}
28
+ ></div>
29
+ );
30
+ }
@@ -0,0 +1,27 @@
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
+
6
+ import Flourish from './Flourish';
7
+
8
+ const mockStore = configureStore();
9
+
10
+ test('Flourish component', () => {
11
+ const store = mockStore({
12
+ intl: {
13
+ locale: 'en',
14
+ messages: {},
15
+ },
16
+ });
17
+ const baseUrl = 'http://example.com';
18
+
19
+ const component = renderer.create(
20
+ <Provider store={store}>
21
+ <Flourish baseUrl={baseUrl} />
22
+ </Provider>,
23
+ );
24
+
25
+ const json = component.toJSON();
26
+ expect(json).toMatchSnapshot();
27
+ });
@@ -1,16 +1,13 @@
1
+ import { default as Flourish } from '@eeacms/volto-flourish/components/Flourish';
2
+
1
3
  const FlourishViewWidget = (props) => {
2
4
  const flourish_url = props.value?.download?.replace(
3
5
  '/@@download/flourish_zip',
4
- '/@@flourish/index.html',
6
+ '/',
5
7
  );
6
8
  return props.value ? (
7
9
  <div className="flourish-view-widget">
8
- <iframe
9
- src={flourish_url}
10
- height="100%"
11
- width="100%"
12
- title="Flourish Widget"
13
- ></iframe>
10
+ <Flourish baseUrl={flourish_url} />
14
11
  </div>
15
12
  ) : null;
16
13
  };
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import renderer from 'react-test-renderer';
3
+ import { Provider } from 'react-intl-redux';
4
+ import configureStore from 'redux-mock-store';
5
+ import FlourishViewWidget from './FlourishViewWidget';
6
+
7
+ const mockStore = configureStore();
8
+
9
+ const store = mockStore({
10
+ intl: {
11
+ locale: 'en',
12
+ messages: {},
13
+ },
14
+ });
15
+
16
+ jest.mock('@eeacms/volto-flourish/components/Flourish', () => () => (
17
+ <div data-testid="flourish-component" />
18
+ ));
19
+
20
+ test('renders FlourishViewWidget component', () => {
21
+ const mockValue = {
22
+ download: 'http://example.com/flourish/@@download/flourish_zip',
23
+ };
24
+
25
+ const component = renderer.create(
26
+ <Provider store={store}>
27
+ <FlourishViewWidget value={mockValue} />
28
+ </Provider>,
29
+ );
30
+
31
+ const json = component.toJSON();
32
+
33
+ expect(json).toMatchSnapshot();
34
+ });