@eeacms/volto-clms-theme 1.1.169 → 1.1.171

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,20 @@ 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
+ ### [1.1.171](https://github.com/eea/volto-clms-theme/compare/1.1.170...1.1.171) - 18 July 2024
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - CLMS-27147 (task): static dependency for useEffect [Unai Bolivar - [`db3614d`](https://github.com/eea/volto-clms-theme/commit/db3614dbb6816086839acb4e939d5a6c6465c5c1)]
12
+ - CLMS-27147 (task): reuploading [Unai Bolivar - [`eafdeeb`](https://github.com/eea/volto-clms-theme/commit/eafdeeb87091f0e082c41b37c65b571d715b44ee)]
13
+ - CLMS-27147 (bug): extracted comples expression from dependency array [Unai Bolivar - [`f68b933`](https://github.com/eea/volto-clms-theme/commit/f68b9330d11063885a47620e56391e0c60b96076)]
14
+ - CLMS-271247 (task): When the selected format is NetCDF, the projection combo should have EPSG:4326 value [Unai Bolivar - [`e37590a`](https://github.com/eea/volto-clms-theme/commit/e37590ab0069dcadbcb99308f5698e93d9274afc)]
15
+ ### [1.1.170](https://github.com/eea/volto-clms-theme/compare/1.1.169...1.1.170) - 18 July 2024
16
+
17
+ #### :hammer_and_wrench: Others
18
+
19
+ - Add userSessionResetMiddleware [Tiberiu Ichim - [`330db04`](https://github.com/eea/volto-clms-theme/commit/330db049bee6007b00e37ebbc65aa0afd82b104e)]
20
+ - Add customUserSession reducer to delete more cookies on logout [Tiberiu Ichim - [`97e826b`](https://github.com/eea/volto-clms-theme/commit/97e826b0db947cc72ec421797a346bc72cc51ce6)]
7
21
  ### [1.1.169](https://github.com/eea/volto-clms-theme/compare/1.1.168...1.1.169) - 16 July 2024
8
22
 
9
23
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-clms-theme",
3
- "version": "1.1.169",
3
+ "version": "1.1.171",
4
4
  "description": "volto-clms-theme: Volto theme for CLMS site",
5
5
  "main": "src/index.js",
6
6
  "author": "CodeSyntax for the European Environment Agency",
@@ -26,6 +26,7 @@ export const FormatNaming = ({
26
26
  (obj) => obj.unique_id === item?.unique_id,
27
27
  );
28
28
  cartItems[objIndex].format = data.value;
29
+ //debugger;
29
30
  setCartItems([...cartItems]);
30
31
  }}
31
32
  />
@@ -20,7 +20,9 @@ const _ProjectionNaming = ({
20
20
  const setProjectionValue = (unique_id, value, cI) => {
21
21
  const new_cartItems = [...cI];
22
22
  const objIndex = cI.findIndex((obj) => obj.unique_id === unique_id);
23
- if (new_cartItems[objIndex]) new_cartItems[objIndex].projection = value;
23
+ if (new_cartItems[objIndex]) {
24
+ new_cartItems[objIndex].projection = value;
25
+ }
24
26
  setCartItems([...new_cartItems]);
25
27
  };
26
28
  const utm = getUtm(item, utmProjections);
@@ -44,44 +46,53 @@ const _ProjectionNaming = ({
44
46
  // eslint-disable-next-line react-hooks/exhaustive-deps
45
47
  }, [choices]);
46
48
 
49
+ const datasetProjections = JSON.stringify(
50
+ projections_uid?.[item.dataset_uid],
51
+ );
52
+
47
53
  useEffect(() => {
48
- if (
49
- projections_uid?.[item.dataset_uid] &&
50
- projections_uid?.[item.dataset_uid].length > 0
51
- ) {
54
+ if (datasetProjections && datasetProjections.length > 0) {
52
55
  setLoading(true);
53
- setChoices(
54
- projections_uid?.[item.dataset_uid]
55
- ?.sort((a, b) => {
56
- if (Number(a.split(':')[1]) > Number(b.split(':')[1])) {
57
- return 1;
58
- } else {
59
- return -1;
60
- }
61
- })
62
- .filter((p) => utm.includes(p) || baseSources.includes(p))
63
- .map((p) => {
64
- const re = new RegExp(p.split(':')[1]);
65
- return {
66
- key: p,
67
- value: p,
68
- default: re.test(item.original_projection) ? true : false,
69
- text: re.test(item.original_projection)
70
- ? `${p} (Source system of the dataset)`
71
- : p,
72
- className: re.test(item.original_projection)
73
- ? 'original_projection'
74
- : 'projection',
75
- };
76
- }),
56
+ const newBaseSources = ['EPSG:4326'];
57
+ const sortedProjections = projections_uid[item.dataset_uid].sort((a, b) =>
58
+ Number(a.split(':')[1]) > Number(b.split(':')[1]) ? 1 : -1,
77
59
  );
60
+
61
+ const filteredProjections =
62
+ item.format === 'Netcdf' ||
63
+ item.format.token === 'Netcdf' ||
64
+ item.format.title === 'Netcdf'
65
+ ? sortedProjections.filter(
66
+ (p) => utm.includes(p) || newBaseSources.includes(p),
67
+ )
68
+ : sortedProjections.filter(
69
+ (p) => utm.includes(p) || baseSources.includes(p),
70
+ );
71
+
72
+ const choices = filteredProjections.map((p) => {
73
+ const re = new RegExp(p.split(':')[1]);
74
+ return {
75
+ key: p,
76
+ value: p,
77
+ default: re.test(item.original_projection),
78
+ text: re.test(item.original_projection)
79
+ ? `${p} (Source system of the dataset)`
80
+ : p,
81
+ className: re.test(item.original_projection)
82
+ ? 'original_projection'
83
+ : 'projection',
84
+ };
85
+ });
86
+
87
+ setChoices(choices);
88
+ setLoading(false);
78
89
  } else {
79
90
  setLoading(true);
80
91
  }
81
92
  return () => {};
82
93
 
83
94
  // eslint-disable-next-line react-hooks/exhaustive-deps
84
- }, [JSON.stringify(projections_uid?.[item.dataset_uid]), item.unique_id]);
95
+ }, [datasetProjections, item.unique_id, item.format]);
85
96
 
86
97
  useEffect(() => {
87
98
  !item.projection && choices.length > 0 && choices.find((ch) => ch.default)
package/src/index.js CHANGED
@@ -59,6 +59,7 @@ import CustomMatomoAppExtra from './components/AppExtra/AppExtra';
59
59
  import FeedbackSurvey from './components/AppExtra/FeedbackSurvey';
60
60
 
61
61
  import ImageView from '@plone/volto/components/theme/View/ImageView';
62
+ import userSessionResetMiddleware from './store/userSessionResetMiddleware';
62
63
 
63
64
  const applyConfig = (config) => {
64
65
  config.views = {
@@ -344,6 +345,16 @@ const applyConfig = (config) => {
344
345
  ...config.settings.loadables,
345
346
  };
346
347
 
348
+ config.settings.storeExtenders.push((middlewareStack) => {
349
+ const index = middlewareStack.findIndex((f) => f.name === 'protectLoadEnd');
350
+ const stack = [
351
+ ...middlewareStack.slice(0, index - 1),
352
+ userSessionResetMiddleware,
353
+ ...middlewareStack.slice(index - 1),
354
+ ];
355
+ return stack;
356
+ });
357
+
347
358
  return config;
348
359
  };
349
360
  export default applyConfig;
@@ -20,6 +20,7 @@ import { importWMSLayersReducer } from './import_wms_layers/import_wms_layers_re
20
20
  import { importWMSFieldsReducer } from './import_wms_fields/import_wms_fields_reducer';
21
21
  import { deleteProfileReducer } from './profile/delete_profile_reducer';
22
22
  import navroot from './navroot/navroot';
23
+ import customUserSession from './userSession';
23
24
 
24
25
  /**
25
26
  * Root reducer.
@@ -49,6 +50,7 @@ const reducers = {
49
50
  importWMSFields: importWMSFieldsReducer,
50
51
  profile_delete: deleteProfileReducer,
51
52
  navroot,
53
+ customUserSession,
52
54
  };
53
55
 
54
56
  export default reducers;
@@ -0,0 +1,27 @@
1
+ import { LOGOUT } from '@plone/volto/constants/ActionTypes';
2
+ import Cookies from 'universal-cookie';
3
+
4
+ const initialState = {
5
+ token: null,
6
+ login: {
7
+ loaded: false,
8
+ loading: false,
9
+ error: null,
10
+ },
11
+ };
12
+
13
+ export default function customUserSession(state = initialState, action = {}) {
14
+ switch (action.type) {
15
+ case `${LOGOUT}_SUCCESS`:
16
+ const cookies = new Cookies();
17
+ const allCookies = cookies.getAll();
18
+ Object.keys(allCookies).forEach((name) => {
19
+ if (/__ac/.test(name) || /ZopeId/.test(name)) {
20
+ cookies.remove(name);
21
+ }
22
+ });
23
+ return state;
24
+ default:
25
+ return state;
26
+ }
27
+ }
@@ -0,0 +1,44 @@
1
+ // backport of https://github.com/plone/volto/pull/6079
2
+ import Cookies from 'universal-cookie';
3
+
4
+ const LOCATION_CHANGE = '@@router/LOCATION_CHANGE';
5
+
6
+ const userSessionReset = ({ dispatch, getState }) => (next) => (action) => {
7
+ if (typeof action === 'function') {
8
+ return next(action);
9
+ }
10
+
11
+ switch (action.type) {
12
+ case LOCATION_CHANGE:
13
+ if (action.request?.subrequest || __SERVER__) {
14
+ return next(action);
15
+ }
16
+
17
+ const cookies = new Cookies();
18
+ const token = cookies.get('auth_token');
19
+ const state = getState();
20
+
21
+ if (token && !state.userSession?.token) {
22
+ const loginAction = {
23
+ type: 'LOGIN_SUCCESS',
24
+ result: {
25
+ token,
26
+ },
27
+ };
28
+ dispatch(loginAction);
29
+ } else if (!token && state.userSession?.token) {
30
+ const logoutAction = {
31
+ type: 'LOGOUT_SUCCESS',
32
+ result: {
33
+ token,
34
+ },
35
+ };
36
+ dispatch(logoutAction);
37
+ }
38
+ return next(action);
39
+ default:
40
+ return next(action);
41
+ }
42
+ };
43
+
44
+ export default userSessionReset;