@eeacms/volto-clms-theme 1.0.63 → 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 (204) hide show
  1. package/CHANGELOG.md +148 -3
  2. package/jest-addon.config.js +5 -0
  3. package/package.json +20 -17
  4. package/src/actions/datasets_by_uid/datasets_by_uid.test.js +14 -0
  5. package/src/actions/downloadtool/downloadtool.test.js +54 -0
  6. package/src/actions/downloadtool/get_downloadtool.js +22 -1
  7. package/src/actions/extra_breadcrumbs/extra_breadcrumb.test.js +16 -0
  8. package/src/actions/format_conversion_table/format_conversion_table.test.js +16 -0
  9. package/src/actions/geonetwork/import_geonetwork.test.js +15 -0
  10. package/src/actions/index.js +2 -0
  11. package/src/actions/meeting/meeting.test.js +41 -0
  12. package/src/actions/newsletter/get_newsletter_subscribers.test.js +14 -0
  13. package/src/actions/projections/get_projections.test.js +13 -0
  14. package/src/actions/registry/registry.test.js +15 -0
  15. package/src/actions/subscription/post_subscription.js +0 -3
  16. package/src/actions/subscription/post_subscription.test.js +64 -0
  17. package/src/actions/tokens/tokens.test.js +39 -0
  18. package/src/actions/userschema/userschema.test.js +14 -0
  19. package/src/components/Blocks/CclButtonBlock/CclButtonBlockEdit.test.jsx +123 -0
  20. package/src/components/Blocks/CclButtonBlock/CclButtonBlockView.jsx +8 -11
  21. package/src/components/Blocks/CclButtonBlock/CclButtonBlockView.test.jsx +42 -0
  22. package/src/components/Blocks/CclButtonBlock/__snapshots__/CclButtonBlockEdit.test.jsx.snap +27 -0
  23. package/src/components/Blocks/CclButtonBlock/__snapshots__/CclButtonBlockView.test.jsx.snap +56 -0
  24. package/src/components/Blocks/CclCardBlock/CclCardBlockEdit.jsx +8 -8
  25. package/src/components/Blocks/CclCardBlock/CclCardBlockEdit.test.jsx +159 -0
  26. package/src/components/Blocks/CclCardBlock/CclCardBlockView.test.jsx +61 -0
  27. package/src/components/Blocks/CclCardBlock/__snapshots__/CclCardBlockEdit.test.jsx.snap +45 -0
  28. package/src/components/Blocks/CclCardContainerBlock/CclCardContainerBlockEdit.jsx +8 -12
  29. package/src/components/Blocks/CclCardContainerBlock/CclCardContainerBlockView.jsx +3 -3
  30. package/src/components/Blocks/CclContextNavigationBlock/CclContextNavigationBlockEdit.test.jsx +42 -0
  31. package/src/components/Blocks/CclContextNavigationBlock/CclContextNavigationBlockView.test.jsx +42 -0
  32. package/src/components/Blocks/CclContextNavigationBlock/__snapshots__/CclContextNavigationBlockEdit.test.jsx.snap +12 -0
  33. package/src/components/Blocks/CclContextNavigationBlock/__snapshots__/CclContextNavigationBlockView.test.jsx.snap +3 -0
  34. package/src/components/Blocks/CclHomeBgImageBlock/CclHomeImageEditor.jsx +43 -41
  35. package/src/components/Blocks/CclHomeProductsBlock/CclHomeProductsBlockView.test.jsx +54 -0
  36. package/src/components/Blocks/CclHomeProductsBlock/__snapshots__/CclHomeProductsBlockView.test.jsx.snap +57 -0
  37. package/src/components/Blocks/CclHomeSearchBlock/CclHomeSearchBlockEdit.jsx +9 -10
  38. package/src/components/Blocks/CclHomeSearchBlock/CclHomeSearchBlockView.jsx +28 -9
  39. package/src/components/Blocks/CclHomeSearchBlock/CclHomeSearchBlockView.test.jsx +113 -0
  40. package/src/components/Blocks/CclHomeSearchBlock/__snapshots__/CclHomeSearchBlockView.test.jsx.snap +310 -0
  41. package/src/components/Blocks/CclHomeUsersBlock/CclHomeUserBlockView.test.jsx +61 -0
  42. package/src/components/Blocks/CclHomeUsersBlock/CclHomeUsersBlockEdit.jsx +180 -146
  43. package/src/components/Blocks/CclHomeUsersBlock/CclHomeUsersBlockView.jsx +8 -1
  44. package/src/components/Blocks/CclHomeUsersBlock/HomeUsersSchema.js +0 -1
  45. package/src/components/Blocks/CclRelatedListingBlock/CclRelatedListingEdit.jsx +4 -6
  46. package/src/components/Blocks/CclRelatedListingBlock/CclRelatedListingView.jsx +26 -23
  47. package/src/components/Blocks/CclTextLinkCarouselBlock/CclTextLinkCarouselEdit.jsx +4 -10
  48. package/src/components/Blocks/CclTextLinkCarouselBlock/CclTextLinkCarouselView.jsx +2 -6
  49. package/src/components/Blocks/CclUseCaseList/CclUseCaseListEdit.jsx +16 -13
  50. package/src/components/Blocks/CclUseCaseList/CclUseCaseListView.jsx +17 -19
  51. package/src/components/Blocks/CclUseCaseList/utils.js +1 -1
  52. package/src/components/Blocks/CustomTemplates/VoltoArcgisBlock/CclMapMenu.jsx +2 -2
  53. package/src/components/Blocks/CustomTemplates/VoltoFormBlock/customIdFieldSchema.js +2 -2
  54. package/src/components/Blocks/CustomTemplates/VoltoListingBlock/CclListingCards.jsx +0 -3
  55. package/src/components/Blocks/CustomTemplates/VoltoListingBlock/CclListingCards.test.jsx +247 -0
  56. package/src/components/Blocks/CustomTemplates/VoltoSearchBlock/AccordionFacet.jsx +82 -0
  57. package/src/components/Blocks/CustomTemplates/VoltoSearchBlock/RightModalFacets.jsx +37 -31
  58. package/src/components/Blocks/CustomTemplates/VoltoSearchBlock/WithType.jsx +8 -0
  59. package/src/components/Blocks/CustomTemplates/VoltoSearchBlock/index.js +3 -3
  60. package/src/components/Blocks/CustomTemplates/VoltoTabsBlock/CclCarouselView.jsx +17 -48
  61. package/src/components/Blocks/CustomTemplates/VoltoTabsBlock/CclTabsView.jsx +11 -55
  62. package/src/components/Blocks/CustomTemplates/VoltoTabsBlock/CclVerticalFaqTabsView.jsx +17 -17
  63. package/src/components/Blocks/CustomTemplates/VoltoTabsBlock/CclVerticalTabsView.jsx +24 -15
  64. package/src/components/Blocks/CustomTemplates/VoltoTabsBlock/RoutingHOC.jsx +18 -48
  65. package/src/components/Blocks/CustomTemplates/VoltoTabsBlock/TabsWidget.jsx +11 -8
  66. package/src/components/Blocks/customBlocks.js +57 -155
  67. package/src/components/Blocks/{CclCardContainerBlock/utils.js → utils.js} +0 -0
  68. package/src/components/CLMSDatasetDetailView/BoundingBoxComponent.test.jsx +27 -0
  69. package/src/components/CLMSDatasetDetailView/CLMSDatasetDetailView.jsx +14 -21
  70. package/src/components/CLMSDatasetDetailView/CLMSDatasetDetailView.test.jsx +194 -0
  71. package/src/components/CLMSDatasetDetailView/ContactComponent.test.jsx +34 -0
  72. package/src/components/CLMSDatasetDetailView/DataSetInfoContent.jsx +155 -101
  73. package/src/components/CLMSDatasetDetailView/DataSetInfoContent.test.jsx +63 -0
  74. package/src/components/CLMSDatasetDetailView/DistributionInfoComponent.test.jsx +24 -0
  75. package/src/components/CLMSDatasetDetailView/DownloadDataSetContent.jsx +1 -13
  76. package/src/components/CLMSDatasetDetailView/DownloadDataSetContent.test.jsx +136 -0
  77. package/src/components/CLMSDatasetDetailView/index.js +0 -1
  78. package/src/components/CLMSDownloadCartView/CLMSCartContent.jsx +202 -144
  79. package/src/components/CLMSDownloadCartView/CLMSCartContent.test.jsx +5 -0
  80. package/src/components/CLMSDownloadCartView/CLMSDownloadCartView.jsx +39 -45
  81. package/src/components/CLMSDownloadCartView/CLMSDownloadCartView.test.jsx +5 -0
  82. package/src/components/CLMSDownloadCartView/cartUtils.js +9 -7
  83. package/src/components/CLMSDownloadCartView/cartUtils.test.js +5 -0
  84. package/src/components/CLMSDownloadCartView/conversion.js +1 -2
  85. package/src/components/CLMSDownloadCartView/conversion.test.js +5 -0
  86. package/src/components/CLMSDownloadableFileView/CLMSDownloadableFile.test.jsx +5 -0
  87. package/src/components/CLMSDownloadableFileView/CLMSDownloadableFileView.jsx +10 -1
  88. package/src/components/CLMSDownloadsView/CLMSDownloadTasks.jsx +196 -0
  89. package/src/components/CLMSDownloadsView/CLMSDownloadTasks.test.jsx +5 -0
  90. package/src/components/CLMSDownloadsView/CLMSDownloadsView.jsx +141 -0
  91. package/src/components/CLMSDownloadsView/CLMSDownloadsView.test.jsx +5 -0
  92. package/src/components/CLMSDownloadsView/FileCard.jsx +231 -0
  93. package/src/components/CLMSDownloadsView/FileCard.test.jsx +5 -0
  94. package/src/components/CLMSDownloadsView/filecard.less +21 -0
  95. package/src/components/CLMSMapViewerView/CLMSMapViewerView.jsx +3 -3
  96. package/src/components/CLMSMapViewerView/CLMSMapViewerView.test.jsx +5 -0
  97. package/src/components/CLMSMeetingView/CLMSMeetingEmailView.test.jsx +5 -0
  98. package/src/components/CLMSMeetingView/CLMSMeetingEmailsView.jsx +6 -5
  99. package/src/components/CLMSMeetingView/CLMSMeetingEmailsView.test.jsx +5 -0
  100. package/src/components/CLMSMeetingView/CLMSMeetingSubscriberVew.test.jsx +5 -0
  101. package/src/components/CLMSMeetingView/CLMSMeetingSubscriberView.test.jsx +5 -0
  102. package/src/components/CLMSMeetingView/CLMSMeetingSubscribersView.test.jsx +5 -0
  103. package/src/components/CLMSMeetingView/CLMSMeetingView.jsx +49 -36
  104. package/src/components/CLMSNewsItemView/CLMSNewsItemView.test.jsx +44 -0
  105. package/src/components/CLMSProfileView/CLMSApiTokensView.test.jsx +5 -0
  106. package/src/components/CLMSProfileView/CLMSNewsletterSubscriberView.test.jsx +5 -0
  107. package/src/components/CLMSProfileView/CLMSProfileView.jsx +6 -3
  108. package/src/components/CLMSProfileView/CLMSProfileView.test.jsx +5 -0
  109. package/src/components/CLMSProfileView/CLMSUserProfileView.test.jsx +5 -0
  110. package/src/components/CLMSSubscriptionView/ConfirmSubscriptionView.jsx +18 -12
  111. package/src/components/CLMSSubscriptionView/ConfirmSubscriptionView.test.jsx +5 -0
  112. package/src/components/CLMSSubscriptionView/SubscriptionView.jsx +33 -33
  113. package/src/components/CLMSSubscriptionView/SubscriptionView.test.jsx +5 -0
  114. package/src/components/CLMSSubscriptionView/subscription_utils.test.js +5 -0
  115. package/src/components/CclButton/CclButton.jsx +4 -3
  116. package/src/components/CclButton/CclButton.test.js +76 -0
  117. package/src/components/CclCard/CclCard.jsx +5 -34
  118. package/src/components/CclCard/CclCard.test.jsx +133 -0
  119. package/src/components/CclCitation/CclCitation.test.jsx +11 -0
  120. package/src/components/CclCitation/__snapshots__/CclCitation.test.jsx.snap +14 -0
  121. package/src/components/CclDownloadTable/CclDownloadTable.jsx +145 -40
  122. package/src/components/CclDownloadTable/CclDownloadTable.test.jsx +5 -0
  123. package/src/components/CclDownloadTable/download-table.less +14 -1
  124. package/src/components/CclDownloadTable/modkData.test.js +5 -0
  125. package/src/components/CclExpandableFilter/CclExpandableFilter.test.jsx +60 -0
  126. package/src/components/CclFiltersModal/CclFiltersModal.test.jsx +5 -0
  127. package/src/components/CclFooterColumn/CclFooterColumn.test.jsx +5 -0
  128. package/src/components/CclInfoDescription/CclInfoContainer.test.js +16 -0
  129. package/src/components/CclInfoDescription/CclInfoDescription.test.js +18 -0
  130. package/src/components/CclLanguageSelector/CclLanguageSelector.jsx +80 -109
  131. package/src/components/CclLanguageSelector/CclLanguageSelector.test.jsx +117 -0
  132. package/src/components/CclLanguageSelector/__snapshots__/CclLanguageSelector.test.jsx.snap +43 -0
  133. package/src/components/CclLoginModal/CclLoginModal.jsx +3 -1
  134. package/src/components/CclLoginModal/CclLoginModal.test.jsx +5 -0
  135. package/src/components/CclModal/CclModal.test.js +71 -0
  136. package/src/components/CclTab/CclTab.jsx +8 -3
  137. package/src/components/CclTab/CclTab.test.jsx +55 -0
  138. package/src/components/CclTab/CclTabs.jsx +10 -11
  139. package/src/components/CclTab/CclTabs.test.jsx +5 -0
  140. package/src/components/CclTopMainMenu/CclFooterMenu.jsx +4 -4
  141. package/src/components/CclTopMainMenu/CclFooterMenu.test.jsx +5 -0
  142. package/src/components/CclTopMainMenu/CclTopMainMenu.jsx +6 -6
  143. package/src/components/CclTopMainMenu/CclTopMainMenu.test.jsx +5 -0
  144. package/src/components/CclTopMainMenu/multilingualPath.js +1 -3
  145. package/src/components/CclTopMainMenu/multilingualPath.test.js +5 -0
  146. package/src/components/CclUtils/StringToHTML.test.jsx +5 -0
  147. package/src/components/CclVerticalFilterMenu/CclVerticalFilterMenu.jsx +2 -2
  148. package/src/components/CclVerticalFilterMenu/CclVerticalFilterMenu.test.jsx +30 -0
  149. package/src/components/Widgets/BoundingWidget.test.jsx +5 -0
  150. package/src/components/Widgets/ContactWidget.test.jsx +5 -0
  151. package/src/components/Widgets/DistributionInfoWidget.test.jsx +5 -0
  152. package/src/components/Widgets/DownloadableFilesWidget.test.jsx +5 -0
  153. package/src/components/Widgets/GeonetworkIdentifiersWidget.test.jsx +5 -0
  154. package/src/components/Widgets/MapLayersWidget.jsx +8 -1
  155. package/src/components/Widgets/MapLayersWidget.test.jsx +5 -0
  156. package/src/components/Widgets/TextLinkWidget.test.jsx +5 -0
  157. package/src/customizations/volto/components/manage/Toolbar/Toolbar.test.jsx +5 -0
  158. package/src/customizations/volto/components/theme/Breadcrumbs/Breadcrumbs.test.jsx +5 -0
  159. package/src/customizations/volto/components/theme/Footer/Footer.jsx +58 -34
  160. package/src/customizations/volto/components/theme/Footer/Footer.test.jsx +5 -0
  161. package/src/customizations/volto/components/theme/Header/Header.jsx +57 -71
  162. package/src/customizations/volto/components/theme/Header/Header.test.jsx +5 -0
  163. package/src/customizations/volto/components/theme/Logo/Logo.test.jsx +5 -0
  164. package/src/customizations/volto/components/theme/Logout/Logout.jsx +74 -0
  165. package/src/customizations/volto/components/theme/Logout/Logout.test.jsx +5 -0
  166. package/src/customizations/volto/components/theme/Navigation/ContextNavigation.test.jsx +5 -0
  167. package/src/customizations/volto/components/theme/Navigation/Navigation.test.jsx +5 -0
  168. package/src/customizations/volto/components/theme/SearchWidget/SerachWidget.test.jsx +5 -0
  169. package/src/index.js +9 -5
  170. package/src/reducers/datasets_by_uid/datasets_by_uid.test.js +53 -0
  171. package/src/reducers/downloadtool/downloadtool_reducer.js +34 -66
  172. package/src/reducers/downloadtool/downloadtool_reducer.test.js +340 -0
  173. package/src/reducers/downloadtool/nutsnames_reducer.js +45 -0
  174. package/src/reducers/downloadtool/nutsnames_reducer.test.js +61 -0
  175. package/src/reducers/extra_breadcrumbs/extra_breadcrumb_reducer.js +21 -1
  176. package/src/reducers/extra_breadcrumbs/extra_breadcrumb_reducer.test.js +51 -0
  177. package/src/reducers/geonetwork/import_geonetwork_reducer.test.js +60 -0
  178. package/src/reducers/index.js +4 -4
  179. package/src/reducers/meeting/meeting_register_reducer.test.js +82 -0
  180. package/src/reducers/meeting/meeting_subscribers_reducer.js +4 -2
  181. package/src/reducers/meeting/meeting_subscribers_reducer.test.js +149 -0
  182. package/src/reducers/newsletter/get_newsletter_reducer.test.js +75 -0
  183. package/src/reducers/registry/registry.test.js +74 -0
  184. package/src/reducers/subscription/subscription_reducer.test.js +71 -0
  185. package/src/reducers/tokens/tokens.test.js +221 -0
  186. package/src/reducers/userschema/userschema.js +1 -1
  187. package/src/reducers/userschema/userschema.test.js +63 -0
  188. package/theme/clms/css/carousel.css +1 -1
  189. package/theme/clms/css/header.css +4 -0
  190. package/theme/clms/css/home.css +4 -4
  191. package/theme/clms/css/styles.less +17 -4
  192. package/src/components/Blocks/CclHomeUsersBlock/utils.js +0 -27
  193. package/src/components/Blocks/CclProductLeftMenu/CclProductLeftMenuEdit.jsx +0 -124
  194. package/src/components/Blocks/CclProductLeftMenu/CclProductLeftMenuView.jsx +0 -48
  195. package/src/components/Blocks/CclProductLeftMenu/LeftMenuSchema.js +0 -78
  196. package/src/components/Blocks/CclProductLeftMenu/utils.js +0 -25
  197. package/src/components/Blocks/CustomTemplates/VoltoSearchBlock/AccordionCheckboxFacet.jsx +0 -56
  198. package/src/components/Blocks/CustomTemplates/VoltoSearchBlock/AccordionLabelFacet.jsx +0 -58
  199. package/src/components/CLMSDatasetDetailView/MetadataContent.jsx +0 -255
  200. package/src/components/CLMSDownloadCartView/CLMSTasksInProgress.jsx +0 -238
  201. package/src/components/CLMSEventView/CLMSEventView.jsx +0 -53
  202. package/src/components/CclTable/CclTable.jsx +0 -95
  203. package/src/components/CclTable/table.less +0 -42
  204. package/src/i18n.js +0 -183
@@ -0,0 +1,39 @@
1
+ import {
2
+ GET_TOKENS,
3
+ CREATE_TOKENS,
4
+ DELETE_TOKENS,
5
+ } from '../../constants/ActionTypes';
6
+ import { getTokens, createTokens, deleteTokens } from './tokens';
7
+
8
+ describe('Tokens actions', () => {
9
+ describe('getTokens', () => {
10
+ it('should create an action to get tokens', () => {
11
+ const action = getTokens();
12
+
13
+ expect(action.type).toEqual(GET_TOKENS);
14
+ expect(action.request.op).toEqual('get');
15
+ expect(action.request.path).toEqual('/@service-keys');
16
+ });
17
+ });
18
+ describe('createTokens', () => {
19
+ it('should create an action to post tokens', () => {
20
+ const tokenTitle = 'tokentitle';
21
+ const action = createTokens(tokenTitle);
22
+
23
+ expect(action.type).toEqual(CREATE_TOKENS);
24
+ expect(action.request.op).toEqual('post');
25
+ expect(action.request.path).toEqual('/@service-keys');
26
+ expect(action.request.data).toEqual({ title: tokenTitle });
27
+ });
28
+ });
29
+ describe('deleteTokens', () => {
30
+ it('should create an action to delete tokens', () => {
31
+ const key_id = 'key_id';
32
+ const action = deleteTokens(key_id);
33
+
34
+ expect(action.type).toEqual(DELETE_TOKENS);
35
+ expect(action.request.op).toEqual('del');
36
+ expect(action.request.path).toEqual(`/@service-keys/${key_id}`);
37
+ });
38
+ });
39
+ });
@@ -0,0 +1,14 @@
1
+ import { getUserSchema } from './userschema';
2
+ import { GET_USERSCHEMA } from '../../constants/ActionTypes';
3
+
4
+ describe('User Schema action', () => {
5
+ describe('getUserSchema', () => {
6
+ it('should create an action to get the user schema', () => {
7
+ const action = getUserSchema();
8
+
9
+ expect(action.type).toEqual(GET_USERSCHEMA);
10
+ expect(action.request.op).toEqual('get');
11
+ expect(action.request.path).toEqual('/@userschema');
12
+ });
13
+ });
14
+ });
@@ -0,0 +1,123 @@
1
+ import Enzyme, { mount } from 'enzyme';
2
+
3
+ import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
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';
10
+
11
+ // import { shallow } from 'enzyme';
12
+
13
+ Enzyme.configure({ adapter: new Adapter() });
14
+
15
+ global.__SERVER__ = true; // eslint-disable-line no-underscore-dangle
16
+
17
+ const mockStore = configureStore();
18
+
19
+ describe('CclButtonBlockEdit', () => {
20
+ it('CclButtonBlockEdit block clicks', () => {
21
+ const store = mockStore({
22
+ content: {
23
+ create: {},
24
+ data: {},
25
+ },
26
+ intl: {
27
+ locale: 'en',
28
+ messages: {},
29
+ },
30
+ });
31
+ const data = {
32
+ href: 'https://www.google.com',
33
+ disabled: false,
34
+ style: 'default',
35
+ download: false,
36
+ };
37
+ // const component = shallow(
38
+ const component = mount(
39
+ <Provider store={store}>
40
+ <MemoryRouter>
41
+ <CclButtonBlockEdit
42
+ data={data}
43
+ selected={false}
44
+ block="1234"
45
+ onChangeBlock={() => {}}
46
+ setSidebarTab={() => {}}
47
+ />
48
+ </MemoryRouter>
49
+ </Provider>,
50
+ );
51
+ const legend = component.find('.ccl-block-editor-header legend');
52
+ legend.simulate('click');
53
+ expect(legend).toBeDefined();
54
+ });
55
+ it('renders an CclButtonBlockEdit block component', () => {
56
+ const store = mockStore({
57
+ content: {
58
+ create: {},
59
+ data: {},
60
+ },
61
+ intl: {
62
+ locale: 'en',
63
+ messages: {},
64
+ },
65
+ });
66
+ const data = {
67
+ href: ['https://www.google.com', 'https://www.google.com'],
68
+ disabled: true,
69
+ };
70
+ const component = renderer.create(
71
+ <Provider store={store}>
72
+ <MemoryRouter>
73
+ <CclButtonBlockEdit
74
+ data={data}
75
+ selected={false}
76
+ block="1234"
77
+ onChangeBlock={() => {}}
78
+ onSelectBlock={() => {}}
79
+ onChangeField={() => {}}
80
+ setSidebarTab={() => {}}
81
+ />
82
+ </MemoryRouter>
83
+ </Provider>,
84
+ );
85
+
86
+ const json = component.toJSON();
87
+ expect(json).toMatchSnapshot();
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
+ });
123
+ });
@@ -1,19 +1,20 @@
1
- import React from 'react';
2
1
  import CclButton from '@eeacms/volto-clms-theme/components/CclButton/CclButton';
2
+ import React from 'react';
3
3
  import { flattenToAppURL } from '@plone/volto/helpers/Url/Url';
4
4
 
5
5
  const CclButtonBlockView = (props) => {
6
6
  const { data } = props;
7
7
  const flattern_url = flattenToAppURL(data?.href?.[0]?.['@id']);
8
+ function buttonURL(bData, bFlattern_url) {
9
+ return bData.download && bData?.href?.[0]?.['@type'] === 'File'
10
+ ? bFlattern_url + '/@@download/file'
11
+ : bFlattern_url;
12
+ }
8
13
  return {
9
14
  ...(data.style === 'left menu' ? (
10
15
  <div className="left-menu-detail">
11
16
  <CclButton
12
- url={
13
- data.download && data?.href?.[0]?.['@type'] === 'File'
14
- ? flattern_url + '/@@download/file'
15
- : flattern_url
16
- }
17
+ url={buttonURL(data, flattern_url)}
17
18
  disabled={data?.disabled}
18
19
  download={data?.download || data?.href?.[0]?.['@type'] === 'File'}
19
20
  target={
@@ -27,11 +28,7 @@ const CclButtonBlockView = (props) => {
27
28
  </div>
28
29
  ) : (
29
30
  <CclButton
30
- url={
31
- data.download && data?.href?.[0]?.['@type'] === 'File'
32
- ? flattern_url + '/@@download/file'
33
- : flattern_url
34
- }
31
+ url={buttonURL(data, flattern_url)}
35
32
  disabled={data?.disabled}
36
33
  download={data?.download || data?.href?.[0]?.['@type'] === 'File'}
37
34
  target={
@@ -0,0 +1,42 @@
1
+ import React from 'react';
2
+ import renderer from 'react-test-renderer';
3
+ import CclButtonBlockView from './CclButtonBlockView';
4
+
5
+ test('renders a CclButtonBlockView component', () => {
6
+ const data = {
7
+ href: [{ '@type': 'File', '@id': 'https://www.google.com' }],
8
+ disabled: true,
9
+ download: true,
10
+ };
11
+ const component = renderer.create(<CclButtonBlockView data={data} />);
12
+ const json = component.toJSON();
13
+ expect(json).toMatchSnapshot();
14
+
15
+ const data2 = {
16
+ href: [{ '@type': 'News Item', '@id': 'https://www.google.com' }],
17
+ disabled: true,
18
+ };
19
+ const component2 = renderer.create(<CclButtonBlockView data={data2} />);
20
+ const json2 = component2.toJSON();
21
+ expect(json2).toMatchSnapshot();
22
+
23
+ const data3 = {
24
+ href: [{ '@type': 'File', '@id': 'https://www.google.com' }],
25
+ disabled: false,
26
+ download: true,
27
+ style: 'left menu',
28
+ };
29
+ const component3 = renderer.create(<CclButtonBlockView data={data3} />);
30
+ const json3 = component3.toJSON();
31
+ expect(json3).toMatchSnapshot();
32
+
33
+ const data4 = {
34
+ href: [{ '@type': 'File', '@id': 'https://www.google.com' }],
35
+ disabled: false,
36
+ download: false,
37
+ style: 'left menu',
38
+ };
39
+ const component4 = renderer.create(<CclButtonBlockView data={data4} />);
40
+ const json4 = component4.toJSON();
41
+ expect(json4).toMatchSnapshot();
42
+ });
@@ -0,0 +1,27 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`CclButtonBlockEdit renders an CclButtonBlockEdit block component 1`] = `
4
+ Array [
5
+ <div
6
+ className="ccl-block-editor-header"
7
+ >
8
+ <legend
9
+ aria-hidden="true"
10
+ onClick={[Function]}
11
+ >
12
+ Default
13
+ button
14
+ disabled
15
+ </legend>
16
+ </div>,
17
+ <a
18
+ className="ccl-button ccl-button--default"
19
+ disabled={true}
20
+ download={false}
21
+ href="/"
22
+ onClick={[Function]}
23
+ >
24
+ Text example...
25
+ </a>,
26
+ ]
27
+ `;
@@ -0,0 +1,56 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`renders a CclButtonBlockView component 1`] = `
4
+ <a
5
+ className="ccl-button ccl-button--default"
6
+ disabled={true}
7
+ download={true}
8
+ href="https://www.google.com/@@download/file"
9
+ target="_blank"
10
+ >
11
+ Text example...
12
+ </a>
13
+ `;
14
+
15
+ exports[`renders a CclButtonBlockView component 2`] = `
16
+ <a
17
+ className="ccl-button ccl-button--default"
18
+ disabled={true}
19
+ download={false}
20
+ href="https://www.google.com"
21
+ >
22
+ Text example...
23
+ </a>
24
+ `;
25
+
26
+ exports[`renders a CclButtonBlockView component 3`] = `
27
+ <div
28
+ className="left-menu-detail"
29
+ >
30
+ <a
31
+ className="ccl-button"
32
+ disabled={false}
33
+ download={true}
34
+ href="https://www.google.com/@@download/file"
35
+ target="_blank"
36
+ >
37
+ Text example...
38
+ </a>
39
+ </div>
40
+ `;
41
+
42
+ exports[`renders a CclButtonBlockView component 4`] = `
43
+ <div
44
+ className="left-menu-detail"
45
+ >
46
+ <a
47
+ className="ccl-button"
48
+ disabled={false}
49
+ download={true}
50
+ href="https://www.google.com"
51
+ target={false}
52
+ >
53
+ Text example...
54
+ </a>
55
+ </div>
56
+ `;
@@ -48,15 +48,15 @@ const CclCardBlockEdit = (props) => {
48
48
 
49
49
  return (
50
50
  <>
51
- <div
52
- onClick={() => {
53
- props.setSidebarTab(1);
54
- }}
55
- aria-hidden="true"
56
- >
57
- <CclCard type={data.cardStyle || 'line'} card={card} />
51
+ <div className="ccl-block-editor-header">
52
+ <legend
53
+ onClick={() => {
54
+ props.setSidebarTab(1);
55
+ }}
56
+ aria-hidden="true"
57
+ />
58
58
  </div>
59
-
59
+ <CclCard type={data.cardStyle || 'line'} card={card} />
60
60
  <SidebarPortal selected={selected}>
61
61
  <InlineForm
62
62
  schema={CardBlockSchema()}
@@ -0,0 +1,159 @@
1
+ import Enzyme, { mount } from 'enzyme';
2
+
3
+ import Adapter from '@wojtekmaj/enzyme-adapter-react-17';
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';
10
+
11
+ // import { shallow } from 'enzyme';
12
+
13
+ Enzyme.configure({ adapter: new Adapter() });
14
+
15
+ global.__SERVER__ = true; // eslint-disable-line no-underscore-dangle
16
+
17
+ const mockStore = configureStore();
18
+
19
+ describe('CclCardBlockEdit', () => {
20
+ it('CclCardBlockEdit block clicks', () => {
21
+ const store = mockStore({
22
+ content: {
23
+ create: {},
24
+ data: {},
25
+ },
26
+ intl: {
27
+ locale: 'en',
28
+ messages: {},
29
+ },
30
+ });
31
+ const data = {
32
+ title: 'example title',
33
+ description: 'example description',
34
+ image: [
35
+ {
36
+ scales: [
37
+ {
38
+ icon: {
39
+ download:
40
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
41
+ },
42
+ large: {
43
+ download:
44
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
45
+ },
46
+ listing: {
47
+ download:
48
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
49
+ },
50
+ mini: {
51
+ download:
52
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
53
+ },
54
+ preview: {
55
+ download:
56
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
57
+ },
58
+ thumb: {
59
+ download:
60
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
61
+ },
62
+ tile: {
63
+ download:
64
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
65
+ },
66
+ },
67
+ ],
68
+ },
69
+ ],
70
+ url: 'https://www.google.com',
71
+ };
72
+ // const component = shallow(
73
+ const component = mount(
74
+ <Provider store={store}>
75
+ <MemoryRouter>
76
+ <CclCardBlockEdit
77
+ data={data}
78
+ block="1234"
79
+ onChangeBlock={() => {}}
80
+ setSidebarTab={() => {}}
81
+ />
82
+ </MemoryRouter>
83
+ </Provider>,
84
+ );
85
+ const legend = component.find('.ccl-block-editor-header legend');
86
+ legend.simulate('click');
87
+ expect(legend).toBeDefined();
88
+ });
89
+ it('renders a CclCardBlockEdit block component', () => {
90
+ const store = mockStore({
91
+ content: {
92
+ create: {},
93
+ data: {},
94
+ },
95
+ intl: {
96
+ locale: 'en',
97
+ messages: {},
98
+ },
99
+ });
100
+ const data = {
101
+ title: 'example title',
102
+ description: 'example description',
103
+ image: [
104
+ {
105
+ scales: [
106
+ {
107
+ icon: {
108
+ download:
109
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
110
+ },
111
+ large: {
112
+ download:
113
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
114
+ },
115
+ listing: {
116
+ download:
117
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
118
+ },
119
+ mini: {
120
+ download:
121
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
122
+ },
123
+ preview: {
124
+ download:
125
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
126
+ },
127
+ thumb: {
128
+ download:
129
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
130
+ },
131
+ tile: {
132
+ download:
133
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
134
+ },
135
+ },
136
+ ],
137
+ },
138
+ ],
139
+ url: 'https://www.google.com',
140
+ };
141
+ const component = renderer.create(
142
+ <Provider store={store}>
143
+ <MemoryRouter>
144
+ <CclCardBlockEdit
145
+ data={data}
146
+ block="1234"
147
+ onChangeBlock={() => {}}
148
+ onSelectBlock={() => {}}
149
+ onChangeField={() => {}}
150
+ setSidebarTab={() => {}}
151
+ />
152
+ </MemoryRouter>
153
+ </Provider>,
154
+ );
155
+
156
+ const json = component.toJSON();
157
+ expect(json).toMatchSnapshot();
158
+ });
159
+ });
@@ -0,0 +1,61 @@
1
+ import React from 'react';
2
+ import renderer from 'react-test-renderer';
3
+ import CclCardBlockView from './CclCardBlockView';
4
+ import { MemoryRouter } from 'react-router-dom';
5
+
6
+ describe('CclCardBlockView', () => {
7
+ it('Check card block view', () => {
8
+ const data = {
9
+ title: 'example title',
10
+ description: 'example description',
11
+ image: [
12
+ {
13
+ scales: [
14
+ {
15
+ icon: {
16
+ download:
17
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
18
+ },
19
+ large: {
20
+ download:
21
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
22
+ },
23
+ listing: {
24
+ download:
25
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
26
+ },
27
+ mini: {
28
+ download:
29
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
30
+ },
31
+ preview: {
32
+ download:
33
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
34
+ },
35
+ thumb: {
36
+ download:
37
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
38
+ },
39
+ tile: {
40
+ download:
41
+ 'https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg',
42
+ },
43
+ },
44
+ ],
45
+ },
46
+ ],
47
+ url: './',
48
+ };
49
+
50
+ const CardBlockView = renderer
51
+ .create(
52
+ <MemoryRouter>
53
+ <CclCardBlockView data={data}>
54
+ <p>Card block view test</p>
55
+ </CclCardBlockView>
56
+ </MemoryRouter>,
57
+ )
58
+ .toJSON();
59
+ expect(CardBlockView).toBeDefined();
60
+ });
61
+ });
@@ -0,0 +1,45 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`CclCardBlockEdit renders a CclCardBlockEdit block component 1`] = `
4
+ Array [
5
+ <div
6
+ className="ccl-block-editor-header"
7
+ >
8
+ <legend
9
+ aria-hidden="true"
10
+ onClick={[Function]}
11
+ />
12
+ </div>,
13
+ <div
14
+ className="card-line"
15
+ >
16
+ <div
17
+ className="card-image"
18
+ >
19
+ <img
20
+ alt="Placeholder"
21
+ src="https://eu-copernicus.github.io/copernicus-component-library/assets/images/image_placeholder.jpg"
22
+ />
23
+ </div>
24
+ <div
25
+ className="card-text"
26
+ >
27
+ <div
28
+ className="card-title"
29
+ >
30
+ <a
31
+ href="/"
32
+ onClick={[Function]}
33
+ >
34
+ Card default title
35
+ </a>
36
+ </div>
37
+ <div
38
+ className="card-description"
39
+ >
40
+ example description
41
+ </div>
42
+ </div>
43
+ </div>,
44
+ ]
45
+ `;
@@ -1,21 +1,17 @@
1
- import React, { useState } from 'react';
1
+ import './styles.less';
2
2
 
3
- import { SidebarPortal } from '@plone/volto/components'; // BlocksForm, Icon,
4
- import { CardContainerSchema, CardBlockSchema } from './CardContainerSchema';
5
- import InlineForm from '@plone/volto/components/manage/Form/InlineForm';
3
+ import { CardBlockSchema, CardContainerSchema } from './CardContainerSchema';
4
+ import React, { useState } from 'react';
5
+ import { emptyCard, getPanels } from '../utils';
6
6
 
7
7
  import CclCard from '@eeacms/volto-clms-theme/components/CclCard/CclCard';
8
-
9
- import './styles.less';
10
-
8
+ import InlineForm from '@plone/volto/components/manage/Form/InlineForm';
9
+ import { SidebarPortal } from '@plone/volto/components'; // BlocksForm, Icon,
11
10
  import { compose } from 'redux';
12
- import withObjectBrowser from '@plone/volto/components/manage/Sidebar/ObjectBrowser';
13
11
  import { injectIntl } from 'react-intl';
14
-
15
- import { useSelector } from 'react-redux';
16
-
17
12
  import { isEmpty } from 'lodash';
18
- import { emptyCard, getPanels } from './utils';
13
+ import { useSelector } from 'react-redux';
14
+ import withObjectBrowser from '@plone/volto/components/manage/Sidebar/ObjectBrowser';
19
15
 
20
16
  const CclCardContainerBlockEdit = (props) => {
21
17
  const { block, data, onChangeBlock, selected } = props;
@@ -1,7 +1,7 @@
1
- import React from 'react';
1
+ import { useDispatch, useSelector } from 'react-redux';
2
2
 
3
3
  import CclCard from '@eeacms/volto-clms-theme/components/CclCard/CclCard';
4
- import { useDispatch, useSelector } from 'react-redux';
4
+ import React from 'react';
5
5
  import { searchContent } from '@plone/volto/actions';
6
6
 
7
7
  const CclCardContainerBlockView = (props) => {
@@ -16,7 +16,7 @@ const CclCardContainerBlockView = (props) => {
16
16
  path = metadata ? metadata['@id'] : properties['@id'];
17
17
  } else if (data.cardOrigin === 'selection') {
18
18
  path = data.containerSelection ? data.containerSelection[0]['@id'] : '';
19
- } else if ((data.cardOrigin = 'custom')) {
19
+ } else if (data.cardOrigin === 'custom') {
20
20
  cards = data?.customCards?.blocks_layout?.items.map(
21
21
  (uid) => data.customCards.blocks[uid],
22
22
  );