@eeacms/volto-cca-policy 0.1.51 → 0.1.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,22 @@ 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
+ ### [0.1.53](https://github.com/eea/volto-cca-policy/compare/0.1.52...0.1.53) - 19 December 2023
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - Refs #260715 - switch browse folder to getContent test subrequests [Tripon Eugen - [`7744481`](https://github.com/eea/volto-cca-policy/commit/7744481bbebe3a0eedd3d440d58ae3b9adf43a18)]
12
+ - Refs #260715 - switch browse folder to getContent test [Tripon Eugen - [`ca17c9c`](https://github.com/eea/volto-cca-policy/commit/ca17c9c9a2972129fdbcef1d7dcceb2af1062cf2)]
13
+ - Refs #260715 - switch browse folder to getContent jenkins [Tripon Eugen - [`866118c`](https://github.com/eea/volto-cca-policy/commit/866118c4d5537d00c7bb7ffed272c16cd9516194)]
14
+ - Refs #260715 - switch browse folder to getContent [Tripon Eugen - [`4c6cb1b`](https://github.com/eea/volto-cca-policy/commit/4c6cb1b74812c020f670b1e660fae74eca7bbd8d)]
15
+ - WIP [Tiberiu Ichim - [`baef385`](https://github.com/eea/volto-cca-policy/commit/baef385bc65818b1a7b294fd6fcbbe65aef731f2)]
16
+ - WIP [Tiberiu Ichim - [`d64813d`](https://github.com/eea/volto-cca-policy/commit/d64813d66b32c785124adfa4e1e2d95bab512592)]
17
+ ### [0.1.52](https://github.com/eea/volto-cca-policy/compare/0.1.51...0.1.52) - 15 December 2023
18
+
19
+ #### :rocket: New Features
20
+
21
+ - feat: add config for mission stories [kreafox - [`781f3a7`](https://github.com/eea/volto-cca-policy/commit/781f3a7692b7609b917b458dce6ef2c7effb35a4)]
22
+
7
23
  ### [0.1.51](https://github.com/eea/volto-cca-policy/compare/0.1.50...0.1.51) - 12 December 2023
8
24
 
9
25
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.1.51",
3
+ "version": "0.1.53",
4
4
  "description": "@eeacms/volto-cca-policy: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -5,21 +5,18 @@ import RASTMap from './RASTMap';
5
5
  import RASTAccordion from './RASTAccordion';
6
6
  import { useLocation } from 'react-router-dom';
7
7
 
8
- import { withContentNavigation } from '@plone/volto/components/theme/Navigation/withContentNavigation';
9
-
10
8
  /**
11
9
  * A navigation slot implementation, similar to the classic Plone navigation
12
10
  * portlet. It uses the same API, so the options are similar to
13
11
  * INavigationPortlet
14
12
  */
15
13
  export function ContextNavigationComponent(props) {
16
- const { navigation = {}, location } = props;
17
- const { items = [] } = navigation;
14
+ const { location, items } = props;
18
15
  let activeMenu = null;
19
16
 
20
17
  const curent_location = useLocation();
21
18
  for (let i = 0; i < items.length; i++) {
22
- let itemUrl = '/' + items[i].href.split('/').slice(3).join('/');
19
+ let itemUrl = '/' + items[i]['@id'].split('/').slice(3).join('/');
23
20
  items[i].is_active = false;
24
21
  if (curent_location.pathname.includes(itemUrl)) {
25
22
  activeMenu = i;
@@ -35,10 +32,11 @@ export function ContextNavigationComponent(props) {
35
32
  activeMenu={activeMenu}
36
33
  />
37
34
  {items.length ? (
38
- <RASTAccordion datasets={items} activeMenu={activeMenu} />
35
+ <RASTAccordion items={items} activeMenu={activeMenu} />
39
36
  ) : null}
40
37
  </>
41
38
  );
42
39
  }
43
40
 
44
- export default compose(withContentNavigation)(ContextNavigationComponent);
41
+ // withContentNavigation
42
+ export default compose()(ContextNavigationComponent);
@@ -3,7 +3,7 @@ import { Accordion, Icon } from 'semantic-ui-react';
3
3
  import RASTAccordionContent from './RASTAccordionContent';
4
4
 
5
5
  const RASTAccordion = (props) => {
6
- const { datasets = {}, activeMenu } = props;
6
+ const { items = {}, activeMenu } = props;
7
7
 
8
8
  const [activeIndex, setActiveIndex] = React.useState([activeMenu]);
9
9
 
@@ -25,10 +25,9 @@ const RASTAccordion = (props) => {
25
25
  };
26
26
  return (
27
27
  <>
28
- {datasets.map((dataset, index) => {
29
- const { id } = dataset;
28
+ {items.map((item, index) => {
29
+ const { id } = item;
30
30
  const active = isActive(index);
31
- let datasetPath = '/' + dataset.href.split('/').slice(3).join('/');
32
31
 
33
32
  return (
34
33
  <Accordion id={id} key={index} className="secondary">
@@ -38,15 +37,15 @@ const RASTAccordion = (props) => {
38
37
  active={active}
39
38
  aria-expanded={active}
40
39
  index={index}
41
- onClick={(e) => handleClick(e, { index, id, dataset })}
40
+ onClick={(e) => handleClick(e, { index, id, item })}
42
41
  onKeyDown={(e) => {
43
42
  if (e.keyCode === 13 || e.keyCode === 32) {
44
43
  e.preventDefault();
45
- handleClick(e, { index, id, dataset });
44
+ handleClick(e, { index, id, item });
46
45
  }
47
46
  }}
48
47
  >
49
- <span className="dataset-title">{dataset.title}</span>
48
+ <span className="item-title">{item.title}</span>
50
49
  {active ? (
51
50
  <Icon className="ri-arrow-up-s-line" />
52
51
  ) : (
@@ -56,17 +55,11 @@ const RASTAccordion = (props) => {
56
55
  <Accordion.Content active={active}>
57
56
  <RASTAccordionContent
58
57
  key={index}
59
- params={{
60
- name: 'CurrentTitle',
61
- includeTop: false,
62
- currentFolderOnly: true,
63
- topLevel: 3,
64
- bottomLevel: 6,
65
- rootPath: datasetPath,
66
- title: dataset.title,
58
+ main={{
59
+ title: item.title,
60
+ href: item['@id'],
61
+ url: item.url,
67
62
  }}
68
- location={{ pathname: datasetPath }}
69
- main={{ title: dataset.title, href: dataset['@id'] }}
70
63
  />
71
64
  </Accordion.Content>
72
65
  </Accordion>
@@ -11,12 +11,12 @@ const mockStore = configureStore();
11
11
  describe('RASTAccordion', () => {
12
12
  it('should render the component', () => {
13
13
  const data = {
14
- datasets: [
14
+ items: [
15
15
  {
16
- id: 'my-dataset',
16
+ id: 'my-item',
17
17
  title: 'Hello',
18
- '@id': '/my-dataset',
19
- href: '/my-dataset-href',
18
+ '@id': '/my-item',
19
+ href: '/my-item-href',
20
20
  },
21
21
  ],
22
22
  activeMenu: 1,
@@ -1,13 +1,27 @@
1
+ import React from 'react';
1
2
  import { List } from 'semantic-ui-react';
2
3
  import { Link } from 'react-router-dom';
3
4
  import { compose } from 'redux';
4
5
  import { flattenToAppURL, getBaseUrl } from '@plone/volto/helpers';
5
-
6
- import { withContentNavigation } from '@plone/volto/components/theme/Navigation/withContentNavigation';
6
+ import { useDispatch, useSelector } from 'react-redux';
7
+ import { getContent } from '@plone/volto/actions';
8
+ // import useChildren from './RASTView';
7
9
 
8
10
  const RASTAccordionContent = (props) => {
9
11
  const { main } = props;
10
- const items = props.navigation?.items;
12
+ const dispatch = useDispatch();
13
+ const location = main.url;
14
+ let items = [];
15
+
16
+ React.useEffect(() => {
17
+ const action = getContent(location, null, location);
18
+ dispatch(action);
19
+ }, [location, dispatch]);
20
+
21
+ items = useSelector(
22
+ (state) => state.content?.subrequests?.[location]?.data?.items || [],
23
+ );
24
+ // const items = useChildren(location);
11
25
 
12
26
  return (
13
27
  <div className="dataset-content">
@@ -21,24 +35,22 @@ const RASTAccordionContent = (props) => {
21
35
  </div>
22
36
  </List.Content>
23
37
  </List.Item>
24
- {items
25
- ? items.map((item, index) => {
26
- return (
27
- <List.Item key={item.id}>
28
- <List.Content>
29
- <div className="dataset-item">
30
- <Link to={flattenToAppURL(getBaseUrl(item['@id']))}>
31
- {item.title}
32
- </Link>
33
- </div>
34
- </List.Content>
35
- </List.Item>
36
- );
37
- })
38
+ {items.length
39
+ ? items.map((item) => (
40
+ <List.Item key={item.id}>
41
+ <List.Content>
42
+ <div className="dataset-item">
43
+ <Link to={flattenToAppURL(getBaseUrl(item['@id']))}>
44
+ {item.title}
45
+ </Link>
46
+ </div>
47
+ </List.Content>
48
+ </List.Item>
49
+ ))
38
50
  : null}
39
51
  </div>
40
52
  </div>
41
53
  );
42
54
  };
43
55
 
44
- export default compose(withContentNavigation)(RASTAccordionContent);
56
+ export default compose()(RASTAccordionContent);
@@ -1,27 +1,35 @@
1
1
  import React from 'react';
2
2
  import './styles.less';
3
3
  import ContextNavigation from './ContextNavigation';
4
+ import { useDispatch, useSelector } from 'react-redux';
5
+ import { getContent } from '@plone/volto/actions';
6
+
7
+ function useChildren(location) {
8
+ const dispatch = useDispatch();
9
+ React.useEffect(() => {
10
+ const action = getContent(location, null, location);
11
+ dispatch(action);
12
+ }, [location, dispatch]);
13
+
14
+ const items = useSelector(
15
+ (state) => state.content.subrequests?.[location]?.data?.items || [],
16
+ );
17
+ return items;
18
+ }
4
19
 
5
20
  export default function RASTView(props) {
6
21
  const { data } = props;
7
22
  let root_path = data?.root_path;
8
- let top_level = 1;
9
23
  if (typeof root_path === 'undefined') {
10
24
  root_path = '/';
11
25
  }
12
- top_level = (root_path.match(/\//g) || []).length - 1;
26
+
27
+ const items = useChildren(root_path);
13
28
 
14
29
  return (
15
30
  <div className="block rast-block">
16
31
  <ContextNavigation
17
- params={{
18
- // name: 'CurrentTitle',
19
- // includeTop: false,
20
- // currentFolderOnly: false,
21
- topLevel: top_level,
22
- // topLevel: 2,
23
- // rootPath: '/en/about/test-rast/',
24
- }}
32
+ items={items}
25
33
  location={{
26
34
  pathname: root_path,
27
35
  }}
@@ -0,0 +1,50 @@
1
+ import { mergeConfig } from '@eeacms/search';
2
+
3
+ import facets from './facets-mission-stories';
4
+
5
+ const getClientProxyAddress = () => {
6
+ const url = new URL(window.location);
7
+ url.pathname = '';
8
+ url.search = '';
9
+ return url.toString();
10
+ };
11
+
12
+ const missionStoriesConfig = {
13
+ title: 'Mission stories',
14
+ ...facets,
15
+ // ...views,
16
+ };
17
+
18
+ export default function installMissionStoriesSearch(config) {
19
+ const envConfig = process.env.RAZZLE_ENV_CONFIG
20
+ ? JSON.parse(process.env.RAZZLE_ENV_CONFIG)
21
+ : missionStoriesConfig;
22
+
23
+ const pjson = require('@eeacms/volto-cca-policy/../package.json');
24
+ envConfig.app_name = pjson.name;
25
+ envConfig.app_version = pjson.version;
26
+
27
+ config.searchui.missionStoriesSearch = {
28
+ ...mergeConfig(envConfig, config.searchui.globalsearchbase),
29
+ elastic_index: '_es/missionStoriesSearch',
30
+ index_name: 'ccatest_searchui',
31
+ host: process.env.RAZZLE_ES_PROXY_ADDR || 'http://localhost:3000',
32
+ };
33
+
34
+ const { missionStoriesSearch } = config.searchui;
35
+
36
+ missionStoriesSearch.permanentFilters.push({
37
+ terms: {
38
+ objectProvides: ['mission_storyy'],
39
+ },
40
+ });
41
+
42
+ missionStoriesSearch.facets = facets;
43
+
44
+ if (typeof window !== 'undefined') {
45
+ config.searchui.missionStoriesSearch.host =
46
+ process.env.RAZZLE_ES_PROXY_ADDR || getClientProxyAddress();
47
+ }
48
+
49
+ return config;
50
+ }
@@ -0,0 +1,41 @@
1
+ import { multiTermFacet } from '@eeacms/search';
2
+
3
+ import globalSearchBaseConfig from '@eeacms/volto-globalsearch/config/global-search-base-config.js';
4
+
5
+ const facets = [
6
+ ...globalSearchBaseConfig.facets,
7
+ // multiTermFacet({
8
+ // field: 'spatial',
9
+ // isFilterable: false,
10
+ // isMulti: true,
11
+ // label: 'Country',
12
+ // iconsFamily: 'Country',
13
+ // alwaysVisible: false,
14
+ // }),
15
+ multiTermFacet({
16
+ field: 'cca_adaptation_sectors.keyword',
17
+ isFilterable: false,
18
+ isMulti: true,
19
+ label: 'Sectors',
20
+ iconsFamily: 'Sectors',
21
+ alwaysVisible: false,
22
+ }),
23
+ multiTermFacet({
24
+ field: 'key_system.keyword',
25
+ isFilterable: false,
26
+ isMulti: true,
27
+ label: 'Key System',
28
+ iconsFamily: 'Key System',
29
+ alwaysVisible: false,
30
+ }),
31
+ multiTermFacet({
32
+ field: 'climate_threats.keyword',
33
+ isFilterable: false,
34
+ isMulti: true,
35
+ label: 'Hazard Type',
36
+ iconsFamily: 'Hazard Type',
37
+ alwaysVisible: false,
38
+ }),
39
+ ];
40
+
41
+ export default facets;
@@ -1,5 +1,6 @@
1
1
  import installMainSearch from './config';
2
2
  import installHealthSearch from './config-health';
3
+ import installMissionStoriesSearch from './config-mission-stories';
3
4
 
4
5
  // import DatahubCardItem from './components/Result/DatahubCardItem';
5
6
  // import DatahubItemView from './components/ItemView/ItemView';
@@ -21,7 +22,9 @@ const applyConfig = (config) => {
21
22
  config.settings.searchlib = installHealthSearch(
22
23
  installMainSearch(config.settings.searchlib),
23
24
  );
24
-
25
+ config.settings.searchlib = installMissionStoriesSearch(
26
+ config.settings.searchlib,
27
+ );
25
28
  return config;
26
29
  };
27
30