@eeacms/volto-eea-website-theme 3.5.5 → 3.6.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 +12 -24
- package/package.json +1 -1
- package/src/components/manage/Blocks/Title/variations/WebReport.test.jsx +134 -0
- package/src/components/theme/Widgets/ContributorsViewWidget.jsx +23 -0
- package/src/components/theme/Widgets/ContributorsViewWidget.test.jsx +60 -0
- package/src/components/theme/Widgets/CreatorsViewWidget.jsx +23 -0
- package/src/components/theme/Widgets/CreatorsViewWidget.test.jsx +60 -0
- package/src/components/theme/Widgets/ImageViewWidget.jsx +1 -1
- package/src/components/theme/Widgets/UserSelectWidget.jsx +331 -0
- package/src/components/theme/Widgets/UserSelectWidget.test.jsx +255 -0
- package/src/customizations/volto/actions/vocabularies/vocabularies.js +89 -0
- package/src/customizations/volto/actions/vocabularies/vocabularies.js.diff +32 -0
- package/src/customizations/volto/actions/vocabularies/vocabularies.js.md +4 -0
- package/src/customizations/volto/actions/vocabularies/vocabularies.test.js +57 -0
- package/src/customizations/volto/actions/vocabularies/vocabularies.test.js.diff +45 -0
- package/src/hocs/withRootNavigation.test.jsx +70 -0
- package/src/index.js +8 -3
@@ -0,0 +1,57 @@
|
|
1
|
+
import { getVocabulary } from './vocabularies';
|
2
|
+
import { GET_VOCABULARY } from '@plone/volto/constants/ActionTypes';
|
3
|
+
|
4
|
+
describe('Vocabularies actions', () => {
|
5
|
+
describe('getVocabulary', () => {
|
6
|
+
it('should create an action to get a vocabulary', () => {
|
7
|
+
const vocabNameOrURL = 'plone.app.vocabularies.Keywords';
|
8
|
+
const query = 'john';
|
9
|
+
const action = getVocabulary({ vocabNameOrURL, query });
|
10
|
+
|
11
|
+
expect(action.type).toEqual(GET_VOCABULARY);
|
12
|
+
expect(action.vocabulary).toEqual(vocabNameOrURL);
|
13
|
+
expect(action.request.op).toEqual('get');
|
14
|
+
expect(action.request.path).toEqual(
|
15
|
+
`/@vocabularies/${vocabNameOrURL}?b_start=0&title=${query}`,
|
16
|
+
);
|
17
|
+
});
|
18
|
+
it('should create an action to get a vocabulary if a URL is passed', () => {
|
19
|
+
const vocabNameOrURL =
|
20
|
+
'http://localhost:3000/@vocabularies/plone.app.vocabularies.Keywords';
|
21
|
+
const query = 'john';
|
22
|
+
const action = getVocabulary({ vocabNameOrURL, query });
|
23
|
+
|
24
|
+
expect(action.type).toEqual(GET_VOCABULARY);
|
25
|
+
expect(action.vocabulary).toEqual(vocabNameOrURL);
|
26
|
+
expect(action.request.op).toEqual('get');
|
27
|
+
expect(action.request.path).toEqual(
|
28
|
+
`/@vocabularies/plone.app.vocabularies.Keywords?b_start=0&title=${query}`,
|
29
|
+
);
|
30
|
+
});
|
31
|
+
it('should create an action to get a vocabulary if a URL with path is passed', () => {
|
32
|
+
const vocabNameOrURL =
|
33
|
+
'http://localhost:3000/de/foo/bar/@vocabularies/plone.app.vocabularies.Keywords';
|
34
|
+
const query = 'john';
|
35
|
+
const action = getVocabulary({ vocabNameOrURL, query });
|
36
|
+
|
37
|
+
expect(action.type).toEqual(GET_VOCABULARY);
|
38
|
+
expect(action.vocabulary).toEqual(vocabNameOrURL);
|
39
|
+
expect(action.request.op).toEqual('get');
|
40
|
+
expect(action.request.path).toEqual(
|
41
|
+
`/de/foo/bar/@vocabularies/plone.app.vocabularies.Keywords?b_start=0&title=${query}`,
|
42
|
+
);
|
43
|
+
});
|
44
|
+
it('should create an action to get a vocabulary if an b_size=-1 is passed', () => {
|
45
|
+
const vocabNameOrURL =
|
46
|
+
'http://localhost:3000/de/foo/bar/@vocabularies/plone.app.vocabularies.Keywords';
|
47
|
+
const action = getVocabulary({ vocabNameOrURL, size: -1 });
|
48
|
+
|
49
|
+
expect(action.type).toEqual(GET_VOCABULARY);
|
50
|
+
expect(action.vocabulary).toEqual(vocabNameOrURL);
|
51
|
+
expect(action.request.op).toEqual('get');
|
52
|
+
expect(action.request.path).toEqual(
|
53
|
+
`/de/foo/bar/@vocabularies/plone.app.vocabularies.Keywords?b_start=0&b_size=-1`,
|
54
|
+
);
|
55
|
+
});
|
56
|
+
});
|
57
|
+
});
|
@@ -0,0 +1,45 @@
|
|
1
|
+
diff --git a/src/customizations/volto/actions/vocabularies/vocabularies.test.js b/src/customizations/volto/actions/vocabularies/vocabularies.test.js
|
2
|
+
index b7deafc..ca4fc8a 100644
|
3
|
+
--- a/src/customizations/volto/actions/vocabularies/vocabularies.test.js
|
4
|
+
+++ b/src/customizations/volto/actions/vocabularies/vocabularies.test.js
|
5
|
+
@@ -17,7 +17,7 @@ describe('Vocabularies actions', () => {
|
6
|
+
});
|
7
|
+
it('should create an action to get a vocabulary if a URL is passed', () => {
|
8
|
+
const vocabNameOrURL =
|
9
|
+
- 'http://localhost:8080/@vocabularies/plone.app.vocabularies.Keywords';
|
10
|
+
+ 'http://localhost:3000/@vocabularies/plone.app.vocabularies.Keywords';
|
11
|
+
const query = 'john';
|
12
|
+
const action = getVocabulary({ vocabNameOrURL, query });
|
13
|
+
|
14
|
+
@@ -30,7 +30,7 @@ describe('Vocabularies actions', () => {
|
15
|
+
});
|
16
|
+
it('should create an action to get a vocabulary if a URL with path is passed', () => {
|
17
|
+
const vocabNameOrURL =
|
18
|
+
- 'http://localhost:8080/de/foo/bar/@vocabularies/plone.app.vocabularies.Keywords';
|
19
|
+
+ 'http://localhost:3000/de/foo/bar/@vocabularies/plone.app.vocabularies.Keywords';
|
20
|
+
const query = 'john';
|
21
|
+
const action = getVocabulary({ vocabNameOrURL, query });
|
22
|
+
|
23
|
+
@@ -38,19 +38,19 @@ describe('Vocabularies actions', () => {
|
24
|
+
expect(action.vocabulary).toEqual(vocabNameOrURL);
|
25
|
+
expect(action.request.op).toEqual('get');
|
26
|
+
expect(action.request.path).toEqual(
|
27
|
+
- `/@vocabularies/plone.app.vocabularies.Keywords?b_start=0&title=${query}`,
|
28
|
+
+ `/de/foo/bar/@vocabularies/plone.app.vocabularies.Keywords?b_start=0&title=${query}`,
|
29
|
+
);
|
30
|
+
});
|
31
|
+
it('should create an action to get a vocabulary if an b_size=-1 is passed', () => {
|
32
|
+
const vocabNameOrURL =
|
33
|
+
- 'http://localhost:8080/de/foo/bar/@vocabularies/plone.app.vocabularies.Keywords';
|
34
|
+
+ 'http://localhost:3000/de/foo/bar/@vocabularies/plone.app.vocabularies.Keywords';
|
35
|
+
const action = getVocabulary({ vocabNameOrURL, size: -1 });
|
36
|
+
|
37
|
+
expect(action.type).toEqual(GET_VOCABULARY);
|
38
|
+
expect(action.vocabulary).toEqual(vocabNameOrURL);
|
39
|
+
expect(action.request.op).toEqual('get');
|
40
|
+
expect(action.request.path).toEqual(
|
41
|
+
- `/@vocabularies/plone.app.vocabularies.Keywords?b_start=0&b_size=-1`,
|
42
|
+
+ `/de/foo/bar/@vocabularies/plone.app.vocabularies.Keywords?b_start=0&b_size=-1`,
|
43
|
+
);
|
44
|
+
});
|
45
|
+
});
|
@@ -0,0 +1,70 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { Provider } from 'react-redux';
|
3
|
+
import configureStore from 'redux-mock-store';
|
4
|
+
import thunk from 'redux-thunk'; // ✅ Add redux-thunk middleware
|
5
|
+
import { render } from '@testing-library/react';
|
6
|
+
import withRootNavigation from './withRootNavigation';
|
7
|
+
import { getNavigation } from '@plone/volto/actions';
|
8
|
+
import { getBaseUrl, hasApiExpander } from '@plone/volto/helpers';
|
9
|
+
import config from '@plone/volto/registry';
|
10
|
+
|
11
|
+
// Mock dependencies
|
12
|
+
jest.mock('@plone/volto/actions', () => ({
|
13
|
+
getNavigation: jest.fn(() => ({ type: 'GET_NAVIGATION' })), // ✅ Ensure it returns a plain object
|
14
|
+
}));
|
15
|
+
jest.mock('@plone/volto/helpers', () => ({
|
16
|
+
getBaseUrl: jest.fn(() => '/en'),
|
17
|
+
hasApiExpander: jest.fn(() => false),
|
18
|
+
}));
|
19
|
+
jest.mock('@plone/volto/registry', () => ({
|
20
|
+
settings: { navDepth: 2 },
|
21
|
+
}));
|
22
|
+
|
23
|
+
// ✅ Use redux-thunk middleware
|
24
|
+
const mockStore = configureStore([thunk]); // Add thunk to support async actions
|
25
|
+
|
26
|
+
const initialState = {
|
27
|
+
navigation: { items: [{ title: 'Home', url: '/' }] },
|
28
|
+
intl: { locale: 'en' },
|
29
|
+
};
|
30
|
+
|
31
|
+
const store = mockStore(initialState);
|
32
|
+
|
33
|
+
// Mock Wrapped Component
|
34
|
+
const MockComponent = (props) => {
|
35
|
+
return (
|
36
|
+
<div data-testid="wrapped-component">{JSON.stringify(props.items)}</div>
|
37
|
+
);
|
38
|
+
};
|
39
|
+
|
40
|
+
const WrappedComponent = withRootNavigation(MockComponent);
|
41
|
+
|
42
|
+
describe('withRootNavigation HOC', () => {
|
43
|
+
beforeEach(() => {
|
44
|
+
jest.clearAllMocks();
|
45
|
+
});
|
46
|
+
|
47
|
+
test('calls getNavigation when API expander is not set', () => {
|
48
|
+
render(
|
49
|
+
<Provider store={store}>
|
50
|
+
<WrappedComponent />
|
51
|
+
</Provider>,
|
52
|
+
);
|
53
|
+
|
54
|
+
expect(getBaseUrl).toHaveBeenCalledWith('/en'); // Check base URL calculation
|
55
|
+
expect(hasApiExpander).toHaveBeenCalledWith('navigation', '/en'); // Ensure API expander is checked
|
56
|
+
expect(getNavigation).toHaveBeenCalledWith('/en', config.settings.navDepth); // Ensure getNavigation is dispatched
|
57
|
+
});
|
58
|
+
|
59
|
+
test('does not call getNavigation if API expander is already set', () => {
|
60
|
+
hasApiExpander.mockReturnValue(true); // Simulate that API expander is already set
|
61
|
+
|
62
|
+
render(
|
63
|
+
<Provider store={store}>
|
64
|
+
<WrappedComponent />
|
65
|
+
</Provider>,
|
66
|
+
);
|
67
|
+
|
68
|
+
expect(getNavigation).not.toHaveBeenCalled(); // Ensure getNavigation is NOT called
|
69
|
+
});
|
70
|
+
});
|
package/src/index.js
CHANGED
@@ -2,7 +2,6 @@ import React from 'react';
|
|
2
2
|
import { v4 as uuid } from 'uuid';
|
3
3
|
import { Icon } from '@plone/volto/components';
|
4
4
|
import { default as TokenWidgetEdit } from '@plone/volto/components/manage/Widgets/TokenWidget';
|
5
|
-
import SelectAutoCompleteWidget from '@plone/volto/components/manage/Widgets/SelectAutoComplete';
|
6
5
|
import { serializeNodesToText } from '@plone/volto-slate/editor/render';
|
7
6
|
import TableBlockEdit from '@plone/volto-slate/blocks/Table/TableBlockEdit';
|
8
7
|
import TableBlockView from '@plone/volto-slate/blocks/Table/TableBlockView';
|
@@ -20,7 +19,10 @@ import { TopicsWidget } from '@eeacms/volto-eea-website-theme/components/theme/W
|
|
20
19
|
import { DateWidget } from '@eeacms/volto-eea-website-theme/components/theme/Widgets/DateWidget';
|
21
20
|
import { DatetimeWidget } from '@eeacms/volto-eea-website-theme/components/theme/Widgets/DatetimeWidget';
|
22
21
|
import CreatableSelectWidget from '@eeacms/volto-eea-website-theme/components/theme/Widgets/CreatableSelectWidget';
|
22
|
+
import UserSelectWidget from '@eeacms/volto-eea-website-theme/components/theme/Widgets/UserSelectWidget';
|
23
23
|
import ImageViewWidget from '@eeacms/volto-eea-website-theme/components/theme/Widgets/ImageViewWidget';
|
24
|
+
import CreatorsViewWidget from '@eeacms/volto-eea-website-theme/components/theme/Widgets/CreatorsViewWidget';
|
25
|
+
import ContributorsViewWidget from '@eeacms/volto-eea-website-theme/components/theme/Widgets/ContributorsViewWidget';
|
24
26
|
|
25
27
|
import Tag from '@eeacms/volto-eea-design-system/ui/Tag/Tag';
|
26
28
|
|
@@ -371,9 +373,12 @@ const applyConfig = (config) => {
|
|
371
373
|
config.widgets.views.id.topics = TopicsWidget;
|
372
374
|
config.widgets.views.id.subjects = TokenWidget;
|
373
375
|
config.widgets.views.widget.tags = TokenWidget;
|
376
|
+
config.widgets.views.id.creators = CreatorsViewWidget;
|
377
|
+
config.widgets.views.id.contributors = ContributorsViewWidget;
|
378
|
+
config.widgets.views.widget.contributors = ContributorsViewWidget;
|
379
|
+
config.widgets.views.widget.creators = CreatorsViewWidget;
|
374
380
|
config.widgets.widget.creatable_select = CreatableSelectWidget;
|
375
|
-
config.widgets.vocabulary['plone.app.vocabularies.Users'] =
|
376
|
-
SelectAutoCompleteWidget;
|
381
|
+
config.widgets.vocabulary['plone.app.vocabularies.Users'] = UserSelectWidget;
|
377
382
|
|
378
383
|
config.widgets.views.factory = {
|
379
384
|
...(config.widgets.views.factory || {}),
|