@eeacms/volto-flourish 0.1.1 → 0.1.2

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,29 @@ 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.2](https://github.com/eea/volto-flourish/compare/0.1.1...0.1.2) - 16 September 2024
8
+
9
+ #### :house: Internal changes
10
+
11
+ - style: Automated code fix [eea-jenkins - [`71fbb9b`](https://github.com/eea/volto-flourish/commit/71fbb9b4e6521de530d7abdd1c4fe20ba6afd092)]
12
+ - style: Automated code fix [eea-jenkins - [`d90efae`](https://github.com/eea/volto-flourish/commit/d90efaeddab695ebdb356032eadeeb535650ad97)]
13
+
14
+ #### :hammer_and_wrench: Others
15
+
16
+ - set default value [Tripon Eugen - [`fceac76`](https://github.com/eea/volto-flourish/commit/fceac761126034e78494a0876ca751532a449767)]
17
+ - add test params [Tripon Eugen - [`72e582e`](https://github.com/eea/volto-flourish/commit/72e582ecc219836f6615249d5716b9438e7692e2)]
18
+ - add toolbar [Tripon Eugen - [`e786558`](https://github.com/eea/volto-flourish/commit/e786558bea8a8951b663f1b924b7c8198741163d)]
19
+ - wip [Tripon Eugen - [`162ae1f`](https://github.com/eea/volto-flourish/commit/162ae1fecb3cc68ffc3cf0890e4b86099a395146)]
20
+ - update test and default values [Tripon Eugen - [`4ae23a8`](https://github.com/eea/volto-flourish/commit/4ae23a8e62fa135d228ed9ed552b55273ad31fdf)]
21
+ - add test data [Tripon Eugen - [`2089c05`](https://github.com/eea/volto-flourish/commit/2089c054e21dd1eacd4870109add6ba4c1ed72f3)]
22
+ - add test data [Tripon Eugen - [`9ba6954`](https://github.com/eea/volto-flourish/commit/9ba6954de4dacdf3da9aa9a7a7b46bb326aec2d4)]
23
+ - add test [Tripon Eugen - [`5cd1f8d`](https://github.com/eea/volto-flourish/commit/5cd1f8d472bd3f78a887b88a784e2859c7e752fd)]
24
+ - Update Jenkinsfile: don't run volto 16 tests [Krisztina Elekes - [`4fe41ed`](https://github.com/eea/volto-flourish/commit/4fe41ed2364fb7c138b521651c2281c97f93d156)]
25
+ - eslint [Tripon Eugen - [`04eda9a`](https://github.com/eea/volto-flourish/commit/04eda9a5097471e0222a36a97aee6821673b30f3)]
26
+ - add volto-embed dependencies [Tripon Eugen - [`6147417`](https://github.com/eea/volto-flourish/commit/614741750ebf1403b0b33aea10957b60fa511b72)]
27
+ - add dependecies volto-embed [Tripon Eugen - [`76f1651`](https://github.com/eea/volto-flourish/commit/76f165140cc79d8ef0ab944f36f12e4a88be9c50)]
28
+ - show sources [Tripon Eugen - [`2410686`](https://github.com/eea/volto-flourish/commit/241068652f53ba9ec70454fd4d1428f04bd40076)]
29
+ - show sources [Tripon Eugen - [`246d415`](https://github.com/eea/volto-flourish/commit/246d415376f2c71987fb45a9be56cd57939c9b9d)]
7
30
  ### [0.1.1](https://github.com/eea/volto-flourish/compare/0.1.0...0.1.1) - 20 August 2024
8
31
 
9
32
  #### :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.2",
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
  }
@@ -1,24 +1,99 @@
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 { Sources } from '@eeacms/volto-embed/Toolbar';
6
+
7
+ import {
8
+ FigureNote,
9
+ Sources,
10
+ MoreInfo,
11
+ Share,
12
+ Enlarge,
13
+ } from '@eeacms/volto-embed/Toolbar';
14
+
15
+ export default function View(props) {
16
+ const { id, data } = props;
17
+
18
+ const {
19
+ with_sources,
20
+ // with_download,
21
+ with_notes,
22
+ with_share,
23
+ with_enlarge,
24
+ with_more_info,
25
+ flourish_item_url,
26
+ flourish_iframe_height = '600px',
27
+ } = data;
28
+
29
+ const flourish_url = flourish_item_url + '/@@flourish/index.html';
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
+ <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>
57
+ {flourishItemContent && (
58
+ <div className="visualization-toolbar">
59
+ <div className="left-col">
60
+ {with_notes && (
61
+ <FigureNote notes={flourishItemContent?.figure_note || []} />
62
+ )}
63
+ {flourishItemContent && with_sources && (
64
+ <Sources
65
+ sources={flourishItemContent?.data_provenance?.data || []}
66
+ />
67
+ )}
68
+ {with_more_info && (
69
+ <MoreInfo href={flourishItemContent['@id']} />
70
+ )}
71
+ </div>
72
+ <div className="right-col">
73
+ {with_share && <Share href={flourishItemContent['@id']} />}
74
+ {with_enlarge && (
75
+ <Enlarge>
76
+ <View
77
+ {...props}
78
+ data={{
79
+ ...props.data,
80
+ with_notes: false,
81
+ with_sources: false,
82
+ with_more_info: false,
83
+ with_enlarge: false,
84
+ with_share: false,
85
+ with_download: false,
86
+ }}
87
+ />
88
+ </Enlarge>
89
+ )}
90
+ </div>
91
+ </div>
92
+ )}
93
+ </div>
17
94
  ) : props.mode ? (
18
95
  <div>Embed flourish</div>
19
96
  ) : null}
20
97
  </div>
21
98
  );
22
- };
23
-
24
- export default View;
99
+ }
@@ -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
+ });
@@ -18,7 +18,23 @@ const schema = (props) => {
18
18
  {
19
19
  id: 'default',
20
20
  title: 'Default',
21
- fields: ['flourish_item_url', 'flourish_iframe_height'],
21
+ fields: [
22
+ 'flourish_test_url',
23
+ 'flourish_item_url',
24
+ 'flourish_iframe_height',
25
+ ],
26
+ },
27
+ {
28
+ id: 'toolbar',
29
+ title: 'Toolbar',
30
+ fields: [
31
+ 'with_sources',
32
+ 'with_notes',
33
+ 'with_more_info',
34
+ // 'with_download',
35
+ 'with_share',
36
+ 'with_enlarge',
37
+ ],
22
38
  },
23
39
  ],
24
40
  properties: {
@@ -46,6 +62,37 @@ const schema = (props) => {
46
62
  messages.CSSFlourishHeightDescription,
47
63
  ),
48
64
  },
65
+ with_notes: {
66
+ title: 'Show note',
67
+ type: 'boolean',
68
+ default: true,
69
+ },
70
+ with_sources: {
71
+ title: 'Show sources',
72
+ description: 'Will show sources set in this page Data provenance',
73
+ type: 'boolean',
74
+ default: true,
75
+ },
76
+ with_more_info: {
77
+ title: 'Show more info',
78
+ type: 'boolean',
79
+ default: true,
80
+ },
81
+ with_enlarge: {
82
+ title: 'Show enlarge button',
83
+ type: 'boolean',
84
+ default: true,
85
+ },
86
+ // with_download: {
87
+ // title: 'Show download button',
88
+ // type: 'boolean',
89
+ // default: true,
90
+ // },
91
+ with_share: {
92
+ title: 'Show share button',
93
+ type: 'boolean',
94
+ default: true,
95
+ },
49
96
  },
50
97
 
51
98
  required: ['flourish_item_url'],