@eeacms/volto-datahub 1.0.28 → 1.0.29

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,13 @@ 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.29](https://github.com/eea/volto-datahub/compare/1.0.28...1.0.29) - 13 September 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - Fix snapshot [kreafox - [`3e070c5`](https://github.com/eea/volto-datahub/commit/3e070c5973e314935d674c5d41a361882317937b)]
12
+ - Add test [kreafox - [`5683383`](https://github.com/eea/volto-datahub/commit/568338374247690706c4b5b1b766e1663602ace9)]
13
+ - Fix crash in dataset view [Tiberiu Ichim - [`f3a7310`](https://github.com/eea/volto-datahub/commit/f3a7310344b760bc8b4246bf69f47912068d6d90)]
7
14
  ### [1.0.28](https://github.com/eea/volto-datahub/compare/1.0.27...1.0.28) - 8 September 2023
8
15
 
9
16
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-datahub",
3
- "version": "1.0.28",
3
+ "version": "1.0.29",
4
4
  "description": "@eeacms/volto-datahub: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -18,25 +18,25 @@ const ItemLink = ({ item }) => (
18
18
  >
19
19
  {item.protocol} {item.name || item.description}
20
20
  </a>
21
- {isInternalURL(item.url) && <SVGIcon name={lockSVG} size="20px" />}
21
+ {isInternalURL(item.url) ? (
22
+ <SVGIcon name={lockSVG} size="20px" />
23
+ ) : null}
22
24
  </div>
23
25
  </List.Content>
24
26
  </List.Item>
25
27
  );
26
28
 
27
29
  export default function DatasetEsri({ dataset }) {
28
- return (
29
- (dataset['ESRI:REST'] || dataset['OGC:WMS']) && (
30
- <>
31
- <h5>Services:</h5>
32
- <List divided relaxed>
33
- {[...(dataset['ESRI:REST'] || []), ...(dataset['OGC:WMS'] || [])].map(
34
- (item, i) => (
35
- <ItemLink item={item} key={item.id} />
36
- ),
37
- )}
38
- </List>
39
- </>
40
- )
41
- );
30
+ return dataset['ESRI:REST'] || dataset['OGC:WMS'] ? (
31
+ <>
32
+ <h5>Services:</h5>
33
+ <List divided relaxed>
34
+ {[...(dataset['ESRI:REST'] || []), ...(dataset['OGC:WMS'] || [])].map(
35
+ (item, i) => (
36
+ <ItemLink item={item} key={item.id} />
37
+ ),
38
+ )}
39
+ </List>
40
+ </>
41
+ ) : null;
42
42
  }
@@ -5,63 +5,61 @@ import { SVGIcon } from '../utils.js';
5
5
  import lockSVG from 'remixicon/icons/System/lock-line.svg';
6
6
 
7
7
  export default function DatasetHttpLinks({ dataset }) {
8
- return (
9
- (dataset['WWW:LINK-1.0-http--link'] || dataset['DOI']) && (
10
- <>
11
- <h5>Links:</h5>
12
- <List divided relaxed>
13
- {(dataset['WWW:LINK-1.0-http--link'] || []).map((item, i) => {
14
- return (
15
- <List.Item key={i}>
16
- <List.Content>
17
- <div className="dataset-item">
18
- <Icon className="linkify" />
19
- <a
20
- href={item.url}
21
- className="item-link"
22
- target="_blank"
23
- rel="noreferrer"
24
- >
25
- <span>{item.name || item.url}</span>
26
- </a>
27
- {isInternalURL(item.url) && (
28
- <SVGIcon name={lockSVG} size="20px" />
29
- )}
30
- </div>
31
- </List.Content>
32
- {item.description && (
33
- <span className="item-description">{item.description}</span>
34
- )}
35
- </List.Item>
36
- );
37
- })}
38
- {(dataset['DOI'] || []).map((item, i) => {
39
- return (
40
- <List.Item key={i}>
41
- <List.Content>
42
- <div className="dataset-item">
43
- <Icon className="info circle" />
44
- <a
45
- href={item.url}
46
- className="item-link"
47
- target="_blank"
48
- rel="noreferrer"
49
- >
50
- <span>{item.name || item.url}</span>
51
- </a>
52
- {isInternalURL(item.url) && (
53
- <SVGIcon name={lockSVG} size="20px" />
54
- )}
55
- </div>
56
- </List.Content>
57
- {item.description && (
58
- <span className="item-description">{item.description}</span>
59
- )}
60
- </List.Item>
61
- );
62
- })}
63
- </List>
64
- </>
65
- )
66
- );
8
+ return dataset['WWW:LINK-1.0-http--link'] || dataset['DOI'] ? (
9
+ <>
10
+ <h5>Links:</h5>
11
+ <List divided relaxed>
12
+ {(dataset['WWW:LINK-1.0-http--link'] || []).map((item, i) => {
13
+ return (
14
+ <List.Item key={i}>
15
+ <List.Content>
16
+ <div className="dataset-item">
17
+ <Icon className="linkify" />
18
+ <a
19
+ href={item.url}
20
+ className="item-link"
21
+ target="_blank"
22
+ rel="noreferrer"
23
+ >
24
+ <span>{item.name || item.url}</span>
25
+ </a>
26
+ {isInternalURL(item.url) ? (
27
+ <SVGIcon name={lockSVG} size="20px" />
28
+ ) : null}
29
+ </div>
30
+ </List.Content>
31
+ {item.description ? (
32
+ <span className="item-description">{item.description}</span>
33
+ ) : null}
34
+ </List.Item>
35
+ );
36
+ })}
37
+ {(dataset['DOI'] || []).map((item, i) => {
38
+ return (
39
+ <List.Item key={i}>
40
+ <List.Content>
41
+ <div className="dataset-item">
42
+ <Icon className="info circle" />
43
+ <a
44
+ href={item.url}
45
+ className="item-link"
46
+ target="_blank"
47
+ rel="noreferrer"
48
+ >
49
+ <span>{item.name || item.url}</span>
50
+ </a>
51
+ {isInternalURL(item.url) ? (
52
+ <SVGIcon name={lockSVG} size="20px" />
53
+ ) : null}
54
+ </div>
55
+ </List.Content>
56
+ {item.description ? (
57
+ <span className="item-description">{item.description}</span>
58
+ ) : null}
59
+ </List.Item>
60
+ );
61
+ })}
62
+ </List>
63
+ </>
64
+ ) : null;
67
65
  }
@@ -10,13 +10,16 @@ import DatasetHttpLinks from './DatasetHttpLinks';
10
10
  const DatasetItemDownloadList = (props) => {
11
11
  const { link } = props;
12
12
  const dataset = groupBy(link, 'protocol');
13
+ const showDownload = !!(
14
+ dataset['WWW:URL'] ||
15
+ dataset['WWW:LINK'] ||
16
+ dataset['EEA:FILEPATH'] ||
17
+ dataset['EEA:FOLDERPATH']
18
+ );
13
19
 
14
20
  return (
15
21
  <div>
16
- {(dataset['WWW:URL'] ||
17
- dataset['WWW:LINK'] ||
18
- dataset['EEA:FILEPATH'] ||
19
- dataset['EEA:FOLDERPATH']) && (
22
+ {showDownload ? (
20
23
  <>
21
24
  <h5>Download:</h5>
22
25
  <List divided relaxed>
@@ -24,7 +27,7 @@ const DatasetItemDownloadList = (props) => {
24
27
  <DatasetLinks dataset={dataset} />
25
28
  </List>
26
29
  </>
27
- )}
30
+ ) : null}
28
31
 
29
32
  <DatasetEsri dataset={dataset} />
30
33
  <DatasetHttpLinks dataset={dataset} />
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import renderer from 'react-test-renderer';
3
+
4
+ import DatasetUrls from './DatasetUrls';
5
+
6
+ jest.mock('@eeacms/search', () => ({
7
+ runRequest: jest.fn(),
8
+ }));
9
+
10
+ const dataset = {
11
+ 'WWW:URL': [
12
+ {
13
+ url: 'https://example.org/1',
14
+ name: 'Direct download',
15
+ description: 'Download link description',
16
+ },
17
+ ],
18
+ };
19
+
20
+ describe('DatasetUrl', () => {
21
+ it('renders correctly', () => {
22
+ const tree = renderer.create(<DatasetUrls dataset={dataset} />).toJSON();
23
+ expect(tree).toMatchSnapshot();
24
+ });
25
+ });