@eeacms/volto-tableau 7.1.0 → 7.2.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/.env ADDED
@@ -0,0 +1 @@
1
+ JEST_USE_SETUP=ON
package/.eslintrc.js ADDED
@@ -0,0 +1,65 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const projectRootPath = fs.realpathSync(__dirname + '/../../../');
4
+
5
+ let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
6
+ let configFile;
7
+ if (fs.existsSync(`${projectRootPath}/tsconfig.json`))
8
+ configFile = `${projectRootPath}/tsconfig.json`;
9
+ else if (fs.existsSync(`${projectRootPath}/jsconfig.json`))
10
+ configFile = `${projectRootPath}/jsconfig.json`;
11
+
12
+ if (configFile) {
13
+ const jsConfig = require(configFile).compilerOptions;
14
+ const pathsConfig = jsConfig.paths;
15
+ if (pathsConfig['@plone/volto'])
16
+ voltoPath = `./${jsConfig.baseUrl}/${pathsConfig['@plone/volto'][0]}`;
17
+ }
18
+
19
+ const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
20
+ const reg = new AddonConfigurationRegistry(projectRootPath);
21
+
22
+ // Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
23
+ const addonAliases = Object.keys(reg.packages).map((o) => [
24
+ o,
25
+ reg.packages[o].modulePath,
26
+ ]);
27
+
28
+ const addonExtenders = reg.getEslintExtenders().map((m) => require(m));
29
+
30
+ const defaultConfig = {
31
+ extends: `${voltoPath}/.eslintrc`,
32
+ settings: {
33
+ 'import/resolver': {
34
+ alias: {
35
+ map: [
36
+ ['@plone/volto', '@plone/volto/src'],
37
+ ['@plone/volto-slate', '@plone/volto/packages/volto-slate/src'],
38
+ ...addonAliases,
39
+ ['@package', `${__dirname}/src`],
40
+ ['@root', `${__dirname}/src`],
41
+ ['~', `${__dirname}/src`],
42
+ ],
43
+ extensions: ['.js', '.jsx', '.json'],
44
+ },
45
+ 'babel-plugin-root-import': {
46
+ rootPathSuffix: 'src',
47
+ },
48
+ },
49
+ },
50
+ rules: {
51
+ 'react/jsx-no-target-blank': [
52
+ 'error',
53
+ {
54
+ allowReferrer: true,
55
+ },
56
+ ],
57
+ }
58
+ };
59
+
60
+ const config = addonExtenders.reduce(
61
+ (acc, extender) => extender.modify(acc),
62
+ defaultConfig,
63
+ );
64
+
65
+ module.exports = config;
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
+ ### [7.2.1](https://github.com/eea/volto-tableau/compare/7.2.0...7.2.1) - 31 January 2024
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - fix tests [Razvan - [`e370ea4`](https://github.com/eea/volto-tableau/commit/e370ea49343f52b1a07dbe402ce48c9ef53b6a7b)]
12
+ - fix eslint [Razvan - [`82f9311`](https://github.com/eea/volto-tableau/commit/82f9311fadd7c269321c23d4a3e029c2d5a133c6)]
13
+ - test: Update jest,Jenkinsfile,lint to volto-addons-template PR30 [valentinab25 - [`6a19c5c`](https://github.com/eea/volto-tableau/commit/6a19c5ceaf229d944f3f15ee32a833ae37619d74)]
14
+ - fallbacks [Razvan - [`efcc619`](https://github.com/eea/volto-tableau/commit/efcc6196c454df58cb83801297332fd2d98edd97)]
15
+ ### [7.2.0](https://github.com/eea/volto-tableau/compare/7.1.0...7.2.0) - 17 January 2024
16
+
17
+ #### :bug: Bug Fixes
18
+
19
+ - fix: infinit requests patch [Razvan - [`9a9afa2`](https://github.com/eea/volto-tableau/commit/9a9afa2d73821c61d66044d5c44806ab060d3bd3)]
20
+
21
+ #### :hammer_and_wrench: Others
22
+
23
+ - Release 7.2.0 [Alin Voinea - [`7c0af33`](https://github.com/eea/volto-tableau/commit/7c0af336f63abfe5e25058a1ff1b07000a9a8c87)]
24
+ - fix tests [Razvan - [`48f255a`](https://github.com/eea/volto-tableau/commit/48f255a7a437a909e018604fe81db8987b6bfe87)]
7
25
  ### [7.1.0](https://github.com/eea/volto-tableau/compare/7.0.5...7.1.0) - 13 December 2023
8
26
 
9
27
  #### :rocket: New Features
package/Jenkinsfile CHANGED
@@ -162,10 +162,16 @@ pipeline {
162
162
  script {
163
163
  try {
164
164
  sh '''docker run --pull always --rm -d --name="$IMAGE_NAME-plone" -e SITE="Plone" -e PROFILES="$BACKEND_PROFILES" -e ADDONS="$BACKEND_ADDONS" eeacms/plone-backend'''
165
- sh '''docker run -d --shm-size=3g --link $IMAGE_NAME-plone:plone --name="$IMAGE_NAME-cypress" -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend start-ci'''
165
+ sh '''docker run -d --shm-size=4g --link $IMAGE_NAME-plone:plone --name="$IMAGE_NAME-cypress" -e "RAZZLE_INTERNAL_API_PATH=http://plone:8080/Plone" --entrypoint=make --workdir=/app/src/addons/$GIT_NAME $IMAGE_NAME-frontend start-ci'''
166
+ frontend = sh script:'''docker exec --workdir=/app/src/addons/${GIT_NAME} $IMAGE_NAME-cypress make check-ci''', returnStatus: true
167
+ if ( frontend != 0 ) {
168
+ sh '''docker logs $IMAGE_NAME-cypress; exit 1'''
169
+ }
170
+
166
171
  sh '''timeout -s 9 1800 docker exec --workdir=/app/src/addons/${GIT_NAME} $IMAGE_NAME-cypress make cypress-ci'''
167
172
  } finally {
168
173
  try {
174
+ if ( frontend == 0 ) {
169
175
  sh '''rm -rf cypress-videos cypress-results cypress-coverage cypress-screenshots'''
170
176
  sh '''mkdir -p cypress-videos cypress-results cypress-coverage cypress-screenshots'''
171
177
  videos = sh script: '''docker cp $IMAGE_NAME-cypress:/app/src/addons/$GIT_NAME/cypress/videos cypress-videos/''', returnStatus: true
@@ -189,6 +195,7 @@ pipeline {
189
195
  sh '''for file in $(find cypress-results -name *.xml); do if [ $(grep -E 'failures="[1-9].*"' $file | wc -l) -eq 0 ]; then testname=$(grep -E 'file=.*failures="0"' $file | sed 's#.* file=".*\\/\\(.*\\.[jsxt]\\+\\)" time.*#\\1#' ); rm -f cypress-videos/videos/$testname.mp4; fi; done'''
190
196
  archiveArtifacts artifacts: 'cypress-videos/**/*.mp4', fingerprint: true, allowEmptyArchive: true
191
197
  }
198
+ }
192
199
  } finally {
193
200
  catchError(buildResult: 'SUCCESS', stageResult: 'SUCCESS') {
194
201
  junit testResults: 'cypress-results/**/*.xml', allowEmptyResults: true
package/Makefile CHANGED
@@ -86,7 +86,7 @@ cypress-open: ## Open cypress integration tests
86
86
 
87
87
  .PHONY: cypress-run
88
88
  cypress-run: ## Run cypress integration tests
89
- CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run --browser chromium
89
+ CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run
90
90
 
91
91
  .PHONY: test
92
92
  test: ## Run jest tests
@@ -155,8 +155,11 @@ start-ci:
155
155
  cd ../..
156
156
  yarn start
157
157
 
158
+ .PHONY: check-ci
159
+ check-ci:
160
+ $(NODE_MODULES)/.bin/wait-on -t 240000 http://localhost:3000
161
+
158
162
  .PHONY: cypress-ci
159
163
  cypress-ci:
160
164
  $(NODE_MODULES)/.bin/wait-on -t 240000 http://localhost:3000
161
- NODE_ENV=development make cypress-run
162
-
165
+ CYPRESS_API_PATH="${RAZZLE_DEV_PROXY_API_PATH}" NODE_ENV=development $(NODE_MODULES)/cypress/bin/cypress run --browser chromium
@@ -1,3 +1,5 @@
1
+ require('dotenv').config({ path: __dirname + '/.env' })
2
+
1
3
  module.exports = {
2
4
  testMatch: ['**/src/addons/**/?(*.)+(spec|test).[jt]s?(x)'],
3
5
  collectCoverageFrom: [
@@ -13,6 +15,8 @@ module.exports = {
13
15
  '@root/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
14
16
  '@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
15
17
  '@eeacms/(.*?)/(.*)$': '<rootDir>/node_modules/@eeacms/$1/src/$2',
18
+ '@plone/volto-slate$':
19
+ '<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
16
20
  '@plone/volto-slate/(.*)$':
17
21
  '<rootDir>/node_modules/@plone/volto/packages/volto-slate/src/$1',
18
22
  '~/(.*)$': '<rootDir>/src/$1',
@@ -36,7 +40,9 @@ module.exports = {
36
40
  statements: 5,
37
41
  },
38
42
  },
39
- setupFilesAfterEnv: [
40
- '<rootDir>/node_modules/@eeacms/volto-tableau/jest.setup.js',
41
- ],
42
- };
43
+ ...(process.env.JEST_USE_SETUP === 'ON' && {
44
+ setupFilesAfterEnv: [
45
+ '<rootDir>/node_modules/@eeacms/volto-tableau/jest.setup.js',
46
+ ],
47
+ }),
48
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-tableau",
3
- "version": "7.1.0",
3
+ "version": "7.2.1",
4
4
  "description": "@eeacms/volto-tableau: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -32,7 +32,8 @@
32
32
  "babel-plugin-transform-class-properties": "^6.24.1",
33
33
  "husky": "^8.0.3",
34
34
  "lint-staged": "^14.0.1",
35
- "md5": "^2.3.0"
35
+ "md5": "^2.3.0",
36
+ "dotenv": "^16.3.2"
36
37
  },
37
38
  "lint-staged": {
38
39
  "src/**/*.{js,jsx,ts,tsx,json}": [
@@ -41,7 +41,6 @@ const View = (props) => {
41
41
  } = props;
42
42
  const {
43
43
  with_notes = true,
44
- with_sources = true,
45
44
  with_more_info = true,
46
45
  with_download = true,
47
46
  with_share = true,
@@ -135,7 +134,13 @@ const View = (props) => {
135
134
  * tableau visualization
136
135
  */
137
136
  const tableauVisId = flattenToAppURL(tableauVisualization['@id'] || '');
138
- if (isBlock && tableau_vis_url && tableau_vis_url !== tableauVisId) {
137
+ if (
138
+ mode === 'edit' &&
139
+ !tableauVisualization.error &&
140
+ isBlock &&
141
+ tableau_vis_url &&
142
+ tableau_vis_url !== tableauVisId
143
+ ) {
139
144
  getContent(tableau_vis_url, null, id);
140
145
  }
141
146
  }, [id, isBlock, getContent, mode, tableau_vis_url, tableauVisualization]);
@@ -144,6 +149,12 @@ const View = (props) => {
144
149
  return <Message>Please select a tableau from block editor.</Message>;
145
150
  }
146
151
 
152
+ if (tableauVisualization?.error) {
153
+ return (
154
+ <p dangerouslySetInnerHTML={{ __html: tableauVisualization.error }} />
155
+ );
156
+ }
157
+
147
158
  return (
148
159
  <div className="embed-tableau">
149
160
  <PrivacyProtection
@@ -157,7 +168,7 @@ const View = (props) => {
157
168
  tableau_height:
158
169
  tableau_height || tableauVisualization.tableau_height,
159
170
  with_notes,
160
- with_sources,
171
+ with_sources: true,
161
172
  with_more_info,
162
173
  with_download,
163
174
  with_share,
@@ -82,7 +82,7 @@ Array [
82
82
  >
83
83
  <a
84
84
  href="https://developer.mozilla.org/en-US/docs/Web/CSS/height"
85
- rel="noreferrer"
85
+ rel="noopener noreferrer"
86
86
  target="_blank"
87
87
  >
88
88
  CSS height
@@ -154,14 +154,6 @@ Array [
154
154
  -
155
155
  No description
156
156
  </div>
157
- <div
158
- className="mocked-boolean-widget"
159
- id="mocked-field-with_sources"
160
- >
161
- Show sources
162
- -
163
- Will show sources set in this page Data provenance
164
- </div>
165
157
  <div
166
158
  className="mocked-boolean-widget"
167
159
  id="mocked-field-with_more_info"
@@ -83,7 +83,6 @@ export default (props) => {
83
83
  title: 'Toolbar',
84
84
  fields: [
85
85
  'with_notes',
86
- 'with_sources',
87
86
  'with_more_info',
88
87
  'with_download',
89
88
  'with_share',
@@ -156,7 +155,7 @@ export default (props) => {
156
155
  tableau_height: {
157
156
  title: (
158
157
  <a
159
- rel="noreferrer"
158
+ rel="noopener noreferrer"
160
159
  target="_blank"
161
160
  href="https://developer.mozilla.org/en-US/docs/Web/CSS/height"
162
161
  >
@@ -118,6 +118,7 @@ const Tableau = forwardRef((props, ref) => {
118
118
  setVizState,
119
119
  onChangeBlock,
120
120
  } = props;
121
+
121
122
  const {
122
123
  data_provenance = {},
123
124
  figure_note = [],
@@ -28,19 +28,24 @@ export function getQuery({
28
28
  export function getTableauVisualization({
29
29
  isBlock,
30
30
  data,
31
- tableauContent,
32
- content,
31
+ tableauContent = {},
32
+ content = {},
33
33
  }) {
34
- const mergedContent = (isBlock ? tableauContent : content) || {};
35
- const tableau_visualization =
34
+ const mergedContent =
36
35
  (isBlock
37
- ? tableauContent?.tableau_visualization
38
- : content?.tableau_visualization) ||
39
- data?.tableau_visualization ||
40
- {};
36
+ ? tableauContent
37
+ : {
38
+ ...content,
39
+ tableau_visualization: {
40
+ ...(content.tableau_visualization || {}),
41
+ ...pickMetadata(content),
42
+ },
43
+ }) || {};
44
+ const tableau_visualization =
45
+ mergedContent.tableau_visualization || data?.tableau_visualization || {};
41
46
  return {
42
- ...pickMetadata(mergedContent),
43
47
  ...tableau_visualization,
48
+ ...(isBlock ? pickMetadata(mergedContent) : {}),
44
49
  };
45
50
  }
46
51
 
@@ -19,6 +19,7 @@ import '@eeacms/volto-tableau/less/tableau.less';
19
19
 
20
20
  const VisualizationWidget = (props) => {
21
21
  const { location, content } = props;
22
+ const ogValue = props.value || {};
22
23
  const viz = React.useRef();
23
24
  const [schema, setSchema] = React.useState(null);
24
25
  const [vizState, setVizState] = React.useState({
@@ -27,7 +28,7 @@ const VisualizationWidget = (props) => {
27
28
  error: null,
28
29
  });
29
30
  const [open, setOpen] = React.useState(false);
30
- const [value, setValue] = React.useState(props.value);
31
+ const [value, setValue] = React.useState(ogValue);
31
32
 
32
33
  const [tableauVisualization, setTableauVisualization] = useState(() =>
33
34
  getTableauVisualization({
@@ -57,13 +58,13 @@ const VisualizationWidget = (props) => {
57
58
  };
58
59
 
59
60
  const handleClose = () => {
60
- setValue(props.value);
61
+ setValue(ogValue);
61
62
  setOpen(false);
62
63
  };
63
64
 
64
65
  React.useEffect(() => {
65
- if (!open && !isEqual(props.value, value)) {
66
- setValue(props.value);
66
+ if (!open && !isEqual(props.value || {}, value)) {
67
+ setValue(props.value || {});
67
68
  }
68
69
  }, [props.value, value, open]);
69
70
 
@@ -1,47 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
-
4
- const projectRootPath = fs.existsSync('./project')
5
- ? fs.realpathSync('./project')
6
- : fs.realpathSync('./../../../');
7
- const packageJson = require(path.join(projectRootPath, 'package.json'));
8
- const jsConfig = require(path.join(projectRootPath, 'jsconfig.json'))
9
- .compilerOptions;
10
-
11
- const pathsConfig = jsConfig.paths;
12
-
13
- let voltoPath = path.join(projectRootPath, 'node_modules/@plone/volto');
14
-
15
- Object.keys(pathsConfig).forEach((pkg) => {
16
- if (pkg === '@plone/volto') {
17
- voltoPath = `./${jsConfig.baseUrl}/${pathsConfig[pkg][0]}`;
18
- }
19
- });
20
- const AddonConfigurationRegistry = require(`${voltoPath}/addon-registry.js`);
21
- const reg = new AddonConfigurationRegistry(projectRootPath);
22
-
23
- // Extends ESlint configuration for adding the aliases to `src` directories in Volto addons
24
- const addonAliases = Object.keys(reg.packages).map((o) => [
25
- o,
26
- reg.packages[o].modulePath,
27
- ]);
28
-
29
- module.exports = {
30
- extends: `${projectRootPath}/node_modules/@plone/volto/.eslintrc`,
31
- settings: {
32
- 'import/resolver': {
33
- alias: {
34
- map: [
35
- ['@plone/volto', '@plone/volto/src'],
36
- ...addonAliases,
37
- ['@package', `${__dirname}/src`],
38
- ['~', `${__dirname}/src`],
39
- ],
40
- extensions: ['.js', '.jsx', '.json'],
41
- },
42
- 'babel-plugin-root-import': {
43
- rootPathSuffix: 'src',
44
- },
45
- },
46
- },
47
- };