@eeacms/volto-eea-website-theme 3.19.1 → 4.0.1
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/.eslintrc.js +7 -6
- package/CHANGELOG.md +26 -0
- package/DEVELOP.md +19 -17
- package/README.md +19 -7
- package/docker-compose.yml +1 -1
- package/jest-addon.config.js +8 -4
- package/package.json +1 -1
- package/src/actions/navigation.js +1 -1
- package/src/components/manage/Blocks/ContextNavigation/ContextNavigationEdit.jsx +4 -2
- package/src/components/manage/Blocks/ContextNavigation/ContextNavigationEdit.test.jsx +25 -19
- package/src/components/manage/Blocks/ContextNavigation/ContextNavigationView.jsx +2 -1
- package/src/components/manage/Blocks/ContextNavigation/ContextNavigationView.test.jsx +6 -4
- package/src/components/manage/Blocks/ContextNavigation/variations/Accordion.jsx +2 -2
- package/src/components/manage/Blocks/ContextNavigation/variations/ReportNavigation.jsx +4 -2
- package/src/components/manage/Blocks/ContextNavigation/variations/ReportNavigation.test.jsx +1 -1
- package/src/components/manage/Blocks/GroupBlockTemplate/FlexGroup/FlexGroup.jsx +12 -44
- package/src/components/manage/Blocks/GroupBlockTemplate/FlexGroup/RenderBlocks.jsx +5 -4
- package/src/components/manage/Blocks/GroupBlockTemplate/FlexGroup/editor-flex.less +45 -4
- package/src/components/manage/Blocks/LayoutSettings/LayoutSettingsEdit.jsx +2 -1
- package/src/components/manage/Blocks/LayoutSettings/LayoutSettingsEdit.test.jsx +12 -4
- package/src/components/manage/Blocks/LayoutSettings/LayoutSettingsView.jsx +1 -1
- package/src/components/manage/Blocks/Title/Edit.jsx +3 -3
- package/src/components/manage/Blocks/Title/View.jsx +2 -1
- package/src/components/manage/Blocks/Title/variations/WebReport.jsx +2 -2
- package/src/components/manage/Blocks/Title/variations/WebReport.test.jsx +6 -4
- package/src/components/manage/Blocks/Title/variations/WebReportPage.jsx +2 -2
- package/src/components/manage/Blocks/Title/variations/WebReportPage.test.jsx +6 -4
- package/src/components/theme/Banner/View.jsx +1 -1
- package/src/components/theme/BaseTag.jsx +2 -1
- package/src/components/theme/BaseTag.test.jsx +7 -2
- package/src/components/theme/DraftBackground/DraftBackground.jsx +2 -1
- package/src/components/theme/Homepage/HomePageInverseView.jsx +3 -3
- package/src/components/theme/Homepage/HomePageInverseView.test.jsx +1 -1
- package/src/components/theme/Homepage/HomePageView.jsx +3 -3
- package/src/components/theme/Homepage/HomePageView.test.jsx +1 -1
- package/src/components/theme/Logo.jsx +3 -3
- package/src/components/theme/NotFound/GoneView.jsx +3 -2
- package/src/components/theme/NotFound/GoneView.test.jsx +5 -4
- package/src/components/theme/NotFound/NotFound.jsx +1 -1
- package/src/components/theme/NotFound/NotFound.test.jsx +3 -2
- package/src/components/theme/PrintLoader/PrintLoader.test.jsx +1 -1
- package/src/components/theme/SubsiteClass.jsx +6 -4
- package/src/components/theme/SubsiteClass.test.jsx +3 -2
- package/src/components/theme/WebReport/WebReportSectionView.jsx +2 -2
- package/src/components/theme/WebReport/WebReportSectionView.test.jsx +10 -5
- package/src/components/theme/Widgets/ADUserGroupSelectWidget.jsx +2 -2
- package/src/components/theme/Widgets/ContributorsViewWidget.jsx +1 -1
- package/src/components/theme/Widgets/CreatableSelectWidget.jsx +7 -4
- package/src/components/theme/Widgets/CreatorsViewWidget.jsx +1 -1
- package/src/components/theme/Widgets/DateWidget.jsx +1 -1
- package/src/components/theme/Widgets/DateWidget.test.js +1 -1
- package/src/components/theme/Widgets/DatetimeWidget.jsx +1 -1
- package/src/components/theme/Widgets/DatetimeWidget.test.js +1 -1
- package/src/components/theme/Widgets/ImageViewWidget.jsx +1 -0
- package/src/components/theme/Widgets/NavigationBehaviorWidget.jsx +7 -3
- package/src/components/theme/Widgets/NavigationBehaviorWidget.test.jsx +51 -46
- package/src/components/theme/Widgets/UserSelectWidget.jsx +13 -10
- package/src/customizations/@plone/volto-slate/blocks/Table/TableBlockView.jsx +3 -3
- package/src/customizations/@plone/volto-slate/blocks/Text/TextBlockView.jsx +2 -2
- package/src/customizations/@plone/volto-slate/editor/SlateEditor.jsx +23 -10
- package/src/customizations/@plone/volto-slate/editor/render.jsx +7 -3
- package/src/customizations/@plone/volto-slate/utils/blocks.js +11 -8
- package/src/customizations/volto/components/manage/Blocks/Grid/View.jsx +2 -2
- package/src/customizations/volto/components/manage/Blocks/Image/Edit.jsx +30 -27
- package/src/customizations/volto/components/manage/Blocks/Image/Edit.test.jsx +244 -246
- package/src/customizations/volto/components/manage/Blocks/Image/View.jsx +23 -25
- package/src/customizations/volto/components/manage/Blocks/LeadImage/Edit.jsx +6 -4
- package/src/customizations/volto/components/manage/Blocks/LeadImage/LeadImageSidebar.jsx +4 -2
- package/src/customizations/volto/components/manage/Blocks/LeadImage/View.jsx +2 -2
- package/src/customizations/volto/components/manage/Controlpanels/Groups/RenderGroups.jsx +1 -1
- package/src/customizations/volto/components/manage/Controlpanels/Groups/RenderGroups.test.jsx +108 -42
- package/src/customizations/volto/components/manage/Diff/DiffField.jsx +4 -3
- package/src/customizations/volto/components/manage/Display/Display.jsx +8 -7
- package/src/customizations/volto/components/manage/Sidebar/ObjectBrowserBody.jsx +42 -21
- package/src/customizations/volto/components/manage/Sidebar/ObjectBrowserNav.jsx +2 -1
- package/src/customizations/volto/components/manage/Sidebar/SidebarPopup.jsx +46 -24
- package/src/customizations/volto/components/manage/Sidebar/objectBrowserSelection.js +58 -0
- package/src/customizations/volto/components/manage/Toolbar/More.jsx +8 -10
- package/src/customizations/volto/components/manage/Widgets/NumberWidget.jsx +1 -1
- package/src/customizations/volto/components/manage/Widgets/NumberWidget.test.jsx +6 -1
- package/src/customizations/volto/components/manage/Widgets/ObjectBrowserWidget.jsx +66 -12
- package/src/customizations/volto/components/manage/Workflow/Workflow.jsx +10 -9
- package/src/customizations/volto/components/theme/Breadcrumbs/Breadcrumbs.jsx +3 -2
- package/src/customizations/volto/components/theme/Comments/Comments.jsx +9 -8
- package/src/customizations/volto/components/theme/Comments/Comments.test.jsx +29 -7
- package/src/customizations/volto/components/theme/ContactForm/ContactForm.jsx +1 -1
- package/src/customizations/volto/components/theme/ContactForm/ContactForm.test.js +5 -0
- package/src/customizations/volto/components/theme/ContentMetadataTags/ContentMetadataTags.jsx +5 -7
- package/src/customizations/volto/components/theme/EventDetails/EventDetails.jsx +2 -2
- package/src/customizations/volto/components/theme/Footer/Footer.jsx +1 -1
- package/src/customizations/volto/components/theme/Header/Header.jsx +10 -8
- package/src/customizations/volto/components/theme/Header/Header.test.jsx +1 -1
- package/src/customizations/volto/components/theme/Header/LanguageSwitcher.jsx +3 -3
- package/src/customizations/volto/components/theme/Image/Image.jsx +4 -3
- package/src/customizations/volto/components/theme/Unauthorized/Unauthorized.jsx +1 -1
- package/src/customizations/volto/components/theme/View/DefaultView.jsx +4 -3
- package/src/customizations/volto/components/theme/View/EventView.jsx +3 -2
- package/src/customizations/volto/helpers/Html/Html.jsx +16 -6
- package/src/customizations/volto/helpers/Html/Readme.md +7 -1
- package/src/customizations/volto/reducers/breadcrumbs/breadcrumbs.js +3 -6
- package/src/customizations/volto/server.jsx +13 -15
- package/src/helpers/schema-utils.js +1 -1
- package/src/helpers/schema-utils.test.js +1 -1
- package/src/hocs/withErrorBoundary.jsx +1 -1
- package/src/hocs/withErrorBoundary.test.jsx +4 -11
- package/src/hocs/withRootNavigation.jsx +3 -2
- package/src/hocs/withRootNavigation.test.jsx +18 -14
- package/src/index.js +3 -3
- package/src/slate.js +1 -1
- package/src/customizations/volto/components/manage/Blocks/LeadImage/AlignChooser.jsx +0 -76
- package/src/customizations/volto/components/manage/Blocks/LeadImage/AlignChooser.test.js +0 -50
- package/src/customizations/volto/components/manage/Sidebar/SidebarPopup copy.jsx +0 -82
|
@@ -4,12 +4,9 @@
|
|
|
4
4
|
* Customized reducer as part of ticket 271001 in order to receive portal_type info
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
getBaseUrl,
|
|
11
|
-
hasApiExpander,
|
|
12
|
-
} from '@plone/volto/helpers';
|
|
7
|
+
import map from 'lodash/map';
|
|
8
|
+
import { flattenToAppURL, getBaseUrl } from '@plone/volto/helpers/Url/Url';
|
|
9
|
+
import { hasApiExpander } from '@plone/volto/helpers/Utils/Utils';
|
|
13
10
|
|
|
14
11
|
import {
|
|
15
12
|
GET_BREADCRUMBS,
|
|
@@ -8,7 +8,6 @@ import express from 'express';
|
|
|
8
8
|
import { renderToString } from 'react-dom/server';
|
|
9
9
|
import { createMemoryHistory } from 'history';
|
|
10
10
|
import { parse as parseUrl } from 'url';
|
|
11
|
-
import { keys } from 'lodash';
|
|
12
11
|
import locale from 'locale';
|
|
13
12
|
import { detect } from 'detect-browser';
|
|
14
13
|
import path from 'path';
|
|
@@ -18,28 +17,24 @@ import { CookiesProvider } from 'react-cookie';
|
|
|
18
17
|
import cookiesMiddleware from 'universal-cookie-express';
|
|
19
18
|
import debug from 'debug';
|
|
20
19
|
import crypto from 'crypto';
|
|
21
|
-
|
|
22
|
-
import routes from '@
|
|
20
|
+
// eslint-disable-next-line
|
|
21
|
+
import routes from '@root/routes';
|
|
23
22
|
import config from '@plone/volto/registry';
|
|
24
23
|
|
|
24
|
+
import { flattenToAppURL } from '@plone/volto/helpers/Url/Url';
|
|
25
|
+
import Html from '@plone/volto/helpers/Html/Html';
|
|
26
|
+
import Api from '@plone/volto/helpers/Api/Api';
|
|
27
|
+
import { persistAuthToken } from '@plone/volto/helpers/AuthToken/AuthToken';
|
|
25
28
|
import {
|
|
26
|
-
flattenToAppURL,
|
|
27
|
-
Html,
|
|
28
|
-
Api,
|
|
29
|
-
persistAuthToken,
|
|
30
29
|
toBackendLang,
|
|
31
30
|
toGettextLang,
|
|
32
31
|
toReactIntlLang,
|
|
33
|
-
} from '@plone/volto/helpers';
|
|
34
|
-
import { changeLanguage } from '@plone/volto/actions';
|
|
32
|
+
} from '@plone/volto/helpers/Utils/Utils';
|
|
33
|
+
import { changeLanguage } from '@plone/volto/actions/language/language';
|
|
35
34
|
|
|
36
35
|
import userSession from '@plone/volto/reducers/userSession/userSession';
|
|
37
|
-
|
|
38
|
-
import ErrorPage from '@plone/volto/error';
|
|
39
|
-
|
|
40
|
-
import languages from '@plone/volto/constants/Languages';
|
|
41
|
-
|
|
42
36
|
import configureStore from '@plone/volto/store';
|
|
37
|
+
import ErrorPage from '@plone/volto/error';
|
|
43
38
|
import {
|
|
44
39
|
ReduxAsyncConnect,
|
|
45
40
|
loadOnServer,
|
|
@@ -61,7 +56,10 @@ function reactIntlErrorHandler(error) {
|
|
|
61
56
|
debug('i18n')(error);
|
|
62
57
|
}
|
|
63
58
|
|
|
64
|
-
const supported = new locale.Locales(
|
|
59
|
+
const supported = new locale.Locales(
|
|
60
|
+
config.settings?.supportedLanguages || ['en'],
|
|
61
|
+
'en',
|
|
62
|
+
);
|
|
65
63
|
|
|
66
64
|
const server = express()
|
|
67
65
|
.disable('x-powered-by')
|
|
@@ -5,7 +5,7 @@ import imageFullSVG from '@plone/volto/icons/image-full.svg';
|
|
|
5
5
|
import alignTopSVG from '@plone/volto/icons/move-up.svg';
|
|
6
6
|
import alignCenterSVG from '@plone/volto/icons/row.svg';
|
|
7
7
|
import alignBottomSVG from '@plone/volto/icons/move-down.svg';
|
|
8
|
-
import { addStyling } from '@plone/volto/helpers';
|
|
8
|
+
import { addStyling } from '@plone/volto/helpers/Extensions';
|
|
9
9
|
|
|
10
10
|
export const ALIGN_INFO_MAP = {
|
|
11
11
|
narrow_width: [imageNarrowSVG, 'Narrow width'],
|
|
@@ -16,7 +16,7 @@ jest.mock('@plone/volto/icons/move-up.svg', () => 'move-up-svg');
|
|
|
16
16
|
jest.mock('@plone/volto/icons/row.svg', () => 'row-svg');
|
|
17
17
|
jest.mock('@plone/volto/icons/move-down.svg', () => 'move-down-svg');
|
|
18
18
|
|
|
19
|
-
jest.mock('@plone/volto/helpers', () => ({
|
|
19
|
+
jest.mock('@plone/volto/helpers/Extensions', () => ({
|
|
20
20
|
addStyling: jest.fn((props) => ({
|
|
21
21
|
properties: {
|
|
22
22
|
styles: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import ErrorBoundary from '@plone/volto/components/theme/Error/ErrorBoundary';
|
|
3
3
|
|
|
4
4
|
export default function withErrorBoundary(WrappedComponent, options = {}) {
|
|
5
5
|
// Handle backward compatibility - if second param is a component, treat as fallback
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import { render, screen } from '@testing-library/react';
|
|
2
2
|
import '@testing-library/jest-dom';
|
|
3
|
-
import
|
|
3
|
+
import ErrorBoundary from '@plone/volto/components/theme/Error/ErrorBoundary';
|
|
4
4
|
import withErrorBoundary from './withErrorBoundary';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
try {
|
|
10
|
-
return children;
|
|
11
|
-
} catch (error) {
|
|
12
|
-
if (onError) onError(error, { componentStack: 'test-stack' });
|
|
13
|
-
return fallback || <div>Error occurred</div>;
|
|
14
|
-
}
|
|
15
|
-
}),
|
|
6
|
+
jest.mock('@plone/volto/components/theme/Error/ErrorBoundary', () => ({
|
|
7
|
+
__esModule: true,
|
|
8
|
+
default: jest.fn(({ children, fallback }) => children || fallback || null),
|
|
16
9
|
}));
|
|
17
10
|
|
|
18
11
|
// Test components
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { connect, useDispatch } from 'react-redux';
|
|
3
|
-
import { getBaseUrl
|
|
4
|
-
import {
|
|
3
|
+
import { getBaseUrl } from '@plone/volto/helpers/Url/Url';
|
|
4
|
+
import { hasApiExpander } from '@plone/volto/helpers/Utils/Utils';
|
|
5
|
+
import { getNavigation } from '@plone/volto/actions/navigation/navigation';
|
|
5
6
|
import config from '@plone/volto/registry';
|
|
6
7
|
|
|
7
8
|
export default function withRootNavigation(WrappedComponent) {
|
|
@@ -4,24 +4,28 @@ import configureStore from 'redux-mock-store';
|
|
|
4
4
|
import thunk from 'redux-thunk'; // ✅ Add redux-thunk middleware
|
|
5
5
|
import { render } from '@testing-library/react';
|
|
6
6
|
import withRootNavigation from './withRootNavigation';
|
|
7
|
-
import { getNavigation } from '@plone/volto/actions';
|
|
8
|
-
import { getBaseUrl
|
|
7
|
+
import { getNavigation } from '@plone/volto/actions/navigation/navigation';
|
|
8
|
+
import { getBaseUrl } from '@plone/volto/helpers/Url/Url';
|
|
9
|
+
import { hasApiExpander } from '@plone/volto/helpers/Utils/Utils';
|
|
9
10
|
import config from '@plone/volto/registry';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
jest.
|
|
13
|
-
getNavigation: jest.fn(() => ({ type: 'GET_NAVIGATION' })), // ✅ Ensure it returns a plain object
|
|
12
|
+
jest.mock('@plone/volto/actions/navigation/navigation', () => ({
|
|
13
|
+
getNavigation: jest.fn(() => ({ type: 'GET_NAVIGATION' })),
|
|
14
14
|
}));
|
|
15
|
-
jest.mock('@plone/volto/helpers', () => ({
|
|
15
|
+
jest.mock('@plone/volto/helpers/Url/Url', () => ({
|
|
16
16
|
getBaseUrl: jest.fn(() => '/en'),
|
|
17
|
+
}));
|
|
18
|
+
jest.mock('@plone/volto/helpers/Utils/Utils', () => ({
|
|
17
19
|
hasApiExpander: jest.fn(() => false),
|
|
18
20
|
}));
|
|
19
21
|
jest.mock('@plone/volto/registry', () => ({
|
|
20
|
-
|
|
22
|
+
__esModule: true,
|
|
23
|
+
default: {
|
|
24
|
+
settings: { navDepth: 2 },
|
|
25
|
+
},
|
|
21
26
|
}));
|
|
22
27
|
|
|
23
|
-
|
|
24
|
-
const mockStore = configureStore([thunk]); // Add thunk to support async actions
|
|
28
|
+
const mockStore = configureStore([thunk]);
|
|
25
29
|
|
|
26
30
|
const initialState = {
|
|
27
31
|
navigation: { items: [{ title: 'Home', url: '/' }] },
|
|
@@ -51,13 +55,13 @@ describe('withRootNavigation HOC', () => {
|
|
|
51
55
|
</Provider>,
|
|
52
56
|
);
|
|
53
57
|
|
|
54
|
-
expect(getBaseUrl).toHaveBeenCalledWith('/en');
|
|
55
|
-
expect(hasApiExpander).toHaveBeenCalledWith('navigation', '/en');
|
|
56
|
-
expect(getNavigation).toHaveBeenCalledWith('/en', config.settings.navDepth);
|
|
58
|
+
expect(getBaseUrl).toHaveBeenCalledWith('/en');
|
|
59
|
+
expect(hasApiExpander).toHaveBeenCalledWith('navigation', '/en');
|
|
60
|
+
expect(getNavigation).toHaveBeenCalledWith('/en', config.settings.navDepth);
|
|
57
61
|
});
|
|
58
62
|
|
|
59
63
|
test('does not call getNavigation if API expander is already set', () => {
|
|
60
|
-
hasApiExpander.mockReturnValue(true);
|
|
64
|
+
hasApiExpander.mockReturnValue(true);
|
|
61
65
|
|
|
62
66
|
render(
|
|
63
67
|
<Provider store={store}>
|
|
@@ -65,6 +69,6 @@ describe('withRootNavigation HOC', () => {
|
|
|
65
69
|
</Provider>,
|
|
66
70
|
);
|
|
67
71
|
|
|
68
|
-
expect(getNavigation).not.toHaveBeenCalled();
|
|
72
|
+
expect(getNavigation).not.toHaveBeenCalled();
|
|
69
73
|
});
|
|
70
74
|
});
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { v4 as uuid } from 'uuid';
|
|
3
|
-
import
|
|
3
|
+
import Icon from '@plone/volto/components/theme/Icon/Icon';
|
|
4
4
|
import { default as TokenWidgetEdit } from '@plone/volto/components/manage/Widgets/TokenWidget';
|
|
5
5
|
import { serializeNodesToText } from '@plone/volto-slate/editor/render';
|
|
6
6
|
import TableBlockEdit from '@plone/volto-slate/blocks/Table/TableBlockEdit';
|
|
@@ -396,8 +396,8 @@ const applyConfig = (config) => {
|
|
|
396
396
|
return override_toc && level
|
|
397
397
|
? [parseInt(level.slice(1)), entry_text]
|
|
398
398
|
: config.settings.slate.topLevelTargetElements.includes(type)
|
|
399
|
-
|
|
400
|
-
|
|
399
|
+
? [parseInt(type.slice(1)), plaintext]
|
|
400
|
+
: null;
|
|
401
401
|
};
|
|
402
402
|
}
|
|
403
403
|
// Apply accordion block customization
|
package/src/slate.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
BlockButton,
|
|
7
7
|
} from '@plone/volto-slate/editor/ui';
|
|
8
8
|
import installCallout from '@plone/volto-slate/editor/plugins/Callout';
|
|
9
|
-
import
|
|
9
|
+
import Icon from '@plone/volto/components/theme/Icon/Icon';
|
|
10
10
|
import { Editor, Transforms, Text } from 'slate';
|
|
11
11
|
import { useSlate } from 'slate-react';
|
|
12
12
|
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { defineMessages, useIntl } from 'react-intl';
|
|
2
|
-
import { Icon } from '@plone/volto/components';
|
|
3
|
-
import { Button } from 'semantic-ui-react';
|
|
4
|
-
import imageLeftSVG from '@plone/volto/icons/image-left.svg';
|
|
5
|
-
import imageRightSVG from '@plone/volto/icons/image-right.svg';
|
|
6
|
-
import imageFitSVG from '@plone/volto/icons/image-fit.svg';
|
|
7
|
-
import imageWideSVG from '@plone/volto/icons/image-wide.svg';
|
|
8
|
-
import imageFullSVG from '@plone/volto/icons/image-full.svg';
|
|
9
|
-
|
|
10
|
-
const messages = defineMessages({
|
|
11
|
-
left: {
|
|
12
|
-
id: 'Left',
|
|
13
|
-
defaultMessage: 'Left',
|
|
14
|
-
},
|
|
15
|
-
right: {
|
|
16
|
-
id: 'Right',
|
|
17
|
-
defaultMessage: 'Right',
|
|
18
|
-
},
|
|
19
|
-
center: {
|
|
20
|
-
id: 'Center',
|
|
21
|
-
defaultMessage: 'Center',
|
|
22
|
-
},
|
|
23
|
-
wide: {
|
|
24
|
-
id: 'Wide',
|
|
25
|
-
defaultMessage: 'Wide',
|
|
26
|
-
},
|
|
27
|
-
full: {
|
|
28
|
-
id: 'Full',
|
|
29
|
-
defaultMessage: 'Full',
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const AlignChooser = ({
|
|
34
|
-
align,
|
|
35
|
-
onChangeBlock,
|
|
36
|
-
data,
|
|
37
|
-
block,
|
|
38
|
-
actions = ['left', 'right', 'center', 'full'],
|
|
39
|
-
}) => {
|
|
40
|
-
const intl = useIntl();
|
|
41
|
-
|
|
42
|
-
const ICON_MAP = {
|
|
43
|
-
left: imageLeftSVG,
|
|
44
|
-
right: imageRightSVG,
|
|
45
|
-
center: imageFitSVG,
|
|
46
|
-
wide: imageWideSVG,
|
|
47
|
-
full: imageFullSVG,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
function onAlignBlock(align) {
|
|
51
|
-
onChangeBlock(block, {
|
|
52
|
-
...data,
|
|
53
|
-
copyrightPosition: align,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<div className="align-buttons">
|
|
59
|
-
{actions.map((action) => (
|
|
60
|
-
<Button.Group key={action}>
|
|
61
|
-
<Button
|
|
62
|
-
icon
|
|
63
|
-
basic
|
|
64
|
-
aria-label={intl.formatMessage(messages[action])}
|
|
65
|
-
onClick={() => onAlignBlock(action)}
|
|
66
|
-
active={data.copyrightPosition === action}
|
|
67
|
-
>
|
|
68
|
-
<Icon name={ICON_MAP[action]} size="24px" />
|
|
69
|
-
</Button>
|
|
70
|
-
</Button.Group>
|
|
71
|
-
))}
|
|
72
|
-
</div>
|
|
73
|
-
);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export default AlignChooser;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import configureStore from 'redux-mock-store';
|
|
3
|
-
import { Provider } from 'react-intl-redux';
|
|
4
|
-
import { render } from '@testing-library/react';
|
|
5
|
-
import AlignChooser from './AlignChooser';
|
|
6
|
-
|
|
7
|
-
const mockStore = configureStore();
|
|
8
|
-
|
|
9
|
-
describe('AlignChooser', () => {
|
|
10
|
-
const props = {
|
|
11
|
-
align: 'left',
|
|
12
|
-
onChangeBlock: jest.fn(),
|
|
13
|
-
data: { copyrightPosition: 'left' },
|
|
14
|
-
block: '123',
|
|
15
|
-
actions: ['left', 'right', 'center', 'full'],
|
|
16
|
-
};
|
|
17
|
-
const store = mockStore({
|
|
18
|
-
intl: {
|
|
19
|
-
locale: 'en',
|
|
20
|
-
messages: {},
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('renders the align buttons', () => {
|
|
25
|
-
const { container } = render(
|
|
26
|
-
<Provider store={store}>
|
|
27
|
-
<AlignChooser {...props} />
|
|
28
|
-
</Provider>,
|
|
29
|
-
);
|
|
30
|
-
expect(container).toMatchSnapshot();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('calls onChangeBlock when an align button is clicked', () => {
|
|
34
|
-
const { container } = render(
|
|
35
|
-
<Provider store={store}>
|
|
36
|
-
<AlignChooser {...props} />
|
|
37
|
-
</Provider>,
|
|
38
|
-
);
|
|
39
|
-
expect(container).toMatchSnapshot();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('marks the active align button as active', () => {
|
|
43
|
-
const { container } = render(
|
|
44
|
-
<Provider store={store}>
|
|
45
|
-
<AlignChooser {...props} />
|
|
46
|
-
</Provider>,
|
|
47
|
-
);
|
|
48
|
-
expect(container).toMatchSnapshot();
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
// Check this https://github.com/plone/volto/pull/5520
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Portal } from 'react-portal';
|
|
4
|
-
import { CSSTransition } from 'react-transition-group';
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
6
|
-
import { doesNodeContainClick } from 'semantic-ui-react/dist/commonjs/lib';
|
|
7
|
-
|
|
8
|
-
const DEFAULT_TIMEOUT = 500;
|
|
9
|
-
|
|
10
|
-
const SidebarPopup = (props) => {
|
|
11
|
-
const { children, open, onClose, overlay } = props;
|
|
12
|
-
|
|
13
|
-
const asideElement = React.useRef();
|
|
14
|
-
|
|
15
|
-
const handleClickOutside = (e) => {
|
|
16
|
-
if (asideElement && doesNodeContainClick(asideElement.current, e)) return;
|
|
17
|
-
onClose();
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
React.useEffect(() => {
|
|
21
|
-
document.addEventListener('mousedown', handleClickOutside, false);
|
|
22
|
-
return () => {
|
|
23
|
-
document.removeEventListener('mousedown', handleClickOutside, false);
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<>
|
|
29
|
-
{overlay && (
|
|
30
|
-
<CSSTransition
|
|
31
|
-
in={open}
|
|
32
|
-
timeout={DEFAULT_TIMEOUT}
|
|
33
|
-
classNames="overlay-container"
|
|
34
|
-
unmountOnExit
|
|
35
|
-
>
|
|
36
|
-
<Portal node={document?.body}>
|
|
37
|
-
<div className="overlay-container"></div>
|
|
38
|
-
</Portal>
|
|
39
|
-
</CSSTransition>
|
|
40
|
-
)}
|
|
41
|
-
<CSSTransition
|
|
42
|
-
in={open}
|
|
43
|
-
timeout={DEFAULT_TIMEOUT}
|
|
44
|
-
classNames="sidebar-container"
|
|
45
|
-
unmountOnExit
|
|
46
|
-
>
|
|
47
|
-
<Portal>
|
|
48
|
-
<aside
|
|
49
|
-
id="test"
|
|
50
|
-
role="presentation"
|
|
51
|
-
onClick={(e) => {
|
|
52
|
-
e.stopPropagation();
|
|
53
|
-
}}
|
|
54
|
-
onKeyDown={(e) => {
|
|
55
|
-
e.stopPropagation();
|
|
56
|
-
}}
|
|
57
|
-
ref={asideElement}
|
|
58
|
-
key="sidebarpopup"
|
|
59
|
-
className="sidebar-container"
|
|
60
|
-
style={{ overflowY: 'auto' }}
|
|
61
|
-
>
|
|
62
|
-
{children}
|
|
63
|
-
</aside>
|
|
64
|
-
</Portal>
|
|
65
|
-
</CSSTransition>
|
|
66
|
-
</>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
SidebarPopup.propTypes = {
|
|
71
|
-
open: PropTypes.bool,
|
|
72
|
-
onClose: PropTypes.func,
|
|
73
|
-
overlay: PropTypes.bool,
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
SidebarPopup.defaultProps = {
|
|
77
|
-
open: false,
|
|
78
|
-
onClose: () => {},
|
|
79
|
-
overlay: false,
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export default SidebarPopup;
|