@eeacms/volto-flourish 0.1.1 → 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,47 @@ 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)]
25
+ ### [0.1.2](https://github.com/eea/volto-flourish/compare/0.1.1...0.1.2) - 16 September 2024
26
+
27
+ #### :house: Internal changes
28
+
29
+ - style: Automated code fix [eea-jenkins - [`71fbb9b`](https://github.com/eea/volto-flourish/commit/71fbb9b4e6521de530d7abdd1c4fe20ba6afd092)]
30
+ - style: Automated code fix [eea-jenkins - [`d90efae`](https://github.com/eea/volto-flourish/commit/d90efaeddab695ebdb356032eadeeb535650ad97)]
31
+
32
+ #### :hammer_and_wrench: Others
33
+
34
+ - set default value [Tripon Eugen - [`fceac76`](https://github.com/eea/volto-flourish/commit/fceac761126034e78494a0876ca751532a449767)]
35
+ - add test params [Tripon Eugen - [`72e582e`](https://github.com/eea/volto-flourish/commit/72e582ecc219836f6615249d5716b9438e7692e2)]
36
+ - add toolbar [Tripon Eugen - [`e786558`](https://github.com/eea/volto-flourish/commit/e786558bea8a8951b663f1b924b7c8198741163d)]
37
+ - wip [Tripon Eugen - [`162ae1f`](https://github.com/eea/volto-flourish/commit/162ae1fecb3cc68ffc3cf0890e4b86099a395146)]
38
+ - update test and default values [Tripon Eugen - [`4ae23a8`](https://github.com/eea/volto-flourish/commit/4ae23a8e62fa135d228ed9ed552b55273ad31fdf)]
39
+ - add test data [Tripon Eugen - [`2089c05`](https://github.com/eea/volto-flourish/commit/2089c054e21dd1eacd4870109add6ba4c1ed72f3)]
40
+ - add test data [Tripon Eugen - [`9ba6954`](https://github.com/eea/volto-flourish/commit/9ba6954de4dacdf3da9aa9a7a7b46bb326aec2d4)]
41
+ - add test [Tripon Eugen - [`5cd1f8d`](https://github.com/eea/volto-flourish/commit/5cd1f8d472bd3f78a887b88a784e2859c7e752fd)]
42
+ - Update Jenkinsfile: don't run volto 16 tests [Krisztina Elekes - [`4fe41ed`](https://github.com/eea/volto-flourish/commit/4fe41ed2364fb7c138b521651c2281c97f93d156)]
43
+ - eslint [Tripon Eugen - [`04eda9a`](https://github.com/eea/volto-flourish/commit/04eda9a5097471e0222a36a97aee6821673b30f3)]
44
+ - add volto-embed dependencies [Tripon Eugen - [`6147417`](https://github.com/eea/volto-flourish/commit/614741750ebf1403b0b33aea10957b60fa511b72)]
45
+ - add dependecies volto-embed [Tripon Eugen - [`76f1651`](https://github.com/eea/volto-flourish/commit/76f165140cc79d8ef0ab944f36f12e4a88be9c50)]
46
+ - show sources [Tripon Eugen - [`2410686`](https://github.com/eea/volto-flourish/commit/241068652f53ba9ec70454fd4d1428f04bd40076)]
47
+ - show sources [Tripon Eugen - [`246d415`](https://github.com/eea/volto-flourish/commit/246d415376f2c71987fb45a9be56cd57939c9b9d)]
7
48
  ### [0.1.1](https://github.com/eea/volto-flourish/compare/0.1.0...0.1.1) - 20 August 2024
8
49
 
9
50
  #### :bug: Bug Fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-flourish",
3
- "version": "0.1.1",
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",
@@ -16,6 +16,9 @@
16
16
  "type": "git",
17
17
  "url": "git@github.com:eea/volto-flourish.git"
18
18
  },
19
+ "addons": [
20
+ "@eeacms/volto-embed"
21
+ ],
19
22
  "devDependencies": {
20
23
  "@cypress/code-coverage": "^3.10.0",
21
24
  "@plone/scripts": "*",
@@ -66,5 +69,8 @@
66
69
  "i18n": "make i18n",
67
70
  "cypress:run": "make cypress-run",
68
71
  "cypress:open": "make cypress-open"
72
+ },
73
+ "dependencies": {
74
+ "@eeacms/volto-embed": "*"
69
75
  }
70
76
  }
@@ -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
+ });
@@ -1,24 +1,91 @@
1
- const View = (props) => {
2
- const flourish_url = props.data.flourish_item_url + '/@@flourish/index.html';
3
- const { flourish_iframe_height = '600px' } = props.data;
1
+ import { useEffect } from 'react';
2
+ import { useSelector, useDispatch } from 'react-redux';
3
+ import { getContent } from '@plone/volto/actions';
4
+ import { flattenToAppURL } from '@plone/volto/helpers';
5
+ import { default as Flourish } from '@eeacms/volto-flourish/components/Flourish';
6
+ // import { Sources } from '@eeacms/volto-embed/Toolbar';
7
+
8
+ import {
9
+ FigureNote,
10
+ Sources,
11
+ MoreInfo,
12
+ Share,
13
+ Enlarge,
14
+ } from '@eeacms/volto-embed/Toolbar';
15
+
16
+ export default function View(props) {
17
+ const { id, data } = props;
18
+
19
+ const {
20
+ with_sources,
21
+ // with_download,
22
+ with_notes,
23
+ with_share,
24
+ with_enlarge,
25
+ with_more_info,
26
+ flourish_item_url,
27
+ // flourish_iframe_height = '600px',
28
+ } = data;
29
+
30
+ const vis_url = flattenToAppURL(flourish_item_url || '');
31
+ const dispatch = useDispatch();
32
+
33
+ const flourishItemContent = useSelector(
34
+ (state) => state.content?.subrequests?.[id]?.data,
35
+ );
36
+
37
+ useEffect(() => {
38
+ if (vis_url) {
39
+ const action = getContent(vis_url, null, id);
40
+ dispatch(action);
41
+ }
42
+ }, [dispatch, vis_url, id]);
43
+
4
44
  return (
5
45
  <div className="embed-flourish">
6
- {props.data.flourish_item_url ? (
7
- <iframe
8
- src={flourish_url}
9
- width="100%"
10
- // height={props.data.flourish_iframe_height}
11
- title="FlourishEmbed"
12
- style={{
13
- border: '0px',
14
- height: flourish_iframe_height,
15
- }}
16
- ></iframe>
46
+ {flourish_item_url ? (
47
+ <div>
48
+ <Flourish baseUrl={flourish_item_url} />
49
+ {flourishItemContent && (
50
+ <div className="visualization-toolbar">
51
+ <div className="left-col">
52
+ {with_notes && (
53
+ <FigureNote notes={flourishItemContent?.figure_note || []} />
54
+ )}
55
+ {flourishItemContent && with_sources && (
56
+ <Sources
57
+ sources={flourishItemContent?.data_provenance?.data || []}
58
+ />
59
+ )}
60
+ {with_more_info && (
61
+ <MoreInfo href={flourishItemContent['@id']} />
62
+ )}
63
+ </div>
64
+ <div className="right-col">
65
+ {with_share && <Share href={flourishItemContent['@id']} />}
66
+ {with_enlarge && (
67
+ <Enlarge>
68
+ <View
69
+ {...props}
70
+ data={{
71
+ ...props.data,
72
+ with_notes: false,
73
+ with_sources: false,
74
+ with_more_info: false,
75
+ with_enlarge: false,
76
+ with_share: false,
77
+ with_download: false,
78
+ }}
79
+ />
80
+ </Enlarge>
81
+ )}
82
+ </div>
83
+ </div>
84
+ )}
85
+ </div>
17
86
  ) : props.mode ? (
18
87
  <div>Embed flourish</div>
19
88
  ) : null}
20
89
  </div>
21
90
  );
22
- };
23
-
24
- export default View;
91
+ }
@@ -0,0 +1,39 @@
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 View from './View';
8
+
9
+ const mockStore = configureStore();
10
+
11
+ describe('View', () => {
12
+ it('should render the component', () => {
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 store = mockStore({
23
+ userSession: { token: '1234' },
24
+ intl: {
25
+ locale: 'en',
26
+ messages: {},
27
+ },
28
+ });
29
+
30
+ const { container } = render(
31
+ <Provider store={store}>
32
+ <MemoryRouter>
33
+ <View data={data} />
34
+ </MemoryRouter>
35
+ </Provider>,
36
+ );
37
+ expect(container.querySelector('.embed-flourish')).toBeInTheDocument();
38
+ });
39
+ });
@@ -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 {
@@ -18,7 +17,22 @@ const schema = (props) => {
18
17
  {
19
18
  id: 'default',
20
19
  title: 'Default',
21
- fields: ['flourish_item_url', 'flourish_iframe_height'],
20
+ fields: [
21
+ 'flourish_item_url',
22
+ // 'flourish_iframe_height',
23
+ ],
24
+ },
25
+ {
26
+ id: 'toolbar',
27
+ title: 'Toolbar',
28
+ fields: [
29
+ 'with_sources',
30
+ 'with_notes',
31
+ 'with_more_info',
32
+ // 'with_download',
33
+ 'with_share',
34
+ 'with_enlarge',
35
+ ],
22
36
  },
23
37
  ],
24
38
  properties: {
@@ -31,20 +45,51 @@ const schema = (props) => {
31
45
  </div>
32
46
  ),
33
47
  },
34
- flourish_iframe_height: {
35
- title: (
36
- <a
37
- rel="noopener noreferrer"
38
- target="_blank"
39
- href="https://developer.mozilla.org/en-US/docs/Web/CSS/height"
40
- >
41
- {props.intl.formatMessage(messages.CSSHeight)}
42
- </a>
43
- ),
44
- default: '600px',
45
- description: props.intl.formatMessage(
46
- messages.CSSFlourishHeightDescription,
47
- ),
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
+ // },
63
+ with_notes: {
64
+ title: 'Show note',
65
+ type: 'boolean',
66
+ default: true,
67
+ },
68
+ with_sources: {
69
+ title: 'Show sources',
70
+ description: 'Will show sources set in this page Data provenance',
71
+ type: 'boolean',
72
+ default: true,
73
+ },
74
+ with_more_info: {
75
+ title: 'Show more info',
76
+ type: 'boolean',
77
+ default: true,
78
+ },
79
+ with_enlarge: {
80
+ title: 'Show enlarge button',
81
+ type: 'boolean',
82
+ default: true,
83
+ },
84
+ // with_download: {
85
+ // title: 'Show download button',
86
+ // type: 'boolean',
87
+ // default: true,
88
+ // },
89
+ with_share: {
90
+ title: 'Show share button',
91
+ type: 'boolean',
92
+ default: true,
48
93
  },
49
94
  },
50
95
 
@@ -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
+ });