@eeacms/volto-datahub 0.1.11 → 1.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.
@@ -2,7 +2,7 @@ const defaultBabel = require('@plone/volto/babel');
2
2
 
3
3
  function applyDefault(api) {
4
4
  const voltoBabel = defaultBabel(api);
5
- voltoBabel.plugins.push('@babel/plugin-transform-modules-commonjs', 'transform-class-properties', 'istanbul');
5
+ voltoBabel.plugins.push('istanbul');
6
6
  return voltoBabel;
7
7
  }
8
8
 
@@ -0,0 +1 @@
1
+ module.exports = require('@plone/volto/babel');
package/CHANGELOG.md CHANGED
@@ -4,12 +4,30 @@ 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
+ ### [1.0.0](https://github.com/eea/volto-datahub/compare/0.1.12...1.0.0) - 28 October 2022
8
+
9
+ #### :nail_care: Enhancements
10
+
11
+ - refactor(cypress): Upgrade Cypress 10 / Razzle 4 [Alin Voinea - [`53a5bca`](https://github.com/eea/volto-datahub/commit/53a5bcae5a21af13232c8654f542aa07328d4675)]
12
+ - refactor(volto-slate): Upgrade to @plone/volto-slate - refs #153447 [Alin Voinea - [`d1dc182`](https://github.com/eea/volto-datahub/commit/d1dc1828d5c6f5d8cd553b132981be7af4977a86)]
13
+
14
+ #### :hammer_and_wrench: Others
15
+
16
+ - Cleanup cypress.json [Alin Voinea - [`0ae42af`](https://github.com/eea/volto-datahub/commit/0ae42af39334dae0c4cfb151349c2e5b3a0eb7a3)]
17
+ - Cleanup [Alin Voinea - [`e210800`](https://github.com/eea/volto-datahub/commit/e21080044017c8693e44a5d3d31eec3d9318c783)]
18
+ - Update dependencies [Alin Voinea - [`e4ef04a`](https://github.com/eea/volto-datahub/commit/e4ef04a27e66a608caecf5c9d01cbef97b8576ac)]
19
+ ### [0.1.12](https://github.com/eea/volto-datahub/compare/0.1.11...0.1.12) - 19 October 2022
20
+
21
+ #### :hammer_and_wrench: Others
22
+
23
+ - Add proper class name on the landing page [kreafox - [`767bdac`](https://github.com/eea/volto-datahub/commit/767bdac51851301d229eeff23cee666a381488fb)]
24
+ - Fix undefined error [kreafox - [`a589629`](https://github.com/eea/volto-datahub/commit/a5896295a1d74d0b63bc3625efcbfd25fc39fcda)]
25
+ - added specific model for datahub results [Zoltan Szabo - [`71fd2e7`](https://github.com/eea/volto-datahub/commit/71fd2e78e114f50dcbcc6ff3e8dfa5e96d2b7fd0)]
7
26
  ### [0.1.11](https://github.com/eea/volto-datahub/compare/0.1.10...0.1.11) - 27 September 2022
8
27
 
9
28
  #### :hammer_and_wrench: Others
10
29
 
11
30
  - fixed query for related items [Zoltan Szabo - [`b66faee`](https://github.com/eea/volto-datahub/commit/b66faee1f8a1922cd22b3a36eccc9c7b92e377d4)]
12
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`158fe1a`](https://github.com/eea/volto-datahub/commit/158fe1a0b1767452e2e51a3e2ef97169589a50e8)]
13
31
  ### [0.1.10](https://github.com/eea/volto-datahub/compare/0.1.9...0.1.10) - 21 September 2022
14
32
 
15
33
  #### :hammer_and_wrench: Others
@@ -98,7 +116,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
98
116
  #### :hammer_and_wrench: Others
99
117
 
100
118
  - Hide questions & fix landing page [kreafox - [`a1ef303`](https://github.com/eea/volto-datahub/commit/a1ef3033df0e84f3a72dd0f984c8717dff2a771c)]
101
- - Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`910688e`](https://github.com/eea/volto-datahub/commit/910688e3ddf2f8cda4f941595ae9a6ee0ec0ea3b)]
102
119
  ### [0.1.1](https://github.com/eea/volto-datahub/compare/0.1.0...0.1.1) - 10 June 2022
103
120
 
104
121
  ### [0.1.0](https://github.com/eea/volto-datahub/compare/0.0.1...0.1.0) - 9 June 2022
package/README.md CHANGED
@@ -15,36 +15,14 @@
15
15
  [![Duplicated Lines (%)](https://sonarqube.eea.europa.eu/api/project_badges/measure?project=volto-addon-template-develop&metric=duplicated_lines_density)](https://sonarqube.eea.europa.eu/dashboard?id=volto-addon-template-develop)
16
16
 
17
17
 
18
- [Volto](https://github.com/plone/volto) add-on
18
+ EEA DataHub search [Volto](https://github.com/plone/volto) add-on
19
19
 
20
- ## Features
20
+ ## Demo
21
21
 
22
- Demo GIF
22
+ - https://demo-www.eea.europa.eu/en/datahub
23
23
 
24
24
  ## Getting started
25
25
 
26
- ### Try volto-addon-template with Docker
27
-
28
- 1. Get the latest Docker images
29
-
30
- ```
31
- docker pull plone
32
- docker pull plone/volto
33
- ```
34
-
35
- 1. Start Plone backend
36
- ```
37
- docker run -d --name plone -p 8080:8080 -e SITE=Plone -e PROFILES="profile-plone.restapi:blocks" plone
38
- ```
39
-
40
- 1. Start Volto frontend
41
-
42
- ```
43
- docker run -it --rm -p 3000:3000 --link plone -e ADDONS="@eeacms/volto-addon-template" plone/volto
44
- ```
45
-
46
- 1. Go to http://localhost:3000
47
-
48
26
  ### Add volto-addon-template to your Volto project
49
27
 
50
28
  1. Make sure you have a [Plone backend](https://plone.org/download) up-and-running at http://localhost:8080/Plone
@@ -59,7 +37,7 @@ Demo GIF
59
37
  ],
60
38
 
61
39
  "dependencies": {
62
- "@eeacms/volto-addon-template": "^1.0.0"
40
+ "@eeacms/volto-addon-template": "*"
63
41
  }
64
42
  ```
65
43
 
package/babel.config.js CHANGED
@@ -1,6 +1,6 @@
1
1
  module.exports = function (api) {
2
2
  api.cache(true);
3
- const presets = ['razzle/babel'];
3
+ const presets = ['razzle'];
4
4
  const plugins = [
5
5
  [
6
6
  'react-intl', // React Intl extractor, required for the whole i18n infrastructure to work
@@ -0,0 +1,26 @@
1
+ const { defineConfig } = require('cypress');
2
+
3
+ module.exports = defineConfig({
4
+ viewportWidth: 1280,
5
+ defaultCommandTimeout: 8888,
6
+ chromeWebSecurity: false,
7
+ reporter: 'junit',
8
+ video: true,
9
+ retries: {
10
+ runMode: 8,
11
+ openMode: 0,
12
+ },
13
+ reporterOptions: {
14
+ mochaFile: 'cypress/reports/cypress-[hash].xml',
15
+ jenkinsMode: true,
16
+ toConsole: true,
17
+ },
18
+ e2e: {
19
+ setupNodeEvents(on, config) {
20
+ // e2e testing node events setup code
21
+ require('@cypress/code-coverage/task')(on, config);
22
+ return config;
23
+ },
24
+ baseUrl: 'http://localhost:3000',
25
+ },
26
+ });
@@ -9,18 +9,18 @@ module.exports = {
9
9
  '@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
10
10
  '@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
11
11
  '@package/(.*)$': '<rootDir>/src/$1',
12
+ '@root/(.*)$': '<rootDir>/src/$1',
12
13
  '@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
13
14
  '@eeacms/(.*?)/(.*)$': '<rootDir>/src/addons/$1/src/$2',
14
- 'volto-slate/(.*)$': '<rootDir>/src/addons/volto-slate/src/$1',
15
+ '@plone/volto-slate':
16
+ '<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
15
17
  '~/(.*)$': '<rootDir>/src/$1',
16
18
  'load-volto-addons':
17
19
  '<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
20
+ '\\.(css|less|scss|sass)$': 'identity-obj-proxy',
18
21
  },
19
22
  transform: {
20
23
  '^.+\\.js(x)?$': 'babel-jest',
21
- '^.+\\.css$': 'jest-css-modules',
22
- '^.+\\.less$': 'jest-css-modules',
23
- '^.+\\.scss$': 'jest-css-modules',
24
24
  '^.+\\.(png)$': 'jest-file',
25
25
  '^.+\\.(jpg)$': 'jest-file',
26
26
  '^.+\\.(svg)$': './node_modules/@plone/volto/jest-svgsystem-transform.js',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-datahub",
3
- "version": "0.1.11",
3
+ "version": "1.0.0",
4
4
  "description": "@eeacms/volto-datahub: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -22,8 +22,9 @@
22
22
  },
23
23
  "devDependencies": {
24
24
  "@plone/scripts": "*",
25
- "@cypress/code-coverage": "^3.9.5",
26
- "babel-plugin-transform-class-properties": "^6.24.1"
25
+ "@cypress/code-coverage": "^3.10.0",
26
+ "babel-plugin-transform-class-properties": "^6.24.1",
27
+ "md5": "^2.3.0"
27
28
  },
28
29
  "addons": [
29
30
  "@eeacms/volto-globalsearch",
@@ -31,19 +32,21 @@
31
32
  ],
32
33
  "scripts": {
33
34
  "release": "release-it",
35
+ "release-major-beta": "release-it major --preRelease=beta",
36
+ "release-beta": "release-it --preRelease=beta",
34
37
  "bootstrap": "npm install -g ejs; npm link ejs; node bootstrap",
35
38
  "test": "make test",
36
39
  "test:fix": "make test-update",
37
40
  "pre-commit": "yarn stylelint:fix && yarn prettier:fix && yarn lint:fix",
38
- "stylelint": "if [ -d ./project ]; then ./project/node_modules/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}'; else ../../../node_modules/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}'; fi",
39
- "stylelint:overrides": "if [ -d ./project ]; then ./project/node_modules/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides'; else ../../../node_modules/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides'; fi",
40
- "stylelint:fix": "yarn stylelint --fix && yarn stylelint:overrides --fix",
41
- "prettier": "if [ -d ./project ]; then ./project/node_modules/.bin/prettier --single-quote --check 'src/**/*.{js,jsx,json,css,less,md}'; else ../../../node_modules/.bin/prettier --single-quote --check 'src/**/*.{js,jsx,json,css,less,md}'; fi",
42
- "prettier:fix": "if [ -d ./project ]; then ./project/node_modules/.bin/prettier --single-quote --write 'src/**/*.{js,jsx,json,css,less,md}'; else ../../../node_modules/.bin/prettier --single-quote --write 'src/**/*.{js,jsx,json,css,less,md}'; fi",
43
- "lint": "if [ -d ./project ]; then ./project/node_modules/eslint/bin/eslint.js --max-warnings=0 'src/**/*.{js,jsx}'; else ../../../node_modules/eslint/bin/eslint.js --max-warnings=0 'src/**/*.{js,jsx}'; fi",
44
- "lint:fix": "if [ -d ./project ]; then ./project/node_modules/eslint/bin/eslint.js --fix 'src/**/*.{js,jsx}'; else ../../../node_modules/eslint/bin/eslint.js --fix 'src/**/*.{js,jsx}'; fi",
45
- "i18n": "rm -rf build/messages && NODE_ENV=production i18n --addon",
46
- "cypress:run": "if [ -d ./project ]; then NODE_ENV=development ./project/node_modules/cypress/bin/cypress run; else NODE_ENV=development ../../../node_modules/cypress/bin/cypress run; fi",
47
- "cypress:open": "if [ -d ./project ]; then NODE_ENV=development ./project/node_modules/cypress/bin/cypress open; else NODE_ENV=development ../../../node_modules/cypress/bin/cypress open; fi"
41
+ "stylelint": "make stylelint",
42
+ "stylelint:overrides": "make stylelint-overrides",
43
+ "stylelint:fix": "make stylelint-fix",
44
+ "prettier": "make prettier",
45
+ "prettier:fix": "make prettier-fix",
46
+ "lint": "make lint",
47
+ "lint:fix": "make lint-fix",
48
+ "i18n": "make i18n",
49
+ "cypress:run": "make cypress-run",
50
+ "cypress:open": "make cypress-open"
48
51
  }
49
52
  }
@@ -21,7 +21,7 @@ import {
21
21
  MetadataSection,
22
22
  Datasets,
23
23
  } from '@eeacms/volto-datahub/components/ItemView';
24
- import bannerBG from './banner.svg';
24
+ // import bannerBG from './banner.svg';
25
25
 
26
26
  const appName = 'datahub';
27
27
 
@@ -33,7 +33,12 @@ function ItemView(props) {
33
33
  const result = useResult(null, docid);
34
34
  const item = result ? result._result : null;
35
35
  const { title, description, raw_value } = item || {}; // readingTime
36
- const { changeDate } = raw_value?.raw || {};
36
+ const { changeDate, resourceIdentifier } = raw_value?.raw || {};
37
+
38
+ const prodID = (resourceIdentifier || []).filter((p) => {
39
+ return p.code.includes('DAT');
40
+ })[0]?.code;
41
+
37
42
  const rawTitle = title?.raw || '';
38
43
 
39
44
  React.useEffect(() => {
@@ -66,55 +71,53 @@ function ItemView(props) {
66
71
  <div className="dataset-view">
67
72
  <Portal node={document.getElementById('page-header')}>
68
73
  <div className="dataset">
69
- <Banner image_url={bannerBG} image>
74
+ <Banner>
70
75
  <Banner.Content>
71
- <Banner.Title>Datahub</Banner.Title>
76
+ <Banner.Subtitle>
77
+ <Link
78
+ to={
79
+ location?.state
80
+ ? { pathname: fromPathname, search: fromSearch }
81
+ : {
82
+ pathname: '/en/datahub/',
83
+ }
84
+ }
85
+ >
86
+ <Icon className="arrow left" />
87
+ Datahub overview
88
+ </Link>
89
+ </Banner.Subtitle>
90
+ <Banner.Title>{title?.raw}</Banner.Title>
91
+ <Banner.Metadata>
92
+ <Banner.MetadataField label="Prod-ID" value={prodID} />
93
+ <Banner.MetadataField
94
+ label="Published"
95
+ type="date"
96
+ value={<DateTime format="DATE_MED" value={result.issued} />}
97
+ />
98
+ <Banner.MetadataField
99
+ label="Last modified"
100
+ type="date"
101
+ value={<DateTime format="DATE_MED" value={changeDate} />}
102
+ />
103
+ {/* <Banner.MetadataField
104
+ label="Reading time"
105
+ value={readingTime?.raw}
106
+ /> */}
107
+ </Banner.Metadata>
72
108
  </Banner.Content>
73
109
  </Banner>
74
110
  </div>
75
111
  </Portal>
76
112
 
77
113
  <div className="dataset-container">
78
- <Link
79
- className="search-link"
80
- to={
81
- location?.state
82
- ? { pathname: fromPathname, search: fromSearch }
83
- : {
84
- pathname: '/en/datahub/',
85
- }
86
- }
87
- >
88
- <Icon className="ri-arrow-go-back-line" />
89
- Back to search
90
- </Link>
91
-
92
- <div className="dataset-header">
93
- <h1>{title?.raw}</h1>
94
- <div className="dataset-header-bottom">
95
- <span className="header-data">Prod-ID: -</span>
96
- {/* <span className="header-data">
97
- Created: <DateTime format="DATE_MED" value={issued?.raw} />
98
- </span> */}
99
- <span className="header-data">
100
- Published: <DateTime format="DATE_MED" value={result.issued} />
101
- </span>
102
- <span className="header-data">
103
- Last modified: <DateTime format="DATE_MED" value={changeDate} />
104
- </span>
105
- {/*<span className="header-data">
106
- Reading time: {readingTime?.raw}
107
- </span>*/}
108
- </div>
109
- </div>
110
-
111
114
  <Callout>{description?.raw}</Callout>
112
115
 
113
116
  <Datasets item={item} appConfig={appConfig} />
114
117
 
115
118
  <MetadataSection item={item} appConfig={appConfig} docid={docid} />
116
119
 
117
- <MoreLikeThis docid={docid} title={title.raw} appConfig={appConfig} />
120
+ <MoreLikeThis docid={docid} title={title?.raw} appConfig={appConfig} />
118
121
  </div>
119
122
 
120
123
  {/* <div className="info-wrapper">
@@ -46,7 +46,7 @@ const MoreLikeThis = (props) => {
46
46
  const { index_name } = appConfig;
47
47
  const query_body = buildQuery(title, docid, index_name);
48
48
  const resp = await runRequest(query_body, appConfig);
49
- setSimilarDocs(resp.body.hits.hits);
49
+ setSimilarDocs(resp.body?.hits?.hits);
50
50
  }
51
51
  getSimilarDocs(docid, title, appConfig);
52
52
  }, [appConfig, docid, title]);
@@ -242,7 +242,7 @@ const LandingPage = (props) => {
242
242
  panes={panes}
243
243
  />
244
244
  {hasOverflow ? (
245
- <div className="info">
245
+ <div className="tab-info">
246
246
  <p>Only first {maxPerSection} items are displayed.</p>
247
247
  </div>
248
248
  ) : null}
@@ -14,13 +14,11 @@ const DatahubCardItem = (props) => {
14
14
  // metaType = 'Others';
15
15
  // }
16
16
 
17
- const [resultId] = (result.href || '').split('/').reverse();
18
-
19
17
  const item = {
20
18
  title: (
21
19
  <Link
22
20
  to={{
23
- pathname: `/en/datahub/datahubitem-view/${resultId}`,
21
+ pathname: result.href,
24
22
  state: {
25
23
  fromPathname: window.location.pathname,
26
24
  fromSearch: window.location.search,
@@ -0,0 +1,96 @@
1
+ import { ResultModel } from '@eeacms/search';
2
+ const path = require('path');
3
+
4
+ export class DatahubResultModel extends ResultModel {
5
+ get href() {
6
+ if (__CLIENT__) {
7
+ return path.join(
8
+ window.location.pathname,
9
+ 'datahubitem-view/',
10
+ this._result.about?.raw,
11
+ );
12
+ } else {
13
+ return ''; //TODO
14
+ }
15
+ }
16
+
17
+ get daysSinceIssued() {
18
+ return super.daysSinceIssued;
19
+ }
20
+
21
+ get id() {
22
+ return super.id;
23
+ }
24
+
25
+ get isNew() {
26
+ return super.isNew;
27
+ }
28
+
29
+ get issued() {
30
+ return super.issued;
31
+ }
32
+
33
+ get expires() {
34
+ return super.expires;
35
+ }
36
+
37
+ get isExpired() {
38
+ return super.isExpired;
39
+ }
40
+
41
+ get metaCategories() {
42
+ return super.metaCategories;
43
+ }
44
+
45
+ get clusterIcon() {
46
+ return super.clusterIcon;
47
+ }
48
+
49
+ get clusterInfo() {
50
+ return super.clusterInfo;
51
+ }
52
+
53
+ get clusterName() {
54
+ return super.clusterName;
55
+ }
56
+
57
+ get source() {
58
+ return super.source;
59
+ }
60
+
61
+ get title() {
62
+ return super.title;
63
+ }
64
+
65
+ get description() {
66
+ return super.description;
67
+ }
68
+
69
+ get hasImage() {
70
+ return super.hasImage;
71
+ }
72
+
73
+ get thumbUrl() {
74
+ return super.thumbUrl;
75
+ }
76
+
77
+ get highlight() {
78
+ return super.highlight;
79
+ }
80
+
81
+ get website() {
82
+ return super.website.website;
83
+ }
84
+
85
+ get tags() {
86
+ return super.tags;
87
+ }
88
+
89
+ get metaTypes() {
90
+ return super.metaTypes;
91
+ }
92
+
93
+ get explanation() {
94
+ return super.explanation;
95
+ }
96
+ }
package/src/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import installDatahub from './config';
2
2
  import DatahubCardItem from './components/Result/DatahubCardItem';
3
3
  import DatahubItemView from './components/ItemView/ItemView';
4
+ import { DatahubResultModel } from './config/models';
4
5
 
5
6
  function tweakForNLPService(body, config) {
6
7
  if (!config.enableNLP) {
@@ -20,6 +21,7 @@ const applyConfig = (config) => {
20
21
  } = config.settings.searchlib;
21
22
 
22
23
  resolve.DatahubCardItem = { component: DatahubCardItem };
24
+ resolve.DatahubResultModel = DatahubResultModel;
23
25
 
24
26
  // Tweak the searchlib config to use the middleware instead of the index
25
27
  datahub.elastic_index = '_es/datahub';
@@ -29,6 +31,7 @@ const applyConfig = (config) => {
29
31
  datahub.requestBodyModifiers.push(tweakForNLPService);
30
32
  datahub.indexBaseUrl = 'https://galliwasp.eea.europa.eu';
31
33
  // datahub.resultViews[0].factories.item = "DatahubListingViewItem"
34
+ datahub.resultItemModel.factory = 'DatahubResultModel';
32
35
 
33
36
  config.settings.nonContentRoutes.push(/datahubitem-view\/(.*)/); // \/(.*)\/
34
37
  config.addonRoutes = [
package/cypress.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "baseUrl": "http://localhost:3000",
3
- "viewportWidth": 1280,
4
- "defaultCommandTimeout": 8888,
5
- "chromeWebSecurity": false,
6
- "reporter": "junit",
7
- "video": true,
8
- "retries": {
9
- "runMode": 8,
10
- "openMode": 0
11
- },
12
- "reporterOptions": {
13
- "mochaFile": "cypress/reports/cypress-[hash].xml",
14
- "jenkinsMode": true,
15
- "toConsole": true
16
- }
17
- }