@eeacms/volto-cca-policy 0.1.66 → 0.1.67
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 +6 -0
- package/package.json +1 -1
- package/src/customizations/volto/components/manage/Contents/ContentsBreadcrumbs.jsx +63 -0
- package/src/customizations/volto/components/manage/Contents/Readme.md +3 -0
- package/src/index.js +2 -7
- package/src/store/actions/physical-breadcrumbs.js +11 -0
- package/src/store/constants.js +1 -0
- package/src/store/index.js +7 -0
- package/src/store/reducers/physical-breadcrumbs.js +46 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@ 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.1.67](https://github.com/eea/volto-cca-policy/compare/0.1.66...0.1.67) - 26 January 2024
|
|
8
|
+
|
|
9
|
+
#### :hammer_and_wrench: Others
|
|
10
|
+
|
|
11
|
+
- Refs #263399 - Fix eslint errors. [GhitaB - [`71adad4`](https://github.com/eea/volto-cca-policy/commit/71adad443cacc47d548600a6c81c5a886dd8ecae)]
|
|
12
|
+
- Refs #263399 - Fix eslint errors. [GhitaB - [`a5259d9`](https://github.com/eea/volto-cca-policy/commit/a5259d92432e63e091aa3394ec9b944d628e948c)]
|
|
7
13
|
### [0.1.66](https://github.com/eea/volto-cca-policy/compare/0.1.65...0.1.66) - 26 January 2024
|
|
8
14
|
|
|
9
15
|
#### :hammer_and_wrench: Others
|
package/package.json
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { getBaseUrl } from '@plone/volto/helpers';
|
|
3
|
+
import { Breadcrumb } from 'semantic-ui-react';
|
|
4
|
+
import { useSelector, useDispatch } from 'react-redux';
|
|
5
|
+
import { Link, useLocation } from 'react-router-dom';
|
|
6
|
+
import { defineMessages, useIntl } from 'react-intl';
|
|
7
|
+
|
|
8
|
+
import ContentsBreadcrumbsRootItem from '@plone/volto/components/manage/Contents/ContentsBreadcrumbsRootItem';
|
|
9
|
+
|
|
10
|
+
import { getPhysicalBreadcrumbs } from '@eeacms/volto-cca-policy/store';
|
|
11
|
+
|
|
12
|
+
const messages = defineMessages({
|
|
13
|
+
home: {
|
|
14
|
+
id: 'Home',
|
|
15
|
+
defaultMessage: 'Home',
|
|
16
|
+
},
|
|
17
|
+
root: {
|
|
18
|
+
id: 'Root',
|
|
19
|
+
defaultMessage: 'Root',
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const ContentsBreadcrumbs = () => {
|
|
24
|
+
const items = useSelector((state) => state.physicalBreadcrumbs.items || []);
|
|
25
|
+
const intl = useIntl();
|
|
26
|
+
const pathname = useLocation().pathname;
|
|
27
|
+
const dispatch = useDispatch();
|
|
28
|
+
|
|
29
|
+
React.useEffect(() => {
|
|
30
|
+
const url = getBaseUrl(pathname);
|
|
31
|
+
dispatch(getPhysicalBreadcrumbs(url));
|
|
32
|
+
}, [dispatch, pathname]);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Breadcrumb>
|
|
36
|
+
<Link
|
|
37
|
+
to="/contents"
|
|
38
|
+
className="section"
|
|
39
|
+
title={intl.formatMessage(messages.root)}
|
|
40
|
+
>
|
|
41
|
+
<ContentsBreadcrumbsRootItem />
|
|
42
|
+
</Link>
|
|
43
|
+
{items.map((breadcrumb, index, breadcrumbs) => [
|
|
44
|
+
<Breadcrumb.Divider key={`divider-${breadcrumb.url}`} />,
|
|
45
|
+
index < breadcrumbs.length - 1 ? (
|
|
46
|
+
<Link
|
|
47
|
+
key={breadcrumb.url}
|
|
48
|
+
to={`${breadcrumb.url}/contents`}
|
|
49
|
+
className="section"
|
|
50
|
+
>
|
|
51
|
+
{breadcrumb.nav_title || breadcrumb.title}
|
|
52
|
+
</Link>
|
|
53
|
+
) : (
|
|
54
|
+
<Breadcrumb.Section key={breadcrumb.url} active>
|
|
55
|
+
{breadcrumb.nav_title || breadcrumb.title}
|
|
56
|
+
</Breadcrumb.Section>
|
|
57
|
+
),
|
|
58
|
+
])}
|
|
59
|
+
</Breadcrumb>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default ContentsBreadcrumbs;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
Based on https://github.com/plone/volto/blob/bb1753d13d2adfa4ee33aaed5a0606ac0255d1f8/packages/volto/src/components/manage/Contents/ContentsBreadcrumbs.jsx
|
|
2
|
+
|
|
3
|
+
Customized because we want to use the @physical-breadcrumbs instead of the regular breadcrumbs. Needs dedicated endpoint support
|
package/src/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import europeanComissionLogo from '@eeacms/volto-cca-policy/../theme/assets/imag
|
|
|
23
23
|
|
|
24
24
|
import installBlocks from './components/manage/Blocks';
|
|
25
25
|
import installSearchEngine from './search';
|
|
26
|
+
import installStore from './store';
|
|
26
27
|
|
|
27
28
|
import GeocharsWidget from './components/theme/Widgets/GeocharsWidget';
|
|
28
29
|
import GeolocationWidget from './components/theme/Widgets/GeolocationWidget';
|
|
@@ -346,12 +347,6 @@ const applyConfig = (config) => {
|
|
|
346
347
|
config = installExpressMiddleware(config);
|
|
347
348
|
}
|
|
348
349
|
|
|
349
|
-
// fixes bug caused by https://github.com/eea/volto-eea-website-theme/commit/94078403458a5a3ea725ce9126fffed9d463097d
|
|
350
|
-
config.settings.apiExpanders.push({
|
|
351
|
-
match: '',
|
|
352
|
-
GET_CONTENT: ['breadcrumbs'], // 'navigation', 'actions', 'types'],
|
|
353
|
-
});
|
|
354
|
-
|
|
355
350
|
config.addonRoutes = [
|
|
356
351
|
{
|
|
357
352
|
path: `/(${config.settings?.supportedLanguages.join(
|
|
@@ -363,7 +358,7 @@ const applyConfig = (config) => {
|
|
|
363
358
|
...(config.addonRoutes || []),
|
|
364
359
|
];
|
|
365
360
|
|
|
366
|
-
return compose(installBlocks, installSearchEngine)(config);
|
|
361
|
+
return compose(installBlocks, installSearchEngine, installStore)(config);
|
|
367
362
|
};
|
|
368
363
|
|
|
369
364
|
export default applyConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const GET_PHYSICAL_BREADCRUMBS = 'GET_PHYSICAL_BREADCRUMBS';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import physicalBreadcrumbs from './reducers/physical-breadcrumbs';
|
|
2
|
+
export { getPhysicalBreadcrumbs } from './actions/physical-breadcrumbs';
|
|
3
|
+
|
|
4
|
+
export default function installStore(config) {
|
|
5
|
+
config.addonReducers.physicalBreadcrumbs = physicalBreadcrumbs;
|
|
6
|
+
return config;
|
|
7
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { map } from 'lodash';
|
|
2
|
+
import { flattenToAppURL } from '@plone/volto/helpers';
|
|
3
|
+
|
|
4
|
+
import { GET_PHYSICAL_BREADCRUMBS } from '../constants';
|
|
5
|
+
|
|
6
|
+
const initialState = {
|
|
7
|
+
error: null,
|
|
8
|
+
items: [],
|
|
9
|
+
root: null,
|
|
10
|
+
loaded: false,
|
|
11
|
+
loading: false,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default function physicalBreadcrumbs(state = initialState, action = {}) {
|
|
15
|
+
switch (action.type) {
|
|
16
|
+
case `${GET_PHYSICAL_BREADCRUMBS}_PENDING`:
|
|
17
|
+
return {
|
|
18
|
+
...state,
|
|
19
|
+
error: null,
|
|
20
|
+
loaded: false,
|
|
21
|
+
loading: true,
|
|
22
|
+
};
|
|
23
|
+
case `${GET_PHYSICAL_BREADCRUMBS}_SUCCESS`:
|
|
24
|
+
return {
|
|
25
|
+
...state,
|
|
26
|
+
error: null,
|
|
27
|
+
items: map(action.result.items, (item) => ({
|
|
28
|
+
title: item.title,
|
|
29
|
+
url: flattenToAppURL(item['@id']),
|
|
30
|
+
})),
|
|
31
|
+
root: flattenToAppURL(action.result.root),
|
|
32
|
+
loaded: true,
|
|
33
|
+
loading: false,
|
|
34
|
+
};
|
|
35
|
+
case `${GET_PHYSICAL_BREADCRUMBS}_FAIL`:
|
|
36
|
+
return {
|
|
37
|
+
...state,
|
|
38
|
+
error: action.error,
|
|
39
|
+
items: [],
|
|
40
|
+
loaded: false,
|
|
41
|
+
loading: false,
|
|
42
|
+
};
|
|
43
|
+
default:
|
|
44
|
+
return state;
|
|
45
|
+
}
|
|
46
|
+
}
|