@eeacms/volto-clms-theme 1.0.66 → 1.0.67

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.
Files changed (82) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/package.json +1 -1
  3. package/src/components/Blocks/CclButtonBlock/CclButtonBlockEdit.test.jsx +41 -8
  4. package/src/components/Blocks/CclCardBlock/CclCardBlockEdit.test.jsx +7 -8
  5. package/src/components/Blocks/CustomTemplates/VoltoListingBlock/CclListingCards.test.jsx +6 -6
  6. package/src/components/CLMSDatasetDetailView/BoundingBoxComponent.test.jsx +27 -0
  7. package/src/components/CLMSDatasetDetailView/CLMSDatasetDetailView.jsx +14 -11
  8. package/src/components/CLMSDatasetDetailView/CLMSDatasetDetailView.test.jsx +124 -0
  9. package/src/components/CLMSDatasetDetailView/ContactComponent.test.jsx +34 -0
  10. package/src/components/CLMSDatasetDetailView/DataSetInfoContent.jsx +143 -88
  11. package/src/components/CLMSDatasetDetailView/DataSetInfoContent.test.jsx +7 -5
  12. package/src/components/CLMSDatasetDetailView/DistributionInfoComponent.test.jsx +24 -0
  13. package/src/components/CLMSDatasetDetailView/DownloadDataSetContent.test.jsx +80 -0
  14. package/src/components/CLMSDatasetDetailView/index.js +0 -1
  15. package/src/components/CLMSDownloadCartView/CLMSCartContent.jsx +14 -6
  16. package/src/components/CLMSDownloadCartView/CLMSCartContent.test.jsx +5 -0
  17. package/src/components/CLMSDownloadCartView/CLMSDownloadCartView.test.jsx +5 -0
  18. package/src/components/CLMSDownloadCartView/cartUtils.test.js +5 -0
  19. package/src/components/CLMSDownloadCartView/conversion.test.js +5 -0
  20. package/src/components/CLMSDownloadableFileView/CLMSDownloadableFile.test.jsx +5 -0
  21. package/src/components/CLMSDownloadsView/CLMSDownloadTasks.test.jsx +5 -0
  22. package/src/components/CLMSDownloadsView/CLMSDownloadsView.test.jsx +5 -0
  23. package/src/components/CLMSDownloadsView/FileCard.test.jsx +5 -0
  24. package/src/components/CLMSMapViewerView/CLMSMapViewerView.test.jsx +5 -0
  25. package/src/components/CLMSMeetingView/CLMSMeetingEmailView.test.jsx +5 -0
  26. package/src/components/CLMSMeetingView/CLMSMeetingEmailsView.test.jsx +5 -0
  27. package/src/components/CLMSMeetingView/CLMSMeetingSubscriberVew.test.jsx +5 -0
  28. package/src/components/CLMSMeetingView/CLMSMeetingSubscriberView.test.jsx +5 -0
  29. package/src/components/CLMSMeetingView/CLMSMeetingSubscribersView.test.jsx +5 -0
  30. package/src/components/CLMSProfileView/CLMSApiTokensView.test.jsx +5 -0
  31. package/src/components/CLMSProfileView/CLMSNewsletterSubscriberView.test.jsx +5 -0
  32. package/src/components/CLMSProfileView/CLMSProfileView.test.jsx +5 -0
  33. package/src/components/CLMSProfileView/CLMSUserProfileView.test.jsx +5 -0
  34. package/src/components/CLMSSubscriptionView/ConfirmSubscriptionView.test.jsx +5 -0
  35. package/src/components/CLMSSubscriptionView/SubscriptionView.test.jsx +5 -0
  36. package/src/components/CLMSSubscriptionView/subscription_utils.test.js +5 -0
  37. package/src/components/CclDownloadTable/CclDownloadTable.jsx +104 -7
  38. package/src/components/CclDownloadTable/CclDownloadTable.test.jsx +5 -0
  39. package/src/components/CclDownloadTable/modkData.test.js +5 -0
  40. package/src/components/CclExpandableFilter/CclExpandableFilter.test.jsx +5 -6
  41. package/src/components/CclFiltersModal/CclFiltersModal.test.jsx +5 -0
  42. package/src/components/CclFooterColumn/CclFooterColumn.test.jsx +5 -0
  43. package/src/components/CclLanguageSelector/CclLanguageSelector.test.jsx +8 -9
  44. package/src/components/CclLoginModal/CclLoginModal.test.jsx +5 -0
  45. package/src/components/CclModal/CclModal.test.js +4 -4
  46. package/src/components/CclTab/CclTab.jsx +8 -3
  47. package/src/components/CclTab/CclTab.test.jsx +5 -4
  48. package/src/components/CclTab/CclTabs.jsx +8 -9
  49. package/src/components/CclTab/CclTabs.test.jsx +5 -0
  50. package/src/components/CclTopMainMenu/CclFooterMenu.test.jsx +5 -0
  51. package/src/components/CclTopMainMenu/CclTopMainMenu.test.jsx +5 -0
  52. package/src/components/CclTopMainMenu/multilingualPath.test.js +5 -0
  53. package/src/components/CclUtils/StringToHTML.test.jsx +5 -0
  54. package/src/components/Widgets/BoundingWidget.test.jsx +5 -0
  55. package/src/components/Widgets/ContactWidget.test.jsx +5 -0
  56. package/src/components/Widgets/DistributionInfoWidget.test.jsx +5 -0
  57. package/src/components/Widgets/DownloadableFilesWidget.test.jsx +5 -0
  58. package/src/components/Widgets/GeonetworkIdentifiersWidget.test.jsx +5 -0
  59. package/src/components/Widgets/MapLayersWidget.test.jsx +5 -0
  60. package/src/components/Widgets/TextLinkWidget.test.jsx +5 -0
  61. package/src/customizations/volto/components/manage/Toolbar/Toolbar.test.jsx +5 -0
  62. package/src/customizations/volto/components/theme/Breadcrumbs/Breadcrumbs.test.jsx +5 -0
  63. package/src/customizations/volto/components/theme/Footer/Footer.test.jsx +5 -0
  64. package/src/customizations/volto/components/theme/Header/Header.test.jsx +5 -0
  65. package/src/customizations/volto/components/theme/Logo/Logo.test.jsx +5 -0
  66. package/src/customizations/volto/components/theme/Logout/Logout.test.jsx +5 -0
  67. package/src/customizations/volto/components/theme/Navigation/ContextNavigation.test.jsx +5 -0
  68. package/src/customizations/volto/components/theme/Navigation/Navigation.test.jsx +5 -0
  69. package/src/customizations/volto/components/theme/SearchWidget/SerachWidget.test.jsx +5 -0
  70. package/src/reducers/datasets_by_uid/datasets_by_uid.test.js +8 -9
  71. package/src/reducers/downloadtool/downloadtool_reducer.test.js +340 -0
  72. package/src/reducers/downloadtool/nutsnames_reducer.test.js +61 -0
  73. package/src/reducers/extra_breadcrumbs/extra_breadcrumb_reducer.test.js +4 -8
  74. package/src/reducers/geonetwork/import_geonetwork_reducer.test.js +1 -1
  75. package/src/reducers/meeting/meeting_register_reducer.test.js +82 -0
  76. package/src/reducers/meeting/meeting_subscribers_reducer.test.js +149 -0
  77. package/src/reducers/newsletter/get_newsletter_reducer.test.js +1 -1
  78. package/src/reducers/registry/registry.test.js +1 -1
  79. package/src/reducers/subscription/subscription_reducer.test.js +13 -2
  80. package/src/reducers/tokens/tokens.test.js +1 -1
  81. package/src/reducers/userschema/userschema.test.js +63 -0
  82. package/src/components/CLMSDatasetDetailView/MetadataContent.jsx +0 -256
package/CHANGELOG.md CHANGED
@@ -4,8 +4,23 @@ 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.67](https://github.com/eea/volto-clms-theme/compare/1.0.66...1.0.67)
8
+
9
+ - code smells [`b07ed5d`](https://github.com/eea/volto-clms-theme/commit/b07ed5d8101981349d768e47553277d1f049eed5)
10
+ - small fix [`3fc4119`](https://github.com/eea/volto-clms-theme/commit/3fc4119394c6fc0782d41878e153bff79060605d)
11
+ - all initial test created [`240fc74`](https://github.com/eea/volto-clms-theme/commit/240fc74514051740098b026cc0ad834d3a3a1763)
12
+ - render loading component while libraries accordion is loading [`d7955ae`](https://github.com/eea/volto-clms-theme/commit/d7955aebabc3b969a7753a89e54e63f58799dd1e)
13
+ - fix test imports [`3c61991`](https://github.com/eea/volto-clms-theme/commit/3c61991b8559c508ec009d2a4ebdc8bdb704a985)
14
+ - hide searchbox when the results are less than 10 [`eedda03`](https://github.com/eea/volto-clms-theme/commit/eedda03b4d752f2c54714dbb97c624eba8332494)
15
+ - downloadable files modifications [`7bdf690`](https://github.com/eea/volto-clms-theme/commit/7bdf6909693640d33e4087281d49c8497cf65c02)
16
+ - downloadable files modifications [`16b86fd`](https://github.com/eea/volto-clms-theme/commit/16b86fd056cc2790335505f80fc67d37c674f260)
17
+ - redesign dataset view [`05b2688`](https://github.com/eea/volto-clms-theme/commit/05b2688d0d490c35fe65810e0a5497712948db24)
18
+
7
19
  #### [1.0.66](https://github.com/eea/volto-clms-theme/compare/1.0.65...1.0.66)
8
20
 
21
+ > 9 February 2022
22
+
23
+ - Add tests [`#201`](https://github.com/eea/volto-clms-theme/pull/201)
9
24
  - Setup testing [`#199`](https://github.com/eea/volto-clms-theme/pull/199)
10
25
  - Setup testing [`#200`](https://github.com/eea/volto-clms-theme/pull/200)
11
26
  - Bugs n improvements [`#198`](https://github.com/eea/volto-clms-theme/pull/198)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-clms-theme",
3
- "version": "1.0.66",
3
+ "version": "1.0.67",
4
4
  "description": "volto-clms-theme: Volto theme for CLMS site",
5
5
  "main": "src/index.js",
6
6
  "author": "CodeSyntax for the European Environment Agency",
@@ -1,15 +1,14 @@
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
- import { MemoryRouter } from 'react-router-dom';
1
+ import Enzyme, { mount } from 'enzyme';
6
2
 
3
+ import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
7
4
  import CclButtonBlockEdit from './CclButtonBlockEdit';
5
+ import { MemoryRouter } from 'react-router-dom';
6
+ import { Provider } from 'react-intl-redux';
7
+ import React from 'react';
8
+ import configureStore from 'redux-mock-store';
9
+ import renderer from 'react-test-renderer';
8
10
 
9
- import Enzyme from 'enzyme';
10
- import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
11
11
  // import { shallow } from 'enzyme';
12
- import { mount } from 'enzyme';
13
12
 
14
13
  Enzyme.configure({ adapter: new Adapter() });
15
14
 
@@ -87,4 +86,38 @@ describe('CclButtonBlockEdit', () => {
87
86
  const json = component.toJSON();
88
87
  expect(json).toMatchSnapshot();
89
88
  });
89
+ //jest test for CclButtonBlockEdit onChangeBlock statement
90
+ it('CclButtonBlockEdit onChangeBlock', () => {
91
+ const store = mockStore({
92
+ content: {
93
+ create: {},
94
+ data: {},
95
+ },
96
+ intl: {
97
+ locale: 'en',
98
+ messages: {},
99
+ },
100
+ });
101
+ const data = {
102
+ href: ['https://www.google.com', 'https://www.google.com'],
103
+ disabled: true,
104
+ };
105
+ const component = mount(
106
+ <Provider store={store}>
107
+ <MemoryRouter>
108
+ <CclButtonBlockEdit
109
+ data={data}
110
+ selected={false}
111
+ block="1234"
112
+ onChangeBlock={() => {}}
113
+ onSelectBlock={() => {}}
114
+ onChangeField={() => {}}
115
+ setSidebarTab={() => {}}
116
+ />
117
+ </MemoryRouter>
118
+ </Provider>,
119
+ );
120
+ const legend = component.find('.ccl-block-editor-header');
121
+ legend.simulate('click');
122
+ });
90
123
  });
@@ -1,15 +1,14 @@
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
- import { MemoryRouter } from 'react-router-dom';
1
+ import Enzyme, { mount } from 'enzyme';
6
2
 
3
+ import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
7
4
  import CclCardBlockEdit from './CclCardBlockEdit';
5
+ import { MemoryRouter } from 'react-router-dom';
6
+ import { Provider } from 'react-intl-redux';
7
+ import React from 'react';
8
+ import configureStore from 'redux-mock-store';
9
+ import renderer from 'react-test-renderer';
8
10
 
9
- import Enzyme from 'enzyme';
10
- import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
11
11
  // import { shallow } from 'enzyme';
12
- import { mount } from 'enzyme';
13
12
 
14
13
  Enzyme.configure({ adapter: new Adapter() });
15
14
 
@@ -1,12 +1,12 @@
1
- import CclListingCards from './CclListingCards';
2
- import React from 'react';
3
- import { MemoryRouter } from 'react-router-dom';
1
+ import Enzyme, { mount } from 'enzyme';
4
2
 
5
- import Enzyme from 'enzyme';
6
3
  import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
7
- import configureStore from 'redux-mock-store';
4
+ import CclListingCards from './CclListingCards';
5
+ import { MemoryRouter } from 'react-router-dom';
8
6
  import { Provider } from 'react-intl-redux';
9
- import { mount } from 'enzyme';
7
+ import React from 'react';
8
+ import configureStore from 'redux-mock-store';
9
+
10
10
  Enzyme.configure({ adapter: new Adapter() });
11
11
 
12
12
  const mockStore = configureStore();
@@ -0,0 +1,27 @@
1
+ import BoundingBoxComponent from './BoundingBoxComponent';
2
+ import React from 'react';
3
+ import { MemoryRouter } from 'react-router-dom';
4
+
5
+ import Enzyme from 'enzyme';
6
+ import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
7
+ import { mount } from 'enzyme';
8
+ Enzyme.configure({ adapter: new Adapter() });
9
+
10
+ //jest test for BoundingBoxComponent
11
+ describe('BoundingBoxComponent', () => {
12
+ //test for BoundingBoxComponent rendering
13
+ it('Check if BoundingBoxComponent is rendered', () => {
14
+ const boundingBox = {
15
+ west: -180,
16
+ east: 180,
17
+ north: 90,
18
+ south: -90,
19
+ };
20
+ const wrapper = mount(
21
+ <MemoryRouter>
22
+ <BoundingBoxComponent bbox={boundingBox} />
23
+ </MemoryRouter>,
24
+ );
25
+ expect(wrapper).toBeDefined();
26
+ });
27
+ });
@@ -6,14 +6,13 @@
6
6
  import {
7
7
  DataSetInfoContent,
8
8
  DownloadDataSetContent,
9
- // MetadataContent,
10
9
  } from '@eeacms/volto-clms-theme/components/CLMSDatasetDetailView';
11
- import { FormattedMessage } from 'react-intl';
12
10
  import { Modal, Segment } from 'semantic-ui-react';
13
11
  import { useDispatch, useSelector } from 'react-redux';
14
12
 
15
13
  import CclButton from '@eeacms/volto-clms-theme/components/CclButton/CclButton';
16
14
  import CclTabs from '@eeacms/volto-clms-theme/components/CclTab/CclTabs';
15
+ import { FormattedMessage } from 'react-intl';
17
16
  import PropTypes from 'prop-types';
18
17
  import React from 'react';
19
18
  import { compose } from 'redux';
@@ -181,15 +180,19 @@ const CLMSDatasetDetailView = ({ content, token }) => {
181
180
  )}
182
181
  <CclTabs routing={true}>
183
182
  <div tabTitle="General Info">{DataSetInfoContent(content)}</div>
184
- {/* borratzeko */}
185
- {/* <div tabTitle="Metadata">{MetadataContent(content)}</div> */}
186
- {/* */}
187
-
188
- {content?.downloadable_dataset ? (
189
- <div tabTitle="Download">{DownloadDataSetContent(content)}</div>
190
- ) : (
191
- <div tabTitle=""></div>
192
- )}
183
+ {content?.downloadable_dataset &&
184
+ content?.downloadable_files?.items?.length > 0 && (
185
+ <div tabTitle="Download">{DownloadDataSetContent(content)}</div>
186
+ )}
187
+ {content?.downloadable_dataset &&
188
+ content?.downloadable_files?.items?.length === 0 && (
189
+ <div
190
+ tabTitle="Download"
191
+ redirect={`${location.pathname}/download-by-area`}
192
+ >
193
+ {''}
194
+ </div>
195
+ )}
193
196
 
194
197
  <div underPanel={true}>
195
198
  <nav className="left-menu-detail">
@@ -31,6 +31,81 @@ describe('CLMSDatasetDetailView', () => {
31
31
  'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
32
32
  alt: 'Placeholder',
33
33
  },
34
+ downloadable_dataset: true,
35
+ downloadable_files: [
36
+ {
37
+ title: 'example title',
38
+ description: 'example description',
39
+ tooltip: 'example tooltip',
40
+ url: './example',
41
+ },
42
+ {
43
+ title: 'example title',
44
+ description: 'example description',
45
+ tooltip: 'example tooltip',
46
+ url: './example',
47
+ },
48
+ ],
49
+ };
50
+ const store = mockStore({
51
+ content: {
52
+ ...content,
53
+ },
54
+ intl: {
55
+ locale: 'en',
56
+ messages: {},
57
+ },
58
+ search: {
59
+ subrequest: {
60
+ '123': { items: [] },
61
+ },
62
+ },
63
+ users: {
64
+ user: { roles: ['Manager'] },
65
+ },
66
+ userSession: {
67
+ token:
68
+ 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTY0NDM4MzA0NCwiZnVsbG5hbWUiOm51bGx9.cB_q3Q0Jhu8h2m_SDmmknodpDxDLfb4o-qY6Y2plE04',
69
+ },
70
+ });
71
+
72
+ const DatasetDetailView = renderer
73
+ .create(
74
+ <Provider store={store}>
75
+ <MemoryRouter>
76
+ <CLMSDatasetDetailView content={content}>
77
+ <p>Metadata view test</p>
78
+ </CLMSDatasetDetailView>
79
+ </MemoryRouter>
80
+ </Provider>,
81
+ )
82
+ .toJSON();
83
+ expect(DatasetDetailView).toBeDefined();
84
+ });
85
+ it('Check metadata view without downloadable files', () => {
86
+ const content = {
87
+ title: 'Test title!',
88
+ url: './example',
89
+ description: 'Description test',
90
+ download: true,
91
+ dataResourceTitle: 'example title',
92
+ dataResourceAbstract: {
93
+ data: 'exampledata',
94
+ },
95
+ dataSources: {
96
+ title: 'example title',
97
+ description: 'example description',
98
+ tooltip: 'example tooltip',
99
+ data: 'Source data',
100
+ },
101
+ dataResourceLocator: 'Resource locator',
102
+ image: {
103
+ src:
104
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
105
+ alt: 'Placeholder',
106
+ },
107
+ downloadable_dataset: true,
108
+ downloadable_files: [],
34
109
  };
35
110
  const store = mockStore({
36
111
  content: {
@@ -67,4 +142,53 @@ describe('CLMSDatasetDetailView', () => {
67
142
  .toJSON();
68
143
  expect(DatasetDetailView).toBeDefined();
69
144
  });
145
+ it('Check metadata view with geonetwork_identifiers items lenght > 0 user roles exists and user roles includes manager', () => {
146
+ const content = {
147
+ geonetwork_identifiers: [
148
+ {
149
+ title: 'example title',
150
+ description: 'example description',
151
+ tooltip: 'example tooltip',
152
+ url: './example',
153
+ },
154
+ {
155
+ title: 'example title',
156
+ description: 'example description',
157
+ tooltip: 'example tooltip',
158
+ url: './example',
159
+ },
160
+ ],
161
+ };
162
+ const store = mockStore({
163
+ content: {
164
+ ...content,
165
+ },
166
+ intl: {
167
+ locale: 'en',
168
+ messages: {},
169
+ },
170
+ search: {
171
+ subrequest: {
172
+ '123': { items: [] },
173
+ },
174
+ },
175
+ user: { roles: ['Manager'] },
176
+ userSession: {
177
+ token:
178
+ 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImV4cCI6MTY0NDM4MzA0NCwiZnVsbG5hbWUiOm51bGx9.cB_q3Q0Jhu8h2m_SDmmknodpDxDLfb4o-qY6Y2plE04',
179
+ },
180
+ });
181
+ const DatasetDetailView = renderer
182
+ .create(
183
+ <Provider store={store}>
184
+ <MemoryRouter>
185
+ <CLMSDatasetDetailView content={content}>
186
+ <p>Metadata view test</p>
187
+ </CLMSDatasetDetailView>
188
+ </MemoryRouter>
189
+ </Provider>,
190
+ )
191
+ .toJSON();
192
+ expect(DatasetDetailView).toBeDefined();
193
+ });
70
194
  });
@@ -0,0 +1,34 @@
1
+ import ContactComponent from './ContactComponent';
2
+ import React from 'react';
3
+ import renderer from 'react-test-renderer';
4
+ import { MemoryRouter } from 'react-router-dom';
5
+
6
+ import Enzyme from 'enzyme';
7
+ import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
8
+ Enzyme.configure({ adapter: new Adapter() });
9
+ //jest test for ContactComponent
10
+ describe('ContactComponent', () => {
11
+ //test for ContactComponent rendering
12
+ it('Check if ContactComponent is rendered', () => {
13
+ const contact = {
14
+ organisationName: 'Test',
15
+ deliveryPoint: 'Test',
16
+ city: 'Test',
17
+ administrativeArea: 'Test',
18
+ postalCode: 'Test',
19
+ country: 'Test',
20
+ electronicMailAddress: 'Test',
21
+ url: 'Test',
22
+ urlTitle: 'Test',
23
+ roleCode: 'Test',
24
+ };
25
+ const contactComponent = renderer
26
+ .create(
27
+ <MemoryRouter>
28
+ <ContactComponent contact={contact} />
29
+ </MemoryRouter>,
30
+ )
31
+ .toJSON();
32
+ expect(contactComponent).toBeDefined();
33
+ });
34
+ });
@@ -1,7 +1,7 @@
1
+ import { Accordion, Loader, Segment } from 'semantic-ui-react';
1
2
  import { CclInfoContainer, CclInfoDescription } from '../CclInfoDescription';
2
3
  import { useDispatch, useSelector } from 'react-redux';
3
4
 
4
- import { Accordion } from 'semantic-ui-react';
5
5
  import AnimateHeight from 'react-animate-height';
6
6
  import CclCard from '@eeacms/volto-clms-theme/components/CclCard/CclCard';
7
7
  import CclCitation from '@eeacms/volto-clms-theme/components/CclCitation/CclCitation';
@@ -13,30 +13,37 @@ import { searchContent } from '@plone/volto/actions';
13
13
 
14
14
  const DataSetInfoContent = (props) => {
15
15
  const dispatch = useDispatch();
16
- const { UID, id } = props;
17
- const path = props['@id'];
16
+ const {
17
+ UID,
18
+ id,
19
+ validation,
20
+ dataResourceAbstract,
21
+ data,
22
+ geonetwork_identifiers,
23
+ citation,
24
+ } = props;
18
25
  const searchSubrequests = useSelector((state) => state.search.subrequests);
19
26
  let libraries = searchSubrequests?.[id]?.items || [];
20
-
27
+ let librariesPending = searchSubrequests?.[id]?.loading;
21
28
  React.useEffect(() => {
22
- dispatch(
23
- searchContent(
24
- path,
25
- {
26
- fullobjects: 1,
27
- portal_type: 'TechnicalLibrary',
28
- path: '/',
29
- associated_datasets: UID,
30
- },
31
- id,
32
- ),
33
- );
34
- }, [path, id, UID, dispatch]);
29
+ UID &&
30
+ dispatch(
31
+ searchContent(
32
+ '',
33
+ {
34
+ fullobjects: 1,
35
+ portal_type: 'TechnicalLibrary',
36
+ path: '/',
37
+ associated_datasets: UID,
38
+ },
39
+ id,
40
+ ),
41
+ );
42
+ }, [id, UID, dispatch]);
35
43
 
36
- const [activeIndex, setActiveIndex] = React.useState([0]);
44
+ const [activeIndex, setActiveIndex] = React.useState([99]);
37
45
 
38
- const handleClick = (e, itemProps) => {
39
- const { index } = itemProps;
46
+ const handleClick = ({ index }) => {
40
47
  const newIndex =
41
48
  activeIndex.indexOf(index) === -1
42
49
  ? [...activeIndex, index]
@@ -46,96 +53,144 @@ const DataSetInfoContent = (props) => {
46
53
  };
47
54
  const titleIcons = config.blocks?.blocksConfig?.accordion?.titleIcons;
48
55
 
49
- const isExclusive = (index) => {
50
- return activeIndex.includes(index);
56
+ const renderAccordion = (gn, lib) => {
57
+ return gn?.length > 0 || lib?.length > 0;
51
58
  };
52
59
 
53
- function iconName(iProps, iTitleIcons) {
54
- return iProps?.data?.right_arrows
60
+ function iconName(iconData, iTitleIcons) {
61
+ return iconData?.right_arrows
55
62
  ? iTitleIcons.rightPosition
56
63
  : iTitleIcons.leftPosition;
57
64
  }
58
65
 
59
66
  return (
60
67
  <div>
61
- {props?.validation?.data && (
68
+ {validation?.data && validation?.data !== '<p><br/></p>' && (
62
69
  <CclCitation
63
70
  title="Validation status"
64
71
  marginBottom={true}
65
- children={<StringToHTML string={props.validation.data} />}
72
+ children={<StringToHTML string={validation.data} />}
66
73
  ></CclCitation>
67
74
  )}
68
75
  <CclInfoContainer>
69
- <h2>General Info</h2>
70
-
71
- {props?.dataResourceAbstract?.data && (
72
- <CclInfoDescription
73
- title="Data resource title"
74
- description={props.dataResourceTitle}
75
- tooltip="Name by which the cited resource is known"
76
- ></CclInfoDescription>
77
- )}
78
-
79
- {props?.dataResourceAbstract?.data && (
76
+ {dataResourceAbstract?.data && (
80
77
  <CclInfoDescription
81
78
  title="Data resource abstract"
82
- description={
83
- <StringToHTML string={props.dataResourceAbstract.data} />
84
- }
79
+ description={<StringToHTML string={dataResourceAbstract.data} />}
85
80
  tooltip="Brief narrative summary of the content of the resource(s) with coverage, main attributes, data sources, important of the work, etc."
86
81
  ></CclInfoDescription>
87
82
  )}
88
-
89
- {props?.dataSources?.data && (
90
- <CclInfoDescription
91
- title="Resource type"
92
- description={<StringToHTML string={props.dataSources.data} />}
93
- tooltip="Scope to which metadata applies."
94
- ></CclInfoDescription>
95
- )}
96
83
  </CclInfoContainer>
97
- {libraries?.length > 0 && (
98
- <div className="dataset-info-documents dropdown">
99
- <div className="accordion-block">
100
- <Accordion fluid styled>
101
- <React.Fragment>
102
- <Accordion.Title
103
- as={'h2'}
104
- onClick={handleClick}
105
- className={'accordion-title align-arrow-right'}
106
- >
107
- {isExclusive() ? (
108
- <Icon
109
- name={iconName(props, titleIcons.opened)}
110
- size="24px"
111
- />
112
- ) : (
113
- <Icon
114
- name={iconName(props, titleIcons.closed)}
115
- size="24px"
116
- />
117
- )}
118
- <span>Technical documents</span>
119
- </Accordion.Title>
120
- <Accordion.Content active={isExclusive()}>
121
- <AnimateHeight animateOpacity duration={500} height={'auto'}>
122
- {libraries.map((item, index) => (
123
- <CclCard key={index} type="doc" card={item} />
124
- ))}
125
- </AnimateHeight>
126
- </Accordion.Content>
127
- </React.Fragment>
128
- </Accordion>
129
- </div>
84
+ <div className="dataset-info-documents dropdown">
85
+ <div className="accordion-block">
86
+ {renderAccordion(geonetwork_identifiers?.items, libraries) && (
87
+ <Segment basic>
88
+ {geonetwork_identifiers?.items?.length > 0 && (
89
+ <Accordion fluid styled>
90
+ <Accordion.Title
91
+ as={'h2'}
92
+ onClick={() => handleClick({ index: 0 })}
93
+ className={'accordion-title align-arrow-right'}
94
+ >
95
+ {activeIndex.includes(0) ? (
96
+ <Icon
97
+ name={iconName(data, titleIcons.opened)}
98
+ size="24px"
99
+ />
100
+ ) : (
101
+ <Icon
102
+ name={iconName(data, titleIcons.closed)}
103
+ size="24px"
104
+ />
105
+ )}
106
+ <span>Metadata</span>
107
+ </Accordion.Title>
108
+ <Accordion.Content active={activeIndex.includes(0)}>
109
+ <AnimateHeight
110
+ animateOpacity
111
+ duration={500}
112
+ height={'auto'}
113
+ >
114
+ <ul>
115
+ {geonetwork_identifiers.items.map((geonetwork, key) => (
116
+ <li key={key}>
117
+ <strong>{geonetwork.title}</strong> -{' '}
118
+ <a
119
+ href={
120
+ geonetwork.type === 'EEA'
121
+ ? `https://sdi.eea.europa.eu/catalogue/srv/api/records/${geonetwork.id}/formatters/xsl-view?output=pdf&language=eng&approved=true`
122
+ : `https://land.copernicus.vgt.vito.be/geonetwork/srv/api/records/${geonetwork.id}/formatters/xsl-view?root=div&output=pdf`
123
+ }
124
+ rel="noreferrer"
125
+ target="_blank"
126
+ >
127
+ PDF
128
+ </a>{' '}
129
+ -{' '}
130
+ <a
131
+ href={
132
+ geonetwork.type === 'EEA'
133
+ ? `https://sdi.eea.europa.eu/catalogue/srv/api/records/${geonetwork.id}/formatters/xml?approved=true`
134
+ : `https://land.copernicus.vgt.vito.be/geonetwork/srv/api/records/${geonetwork.id}/formatters/xml?attachment=true`
135
+ }
136
+ rel="noreferrer"
137
+ target="_blank"
138
+ >
139
+ XML
140
+ </a>
141
+ </li>
142
+ ))}
143
+ </ul>
144
+ </AnimateHeight>
145
+ </Accordion.Content>
146
+ </Accordion>
147
+ )}
148
+ {librariesPending && <Loader active inline="centered" />}
149
+ {libraries?.length > 0 && (
150
+ <Accordion fluid styled>
151
+ <Accordion.Title
152
+ as={'h2'}
153
+ onClick={() => handleClick({ index: 1 })}
154
+ className={'accordion-title align-arrow-right'}
155
+ >
156
+ {activeIndex.includes(1) ? (
157
+ <Icon
158
+ name={iconName(data, titleIcons.opened)}
159
+ size="24px"
160
+ />
161
+ ) : (
162
+ <Icon
163
+ name={iconName(data, titleIcons.closed)}
164
+ size="24px"
165
+ />
166
+ )}
167
+ <span>Technical documents</span>
168
+ </Accordion.Title>
169
+ <Accordion.Content active={activeIndex.includes(1)}>
170
+ <AnimateHeight
171
+ animateOpacity
172
+ duration={500}
173
+ height={'auto'}
174
+ >
175
+ {libraries.map((item, index) => (
176
+ <CclCard key={index} type="doc" card={item} />
177
+ ))}
178
+ </AnimateHeight>
179
+ </Accordion.Content>
180
+ </Accordion>
181
+ )}
182
+ </Segment>
183
+ )}
130
184
  </div>
131
- )}
185
+ </div>
132
186
 
133
- <CclCitation title="Dataset citation" marginBottom={true}>
134
- <p>
135
- © European Union, Copernicus Land Monitoring Service , European
136
- Environment Agency (EEA)
137
- </p>
138
- </CclCitation>
187
+ {citation?.data && citation?.data !== '<p><br/></p>' && (
188
+ <CclCitation
189
+ title="Citation status"
190
+ marginBottom={true}
191
+ children={<StringToHTML string={citation?.data} />}
192
+ ></CclCitation>
193
+ )}
139
194
  </div>
140
195
  );
141
196
  };