@eeacms/volto-cca-policy 0.2.4 → 0.2.6

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 (31) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/locales/de/LC_MESSAGES/volto.po +15 -64
  3. package/locales/en/LC_MESSAGES/volto.po +15 -64
  4. package/locales/es/LC_MESSAGES/volto.po +15 -64
  5. package/locales/fr/LC_MESSAGES/volto.po +15 -64
  6. package/locales/it/LC_MESSAGES/volto.po +15 -64
  7. package/locales/pl/LC_MESSAGES/volto.po +15 -64
  8. package/locales/ro/LC_MESSAGES/volto.po +15 -64
  9. package/locales/volto.pot +16 -55
  10. package/package.json +1 -1
  11. package/src/components/index.js +3 -0
  12. package/src/components/manage/Blocks/CountryProfileDetail/CountryTabPane.js +72 -0
  13. package/src/components/manage/Blocks/CountryProfileDetail/CountryTabPane.test.jsx +47 -0
  14. package/src/components/manage/Blocks/CountryProfileDetail/View.js +65 -48
  15. package/src/components/manage/Blocks/CountryProfileDetail/View.test.jsx +40 -0
  16. package/src/components/manage/Blocks/CountryProfileDetail/styles.less +59 -0
  17. package/src/components/manage/Blocks/RASTBlock/RASTMap.jsx +3 -1
  18. package/src/components/manage/Blocks/RASTBlock/RASTView.jsx +4 -2
  19. package/src/components/theme/ASTNavigation/ASTAccordion.jsx +20 -6
  20. package/src/components/theme/MissionDisclaimer/MissionDisclaimer.jsx +24 -0
  21. package/src/components/theme/Views/MissionFundingCCAView.jsx +22 -53
  22. package/src/components/theme/Views/MissionFundingCCAView.test.jsx +1 -3
  23. package/src/components/theme/Views/MissionToolView.jsx +226 -0
  24. package/src/components/theme/Views/MissionToolView.test.jsx +154 -0
  25. package/src/helpers/ContentMetadata.jsx +16 -34
  26. package/src/helpers/Utils.jsx +23 -0
  27. package/src/helpers/index.js +1 -0
  28. package/src/index.js +3 -0
  29. package/theme/elements/list.variables +1 -1
  30. package/theme/globals/mission.less +15 -0
  31. package/src/components/theme/Views/styles.less +0 -7
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+ import { MemoryRouter } from 'react-router-dom';
3
+ import configureStore from 'redux-mock-store';
4
+ import { render } from '@testing-library/react';
5
+ import '@testing-library/jest-dom/extend-expect';
6
+ import { Provider } from 'react-intl-redux';
7
+ import CountryTabPane from './CountryTabPane';
8
+
9
+ const mockStore = configureStore();
10
+
11
+ describe('CountryTabPane', () => {
12
+ const setActivePanes = () => {
13
+ return 0;
14
+ };
15
+ it('should render the component', () => {
16
+ const data = {
17
+ _index: 2,
18
+ contents: [
19
+ [
20
+ {
21
+ type: 'div',
22
+ value: '<div><p class="testing">Just a test</p></div>',
23
+ },
24
+ ],
25
+ ],
26
+ activePanes: 1,
27
+ setActivePanes: setActivePanes,
28
+ };
29
+
30
+ const store = mockStore({
31
+ userSession: { token: '1234' },
32
+ intl: {
33
+ locale: 'en',
34
+ messages: {},
35
+ },
36
+ });
37
+
38
+ const { container } = render(
39
+ <Provider store={store}>
40
+ <MemoryRouter>
41
+ <CountryTabPane {...data} />
42
+ </MemoryRouter>
43
+ </Provider>,
44
+ );
45
+ expect(container).toBeTruthy();
46
+ });
47
+ });
@@ -1,47 +1,30 @@
1
1
  import React from 'react';
2
2
  import { TabPane, Tab } from 'semantic-ui-react';
3
+ import { Accordion, Icon } from 'semantic-ui-react';
4
+ import CountryTabPane from './CountryTabPane';
3
5
 
4
- const extract_body = (html_string) => {
5
- let parser = new DOMParser();
6
- let dom_document = parser.parseFromString(html_string, 'text/html');
7
-
8
- let list = dom_document
9
- .getElementById('third-level-menu')
10
- .getElementsByTagName('a');
11
- let response = { options: [], values: [] };
12
- for (let i = 0; i < list.length; i++) {
13
- let theId = list[i].href.split('#')[1];
14
- response.options.push({
15
- id: theId,
16
- name: list[i].innerHTML.replace('&amp;', '&'),
17
- });
18
- response.values.push(dom_document.getElementById(theId).innerHTML);
19
- }
20
- return response;
21
- };
6
+ import './styles.less';
22
7
 
23
8
  export default function View(props) {
24
- const [data, setData] = React.useState();
25
- const html = props.properties['@components'].countryprofile.html;
26
-
27
- React.useEffect(
28
- () =>
29
- setData(extract_body(html.replaceAll('\n', '').replaceAll('\\"', '"'))),
30
- [html],
31
- );
9
+ // const dataJson = JSON.parse(
10
+ // props?.properties['@components']?.countryprofile?.html,
11
+ // );
12
+ const dataJson = props?.properties['@components']?.countryprofile?.html;
13
+ const [activePanes, setActivePanes] = React.useState({});
32
14
 
33
15
  const panes = [];
34
- if (data?.options) {
35
- data.options.forEach((element, index) => {
16
+ if (dataJson?.menu) {
17
+ dataJson.menu.forEach((element, index) => {
36
18
  panes.push({
37
- menuItem: element.name,
19
+ menuItem: element,
38
20
  render: () => (
39
21
  <TabPane>
40
- {!!data && (
41
- <div
42
- dangerouslySetInnerHTML={{ __html: data.values[index] }}
43
- ></div>
44
- )}
22
+ <CountryTabPane
23
+ _index={index}
24
+ contents={dataJson.content[index]}
25
+ activePanes={activePanes}
26
+ setActivePanes={setActivePanes}
27
+ ></CountryTabPane>
45
28
  </TabPane>
46
29
  ),
47
30
  });
@@ -49,19 +32,53 @@ export default function View(props) {
49
32
  }
50
33
 
51
34
  return (
52
- <Tab
53
- className="secondary mnu"
54
- panes={panes}
55
- grid={{ paneWidth: 8, tabWidth: 4 }}
56
- menu={{
57
- tabular: true,
58
- vertical: true,
59
- inverted: false,
60
- pointing: true,
61
- fluid: true,
62
- className: 'secondary',
63
- tabIndex: 0,
64
- }}
65
- />
35
+ <>
36
+ {dataJson.message_top ? (
37
+ <div class="eea callout">{dataJson.message_top}</div>
38
+ ) : null}
39
+ {dataJson.top_accordeon ? (
40
+ <div className="top-accordion">
41
+ {dataJson.top_accordeon.map((accordion, index) => (
42
+ <Accordion className="secondary">
43
+ <Accordion.Title
44
+ role="button"
45
+ tabIndex={0}
46
+ active={activePanes['_' + index] || false}
47
+ onClick={(e) => {
48
+ const temp = JSON.parse(JSON.stringify(activePanes));
49
+ let val = temp['_' + index] || false;
50
+ temp['_' + index] = !val;
51
+ setActivePanes(temp);
52
+ }}
53
+ >
54
+ <span className="item-title">{accordion.title}</span>
55
+ <Icon className="ri-arrow-down-s-line" />
56
+ </Accordion.Title>
57
+ <Accordion.Content
58
+ active={activePanes['_' + index] || false}
59
+ dangerouslySetInnerHTML={{ __html: accordion.value }}
60
+ ></Accordion.Content>
61
+ </Accordion>
62
+ ))}
63
+ </div>
64
+ ) : null}
65
+ <Tab
66
+ className="secondary menu"
67
+ panes={panes}
68
+ grid={{ paneWidth: 8, tabWidth: 4 }}
69
+ menu={{
70
+ tabular: true,
71
+ vertical: true,
72
+ inverted: false,
73
+ pointing: true,
74
+ fluid: true,
75
+ className: 'secondary',
76
+ tabIndex: 0,
77
+ }}
78
+ />
79
+ {dataJson.updated ? (
80
+ <p>Reported updated until: {dataJson.updated}</p>
81
+ ) : null}
82
+ </>
66
83
  );
67
84
  }
@@ -0,0 +1,40 @@
1
+ import React from 'react';
2
+ import { MemoryRouter } from 'react-router-dom';
3
+ import configureStore from 'redux-mock-store';
4
+ import { render } from '@testing-library/react';
5
+ import '@testing-library/jest-dom/extend-expect';
6
+ import { Provider } from 'react-intl-redux';
7
+ import View from './View';
8
+
9
+ const mockStore = configureStore();
10
+
11
+ describe('View', () => {
12
+ it('should render the component', () => {
13
+ const properties = {
14
+ '@components': {
15
+ countryprofile: {
16
+ html:
17
+ '{"menu":[],"content":[],"html":"","updated":"","message_top":"", "top_accordeon":""}',
18
+ },
19
+ },
20
+ };
21
+ const data = { properties: properties };
22
+
23
+ const store = mockStore({
24
+ userSession: { token: '1234' },
25
+ intl: {
26
+ locale: 'en',
27
+ messages: {},
28
+ },
29
+ });
30
+
31
+ const { container } = render(
32
+ <Provider store={store}>
33
+ <MemoryRouter>
34
+ <View {...data} />
35
+ </MemoryRouter>
36
+ </Provider>,
37
+ );
38
+ expect(container).toBeTruthy();
39
+ });
40
+ });
@@ -0,0 +1,59 @@
1
+ .section-countries-regions.section-countries {
2
+ .secondary.menu > a {
3
+ text-transform: uppercase;
4
+ }
5
+
6
+ .top-accordion {
7
+ margin-bottom: 40px;
8
+ }
9
+
10
+ .ui.segment.active.tab > table {
11
+ margin-top: 0px !important;
12
+ }
13
+
14
+ .ui.segment.active.tab {
15
+ padding-top: 0px;
16
+ margin-top: 0px;
17
+ background-color: #ffffff;
18
+
19
+ table {
20
+ width: 100%;
21
+ margin-top: 20px !important;
22
+
23
+ tr:nth-child(even) {
24
+ background-color: #f9f9f9;
25
+ }
26
+
27
+ th {
28
+ padding: 0.5em 1em;
29
+ border-bottom: 1px solid #d7d7d7;
30
+ background-color: #f9f9f9;
31
+ font-weight: bold;
32
+ text-align: left;
33
+ }
34
+
35
+ td {
36
+ padding: 0.5em 1em;
37
+ border-bottom: 1px solid #d7d7d7;
38
+ text-align: left;
39
+ }
40
+
41
+ th:not(:last-child),
42
+ td:not(:last-child) {
43
+ border-right: 1px solid #d7d7d7;
44
+ }
45
+
46
+ td.bb1 {
47
+ border-bottom: 1px solid #d7d7d7;
48
+ }
49
+ }
50
+ }
51
+
52
+ .ui.accordion .title:not(.ui) {
53
+ padding: 1rem 1rem;
54
+
55
+ span.item-title {
56
+ text-transform: uppercase;
57
+ }
58
+ }
59
+ }
@@ -21,8 +21,10 @@ export default function RASTMap(props) {
21
21
  const { path, pathname, activeMenu, skip_items } = props;
22
22
  const currentPath = path || pathname;
23
23
 
24
- const items = props.items;
25
24
  let data = skip_items.split(',');
25
+ const items = props.items.filter(
26
+ (_item, index) => !data.includes(index.toString()),
27
+ );
26
28
  let currentMenu = activeMenu;
27
29
 
28
30
  if (activeMenu !== null) {
@@ -11,8 +11,10 @@ function useChildren(location) {
11
11
  dispatch(action);
12
12
  }, [location, dispatch]);
13
13
 
14
- const items = useSelector(
15
- (state) => state.content.subrequests?.[location]?.data?.items || [],
14
+ const items = useSelector((state) =>
15
+ (state.content.subrequests?.[location]?.data?.items || []).filter(
16
+ (i) => i.review_state === 'published',
17
+ ),
16
18
  );
17
19
  return items;
18
20
  }
@@ -1,10 +1,22 @@
1
1
  import React from 'react';
2
2
  import { Link, useHistory } from 'react-router-dom';
3
3
  import { Accordion, List } from 'semantic-ui-react';
4
+ import { useIntl, defineMessages } from 'react-intl';
4
5
  import ASTLogoMap from './ASTLogoMap';
5
6
  import UASTLogoMap from './UASTLogoMap';
6
7
  import cx from 'classnames';
7
8
 
9
+ const messages = defineMessages({
10
+ ast_start_title: {
11
+ id: 'The Adaptation Support Tool - Getting started',
12
+ defaultMessage: 'The Adaptation Support Tool - Getting started',
13
+ },
14
+ uast_start_title: {
15
+ id: 'Getting started',
16
+ defaultMessage: 'Getting started',
17
+ },
18
+ });
19
+
8
20
  const sortItems = (items) => {
9
21
  const sortedItems = items.sort((a, b) => {
10
22
  const idA = a['@id'];
@@ -19,7 +31,7 @@ const sortItems = (items) => {
19
31
  return sortedItems;
20
32
  };
21
33
 
22
- const groupItemsByStep = (object, isAST, isUAST, lang) => {
34
+ const groupItemsByStep = (object, isAST, isUAST, lang, intl) => {
23
35
  const grouped = {};
24
36
  const items = {};
25
37
 
@@ -61,15 +73,15 @@ const groupItemsByStep = (object, isAST, isUAST, lang) => {
61
73
  items[key] = grouped[key];
62
74
  });
63
75
 
76
+ const astPath = 'knowledge/tools/adaptation-support-tool';
77
+
64
78
  if (Object.keys(items).length !== 0) {
65
79
  if (isAST) {
66
- items['step-0'][
67
- '@id'
68
- ] = `/${lang}/knowledge/tools/adaptation-support-tool`;
69
- items['step-0'].title = 'The Adaptation Support Tool - Getting started';
80
+ items['step-0']['@id'] = `/${lang}/${astPath}`;
81
+ items['step-0'].title = intl.formatMessage(messages.ast_start_title);
70
82
  }
71
83
  if (isUAST) {
72
- items['step-0'].title = 'Getting started';
84
+ items['step-0'].title = intl.formatMessage(messages.uast_start_title);
73
85
  }
74
86
  }
75
87
  return items;
@@ -77,6 +89,7 @@ const groupItemsByStep = (object, isAST, isUAST, lang) => {
77
89
 
78
90
  const ASTAccordion = (props) => {
79
91
  const history = useHistory();
92
+ const intl = useIntl();
80
93
  const {
81
94
  astItems,
82
95
  location,
@@ -90,6 +103,7 @@ const ASTAccordion = (props) => {
90
103
  isAdaptationSupportTool,
91
104
  isUrbanAdaptationSupportTool,
92
105
  currentLanguage,
106
+ intl,
93
107
  );
94
108
 
95
109
  return (
@@ -0,0 +1,24 @@
1
+ const MissionDisclaimer = () => {
2
+ return (
3
+ <div className="styled-slate has--style_name--content-box-gray styled">
4
+ <div className="disclaimer content-box">
5
+ <div className="content-box-inner">
6
+ <p>
7
+ <strong>Disclaimer</strong>
8
+ <br />
9
+ The contents and links to third-party items on this Mission webpage
10
+ are developed by the MIP4Adapt team led by Ricardo, under contract
11
+ CINEA/2022/OP/0013/SI2.884597 funded by the European Union and do
12
+ not necessarily reflect those of the European Union, CINEA, or those
13
+ of the European Environment Agency (EEA) as host of the
14
+ Climate-ADAPT Platform. Neither the European Union nor CINEA nor the
15
+ EEA accepts responsibility or liability arising out of or in
16
+ connection with the information on these pages.
17
+ </p>
18
+ </div>
19
+ </div>
20
+ </div>
21
+ );
22
+ };
23
+
24
+ export default MissionDisclaimer;
@@ -1,13 +1,19 @@
1
- import { HTMLField, BannerTitle } from '@eeacms/volto-cca-policy/helpers';
2
- import { Container, Grid } from 'semantic-ui-react';
3
- import { PortalMessage } from '@eeacms/volto-cca-policy/components';
4
- import './styles.less';
1
+ import {
2
+ HTMLField,
3
+ BannerTitle,
4
+ MetadataItemList,
5
+ } from '@eeacms/volto-cca-policy/helpers';
6
+ import { Container, Grid, Segment, List } from 'semantic-ui-react';
7
+ import {
8
+ PortalMessage,
9
+ MissionDisclaimer,
10
+ } from '@eeacms/volto-cca-policy/components';
5
11
 
6
12
  function MissiongFundingCCAView(props) {
7
13
  const { content } = props;
8
14
 
9
15
  return (
10
- <div className="mission-funding-cca-view">
16
+ <div className="mission-item-view">
11
17
  <BannerTitle
12
18
  content={{ ...content, image: '' }}
13
19
  data={{
@@ -99,7 +105,7 @@ function MissiongFundingCCAView(props) {
99
105
  computer={4}
100
106
  className="col-right"
101
107
  >
102
- <div className="metadata">
108
+ <Segment className="metadata">
103
109
  {!!content.country && content.country.length > 0 && (
104
110
  <>
105
111
  <h5>Countries where the funding opportunity is offered</h5>
@@ -119,69 +125,32 @@ function MissiongFundingCCAView(props) {
119
125
  {!!content.rast_steps && content.rast_steps.length > 0 && (
120
126
  <>
121
127
  <h5>RAST step(s) of relevance</h5>
122
- <ul>
123
- {content.rast_steps.map((step) => (
124
- <li>{step.title}</li>
128
+ <List>
129
+ {content.rast_steps.map((step, index) => (
130
+ <List.Item key={index}>{step.title}</List.Item>
125
131
  ))}
126
- </ul>
132
+ </List>
127
133
  </>
128
134
  )}
129
135
  {!!content.eligible_entities &&
130
136
  content.eligible_entities.length > 0 && (
131
137
  <>
132
138
  <h5>Eligible to receive funding</h5>
133
- <ul>
134
- {content.eligible_entities.map((entity) => (
135
- <li>{entity.title}</li>
136
- ))}
137
- </ul>
139
+ <MetadataItemList value={content.eligible_entities} />
138
140
  </>
139
141
  )}
140
- {!!content.sectors && content.eligible_entities.length > 0 && (
142
+ {!!content.sectors && content.sectors.length > 0 && (
141
143
  <>
142
144
  <h5>Adaptation Sectors</h5>
143
- <ul>
144
- {content.sectors.map((sector) => (
145
- <li>{sector.title}</li>
146
- ))}
147
- </ul>
145
+ <MetadataItemList value={content.sectors} />
148
146
  </>
149
147
  )}
150
- </div>
151
- </Grid.Column>
152
- </div>
153
- </Grid>
154
- <Grid columns="12">
155
- <div className="row">
156
- <Grid.Column
157
- mobile={12}
158
- tablet={12}
159
- computer={12}
160
- className="col-full"
161
- >
162
- <div className="styled-slate has--style_name--content-box-gray styled">
163
- <div className="disclaimer content-box">
164
- <div className="content-box-inner">
165
- <p>
166
- <strong>Disclaimer</strong>
167
- <br />
168
- The contents and links to third-party items on this
169
- Mission webpage are developed by the MIP4Adapt team led by
170
- Ricardo, under contract CINEA/2022/OP/0013/SI2.884597
171
- funded by the European Union and do not necessarily
172
- reflect those of the European Union, CINEA, or those of
173
- the European Environment Agency (EEA) as host of the
174
- Climate-ADAPT Platform. Neither the European Union nor
175
- CINEA nor the EEA accepts responsibility or liability
176
- arising out of or in connection with the information on
177
- these pages.
178
- </p>
179
- </div>
180
- </div>
181
- </div>
148
+ </Segment>
182
149
  </Grid.Column>
183
150
  </div>
184
151
  </Grid>
152
+
153
+ <MissionDisclaimer />
185
154
  </Container>
186
155
  </div>
187
156
  );
@@ -99,8 +99,6 @@ describe('MissiongFundingCCAView', () => {
99
99
  </MemoryRouter>
100
100
  </Provider>,
101
101
  );
102
- expect(
103
- container.querySelector('.mission-funding-cca-view'),
104
- ).toBeInTheDocument();
102
+ expect(container.querySelector('.mission-item-view')).toBeInTheDocument();
105
103
  });
106
104
  });