@eeacms/volto-cca-policy 0.2.100 → 0.3.0

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,19 @@ 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.3.0](https://github.com/eea/volto-cca-policy/compare/0.2.100...0.3.0) - 5 February 2025
8
+
9
+ #### :bug: Bug Fixes
10
+
11
+ - fix: test [kreafox - [`478fb27`](https://github.com/eea/volto-cca-policy/commit/478fb2701bee49dd191ba1c4542ce9c9faed9958)]
12
+ - fix(UniversalLink): fix issue with @@download in url - refs #273406 [kreafox - [`544d91c`](https://github.com/eea/volto-cca-policy/commit/544d91cfcccf12a7eb6cc04ddf10313c2883ece7)]
13
+
14
+ #### :hammer_and_wrench: Others
15
+
16
+ - Bump version to 0.3.0 [kreafox - [`7380a83`](https://github.com/eea/volto-cca-policy/commit/7380a8312271bdda07dc7a2494c21ecddffa514a)]
17
+ - Remove console log [Tiberiu Ichim - [`23e5f6e`](https://github.com/eea/volto-cca-policy/commit/23e5f6e395021504b4a955564eb46425933cf4e5)]
18
+ - Make language default a function [Tiberiu Ichim - [`a96766e`](https://github.com/eea/volto-cca-policy/commit/a96766ec8b020f485a184ca77fb1aa3a91800afa)]
19
+ - Add missing code [Tiberiu Ichim - [`b9d2b8d`](https://github.com/eea/volto-cca-policy/commit/b9d2b8ddfda6169ba748d9eed21bba685585e8ab)]
7
20
  ### [0.2.100](https://github.com/eea/volto-cca-policy/compare/0.2.99...0.2.100) - 4 February 2025
8
21
 
9
22
  #### :bug: Bug Fixes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-cca-policy",
3
- "version": "0.2.100",
3
+ "version": "0.3.0",
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",
@@ -58,10 +58,10 @@ const UniversalLink = ({
58
58
 
59
59
  //case: item of type 'File'
60
60
  if (
61
- !token &&
61
+ download &&
62
62
  config.settings.downloadableObjects.includes(item['@type'])
63
63
  ) {
64
- url = `${url}/@@download/file`;
64
+ url = url.includes('/@@download/file') ? url : `${url}/@@download/file`;
65
65
  }
66
66
 
67
67
  if (
@@ -73,15 +73,21 @@ const UniversalLink = ({
73
73
  }
74
74
  }
75
75
 
76
+ if (download && isInternalURL(url)) {
77
+ url = url.includes('/@@download/file') ? url : `${url}/@@download/file`;
78
+ }
79
+
76
80
  const isExternal = !isInternalURL(url);
81
+ const isDownload =
82
+ (!isExternal && url && url.includes('@@download')) || download;
77
83
 
78
- const isDownload = (!isExternal && url.includes('@@download')) || download;
79
84
  const isDisplayFile =
80
85
  (!isExternal && url.includes('@@display-file')) || false;
81
-
82
86
  const checkedURL = URLUtils.checkAndNormalizeUrl(url);
83
87
 
84
- url = checkedURL.url;
88
+ // we can receive an item with a linkWithHash property set from ObjectBrowserWidget
89
+ // if so, we use that instead of the url prop
90
+ url = (item && item['linkWithHash']) || checkedURL.url;
85
91
  let tag = (
86
92
  <Link
87
93
  to={flattenToAppURL(url)}
@@ -95,16 +101,18 @@ const UniversalLink = ({
95
101
  </Link>
96
102
  );
97
103
 
98
- const isBlank =
99
- (isExternal || openLinkInNewTab) &&
100
- (!checkedURL.isMail || !checkedURL.isTelephone);
101
-
102
104
  if (isExternal) {
103
105
  tag = (
104
106
  <a
105
107
  href={url}
106
108
  title={title}
107
- target={isBlank ? '_blank' : null}
109
+ target={
110
+ !checkedURL.isMail &&
111
+ !checkedURL.isTelephone &&
112
+ !(openLinkInNewTab === false)
113
+ ? '_blank'
114
+ : null
115
+ }
108
116
  rel="noopener"
109
117
  className={className}
110
118
  {...props}
@@ -129,6 +137,7 @@ const UniversalLink = ({
129
137
  <a
130
138
  href={flattenToAppURL(url)}
131
139
  title={title}
140
+ target={!(openLinkInNewTab === false) ? '_blank' : null}
132
141
  rel="noopener"
133
142
  className={className}
134
143
  {...props}
@@ -120,9 +120,9 @@ describe('UniversalLink', () => {
120
120
  </Provider>,
121
121
  );
122
122
 
123
- expect(getByTitle('Volto GitHub repository').getAttribute('target')).toBe(
124
- '_blank',
125
- );
123
+ expect(
124
+ getByTitle('Volto GitHub repository').getAttribute('target'),
125
+ ).toBeNull();
126
126
  });
127
127
 
128
128
  it('check UniversalLink renders ext link for blacklisted urls', () => {
@@ -1,6 +1,6 @@
1
1
  import { mergeConfig } from '@eeacms/search';
2
- import { getClientProxyAddress } from './utils';
3
- import vocabs from './vocabulary';
2
+ import { getClientProxyAddress } from '../utils';
3
+ import vocabs from '../vocabulary';
4
4
 
5
5
  import facets from './facets';
6
6
  import views from './views';
@@ -115,6 +115,19 @@ export default function installMainSearch(config) {
115
115
  },
116
116
  });
117
117
 
118
+ // ccaSearch.permanentFilters.push((filters) => {
119
+ // const hasLanguageFilter = filters.find(({ field }) => field === 'language');
120
+ // console.log('permanentFilters', hasLanguageFilter, filters);
121
+ // if (!hasLanguageFilter) {
122
+ // return {
123
+ // terms: {
124
+ // language: ['en'],
125
+ // },
126
+ // };
127
+ // }
128
+ // return null;
129
+ // });
130
+
118
131
  // ccaSearch.permanentFilters.push({
119
132
  // terms: {
120
133
  // objectProvides: [
@@ -3,7 +3,7 @@ import {
3
3
  language,
4
4
  issued_date,
5
5
  geographic_countries,
6
- } from './common';
6
+ } from '../common';
7
7
 
8
8
  const adaptation_sectors = {
9
9
  field: 'cca_adaptation_sectors.keyword',
@@ -136,9 +136,13 @@ export const language = {
136
136
  isFilterable: false,
137
137
  show: 10000,
138
138
  isMulti: true,
139
- default: {
140
- values: ['en'],
141
- type: 'any',
139
+ default: (options) => {
140
+ const { language } = options || {};
141
+ // console.log('options', options);
142
+ return {
143
+ values: [language || 'en'],
144
+ type: 'any',
145
+ };
142
146
  },
143
147
  facetValues: [
144
148
  'de',
@@ -1,4 +1,4 @@
1
- import installMainSearch from './config';
1
+ import installMainSearch from './cca/config';
2
2
  import installHealthSearch from './health_observatory/config-health';
3
3
  import installMissionStoriesSearch from './mission_stories/config-stories';
4
4
  import installMissionToolsSearch from './mission_tools/config-tools';
@@ -37,12 +37,13 @@ const applyConfig = (config) => {
37
37
  installMissionAllSearch,
38
38
  ].reduce((acc, cur) => cur(acc), config.settings.searchlib);
39
39
 
40
- config.settings.searchlib.searchui.ccaSearch.extraQueryParams = extraQueryParams;
41
- config.settings.searchlib.searchui.ccaHealthSearch.extraQueryParams = extraQueryParams;
42
- config.settings.searchlib.searchui.missionProjects.extraQueryParams = extraQueryParams;
43
- config.settings.searchlib.searchui.missionStoriesSearch.extraQueryParams = extraQueryParams;
44
- config.settings.searchlib.searchui.missionToolsSearch.extraQueryParams = extraQueryParams;
45
- config.settings.searchlib.searchui.missionAll.extraQueryParams = extraQueryParams;
40
+ const searchui = config.settings.searchlib.searchui;
41
+ searchui.ccaSearch.extraQueryParams = extraQueryParams;
42
+ searchui.ccaHealthSearch.extraQueryParams = extraQueryParams;
43
+ searchui.missionProjects.extraQueryParams = extraQueryParams;
44
+ searchui.missionStoriesSearch.extraQueryParams = extraQueryParams;
45
+ searchui.missionToolsSearch.extraQueryParams = extraQueryParams;
46
+ searchui.missionAll.extraQueryParams = extraQueryParams;
46
47
 
47
48
  // console.log(config.settings.searchlib);
48
49
 
File without changes