@eeacms/volto-cca-policy 0.3.64 → 0.3.66

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 (45) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/locales/bg/LC_MESSAGES/volto.po +31 -39
  3. package/locales/cs/LC_MESSAGES/volto.po +31 -39
  4. package/locales/da/LC_MESSAGES/volto.po +31 -39
  5. package/locales/de/LC_MESSAGES/volto.po +31 -39
  6. package/locales/el/LC_MESSAGES/volto.po +31 -39
  7. package/locales/en/LC_MESSAGES/volto.po +31 -38
  8. package/locales/es/LC_MESSAGES/volto.po +31 -39
  9. package/locales/et/LC_MESSAGES/volto.po +31 -39
  10. package/locales/fi/LC_MESSAGES/volto.po +31 -39
  11. package/locales/fr/LC_MESSAGES/volto.po +31 -39
  12. package/locales/ga/LC_MESSAGES/volto.po +31 -39
  13. package/locales/hr/LC_MESSAGES/volto.po +31 -39
  14. package/locales/hu/LC_MESSAGES/volto.po +31 -39
  15. package/locales/is/LC_MESSAGES/volto.po +31 -39
  16. package/locales/it/LC_MESSAGES/volto.po +31 -39
  17. package/locales/lt/LC_MESSAGES/volto.po +31 -39
  18. package/locales/lv/LC_MESSAGES/volto.po +31 -39
  19. package/locales/mt/LC_MESSAGES/volto.po +31 -39
  20. package/locales/nl/LC_MESSAGES/volto.po +31 -39
  21. package/locales/nn/LC_MESSAGES/volto.po +31 -39
  22. package/locales/pl/LC_MESSAGES/volto.po +31 -39
  23. package/locales/pt/LC_MESSAGES/volto.po +31 -39
  24. package/locales/ro/LC_MESSAGES/volto.po +31 -39
  25. package/locales/sk/LC_MESSAGES/volto.po +31 -39
  26. package/locales/sl/LC_MESSAGES/volto.po +31 -39
  27. package/locales/sv/LC_MESSAGES/volto.po +31 -39
  28. package/locales/tr/LC_MESSAGES/volto.po +309 -351
  29. package/locales/volto.pot +22 -39
  30. package/package.json +2 -2
  31. package/src/components/manage/Blocks/CaseStudyExplorer/CaseStudyMap.test.jsx +6 -6
  32. package/src/components/manage/Blocks/CaseStudyExplorer/FeatureDisplay.test.jsx +2 -2
  33. package/src/components/theme/Header/Header.jsx +49 -28
  34. package/src/components/theme/Header/LanguageSwitch.jsx +41 -68
  35. package/src/components/theme/ImageGallery/ImageGallery.jsx +2 -2
  36. package/src/components/theme/ImageGallery/ImageGallery.test.jsx +38 -0
  37. package/src/components/theme/MissionSignatoryProfile/TabSections/PlanningTab.test.jsx +3 -2
  38. package/src/components/theme/PortalMessage/PortalMessage.jsx +6 -4
  39. package/src/components/theme/PortalMessage/PortalMessage.test.jsx +24 -0
  40. package/src/components/theme/Widgets/PromotionalImageWidget.jsx +35 -13
  41. package/src/components/theme/Widgets/PromotionalImageWidget.test.jsx +1 -1
  42. package/src/customizations/volto/components/theme/View/DefaultView.jsx +5 -1
  43. package/src/index.js +3 -3
  44. package/src/utils.js +11 -6
  45. package/theme/extras/header.overrides +14 -0
@@ -72,6 +72,24 @@ const messages = defineMessages({
72
72
  * ```
73
73
  *
74
74
  */
75
+ function parseDataURL(dataUrl) {
76
+ if (!dataUrl.startsWith('data:')) return null;
77
+
78
+ const commaIndex = dataUrl.indexOf(',');
79
+ if (commaIndex === -1) return null;
80
+
81
+ const meta = dataUrl.slice(5, commaIndex);
82
+ const data = dataUrl.slice(commaIndex + 1);
83
+
84
+ const [contentType, encoding] = meta.split(';');
85
+
86
+ return {
87
+ 'content-type': contentType || '',
88
+ encoding: encoding || '',
89
+ data: data || '',
90
+ };
91
+ }
92
+
75
93
  const FileWidget = (props) => {
76
94
  const { id, value, onChange, isDisabled } = props;
77
95
  const [fileType, setFileType] = React.useState(false);
@@ -99,27 +117,31 @@ const FileWidget = (props) => {
99
117
  const file = files[0];
100
118
  if (!validateFileUploadSize(file, intl.formatMessage)) return;
101
119
  readAsDataURL(file).then((data) => {
102
- const fields = data.match(/^data:(.*);(.*),(.*)$/);
103
- onChange(id, {
104
- data: fields[3],
105
- encoding: fields[2],
106
- 'content-type': fields[1],
107
- filename: file.name,
108
- });
120
+ const fields = parseDataURL(data);
121
+ if (fields) {
122
+ onChange(id, {
123
+ data: fields.data,
124
+ encoding: fields.encoding,
125
+ 'content-type': fields['content-type'],
126
+ filename: file.name,
127
+ });
128
+ }
109
129
  });
110
130
 
111
- let reader = new FileReader();
131
+ const reader = new FileReader();
112
132
  reader.onload = function () {
113
- const fields = reader.result.match(/^data:(.*);(.*),(.*)$/);
114
- if (imageMimetypes.includes(fields[1])) {
133
+ const parsed = parseDataURL(reader.result);
134
+ if (parsed && imageMimetypes.includes(parsed['content-type'])) {
115
135
  setFileType(true);
116
- let imagePreview = document.getElementById(`field-${id}-image`);
117
- imagePreview.src = reader.result;
136
+ const imagePreview = document.getElementById(`field-${id}-image`);
137
+ if (imagePreview) {
138
+ imagePreview.src = reader.result;
139
+ }
118
140
  } else {
119
141
  setFileType(false);
120
142
  }
121
143
  };
122
- reader.readAsDataURL(files[0]);
144
+ reader.readAsDataURL(file);
123
145
  };
124
146
 
125
147
  return (
@@ -48,7 +48,7 @@ describe('FileWidget', () => {
48
48
  fieldSet="default"
49
49
  onChange={() => {}}
50
50
  value={{
51
- download: 'http://myfile',
51
+ download: 'https://myfile',
52
52
  'content-type': 'image/png',
53
53
  filename: 'myfile',
54
54
  encoding: '',
@@ -24,6 +24,7 @@ import ContextNavigation from '@plone/volto/components/theme/Navigation/ContextN
24
24
  import {
25
25
  BannerTitle,
26
26
  ASTNavigation,
27
+ PortalMessage,
27
28
  } from '@eeacms/volto-cca-policy/components';
28
29
 
29
30
  import { isEqual } from 'lodash';
@@ -92,6 +93,7 @@ const DefaultView = (props) => {
92
93
  <>
93
94
  {currentNavigation ? (
94
95
  <Container id="page-document">
96
+ <PortalMessage content={content} />
95
97
  <Grid>
96
98
  <Grid.Column width={12 - gridColumns}>
97
99
  <BannerTitle {...props} />
@@ -113,6 +115,7 @@ const DefaultView = (props) => {
113
115
  </Container>
114
116
  ) : astNavigation ? (
115
117
  <Container id="page-document">
118
+ <PortalMessage content={content} />
116
119
  <Grid>
117
120
  <Grid.Column mobile={12} tablet={12} computer={4}>
118
121
  <ASTNavigation astNavigation={astNavigation} />
@@ -124,7 +127,8 @@ const DefaultView = (props) => {
124
127
  </Grid>
125
128
  </Container>
126
129
  ) : (
127
- <Container id="page-document" className="here">
130
+ <Container id="page-document">
131
+ <PortalMessage content={content} />
128
132
  {!isChromeless && <BannerTitle {...props} />}
129
133
  <RenderBlocks {...props} path={path} />
130
134
  </Container>
package/src/index.js CHANGED
@@ -522,7 +522,7 @@ const applyConfig = (config) => {
522
522
  },
523
523
  {
524
524
  match: {
525
- path: /(.*)\/add$/,
525
+ path: /^.*\/add$/,
526
526
  },
527
527
  component: RedirectToLogin,
528
528
  },
@@ -532,13 +532,13 @@ const applyConfig = (config) => {
532
532
  ...config.settings.apiExpanders,
533
533
  {
534
534
  match: {
535
- path: /(.*)\/policy-context\/country-profiles\/(.*)/,
535
+ path: /\/policy-context\/country-profiles\/.+/,
536
536
  },
537
537
  GET_CONTENT: ['siblings'],
538
538
  },
539
539
  {
540
540
  match: {
541
- path: /(.*)\/countries-regions\/countries\/(.*)/,
541
+ path: /\/countries-regions\/countries\/.+/,
542
542
  },
543
543
  GET_CONTENT: ['siblings'],
544
544
  },
package/src/utils.js CHANGED
@@ -101,6 +101,15 @@ export const formatTextToHTML = (text) => {
101
101
  : `<p>${formattedText}</p>`;
102
102
  };
103
103
 
104
+ const trimTrailingChars = (str) => {
105
+ const charsToTrim = ['-', '–', ';', ',', ':', ' '];
106
+ let end = str.length;
107
+ while (end > 0 && charsToTrim.includes(str[end - 1])) {
108
+ end--;
109
+ }
110
+ return str.substring(0, end);
111
+ };
112
+
104
113
  export const extractPlanNameAndURL = (text) => {
105
114
  if (!text) return { name: '', url: '' };
106
115
 
@@ -114,12 +123,8 @@ export const extractPlanNameAndURL = (text) => {
114
123
 
115
124
  if (url) {
116
125
  // Remove URL and any punctuation before it
117
- name = name
118
- .replace(`(${url})`, '')
119
- .replace(url, '')
120
- .replace(/[-–;,:\s]+$/, '')
121
- .replace(/[-–;,:\s]+$/, '')
122
- .trim();
126
+ name = name.replace(`(${url})`, '').replace(url, '');
127
+ name = trimTrailingChars(name).trim();
123
128
  }
124
129
 
125
130
  return {
@@ -34,3 +34,17 @@
34
34
  cursor: auto !important;
35
35
  }
36
36
  }
37
+
38
+
39
+ .top-header-right-items {
40
+ display: flex;
41
+ gap: 1.5rem;
42
+
43
+ a,
44
+ a:active,
45
+ a:hover,
46
+ a:focus,
47
+ a:visited {
48
+ color: @dropdownColor;
49
+ }
50
+ }