@eeacms/volto-cca-policy 0.2.40 → 0.2.42
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,14 @@ 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.2.42](https://github.com/eea/volto-cca-policy/compare/0.2.41...0.2.42) - 4 June 2024
|
|
8
|
+
|
|
9
|
+
### [0.2.41](https://github.com/eea/volto-cca-policy/compare/0.2.40...0.2.41) - 4 June 2024
|
|
10
|
+
|
|
11
|
+
#### :rocket: Dependency updates
|
|
12
|
+
|
|
13
|
+
- Release @eeacms/volto-embed@10.0.1 [EEA Jenkins - [`7e807f4`](https://github.com/eea/volto-cca-policy/commit/7e807f45151eb7335a9f690a038bef8a9f1add80)]
|
|
14
|
+
|
|
7
15
|
### [0.2.40](https://github.com/eea/volto-cca-policy/compare/0.2.39...0.2.40) - 31 May 2024
|
|
8
16
|
|
|
9
17
|
#### :bug: Bug Fixes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-cca-policy",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.42",
|
|
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",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@eeacms/volto-datablocks": "*",
|
|
32
32
|
"@eeacms/volto-eea-design-system": "*",
|
|
33
33
|
"@eeacms/volto-eea-website-theme": "^1.33.2",
|
|
34
|
-
"@eeacms/volto-embed": "
|
|
34
|
+
"@eeacms/volto-embed": "10.0.1",
|
|
35
35
|
"@eeacms/volto-globalsearch": "^1.1.0",
|
|
36
36
|
"@eeacms/volto-openlayers-map": "*",
|
|
37
37
|
"@eeacms/volto-searchlib": "^0.9.3",
|
package/src/components/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { default as PortalMessage } from './theme/PortalMessage/PortalMessage';
|
|
|
4
4
|
export { default as TranslationDisclaimer } from './theme/TranslationDisclaimer/TranslationDisclaimer';
|
|
5
5
|
export { default as ShareInfoButton } from './theme/ShareInfoButton/ShareInfoButton';
|
|
6
6
|
export { default as ASTNavigation } from './theme/ASTNavigation/ASTNavigation';
|
|
7
|
+
export { default as RedirectToLogin } from './theme/RedirectToLogin/RedirectToLogin';
|
|
7
8
|
|
|
8
9
|
// Widgets
|
|
9
10
|
export { default as RASTWidgetView } from './theme/Widgets/RASTWidgetView';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export default function RedirectToLogin(props) {
|
|
4
|
+
const { token, location, history } = props;
|
|
5
|
+
const { pathname, search } = location;
|
|
6
|
+
|
|
7
|
+
React.useEffect(() => {
|
|
8
|
+
if (!token) {
|
|
9
|
+
const back = encodeURIComponent(`${pathname}${search}`);
|
|
10
|
+
history.push(`/login?return_url=${back}`);
|
|
11
|
+
}
|
|
12
|
+
}, [token, history, pathname, search]);
|
|
13
|
+
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
3
|
+
import configureStore from 'redux-mock-store';
|
|
4
|
+
import { Provider } from 'react-intl-redux';
|
|
5
|
+
import RedirectToLogin from './RedirectToLogin';
|
|
6
|
+
import config from '@plone/volto/registry';
|
|
7
|
+
import { render } from '@testing-library/react';
|
|
8
|
+
|
|
9
|
+
config.blocks = {
|
|
10
|
+
blocksConfig: {
|
|
11
|
+
title: {
|
|
12
|
+
view: () => <div>Title Block Component</div>,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const mockStore = configureStore();
|
|
18
|
+
|
|
19
|
+
describe('RedirectToLogin', () => {
|
|
20
|
+
it('redirects to login if no token', () => {
|
|
21
|
+
const store = mockStore({
|
|
22
|
+
userSession: { token: '1234' },
|
|
23
|
+
intl: {
|
|
24
|
+
locale: 'en',
|
|
25
|
+
messages: {},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
const history = { push: jest.fn(() => null) };
|
|
29
|
+
const location = {
|
|
30
|
+
pathname: '/en/metadata/add',
|
|
31
|
+
search: '?type=NewsItem',
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
render(
|
|
35
|
+
<Provider store={store}>
|
|
36
|
+
<MemoryRouter>
|
|
37
|
+
<RedirectToLogin history={history} token={null} location={location} />
|
|
38
|
+
</MemoryRouter>
|
|
39
|
+
</Provider>,
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
expect(history.push.mock.calls[0][0]).toBe(
|
|
43
|
+
'/login?return_url=%2Fen%2Fmetadata%2Fadd%3Ftype%3DNewsItem',
|
|
44
|
+
);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('does not redirect to login if token', () => {
|
|
48
|
+
const store = mockStore({
|
|
49
|
+
userSession: { token: '1234' },
|
|
50
|
+
intl: {
|
|
51
|
+
locale: 'en',
|
|
52
|
+
messages: {},
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
const history = { push: jest.fn(() => null) };
|
|
56
|
+
const location = {
|
|
57
|
+
pathname: '/en/metadata/add',
|
|
58
|
+
search: '?type=NewsItem',
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
render(
|
|
62
|
+
<Provider store={store}>
|
|
63
|
+
<MemoryRouter>
|
|
64
|
+
<RedirectToLogin
|
|
65
|
+
history={history}
|
|
66
|
+
token={'something'}
|
|
67
|
+
location={location}
|
|
68
|
+
/>
|
|
69
|
+
</MemoryRouter>
|
|
70
|
+
</Provider>,
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
expect(history.push.mock.calls).toHaveLength(0);
|
|
74
|
+
});
|
|
75
|
+
});
|
package/src/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import DefaultView from '@plone/volto/components/theme/View/DefaultView';
|
|
|
4
4
|
import {
|
|
5
5
|
RASTWidgetView,
|
|
6
6
|
TranslationDisclaimer,
|
|
7
|
+
RedirectToLogin,
|
|
7
8
|
} from '@eeacms/volto-cca-policy/components';
|
|
8
9
|
import { blockAvailableInMission } from '@eeacms/volto-cca-policy/utils';
|
|
9
10
|
|
|
@@ -382,6 +383,12 @@ const applyConfig = (config) => {
|
|
|
382
383
|
match: '',
|
|
383
384
|
component: TranslationDisclaimer,
|
|
384
385
|
},
|
|
386
|
+
{
|
|
387
|
+
match: {
|
|
388
|
+
path: /(.*)\/add/,
|
|
389
|
+
},
|
|
390
|
+
component: RedirectToLogin,
|
|
391
|
+
},
|
|
385
392
|
];
|
|
386
393
|
|
|
387
394
|
config.settings.apiExpanders = [
|
|
@@ -392,6 +399,12 @@ const applyConfig = (config) => {
|
|
|
392
399
|
},
|
|
393
400
|
GET_CONTENT: ['siblings'],
|
|
394
401
|
},
|
|
402
|
+
|
|
403
|
+
{
|
|
404
|
+
match: '',
|
|
405
|
+
GET_CONTENT: ['navigation', 'breadcrumbs', 'actions'],
|
|
406
|
+
querystring: { 'expand.navigation.depth': '3' },
|
|
407
|
+
},
|
|
395
408
|
];
|
|
396
409
|
|
|
397
410
|
// plug custom redux middleware
|