@eeacms/volto-n2k 0.1.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.
Files changed (233) hide show
  1. package/.coverage.babel.config.js +9 -0
  2. package/.release-it.json +17 -0
  3. package/CHANGELOG.md +155 -0
  4. package/DEVELOP.md +53 -0
  5. package/Jenkinsfile +209 -0
  6. package/LICENSE.md +9 -0
  7. package/README.md +62 -0
  8. package/bootstrap +41 -0
  9. package/cypress/fixtures/example.json +5 -0
  10. package/cypress/integration/block-basics.js +32 -0
  11. package/cypress/plugins/index.js +26 -0
  12. package/cypress/support/commands.js +315 -0
  13. package/cypress/support/index.js +53 -0
  14. package/cypress.json +12 -0
  15. package/jest-addon.config.js +36 -0
  16. package/package.json +57 -0
  17. package/src/actions.js +20 -0
  18. package/src/components/index.js +3 -0
  19. package/src/components/manage/Blocks/BodyClass/Edit.jsx +29 -0
  20. package/src/components/manage/Blocks/BodyClass/View.jsx +13 -0
  21. package/src/components/manage/Blocks/BodyClass/index.js +24 -0
  22. package/src/components/manage/Blocks/BodyClass/schema.js +19 -0
  23. package/src/components/manage/Blocks/BubbleChart/BubbleChart.jsx +101 -0
  24. package/src/components/manage/Blocks/BubbleChart/Chart.jsx +67 -0
  25. package/src/components/manage/Blocks/BubbleChart/ChartContext.jsx +3 -0
  26. package/src/components/manage/Blocks/BubbleChart/View.jsx +63 -0
  27. package/src/components/manage/Blocks/BubbleChart/index.js +17 -0
  28. package/src/components/manage/Blocks/BubbleChart/schema.js +124 -0
  29. package/src/components/manage/Blocks/BubbleChart/style.less +12 -0
  30. package/src/components/manage/Blocks/CarouselHorizontal/HorizontalView.jsx +221 -0
  31. package/src/components/manage/Blocks/CarouselHorizontal/index.js +19 -0
  32. package/src/components/manage/Blocks/CarouselHorizontal/schema.js +32 -0
  33. package/src/components/manage/Blocks/CddaShape/View.jsx +109 -0
  34. package/src/components/manage/Blocks/CddaShape/index.js +23 -0
  35. package/src/components/manage/Blocks/CddaShape/schema.js +19 -0
  36. package/src/components/manage/Blocks/CddaShape/style.less +14 -0
  37. package/src/components/manage/Blocks/ContactBlock/View.jsx +56 -0
  38. package/src/components/manage/Blocks/ContactBlock/icons/domain.svg +1 -0
  39. package/src/components/manage/Blocks/ContactBlock/icons/email.svg +1 -0
  40. package/src/components/manage/Blocks/ContactBlock/icons/location.svg +1 -0
  41. package/src/components/manage/Blocks/ContactBlock/index.js +17 -0
  42. package/src/components/manage/Blocks/ContactBlock/schema.js +57 -0
  43. package/src/components/manage/Blocks/ContactBlock/styles.less +31 -0
  44. package/src/components/manage/Blocks/ExplodedPiesChart/Pie.jsx +125 -0
  45. package/src/components/manage/Blocks/ExplodedPiesChart/View.jsx +80 -0
  46. package/src/components/manage/Blocks/ExplodedPiesChart/index.js +17 -0
  47. package/src/components/manage/Blocks/ExplodedPiesChart/schema.js +75 -0
  48. package/src/components/manage/Blocks/ExplodedPiesChart/style.less +80 -0
  49. package/src/components/manage/Blocks/ExploreHabitats/Edit.jsx +29 -0
  50. package/src/components/manage/Blocks/ExploreHabitats/View.jsx +177 -0
  51. package/src/components/manage/Blocks/ExploreHabitats/index.js +24 -0
  52. package/src/components/manage/Blocks/ExploreHabitats/schema.js +15 -0
  53. package/src/components/manage/Blocks/ExploreHabitats/style.less +15 -0
  54. package/src/components/manage/Blocks/ExploreSites/Edit.jsx +29 -0
  55. package/src/components/manage/Blocks/ExploreSites/View.jsx +175 -0
  56. package/src/components/manage/Blocks/ExploreSites/index.js +24 -0
  57. package/src/components/manage/Blocks/ExploreSites/schema.js +15 -0
  58. package/src/components/manage/Blocks/ExploreSites/style.less +15 -0
  59. package/src/components/manage/Blocks/ExploreSpecies/Edit.jsx +29 -0
  60. package/src/components/manage/Blocks/ExploreSpecies/View.jsx +177 -0
  61. package/src/components/manage/Blocks/ExploreSpecies/index.js +24 -0
  62. package/src/components/manage/Blocks/ExploreSpecies/schema.js +15 -0
  63. package/src/components/manage/Blocks/ExploreSpecies/style.less +15 -0
  64. package/src/components/manage/Blocks/HabitatClassification/View.jsx +30 -0
  65. package/src/components/manage/Blocks/HabitatClassification/index.js +17 -0
  66. package/src/components/manage/Blocks/HabitatClassification/schema.js +19 -0
  67. package/src/components/manage/Blocks/HabitatClassification/style.less +3 -0
  68. package/src/components/manage/Blocks/HabitatDistribution/View.jsx +97 -0
  69. package/src/components/manage/Blocks/HabitatDistribution/index.js +23 -0
  70. package/src/components/manage/Blocks/HabitatDistribution/schema.js +19 -0
  71. package/src/components/manage/Blocks/HabitatDistribution/style.less +5 -0
  72. package/src/components/manage/Blocks/HabitatProtectedSites/View.jsx +97 -0
  73. package/src/components/manage/Blocks/HabitatProtectedSites/index.js +23 -0
  74. package/src/components/manage/Blocks/HabitatProtectedSites/schema.js +19 -0
  75. package/src/components/manage/Blocks/HabitatProtectedSites/style.less +5 -0
  76. package/src/components/manage/Blocks/HabitatsBanner/View.jsx +39 -0
  77. package/src/components/manage/Blocks/HabitatsBanner/index.js +17 -0
  78. package/src/components/manage/Blocks/HabitatsBanner/schema.js +19 -0
  79. package/src/components/manage/Blocks/HabitatsBanner/style.less +49 -0
  80. package/src/components/manage/Blocks/ImageText/Edit.jsx +98 -0
  81. package/src/components/manage/Blocks/ImageText/View.jsx +66 -0
  82. package/src/components/manage/Blocks/ImageText/index.js +24 -0
  83. package/src/components/manage/Blocks/ImageText/schema.js +69 -0
  84. package/src/components/manage/Blocks/ImageText/styles.less +87 -0
  85. package/src/components/manage/Blocks/Landing/DefalutView.jsx +83 -0
  86. package/src/components/manage/Blocks/Landing/Edit.jsx +219 -0
  87. package/src/components/manage/Blocks/Landing/EditBlockWrapper.jsx +161 -0
  88. package/src/components/manage/Blocks/Landing/View.jsx +65 -0
  89. package/src/components/manage/Blocks/Landing/images/background.webp +0 -0
  90. package/src/components/manage/Blocks/Landing/images/coasts_and_seas.webp +0 -0
  91. package/src/components/manage/Blocks/Landing/images/forests.webp +0 -0
  92. package/src/components/manage/Blocks/Landing/images/grasslands.webp +0 -0
  93. package/src/components/manage/Blocks/Landing/images/hiker.webp +0 -0
  94. package/src/components/manage/Blocks/Landing/images/islands.webp +0 -0
  95. package/src/components/manage/Blocks/Landing/images/mountains.webp +0 -0
  96. package/src/components/manage/Blocks/Landing/images/natura2000.webp +0 -0
  97. package/src/components/manage/Blocks/Landing/images/natura2000_square.webp +0 -0
  98. package/src/components/manage/Blocks/Landing/images/peatlands.webp +0 -0
  99. package/src/components/manage/Blocks/Landing/images/people_and_nature.webp +0 -0
  100. package/src/components/manage/Blocks/Landing/images/rivers.webp +0 -0
  101. package/src/components/manage/Blocks/Landing/index.js +104 -0
  102. package/src/components/manage/Blocks/Landing/schema.js +62 -0
  103. package/src/components/manage/Blocks/Landing/style.less +174 -0
  104. package/src/components/manage/Blocks/List/View.jsx +37 -0
  105. package/src/components/manage/Blocks/List/index.js +17 -0
  106. package/src/components/manage/Blocks/List/schema.js +49 -0
  107. package/src/components/manage/Blocks/List/style.less +12 -0
  108. package/src/components/manage/Blocks/NavigationAnchors/Edit.jsx +33 -0
  109. package/src/components/manage/Blocks/NavigationAnchors/View.jsx +132 -0
  110. package/src/components/manage/Blocks/NavigationAnchors/assets/external.png +0 -0
  111. package/src/components/manage/Blocks/NavigationAnchors/index.js +23 -0
  112. package/src/components/manage/Blocks/NavigationAnchors/schema.js +76 -0
  113. package/src/components/manage/Blocks/NavigationAnchors/styles.less +104 -0
  114. package/src/components/manage/Blocks/SimpleDataTable/index.js +16 -0
  115. package/src/components/manage/Blocks/SimpleDataTable/templates/colored/View.jsx +178 -0
  116. package/src/components/manage/Blocks/SimpleDataTable/templates/colored/index.js +4 -0
  117. package/src/components/manage/Blocks/SimpleDataTable/templates/colored/schema.js +56 -0
  118. package/src/components/manage/Blocks/SimpleDataTable/templates/colored/style.less +54 -0
  119. package/src/components/manage/Blocks/SiteBanner/View.jsx +148 -0
  120. package/src/components/manage/Blocks/SiteBanner/index.js +17 -0
  121. package/src/components/manage/Blocks/SiteBanner/schema.js +19 -0
  122. package/src/components/manage/Blocks/SiteBanner/style.less +106 -0
  123. package/src/components/manage/Blocks/SiteHabitatsList/View.jsx +89 -0
  124. package/src/components/manage/Blocks/SiteHabitatsList/index.js +17 -0
  125. package/src/components/manage/Blocks/SiteHabitatsList/schema.js +19 -0
  126. package/src/components/manage/Blocks/SiteHabitatsList/style.less +70 -0
  127. package/src/components/manage/Blocks/SiteProtectedHabitats/View.jsx +47 -0
  128. package/src/components/manage/Blocks/SiteProtectedHabitats/images/background.webp +0 -0
  129. package/src/components/manage/Blocks/SiteProtectedHabitats/index.js +17 -0
  130. package/src/components/manage/Blocks/SiteProtectedHabitats/schema.js +19 -0
  131. package/src/components/manage/Blocks/SiteProtectedHabitats/style.less +90 -0
  132. package/src/components/manage/Blocks/SiteProtectedSpecies/View.jsx +55 -0
  133. package/src/components/manage/Blocks/SiteProtectedSpecies/images/background.webp +0 -0
  134. package/src/components/manage/Blocks/SiteProtectedSpecies/index.js +17 -0
  135. package/src/components/manage/Blocks/SiteProtectedSpecies/schema.js +19 -0
  136. package/src/components/manage/Blocks/SiteProtectedSpecies/style.less +90 -0
  137. package/src/components/manage/Blocks/SiteShape/View.jsx +107 -0
  138. package/src/components/manage/Blocks/SiteShape/index.js +23 -0
  139. package/src/components/manage/Blocks/SiteShape/schema.js +19 -0
  140. package/src/components/manage/Blocks/SiteShape/style.less +15 -0
  141. package/src/components/manage/Blocks/SiteSpeciesList/Filters/SortBy.jsx +52 -0
  142. package/src/components/manage/Blocks/SiteSpeciesList/Filters/SpeciesGroups.jsx +43 -0
  143. package/src/components/manage/Blocks/SiteSpeciesList/Filters/View.jsx +200 -0
  144. package/src/components/manage/Blocks/SiteSpeciesList/Filters/index.js +4 -0
  145. package/src/components/manage/Blocks/SiteSpeciesList/View.jsx +253 -0
  146. package/src/components/manage/Blocks/SiteSpeciesList/index.js +17 -0
  147. package/src/components/manage/Blocks/SiteSpeciesList/schema.js +19 -0
  148. package/src/components/manage/Blocks/SiteSpeciesList/style.less +264 -0
  149. package/src/components/manage/Blocks/SiteSpeciesList/utils.js +33 -0
  150. package/src/components/manage/Blocks/SlateLink/render.jsx +77 -0
  151. package/src/components/manage/Blocks/SlateLink/styles.less +22 -0
  152. package/src/components/manage/Blocks/SlateSVG/constants.js +1 -0
  153. package/src/components/manage/Blocks/SlateSVG/extensions.js +11 -0
  154. package/src/components/manage/Blocks/SlateSVG/index.js +47 -0
  155. package/src/components/manage/Blocks/SlateSVG/render.jsx +42 -0
  156. package/src/components/manage/Blocks/SlateSVG/schema.js +12 -0
  157. package/src/components/manage/Blocks/SlateSVG/styles.less +6 -0
  158. package/src/components/manage/Blocks/SpeciesBanner/View.jsx +109 -0
  159. package/src/components/manage/Blocks/SpeciesBanner/index.js +17 -0
  160. package/src/components/manage/Blocks/SpeciesBanner/schema.js +19 -0
  161. package/src/components/manage/Blocks/SpeciesBanner/style.less +115 -0
  162. package/src/components/manage/Blocks/SpeciesClassification/View.jsx +19 -0
  163. package/src/components/manage/Blocks/SpeciesClassification/index.js +17 -0
  164. package/src/components/manage/Blocks/SpeciesClassification/schema.js +19 -0
  165. package/src/components/manage/Blocks/SpeciesClassification/style.less +3 -0
  166. package/src/components/manage/Blocks/SpeciesDistribution/View.jsx +97 -0
  167. package/src/components/manage/Blocks/SpeciesDistribution/index.js +23 -0
  168. package/src/components/manage/Blocks/SpeciesDistribution/schema.js +19 -0
  169. package/src/components/manage/Blocks/SpeciesDistribution/style.less +5 -0
  170. package/src/components/manage/Blocks/SpeciesProtectedSites/View.jsx +97 -0
  171. package/src/components/manage/Blocks/SpeciesProtectedSites/index.js +23 -0
  172. package/src/components/manage/Blocks/SpeciesProtectedSites/schema.js +19 -0
  173. package/src/components/manage/Blocks/SpeciesProtectedSites/style.less +5 -0
  174. package/src/components/manage/Blocks/StackedBarChart/Chart.jsx +127 -0
  175. package/src/components/manage/Blocks/StackedBarChart/ChartContext.jsx +3 -0
  176. package/src/components/manage/Blocks/StackedBarChart/StackedBars.jsx +116 -0
  177. package/src/components/manage/Blocks/StackedBarChart/View.jsx +64 -0
  178. package/src/components/manage/Blocks/StackedBarChart/index.js +17 -0
  179. package/src/components/manage/Blocks/StackedBarChart/schema.js +25 -0
  180. package/src/components/manage/Blocks/StackedBarChart/style.less +37 -0
  181. package/src/components/manage/Blocks/TilesImages/Edit.jsx +32 -0
  182. package/src/components/manage/Blocks/TilesImages/View.jsx +37 -0
  183. package/src/components/manage/Blocks/TilesImages/index.js +23 -0
  184. package/src/components/manage/Blocks/TilesImages/schema.js +72 -0
  185. package/src/components/manage/Blocks/TilesImages/styles.less +57 -0
  186. package/src/components/theme/AppExtras/CopyPaste/CopyPaste.jsx +176 -0
  187. package/src/components/theme/AppExtras/CopyPaste/index.js +3 -0
  188. package/src/components/theme/AppExtras/CopyPaste/style.less +18 -0
  189. package/src/components/theme/AppExtras/MultilingualRedirector/MultilingualRedirector.jsx +35 -0
  190. package/src/components/theme/AppExtras/index.js +13 -0
  191. package/src/components/theme/Footer/Footer.jsx +209 -0
  192. package/src/components/theme/Header/Header.jsx +81 -0
  193. package/src/components/theme/LanguageSelector/LanguageSelector.jsx +79 -0
  194. package/src/components/theme/LanguageSelector/styles.less +44 -0
  195. package/src/components/theme/Navigation/Navigation.jsx +453 -0
  196. package/src/components/theme/Sitemap/Sitemap.jsx +152 -0
  197. package/src/fonts/OpenSans-Bold.ttf +0 -0
  198. package/src/fonts/OpenSans-Regular.ttf +0 -0
  199. package/src/fonts/OpenSans-Semibold.ttf +0 -0
  200. package/src/fonts/Rajdhani-Bold.ttf +0 -0
  201. package/src/fonts/Rajdhani-Regular.ttf +0 -0
  202. package/src/grid.js +78 -0
  203. package/src/helpers.js +148 -0
  204. package/src/hocs/index.js +6 -0
  205. package/src/hocs/useResizeObserver.jsx +26 -0
  206. package/src/hocs/withLocalStorage.jsx +37 -0
  207. package/src/hocs/withScreenSize.jsx +43 -0
  208. package/src/icons/home.svg +12 -0
  209. package/src/icons/info.svg +5 -0
  210. package/src/icons/n2k-logo-transparent.png +0 -0
  211. package/src/icons/n2k-logo.png +0 -0
  212. package/src/icons/natura2000.svg +142 -0
  213. package/src/icons/placeholders/Algae.png +0 -0
  214. package/src/icons/placeholders/Amphibians.png +0 -0
  215. package/src/icons/placeholders/Birds.png +0 -0
  216. package/src/icons/placeholders/Conifers.png +0 -0
  217. package/src/icons/placeholders/Fishes.png +0 -0
  218. package/src/icons/placeholders/Fungi.png +0 -0
  219. package/src/icons/placeholders/Mammals.png +0 -0
  220. package/src/icons/placeholders/Plants.png +0 -0
  221. package/src/icons/placeholders/Reptiles.png +0 -0
  222. package/src/icons/placeholders/default.png +0 -0
  223. package/src/index.js +163 -0
  224. package/src/less/globals.less +3 -0
  225. package/src/less/styles.less +691 -0
  226. package/src/less/variables.less +2 -0
  227. package/src/static/cca.svg +61 -0
  228. package/src/static/ec.png +0 -0
  229. package/src/static/eea.png +0 -0
  230. package/src/static/eu.jpg +0 -0
  231. package/src/static/forest.svg +100 -0
  232. package/src/static/wise.png +0 -0
  233. package/src/store.js +24 -0
@@ -0,0 +1,315 @@
1
+ /* eslint no-console: ["error", { allow: ["log"] }] */
2
+
3
+ // --- AUTOLOGIN -------------------------------------------------------------
4
+ Cypress.Commands.add('autologin', () => {
5
+ let api_url, user, password;
6
+ api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone';
7
+ user = 'admin';
8
+ password = 'admin';
9
+
10
+ return cy
11
+ .request({
12
+ method: 'POST',
13
+ url: `${api_url}/@login`,
14
+ headers: { Accept: 'application/json' },
15
+ body: { login: user, password: password },
16
+ })
17
+ .then((response) => cy.setCookie('auth_token', response.body.token));
18
+ });
19
+
20
+ // --- CREATE CONTENT --------------------------------------------------------
21
+ Cypress.Commands.add(
22
+ 'createContent',
23
+ ({
24
+ contentType,
25
+ contentId,
26
+ contentTitle,
27
+ path = '',
28
+ allow_discussion = false,
29
+ }) => {
30
+ let api_url, auth;
31
+ api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone';
32
+ auth = {
33
+ user: 'admin',
34
+ pass: 'admin',
35
+ };
36
+ if (contentType === 'File') {
37
+ return cy.request({
38
+ method: 'POST',
39
+ url: `${api_url}/${path}`,
40
+ headers: {
41
+ Accept: 'application/json',
42
+ },
43
+ auth: auth,
44
+ body: {
45
+ '@type': contentType,
46
+ id: contentId,
47
+ title: contentTitle,
48
+ file: {
49
+ data: 'dGVzdGZpbGUK',
50
+ encoding: 'base64',
51
+ filename: 'lorem.txt',
52
+ 'content-type': 'text/plain',
53
+ },
54
+ allow_discussion: allow_discussion,
55
+ },
56
+ });
57
+ }
58
+ if (contentType === 'Image') {
59
+ return cy.request({
60
+ method: 'POST',
61
+ url: `${api_url}/${path}`,
62
+ headers: {
63
+ Accept: 'application/json',
64
+ },
65
+ auth: auth,
66
+ body: {
67
+ '@type': contentType,
68
+ id: contentId,
69
+ title: contentTitle,
70
+ image: {
71
+ data:
72
+ 'iVBORw0KGgoAAAANSUhEUgAAANcAAAA4CAMAAABZsZ3QAAAAM1BMVEX29fK42OU+oMvn7u9drtIPisHI4OhstdWZyt4fkcXX5+sAg74umMhNp86p0eJ7vNiKw9v/UV4wAAAAAXRSTlMAQObYZgAABBxJREFUeF7tmuty4yAMhZG4X2zn/Z92J5tsBJwWXG/i3XR6frW2Y/SBLIRAfaQUDNt8E5tLUt9BycfcKfq3R6Mlfyimtx4rzp+K3dtibXkor99zsEqLYZltblTecciogoh+TXfY1Ve4dn07rCDGG9dHSEEOg/GmXl0U1XDxTKxNK5De7BxsyyBr6gGm2/vPxKJ8F6f7BXKfRMp1xIWK9A+5ks25alSb353dWnDJN1k35EL5f8dVGifTf/4tjUuuFq7u4srmXC60yAmldLXIWbg65RKU87lcGxJCFqUPv0IacW0PmSivOZFLE908inPToMmii/roG+MRV/O8FU88i8tFsxV3a06MFUw0Qu7RmAtdV5/HVVaOVMTWNOWSwMljLhzhcB6XIS7OK5V6AvRDNN7t5VJWQs1J40UmalbK56usBG/CuCHSYuc+rkUGeMCViNRARPrzW52N3oQLe6WifNliSuuGaH3czbVNudI9s7ZLUCLHVwWlyES522o1t14uvmbblmVTKqFjaZYJFSTPP4dLL1kU1z7p0lzdbRulmEWLxoQX+z9ce7A8GqEEucllLxePuZwdJl1Lezu0hoswvTPt61DrFcRuujV/2cmlxaGBC7Aw6cpovGANwRiSdOAWJ5AGy4gLL64dl0QhUEAuEUNws+XxV+OKGPdw/hESGYF9XEGaFC7sNLMSXWJjHsnanYi87VK428N2uxpOjOFANcagLM5l+7mSycM8KknZpKLcGi6jmzWGr/vLurZ/0g4u9AZuAoeb5r1ceQhyiTPY1E4wUR6u/F3H2ojSpXMMriBPT9cezTto8Cx+MsglHL4fv1Rxrb1LVw9yvyQpJ3AhFnLZfuRLH2QsOG3FGGD20X/th/u5bFAt16Bt308KjF+MNOXgl/SquIEySX3GhaZvc67KZbDxcCDORz2N8yCWPaY5lyQZO7lQ29fnZbt3Xu6qoge4+DjXl/MocySPOp9rlvdyznahRyHEYd77v3LhugOXDv4J65QXfl803BDAdaWBEDhfVx7nKofjoVCgxnUAqw/UAUDPn788BDvQuG4TDtdtUPvzjSlXAB8DvaDOhhrmhwbywylXAm8CvaouikJTL93gs3y7Yy4VYbIxOHrcMizPqWOjqO9l3Uz52kibQy4xxOgqhJvD+w5rvokOcAlGvNCfeqCv1ste1stzLm0f71Iq3ZfTrPfuE5nhPtF+LvQE2lffQC7pYtQy3tdzdrKvd5TLVVzDetScS3nEKmmwDyt1Cev1kX3YfbvzNK4fzrlw+cB6vm+uiUgf2zdXI62241LawCb7Pi5FXFPF8KpzDoF/Sw2lg+GrHNbno1mhPu+VCF/vfMnw06PnUl6j48dVHD3jHNHPua+fc3o/5yp/zsGi0vYtzi3Pz5mHd4T6BWMIlewacd63AAAAAElFTkSuQmCC',
73
+ encoding: 'base64',
74
+ filename: 'image.png',
75
+ 'content-type': 'image/png',
76
+ },
77
+ },
78
+ });
79
+ }
80
+ if (['Document', 'Folder', 'CMSFolder'].includes(contentType)) {
81
+ return cy
82
+ .request({
83
+ method: 'POST',
84
+ url: `${api_url}/${path}`,
85
+ headers: {
86
+ Accept: 'application/json',
87
+ },
88
+ auth: auth,
89
+ body: {
90
+ '@type': contentType,
91
+ id: contentId,
92
+ title: contentTitle,
93
+ blocks: {
94
+ 'd3f1c443-583f-4e8e-a682-3bf25752a300': { '@type': 'title' },
95
+ '7624cf59-05d0-4055-8f55-5fd6597d84b0': { '@type': 'text' },
96
+ },
97
+ blocks_layout: {
98
+ items: [
99
+ 'd3f1c443-583f-4e8e-a682-3bf25752a300',
100
+ '7624cf59-05d0-4055-8f55-5fd6597d84b0',
101
+ ],
102
+ },
103
+ allow_discussion: allow_discussion,
104
+ },
105
+ })
106
+ .then(() => console.log(`${contentType} created`));
107
+ } else {
108
+ return cy
109
+ .request({
110
+ method: 'POST',
111
+ url: `${api_url}/${path}`,
112
+ headers: {
113
+ Accept: 'application/json',
114
+ },
115
+ auth: auth,
116
+ body: {
117
+ '@type': contentType,
118
+ id: contentId,
119
+ title: contentTitle,
120
+ allow_discussion: allow_discussion,
121
+ },
122
+ })
123
+ .then(() => console.log(`${contentType} created`));
124
+ }
125
+ },
126
+ );
127
+
128
+ // --- REMOVE CONTENT --------------------------------------------------------
129
+ Cypress.Commands.add('removeContent', (path) => {
130
+ let api_url, auth;
131
+ api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone';
132
+ auth = {
133
+ user: 'admin',
134
+ pass: 'admin',
135
+ };
136
+ return cy
137
+ .request({
138
+ method: 'DELETE',
139
+ url: `${api_url}/${path}`,
140
+ headers: {
141
+ Accept: 'application/json',
142
+ },
143
+ auth: auth,
144
+ body: {},
145
+ })
146
+ .then(() => console.log(`${path} removed`));
147
+ });
148
+
149
+ // --- SET WORKFLOW ----------------------------------------------------------
150
+ Cypress.Commands.add(
151
+ 'setWorkflow',
152
+ ({
153
+ path = '/',
154
+ actor = 'admin',
155
+ review_state = 'publish',
156
+ time = '1995-07-31T18:30:00',
157
+ title = '',
158
+ comment = '',
159
+ effective = '2018-01-21T08:00:00',
160
+ expires = '2019-01-21T08:00:00',
161
+ include_children = true,
162
+ }) => {
163
+ let api_url, auth;
164
+ api_url = Cypress.env('API_PATH') || 'http://localhost:8080/Plone';
165
+ auth = {
166
+ user: 'admin',
167
+ pass: 'admin',
168
+ };
169
+ return cy.request({
170
+ method: 'POST',
171
+ url: `${api_url}/${path}/@workflow/${review_state}`,
172
+ headers: {
173
+ Accept: 'application/json',
174
+ },
175
+ auth: auth,
176
+ body: {
177
+ actor: actor,
178
+ review_state: review_state,
179
+ time: time,
180
+ title: title,
181
+ comment: comment,
182
+ effective: effective,
183
+ expires: expires,
184
+ include_children: include_children,
185
+ },
186
+ });
187
+ },
188
+ );
189
+
190
+ // --- waitForResourceToLoad ----------------------------------------------------------
191
+ Cypress.Commands.add('waitForResourceToLoad', (fileName, type) => {
192
+ const resourceCheckInterval = 40;
193
+
194
+ return new Cypress.Promise((resolve) => {
195
+ const checkIfResourceHasBeenLoaded = () => {
196
+ const resource = cy
197
+ .state('window')
198
+ .performance.getEntriesByType('resource')
199
+ .filter((entry) => !type || entry.initiatorType === type)
200
+ .find((entry) => entry.name.includes(fileName));
201
+
202
+ if (resource) {
203
+ resolve();
204
+
205
+ return;
206
+ }
207
+
208
+ setTimeout(checkIfResourceHasBeenLoaded, resourceCheckInterval);
209
+ };
210
+
211
+ checkIfResourceHasBeenLoaded();
212
+ });
213
+ });
214
+
215
+ // Low level command reused by `setSelection` and low level command `setCursor`
216
+ Cypress.Commands.add('selection', { prevSubject: true }, (subject, fn) => {
217
+ cy.wrap(subject).trigger('mousedown').then(fn).trigger('mouseup');
218
+
219
+ cy.document().trigger('selectionchange');
220
+ return cy.wrap(subject);
221
+ });
222
+
223
+ Cypress.Commands.add(
224
+ 'setSelection',
225
+ { prevSubject: true },
226
+ (subject, query, endQuery) => {
227
+ return cy.wrap(subject).selection(($el) => {
228
+ if (typeof query === 'string') {
229
+ const anchorNode = getTextNode($el[0], query);
230
+ const focusNode = endQuery ? getTextNode($el[0], endQuery) : anchorNode;
231
+ const anchorOffset = anchorNode.wholeText.indexOf(query);
232
+ const focusOffset = endQuery
233
+ ? focusNode.wholeText.indexOf(endQuery) + endQuery.length
234
+ : anchorOffset + query.length;
235
+ setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
236
+ } else if (typeof query === 'object') {
237
+ const el = $el[0];
238
+ const anchorNode = getTextNode(el.querySelector(query.anchorQuery));
239
+ const anchorOffset = query.anchorOffset || 0;
240
+ const focusNode = query.focusQuery
241
+ ? getTextNode(el.querySelector(query.focusQuery))
242
+ : anchorNode;
243
+ const focusOffset = query.focusOffset || 0;
244
+ setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
245
+ }
246
+ });
247
+ },
248
+ );
249
+
250
+ // Low level command reused by `setCursorBefore` and `setCursorAfter`, equal to `setCursorAfter`
251
+ Cypress.Commands.add(
252
+ 'setCursor',
253
+ { prevSubject: true },
254
+ (subject, query, atStart) => {
255
+ return cy.wrap(subject).selection(($el) => {
256
+ const node = getTextNode($el[0], query);
257
+ const offset =
258
+ node.wholeText.indexOf(query) + (atStart ? 0 : query.length);
259
+ const document = node.ownerDocument;
260
+ document.getSelection().removeAllRanges();
261
+ document.getSelection().collapse(node, offset);
262
+ });
263
+ // Depending on what you're testing, you may need to chain a `.click()` here to ensure
264
+ // further commands are picked up by whatever you're testing (this was required for Slate, for example).
265
+ },
266
+ );
267
+
268
+ Cypress.Commands.add(
269
+ 'setCursorBefore',
270
+ { prevSubject: true },
271
+ (subject, query) => {
272
+ cy.wrap(subject).setCursor(query, true);
273
+ },
274
+ );
275
+
276
+ Cypress.Commands.add(
277
+ 'setCursorAfter',
278
+ { prevSubject: true },
279
+ (subject, query) => {
280
+ cy.wrap(subject).setCursor(query);
281
+ },
282
+ );
283
+
284
+ // Helper functions
285
+ function getTextNode(el, match) {
286
+ const walk = document.createTreeWalker(el, NodeFilter.SHOW_TEXT, null, false);
287
+ if (!match) {
288
+ return walk.nextNode();
289
+ }
290
+
291
+ let node;
292
+ while ((node = walk.nextNode())) {
293
+ if (node.wholeText.includes(match)) {
294
+ return node;
295
+ }
296
+ }
297
+ }
298
+
299
+ function setBaseAndExtent(...args) {
300
+ const document = args[0].ownerDocument;
301
+ document.getSelection().removeAllRanges();
302
+ document.getSelection().setBaseAndExtent(...args);
303
+ }
304
+
305
+ Cypress.Commands.add('navigate', (route = '') => {
306
+ return cy.window().its('appHistory').invoke('push', route);
307
+ });
308
+
309
+ Cypress.Commands.add('store', () => {
310
+ return cy.window().its('store').invoke('getStore', '');
311
+ });
312
+
313
+ Cypress.Commands.add('settings', (key, value) => {
314
+ return cy.window().its('settings');
315
+ });
@@ -0,0 +1,53 @@
1
+ // ***********************************************************
2
+ // This example support/index.js is processed and
3
+ // loaded automatically before your test files.
4
+ //
5
+ // This is a great place to put global configuration and
6
+ // behavior that modifies Cypress.
7
+ //
8
+ // You can change the location of this file or turn off
9
+ // automatically serving support files with the
10
+ // 'supportFile' configuration option.
11
+ //
12
+ // You can read more here:
13
+ // https://on.cypress.io/configuration
14
+ // ***********************************************************
15
+
16
+ // Import commands.js using ES2015 syntax:
17
+ import './commands';
18
+
19
+ // Alternatively you can use CommonJS syntax:
20
+ // require('./commands')
21
+
22
+ /* coverage-start
23
+ //Generate code-coverage
24
+ import '@cypress/code-coverage/support';
25
+ coverage-end */
26
+
27
+ export const setupBeforeEach = () => {
28
+ cy.autologin();
29
+ cy.createContent({
30
+ contentType: 'Folder',
31
+ contentId: 'cypress',
32
+ contentTitle: 'Cypress',
33
+ });
34
+ cy.createContent({
35
+ contentType: 'Document',
36
+ contentId: 'my-page',
37
+ contentTitle: 'My Page',
38
+ path: 'cypress',
39
+ });
40
+ cy.visit('/cypress/my-page');
41
+ cy.waitForResourceToLoad('@navigation');
42
+ cy.waitForResourceToLoad('@breadcrumbs');
43
+ cy.waitForResourceToLoad('@actions');
44
+ cy.waitForResourceToLoad('@types');
45
+ cy.waitForResourceToLoad('my-page');
46
+ cy.navigate('/cypress/my-page/edit');
47
+ cy.get(`.block.title [data-contents]`);
48
+ };
49
+
50
+ export const tearDownAfterEach = () => {
51
+ cy.autologin();
52
+ cy.removeContent('cypress');
53
+ };
package/cypress.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "baseUrl": "http://localhost:3000",
3
+ "viewportWidth": 1280,
4
+ "defaultCommandTimeout": 15000,
5
+ "reporter": "junit",
6
+ "video": true,
7
+ "reporterOptions": {
8
+ "mochaFile": "cypress/reports/cypress-[hash].xml",
9
+ "jenkinsMode": true,
10
+ "toConsole": true
11
+ }
12
+ }
@@ -0,0 +1,36 @@
1
+ module.exports = {
2
+ testMatch: ['**/src/addons/**/?(*.)+(spec|test).[jt]s?(x)'],
3
+ collectCoverageFrom: [
4
+ 'src/addons/**/src/**/*.{js,jsx,ts,tsx}',
5
+ '!src/**/*.d.ts',
6
+ ],
7
+ moduleNameMapper: {
8
+ '@plone/volto/cypress': '<rootDir>/node_modules/@plone/volto/cypress',
9
+ '@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
10
+ '@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
11
+ '@package/(.*)$': '<rootDir>/src/$1',
12
+ '@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
13
+ '@eeacms/(.*?)/(.*)$': '<rootDir>/src/addons/$1/src/$2',
14
+ 'volto-slate/(.*)$': '<rootDir>/src/addons/volto-slate/src/$1',
15
+ '~/(.*)$': '<rootDir>/src/$1',
16
+ 'load-volto-addons':
17
+ '<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
18
+ },
19
+ transform: {
20
+ '^.+\\.js(x)?$': 'babel-jest',
21
+ '^.+\\.css$': 'jest-css-modules',
22
+ '^.+\\.less$': 'jest-css-modules',
23
+ '^.+\\.scss$': 'jest-css-modules',
24
+ '^.+\\.(png)$': 'jest-file',
25
+ '^.+\\.(jpg)$': 'jest-file',
26
+ '^.+\\.(svg)$': './node_modules/@plone/volto/jest-svgsystem-transform.js',
27
+ },
28
+ coverageThreshold: {
29
+ global: {
30
+ branches: 5,
31
+ functions: 5,
32
+ lines: 5,
33
+ statements: 5,
34
+ },
35
+ },
36
+ };
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@eeacms/volto-n2k",
3
+ "version": "0.1.1",
4
+ "description": "volto-n2k: Volto add-on",
5
+ "main": "src/index.js",
6
+ "author": "European Environment Agency: IDM2 A-Team",
7
+ "license": "MIT",
8
+ "homepage": "https://github.com/eea/volto-n2k",
9
+ "keywords": [
10
+ "volto-addon",
11
+ "volto",
12
+ "plone",
13
+ "react"
14
+ ],
15
+ "addons": [
16
+ "volto-slate",
17
+ "@eeacms/volto-datablocks",
18
+ "@eeacms/volto-openlayers-map",
19
+ "@eeacms/volto-resize-helper",
20
+ "@eeacms/volto-tabs-block"
21
+ ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git@github.com:eea/volto-n2k.git"
25
+ },
26
+ "dependencies": {
27
+ "@eeacms/volto-datablocks": "^2.0.13",
28
+ "@eeacms/volto-resize-helper": "^0.2.4",
29
+ "@eeacms/volto-openlayers-map": "0.1.2",
30
+ "@eeacms/volto-tabs-block": "1.2.7",
31
+ "d3": "^7.1.1",
32
+ "d3-shape": "^3.0.1",
33
+ "react-lazy-load-image-component": "1.5.1",
34
+ "react-stickynode": "^4.0.0",
35
+ "react-use-localstorage": "^3.5.3",
36
+ "resize-observer-polyfill": "1.5.1",
37
+ "slick-carousel": "1.8.1",
38
+ "volto-slate": "^4.0.3"
39
+ },
40
+ "devDependencies": {
41
+ "@cypress/code-coverage": "^3.9.5",
42
+ "babel-plugin-transform-class-properties": "^6.24.1"
43
+ },
44
+ "scripts": {
45
+ "release": "release-it",
46
+ "bootstrap": "npm install -g ejs; npm link ejs; node bootstrap",
47
+ "stylelint": "../../../node_modules/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}'",
48
+ "stylelint:overrides": "../../../node_modules/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides'",
49
+ "stylelint:fix": "yarn stylelint --fix && yarn stylelint:overrides --fix",
50
+ "prettier": "../../../node_modules/.bin/prettier --single-quote --check 'src/**/*.{js,jsx,json,css,less,md}'",
51
+ "prettier:fix": "../../../node_modules/.bin/prettier --single-quote --write 'src/**/*.{js,jsx,json,css,less,md}'",
52
+ "lint": "../../../node_modules/eslint/bin/eslint.js --max-warnings=0 'src/**/*.{js,jsx}'",
53
+ "lint:fix": "../../../node_modules/eslint/bin/eslint.js --fix 'src/**/*.{js,jsx}'",
54
+ "cypress:run": "../../../node_modules/cypress/bin/cypress run",
55
+ "cypress:open": "../../../node_modules/cypress/bin/cypress open"
56
+ }
57
+ }
package/src/actions.js ADDED
@@ -0,0 +1,20 @@
1
+ export const setLocalStorage = (key, value) => {
2
+ return {
3
+ type: 'SET_LOCALSTORAGE',
4
+ key,
5
+ value,
6
+ };
7
+ };
8
+
9
+ export const deleteLocalStorage = (key) => {
10
+ return {
11
+ type: 'DELETE_LOCALSTORAGE',
12
+ key,
13
+ };
14
+ };
15
+
16
+ export const resetLocalStorage = () => {
17
+ return {
18
+ type: 'RESET_LOCALSTORAGE',
19
+ };
20
+ };
@@ -0,0 +1,3 @@
1
+ export Header from '@eeacms/volto-n2k/components/theme/Header/Header';
2
+ export Footer from '@eeacms/volto-n2k/components/theme/Footer/Footer';
3
+ export Sitemap from '@eeacms/volto-n2k/components/theme/Sitemap/Sitemap';
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import { SidebarPortal } from '@plone/volto/components';
3
+ import InlineForm from '@plone/volto/components/manage/Form/InlineForm';
4
+ import schema from './schema';
5
+ import View from './View';
6
+
7
+ const Edit = (props) => {
8
+ return (
9
+ <>
10
+ <View {...props} mode="edit" />
11
+
12
+ <SidebarPortal selected={props.selected}>
13
+ <InlineForm
14
+ schema={schema}
15
+ title={schema.title}
16
+ onChangeField={(id, value) => {
17
+ props.onChangeBlock(props.block, {
18
+ ...props.data,
19
+ [id]: value,
20
+ });
21
+ }}
22
+ formData={props.data}
23
+ />
24
+ </SidebarPortal>
25
+ </>
26
+ );
27
+ };
28
+
29
+ export default Edit;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { BodyClass } from '@plone/volto/helpers';
3
+
4
+ const View = (props) => {
5
+ return (
6
+ <>
7
+ {props.mode === 'edit' ? <p>Body className: {props.data.class}</p> : ''}
8
+ <BodyClass className={props.data.class || ''} />
9
+ </>
10
+ );
11
+ };
12
+
13
+ export default View;
@@ -0,0 +1,24 @@
1
+ import worldSVG from '@plone/volto/icons/world.svg';
2
+ import BodyClassEdit from './Edit';
3
+ import BodyClassView from './View';
4
+
5
+ export default (config) => {
6
+ config.blocks.blocksConfig.body_classname = {
7
+ id: 'body_classname',
8
+ title: 'Body classname',
9
+ icon: worldSVG,
10
+ group: 'natura_2000',
11
+ edit: BodyClassEdit,
12
+ view: BodyClassView,
13
+ restricted: false,
14
+ mostUsed: false,
15
+ sidebarTab: 1,
16
+ blocks: {},
17
+ security: {
18
+ addPermission: [],
19
+ view: [],
20
+ },
21
+ blockHasOwnFocusManagement: true,
22
+ };
23
+ return config;
24
+ };
@@ -0,0 +1,19 @@
1
+ export default {
2
+ title: 'Body class',
3
+
4
+ fieldsets: [
5
+ {
6
+ id: 'default',
7
+ title: 'Default',
8
+ fields: ['class'],
9
+ },
10
+ ],
11
+
12
+ properties: {
13
+ class: {
14
+ title: 'Class',
15
+ },
16
+ },
17
+
18
+ required: [],
19
+ };