design-comuni-plone-theme 8.3.2 → 8.4.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 (38) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/locales/de/LC_MESSAGES/volto.po +31 -16
  3. package/locales/en/LC_MESSAGES/volto.po +36 -21
  4. package/locales/es/LC_MESSAGES/volto.po +31 -16
  5. package/locales/fr/LC_MESSAGES/volto.po +31 -16
  6. package/locales/it/LC_MESSAGES/volto.po +32 -17
  7. package/locales/volto.pot +32 -17
  8. package/package.json +1 -1
  9. package/publiccode.yml +2 -2
  10. package/src/components/Image/helpers.js +2 -1
  11. package/src/components/ItaliaTheme/Blocks/Listing/Commons/utils.js +63 -0
  12. package/src/components/ItaliaTheme/Blocks/Listing/SliderTemplate.jsx +235 -65
  13. package/src/components/ItaliaTheme/Breadcrumbs/Breadcrumbs.jsx +2 -2
  14. package/src/components/ItaliaTheme/CustomerSatisfaction/FeedbackForm.jsx +11 -7
  15. package/src/components/ItaliaTheme/Footer/FooterPNRRLogo.jsx +2 -2
  16. package/src/components/ItaliaTheme/Footer/logo-eu-inverted.svg +1 -17
  17. package/src/components/ItaliaTheme/Header/HeaderSearch/SearchModal.jsx +38 -11
  18. package/src/components/ItaliaTheme/Search/Search.jsx +7 -3
  19. package/src/components/ItaliaTheme/Search/utils.js +5 -3
  20. package/src/components/ItaliaTheme/Unauthorized/Unauthorized.jsx +3 -1
  21. package/src/components/ItaliaTheme/View/PersonaView/PersonaRuolo.jsx +108 -8
  22. package/src/components/ItaliaTheme/manage/Widgets/SubFooterConfigurationForm.jsx +1 -0
  23. package/src/customizations/volto/components/manage/Blocks/ToC/View.jsx +2 -0
  24. package/src/customizations/volto/components/manage/Blocks/ToC/variations/DefaultTocRenderer.jsx +99 -0
  25. package/src/customizations/volto/components/theme/Breadcrumbs/Breadcrumbs.jsx +3 -3
  26. package/src/customizations/volto/components/theme/View/View.jsx +308 -0
  27. package/src/customizations/volto/helpers/Api/Api.jsx +131 -0
  28. package/src/customizations/volto/middleware/api.js +362 -0
  29. package/src/customizations/volto/middleware/blacklistRoutes.js +47 -0
  30. package/src/theme/ItaliaTheme/Blocks/_imageBlock.scss +4 -0
  31. package/src/theme/ItaliaTheme/Blocks/_sliderTemplate.scss +18 -4
  32. package/src/theme/ItaliaTheme/Components/_search.scss +6 -0
  33. package/src/theme/ItaliaTheme/_common.scss +15 -0
  34. package/src/theme/ItaliaTheme/_css_variables.scss +3 -0
  35. package/src/theme/_cms-ui.scss +9 -0
  36. package/src/theme/bootstrap-override/bootstrap-italia/_footer.scss +3 -3
  37. package/src/theme/extras/_search.scss +31 -0
  38. package/src/theme/site.scss +1 -0
@@ -186,7 +186,11 @@ const Search = () => {
186
186
  const [customPath] = useState(qs.parse(location.search)?.custom_path ?? '');
187
187
 
188
188
  const [sortOn, setSortOn] = useState('relevance');
189
- const [currentPage, setCurrentPage] = useState(1);
189
+ const [currentPage, setCurrentPage] = useState(
190
+ qs.parse(location.search)?.b_start
191
+ ? qs.parse(location.search).b_start / config.settings.defaultPageSize + 1
192
+ : 1,
193
+ );
190
194
  const [collapseFilters, _setCollapseFilters] = useState(true);
191
195
  const [advFiltersOpen, setAdvFiltersOpen] = useState(false);
192
196
 
@@ -313,7 +317,7 @@ const Search = () => {
313
317
  options,
314
318
  portalTypes,
315
319
  searchOrderDict[sortOn] ?? {},
316
- (currentPage - 1) * config.settings.defaultPageSize,
320
+ currentPage,
317
321
  customPath,
318
322
  subsite,
319
323
  intl.locale,
@@ -329,7 +333,7 @@ const Search = () => {
329
333
  options,
330
334
  {},
331
335
  searchOrderDict[sortOn] ?? {},
332
- (currentPage - 1) * config.settings.defaultPageSize,
336
+ currentPage,
333
337
  customPath,
334
338
  subsite,
335
339
  intl.locale,
@@ -179,7 +179,9 @@ const getSearchParamsURL = (
179
179
  : config.settings.isMultilingual
180
180
  ? '/' + currentLang
181
181
  : '';
182
-
182
+ const b_start = currentPage
183
+ ? (currentPage - 1) * config.settings.defaultPageSize
184
+ : 0;
183
185
  const activeSections = Object.keys(sections).reduce((secAcc, secKey) => {
184
186
  const sec =
185
187
  sections[secKey].items &&
@@ -247,7 +249,7 @@ const getSearchParamsURL = (
247
249
  ...sortOn,
248
250
  ...portal_type,
249
251
  skipNull: true,
250
- b_start: currentPage ?? 0,
252
+ b_start: b_start,
251
253
  use_site_search_settings: true,
252
254
  };
253
255
 
@@ -268,7 +270,7 @@ const getSearchParamsURL = (
268
270
  },
269
271
  { skipNull: true },
270
272
  ) +
271
- (currentPage && currentPage > 0 ? `&b_start=${currentPage}` : '')
273
+ (b_start > 0 ? `&b_start=${b_start}` : '')
272
274
  );
273
275
  };
274
276
 
@@ -132,6 +132,8 @@ const Unauthorized = (props) => {
132
132
  )}
133
133
  <Row>
134
134
  <Col xs={12} lg={{ size: 10, offset: 1 }}>
135
+ {/*
136
+ Rimosso perchè la form di contatto è stata disabilitata
135
137
  <p>
136
138
  <FormattedMessage
137
139
  id="If you are certain you have the correct web address but are encountering an error, please contact the {site_admin}."
@@ -147,7 +149,7 @@ const Unauthorized = (props) => {
147
149
  ),
148
150
  }}
149
151
  />
150
- </p>
152
+ </p> */}
151
153
  <p>
152
154
  <FormattedMessage id="Thank you." defaultMessage="Thank you." />
153
155
  </p>
@@ -5,6 +5,7 @@ import {
5
5
  RichTextSection,
6
6
  OfficeCard,
7
7
  Gallery,
8
+ Attachment,
8
9
  } from 'design-comuni-plone-theme/components/ItaliaTheme/View';
9
10
  import {
10
11
  contentFolderHasItems,
@@ -20,9 +21,9 @@ const messages = defineMessages({
20
21
  id: 'atto_nomina',
21
22
  defaultMessage: 'Atto di nomina',
22
23
  },
23
- organizzazione_riferimento: {
24
- id: 'organizzazione_riferimento',
25
- defaultMessage: 'Organizzazione',
24
+ strutture_correlate: {
25
+ id: 'persona_strutture_correlate',
26
+ defaultMessage: 'Fa parte di',
26
27
  },
27
28
  responsabile_di: {
28
29
  id: 'responsabile_di',
@@ -40,6 +41,10 @@ const messages = defineMessages({
40
41
  id: 'compensi',
41
42
  defaultMessage: 'Compensi',
42
43
  },
44
+ importi_di_viaggio_e_o_servizi: {
45
+ id: 'importi_di_viaggio_e_o_servizi',
46
+ default: 'Importi di viaggio e/o servizi',
47
+ },
43
48
  deleghe: {
44
49
  id: 'deleghe',
45
50
  defaultMessage: 'Deleghe',
@@ -103,12 +108,83 @@ const PersonaRuolo = ({ content }) => {
103
108
  </div>
104
109
  </RichTextSection>
105
110
  )}
111
+
106
112
  {richTextHasContent(content.incarichi_persona[0].compensi) && (
107
113
  <RichTextSection
108
114
  tag_id="compensi"
109
115
  title={intl.formatMessage(messages.compensi)}
110
116
  data={content.incarichi_persona[0].compensi}
111
- />
117
+ >
118
+ {content.incarichi_persona[0]?.compensi_file?.length > 0 && (
119
+ <div className="compensi-item mb-2">
120
+ <div className="card-wrapper card-teaser-wrapper card-teaser-wrapper-equal">
121
+ {content.incarichi_persona[0]?.compensi_file.map((file) => {
122
+ let itemURL = '#';
123
+ if (file['@type'] === 'File') {
124
+ itemURL = `${file['@id']}/@@download/file`;
125
+ } else if (file['@type'] === 'Link') {
126
+ itemURL =
127
+ file.remoteUrl?.length > 0
128
+ ? file.remoteUrl
129
+ : file['@id'];
130
+ } else {
131
+ itemURL = file['@id'];
132
+ }
133
+ return (
134
+ <Attachment
135
+ key={file['@id']}
136
+ title={file.title}
137
+ description={file.description}
138
+ download_url={itemURL}
139
+ item={file}
140
+ />
141
+ );
142
+ })}
143
+ </div>
144
+ </div>
145
+ )}
146
+ </RichTextSection>
147
+ )}
148
+ {content.incarichi_persona[0]?.importi_di_viaggio_e_o_servizi
149
+ ?.length > 0 && (
150
+ <RichTextSection
151
+ tag_id="importi-di-viaggio"
152
+ title={intl.formatMessage(
153
+ messages.importi_di_viaggio_e_o_servizi,
154
+ )}
155
+ data={content.incarichi_persona[0].importi_di_viaggio_e_o_servizi}
156
+ >
157
+ {content.incarichi_persona[0]?.compensi_file?.length > 0 && (
158
+ <div className="compensi-item mb-2">
159
+ <div className="card-wrapper card-teaser-wrapper card-teaser-wrapper-equal">
160
+ {content.incarichi_persona[0]?.importi_di_viaggio_e_o_servizi.map(
161
+ (file) => {
162
+ let itemURL = '#';
163
+ if (file['@type'] === 'File') {
164
+ itemURL = `${file['@id']}/@@download/file`;
165
+ } else if (file['@type'] === 'Link') {
166
+ itemURL =
167
+ file.remoteUrl?.length > 0
168
+ ? file.remoteUrl
169
+ : file['@id'];
170
+ } else {
171
+ itemURL = file['@id'];
172
+ }
173
+ return (
174
+ <Attachment
175
+ key={file['@id']}
176
+ title={file.title}
177
+ description={file.description}
178
+ download_url={itemURL}
179
+ item={file}
180
+ />
181
+ );
182
+ },
183
+ )}
184
+ </div>
185
+ </div>
186
+ )}
187
+ </RichTextSection>
112
188
  )}
113
189
  <RichTextSection
114
190
  tag_id="data_insediamento"
@@ -124,13 +200,37 @@ const PersonaRuolo = ({ content }) => {
124
200
  </RichTextSection>
125
201
  </>
126
202
  )}
127
- {content.organizzazione_riferimento.length > 0 && (
203
+ {content.assessore_di?.length > 0 && (
204
+ <RichTextSection
205
+ tag_id="assessore_di"
206
+ title={intl.formatMessage(messages.assessore_di)}
207
+ >
208
+ <div className="card-wrapper card-teaser-wrapper card-teaser-wrapper-equal">
209
+ {content.assessore_di.map((item, i) => (
210
+ <OfficeCard key={item['@id']} office={item} size="big" />
211
+ ))}
212
+ </div>
213
+ </RichTextSection>
214
+ )}
215
+ {content.responsabile_di?.length > 0 && (
216
+ <RichTextSection
217
+ tag_id="responsabile_di"
218
+ title={intl.formatMessage(messages.responsabile_di)}
219
+ >
220
+ <div className="card-wrapper card-teaser-wrapper card-teaser-wrapper-equal">
221
+ {content.responsabile_di.map((item, i) => (
222
+ <OfficeCard key={item['@id']} office={item} size="big" />
223
+ ))}
224
+ </div>
225
+ </RichTextSection>
226
+ )}
227
+ {content.strutture_correlate?.length > 0 && (
128
228
  <RichTextSection
129
- tag_id="organization"
130
- title={intl.formatMessage(messages.organizzazione_riferimento)}
229
+ tag_id="strutture_correlate"
230
+ title={intl.formatMessage(messages.strutture_correlate)}
131
231
  >
132
232
  <div className="card-wrapper card-teaser-wrapper card-teaser-wrapper-equal">
133
- {content.organizzazione_riferimento.map((item, i) => (
233
+ {content.strutture_correlate.map((item, i) => (
134
234
  <OfficeCard key={item['@id']} office={item} size="big" />
135
235
  ))}
136
236
  </div>
@@ -120,6 +120,7 @@ const SubFooterConfigurationForm = ({
120
120
  ['privacy-policy-link', 'privacy-policy-link'],
121
121
  ['report-inefficiency', 'report-inefficiency'],
122
122
  ['faq', 'faq'],
123
+ ['legal-notes', 'legal-notes'],
123
124
  ]}
124
125
  value={menuItem.id_lighthouse}
125
126
  onChange={(id, value) => onChangeFormData('id_lighthouse', value)}
@@ -66,6 +66,8 @@ const View = (props) => {
66
66
  title: title || block.plaintext,
67
67
  items,
68
68
  id: draftJSKey,
69
+ override_toc: block.override_toc,
70
+ plaintext: block.plaintext,
69
71
  };
70
72
  if (level < rootLevel) {
71
73
  rootLevel = level;
@@ -0,0 +1,99 @@
1
+ /**
2
+ * CUSTOMIZATIONS: Fix slug variable to work with 'id' if overrride_toc is not set
3
+ * View toc block.
4
+ * @module components/manage/Blocks/ToC/View
5
+ */
6
+
7
+ import React from 'react';
8
+ import PropTypes from 'prop-types';
9
+ import { map } from 'lodash';
10
+ import { List } from 'semantic-ui-react';
11
+ import { FormattedMessage, injectIntl } from 'react-intl';
12
+ import { useHistory } from 'react-router-dom';
13
+ import AnchorLink from 'react-anchor-link-smooth-scroll';
14
+ import Slugger from 'github-slugger';
15
+
16
+ const RenderListItems = ({ items, data, history }) => {
17
+ return map(items, (item) => {
18
+ const { id, level, title, override_toc, plaintext } = item;
19
+ /*
20
+ //volto version:
21
+ const slug = override_toc
22
+ ? Slugger.slug(plaintext)
23
+ : Slugger.slug(title) || id;
24
+ */
25
+ const slug = override_toc
26
+ ? Slugger.slug(plaintext)
27
+ : id || Slugger.slug(title);
28
+ return (
29
+ item && (
30
+ <List.Item key={id} className={`item headline-${level}`} as="li">
31
+ <AnchorLink
32
+ href={`#${slug}`}
33
+ onClick={(e) => {
34
+ history.push({ hash: slug });
35
+ }}
36
+ >
37
+ {title}
38
+ </AnchorLink>
39
+ {item.items?.length > 0 && (
40
+ <List
41
+ ordered={data.ordered}
42
+ bulleted={!data.ordered}
43
+ as={data.ordered ? 'ol' : 'ul'}
44
+ >
45
+ <RenderListItems
46
+ items={item.items}
47
+ data={data}
48
+ history={history}
49
+ />
50
+ </List>
51
+ )}
52
+ </List.Item>
53
+ )
54
+ );
55
+ });
56
+ };
57
+
58
+ /**
59
+ * View toc block class.
60
+ * @class View
61
+ * @extends Component
62
+ */
63
+ const View = ({ data, tocEntries }) => {
64
+ const history = useHistory();
65
+ return (
66
+ <>
67
+ {data.title && !data.hide_title ? (
68
+ <h2>
69
+ {data.title || (
70
+ <FormattedMessage
71
+ id="Table of Contents"
72
+ defaultMessage="Table of Contents"
73
+ />
74
+ )}
75
+ </h2>
76
+ ) : (
77
+ ''
78
+ )}
79
+ <List
80
+ ordered={data.ordered}
81
+ bulleted={!data.ordered}
82
+ as={data.ordered ? 'ol' : 'ul'}
83
+ >
84
+ <RenderListItems items={tocEntries} data={data} history={history} />
85
+ </List>
86
+ </>
87
+ );
88
+ };
89
+
90
+ /**
91
+ * Property types.
92
+ * @property {Object} propTypes Property types.
93
+ * @static
94
+ */
95
+ View.propTypes = {
96
+ properties: PropTypes.objectOf(PropTypes.any).isRequired,
97
+ };
98
+
99
+ export default injectIntl(View);
@@ -16,15 +16,15 @@ const Breadcrumbs = ({ pathname }) => {
16
16
 
17
17
  const CT_CustomBreadcrumbs = ['Pagina Argomento']; //don't display breadcrumbs for this content-types. They will be displayed by content-type view if needed.
18
18
  if (CT_CustomBreadcrumbs?.indexOf(content?.['@type']) >= 0) {
19
- brdc = null;
19
+ return null;
20
20
  }
21
- return brdc ? (
21
+ return (
22
22
  <div className="public-ui">
23
23
  <section id="briciole" className="container px-4 mt-4">
24
24
  <div className="">{brdc}</div>
25
25
  </section>
26
26
  </div>
27
- ) : null;
27
+ );
28
28
  };
29
29
 
30
30
  Breadcrumbs.propTypes = {
@@ -0,0 +1,308 @@
1
+ /**
2
+ * backport https://github.com/plone/volto/pull/4854
3
+ *
4
+ * View container.
5
+ * @module components/theme/View/View
6
+ */
7
+
8
+ import React, { Component } from 'react';
9
+ import PropTypes from 'prop-types';
10
+ import { connect } from 'react-redux';
11
+ import { compose } from 'redux';
12
+ import { Redirect } from 'react-router-dom';
13
+ import { Portal } from 'react-portal';
14
+ import { injectIntl } from 'react-intl';
15
+ import qs from 'query-string';
16
+
17
+ import {
18
+ ContentMetadataTags,
19
+ Comments,
20
+ Tags,
21
+ Toolbar,
22
+ } from '@plone/volto/components';
23
+ import { listActions, getContent } from '@plone/volto/actions';
24
+ import {
25
+ BodyClass,
26
+ getBaseUrl,
27
+ flattenToAppURL,
28
+ getLayoutFieldname,
29
+ hasApiExpander,
30
+ } from '@plone/volto/helpers';
31
+
32
+ import config from '@plone/volto/registry';
33
+
34
+ /**
35
+ * View container class.
36
+ * @class View
37
+ * @extends Component
38
+ */
39
+ class View extends Component {
40
+ /**
41
+ * Property types.
42
+ * @property {Object} propTypes Property types.
43
+ * @static
44
+ */
45
+ static propTypes = {
46
+ actions: PropTypes.shape({
47
+ object: PropTypes.arrayOf(PropTypes.object),
48
+ object_buttons: PropTypes.arrayOf(PropTypes.object),
49
+ user: PropTypes.arrayOf(PropTypes.object),
50
+ }),
51
+ listActions: PropTypes.func.isRequired,
52
+ /**
53
+ * Action to get the content
54
+ */
55
+ getContent: PropTypes.func.isRequired,
56
+ /**
57
+ * Pathname of the object
58
+ */
59
+ pathname: PropTypes.string.isRequired,
60
+ location: PropTypes.shape({
61
+ search: PropTypes.string,
62
+ pathname: PropTypes.string,
63
+ }).isRequired,
64
+ /**
65
+ * Version id of the object
66
+ */
67
+ versionId: PropTypes.string,
68
+ /**
69
+ * Content of the object
70
+ */
71
+ content: PropTypes.shape({
72
+ /**
73
+ * Layout of the object
74
+ */
75
+ layout: PropTypes.string,
76
+ /**
77
+ * Allow discussion of the object
78
+ */
79
+ allow_discussion: PropTypes.bool,
80
+ /**
81
+ * Title of the object
82
+ */
83
+ title: PropTypes.string,
84
+ /**
85
+ * Description of the object
86
+ */
87
+ description: PropTypes.string,
88
+ /**
89
+ * Type of the object
90
+ */
91
+ '@type': PropTypes.string,
92
+ /**
93
+ * Subjects of the object
94
+ */
95
+ subjects: PropTypes.arrayOf(PropTypes.string),
96
+ is_folderish: PropTypes.bool,
97
+ }),
98
+ error: PropTypes.shape({
99
+ /**
100
+ * Error type
101
+ */
102
+ status: PropTypes.number,
103
+ }),
104
+ };
105
+
106
+ /**
107
+ * Default properties.
108
+ * @property {Object} defaultProps Default properties.
109
+ * @static
110
+ */
111
+ static defaultProps = {
112
+ actions: null,
113
+ content: null,
114
+ versionId: null,
115
+ error: null,
116
+ };
117
+
118
+ state = {
119
+ hasObjectButtons: null,
120
+ isClient: false,
121
+ };
122
+
123
+ componentDidMount() {
124
+ // Do not trigger the actions action if the expander is present
125
+ if (!hasApiExpander('actions', getBaseUrl(this.props.pathname))) {
126
+ this.props.listActions(getBaseUrl(this.props.pathname));
127
+ }
128
+ this.props.getContent(
129
+ getBaseUrl(this.props.pathname),
130
+ this.props.versionId,
131
+ );
132
+ this.setState({ isClient: true });
133
+ }
134
+
135
+ /**
136
+ * Component will receive props
137
+ * @method componentWillReceiveProps
138
+ * @param {Object} nextProps Next properties
139
+ * @returns {undefined}
140
+ */
141
+ UNSAFE_componentWillReceiveProps(nextProps) {
142
+ if (nextProps.pathname !== this.props.pathname) {
143
+ // Do not trigger the actions action if the expander is present
144
+ if (!hasApiExpander('actions', getBaseUrl(nextProps.pathname))) {
145
+ this.props.listActions(getBaseUrl(nextProps.pathname));
146
+ }
147
+ this.props.getContent(
148
+ getBaseUrl(nextProps.pathname),
149
+ this.props.versionId,
150
+ );
151
+ }
152
+
153
+ if (nextProps.actions.object_buttons) {
154
+ const objectButtons = nextProps.actions.object_buttons;
155
+ this.setState({
156
+ hasObjectButtons: !!objectButtons.length,
157
+ });
158
+ }
159
+ }
160
+
161
+ /**
162
+ * Default fallback view
163
+ * @method getViewDefault
164
+ * @returns {string} Markup for component.
165
+ */
166
+ getViewDefault = () => config.views.defaultView;
167
+
168
+ /**
169
+ * Get view by content type
170
+ * @method getViewByType
171
+ * @returns {string} Markup for component.
172
+ */
173
+ getViewByType = () =>
174
+ config.views.contentTypesViews[this.props.content['@type']] || null;
175
+
176
+ /**
177
+ * Get view by content layout property
178
+ * @method getViewByLayout
179
+ * @returns {string} Markup for component.
180
+ */
181
+ getViewByLayout = () =>
182
+ config.views.layoutViews[
183
+ this.props.content[getLayoutFieldname(this.props.content)]
184
+ ] || null;
185
+
186
+ /**
187
+ * Cleans the component displayName (specially for connected components)
188
+ * which have the Connect(componentDisplayName)
189
+ * @method cleanViewName
190
+ * @param {string} dirtyDisplayName The displayName
191
+ * @returns {string} Clean displayName (no Connect(...)).
192
+ */
193
+ cleanViewName = (dirtyDisplayName) =>
194
+ dirtyDisplayName
195
+ .replace('Connect(', '')
196
+ .replace('injectIntl(', '')
197
+ .replace(')', '')
198
+ .replace('connect(', '')
199
+ .toLowerCase();
200
+
201
+ /**
202
+ * Render method.
203
+ * @method render
204
+ * @returns {string} Markup for the component.
205
+ */
206
+ render() {
207
+ const { views } = config;
208
+ const status = __SERVER__
209
+ ? this.props.error?.status
210
+ : this.props.error?.code;
211
+ // Checking to see if it's a 3XX HTTP status code. error.status only works on the server
212
+ if (['301', '302', '307', '308'].includes(status?.toString())) {
213
+ const redirectUrl = __SERVER__
214
+ ? this.props.error.response.headers.location
215
+ : this.props.error.url;
216
+ let redirect = flattenToAppURL(redirectUrl);
217
+ // We can hit situations where we end up being redirected to an api route. We don't want that so lets remove ++api++.
218
+ redirect = redirect.replace('/++api++', '');
219
+ return <Redirect to={`${redirect}${this.props.location.search}`} />;
220
+ } else if (this.props.error && !this.props.connectionRefused) {
221
+ let FoundView;
222
+ if (this.props.error.status === undefined) {
223
+ // For some reason, while development and if CORS is in place and the
224
+ // requested resource is 404, it returns undefined as status, then the
225
+ // next statement will fail
226
+ FoundView = views.errorViews.corsError;
227
+ } else {
228
+ FoundView = views.errorViews[this.props.error.status.toString()];
229
+ }
230
+ if (!FoundView) {
231
+ FoundView = views.errorViews['404']; // default to 404
232
+ }
233
+ return (
234
+ <div id="view">
235
+ <FoundView {...this.props} />
236
+ </div>
237
+ );
238
+ }
239
+ if (!this.props.content) {
240
+ return <span />;
241
+ }
242
+ const RenderedView =
243
+ this.getViewByLayout() || this.getViewByType() || this.getViewDefault();
244
+
245
+ return (
246
+ <div id="view">
247
+ <ContentMetadataTags content={this.props.content} />
248
+ {/* Body class if displayName in component is set */}
249
+ <BodyClass
250
+ className={
251
+ RenderedView.displayName
252
+ ? `view-${this.cleanViewName(RenderedView.displayName)}`
253
+ : null
254
+ }
255
+ />
256
+ <RenderedView
257
+ key={this.props.content['@id']}
258
+ content={this.props.content}
259
+ location={this.props.location}
260
+ token={this.props.token}
261
+ history={this.props.history}
262
+ />
263
+ {config.settings.showTags &&
264
+ this.props.content.subjects &&
265
+ this.props.content.subjects.length > 0 && (
266
+ <Tags tags={this.props.content.subjects} />
267
+ )}
268
+ {/* Add opt-in social sharing if required, disabled by default */}
269
+ {/* In the future this might be parameterized from the app config */}
270
+ {/* <SocialSharing
271
+ url={typeof window === 'undefined' ? '' : window.location.href}
272
+ title={this.props.content.title}
273
+ description={this.props.content.description || ''}
274
+ /> */}
275
+ {this.props.content.allow_discussion && (
276
+ <Comments pathname={this.props.pathname} />
277
+ )}
278
+ {this.state.isClient && (
279
+ <Portal node={document.getElementById('toolbar')}>
280
+ <Toolbar pathname={this.props.pathname} inner={<span />} />
281
+ </Portal>
282
+ )}
283
+ </div>
284
+ );
285
+ }
286
+ }
287
+
288
+ export default compose(
289
+ injectIntl,
290
+ connect(
291
+ (state, props) => ({
292
+ actions: state.actions.actions,
293
+ token: state.userSession.token,
294
+ content: state.content.data,
295
+ error: state.content.get.error,
296
+ apiError: state.apierror.error,
297
+ connectionRefused: state.apierror.connectionRefused,
298
+ pathname: props.location.pathname,
299
+ versionId:
300
+ qs.parse(props.location.search) &&
301
+ qs.parse(props.location.search).version,
302
+ }),
303
+ {
304
+ listActions,
305
+ getContent,
306
+ },
307
+ ),
308
+ )(View);