@plone/volto 18.0.0-alpha.41 → 18.0.0-alpha.43
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 +114 -0
- package/finalreleasechangelog.py +48 -0
- package/locales/ca/LC_MESSAGES/volto.po +39 -13
- package/locales/ca.json +1 -1
- package/locales/de/LC_MESSAGES/volto.po +40 -14
- package/locales/de.json +1 -1
- package/locales/en/LC_MESSAGES/volto.po +39 -13
- package/locales/en.json +1 -1
- package/locales/es/LC_MESSAGES/volto.po +40 -14
- package/locales/es.json +1 -1
- package/locales/eu/LC_MESSAGES/volto.po +40 -14
- package/locales/eu.json +1 -1
- package/locales/fi/LC_MESSAGES/volto.po +40 -14
- package/locales/fi.json +1 -1
- package/locales/fr/LC_MESSAGES/volto.po +40 -14
- package/locales/fr.json +1 -1
- package/locales/hi/LC_MESSAGES/volto.po +40 -14
- package/locales/hi.json +1 -1
- package/locales/it/LC_MESSAGES/volto.po +40 -14
- package/locales/it.json +1 -1
- package/locales/ja/LC_MESSAGES/volto.po +39 -13
- package/locales/ja.json +1 -1
- package/locales/nl/LC_MESSAGES/volto.po +39 -13
- package/locales/nl.json +1 -1
- package/locales/pt/LC_MESSAGES/volto.po +39 -13
- package/locales/pt.json +1 -1
- package/locales/pt_BR/LC_MESSAGES/volto.po +40 -14
- package/locales/pt_BR.json +1 -1
- package/locales/ro/LC_MESSAGES/volto.po +39 -13
- package/locales/ro.json +1 -1
- package/locales/volto.pot +40 -14
- package/locales/zh_CN/LC_MESSAGES/volto.po +40 -14
- package/locales/zh_CN.json +1 -1
- package/package.json +5 -6
- package/razzle.config.js +3 -3
- package/src/components/index.js +0 -1
- package/src/components/manage/Actions/Actions.stories.jsx +138 -0
- package/src/components/manage/Add/Add.jsx +7 -4
- package/src/components/manage/BlockChooser/BlockChooser.jsx +9 -1
- package/src/components/manage/Blocks/Block/BlocksForm.jsx +5 -0
- package/src/components/manage/Blocks/Block/Edit.jsx +24 -8
- package/src/components/manage/Blocks/Block/EditBlockWrapper.jsx +17 -1
- package/src/components/manage/Blocks/Block/Order/Item.jsx +8 -2
- package/src/components/manage/Blocks/Block/Order/Order.jsx +2 -0
- package/src/components/manage/Blocks/Container/Data.jsx +10 -2
- package/src/components/manage/Blocks/Grid/View.jsx +3 -0
- package/src/components/manage/Blocks/Image/ImageSidebar.jsx +10 -2
- package/src/components/manage/Blocks/LeadImage/Edit.jsx +74 -126
- package/src/components/manage/Blocks/Listing/ListingData.jsx +10 -2
- package/src/components/manage/Blocks/Maps/MapsSidebar.jsx +3 -1
- package/src/components/manage/Blocks/Search/SearchBlockEdit.jsx +2 -0
- package/src/components/manage/Blocks/Search/SearchBlockView.jsx +18 -2
- package/src/components/manage/Blocks/Search/components/SortOn.jsx +82 -55
- package/src/components/manage/Blocks/Search/hocs/withSearch.jsx +1 -1
- package/src/components/manage/Blocks/Search/widgets/SelectMetadataField.jsx +107 -176
- package/src/components/manage/Blocks/Teaser/Data.jsx +10 -2
- package/src/components/manage/Blocks/Teaser/DefaultBody.jsx +15 -8
- package/src/components/manage/Blocks/ToC/Edit.jsx +36 -28
- package/src/components/manage/Blocks/Video/Edit.jsx +105 -172
- package/src/components/manage/Blocks/Video/Edit.stories.jsx +57 -0
- package/src/components/manage/Blocks/Video/VideoSidebar.jsx +3 -1
- package/src/components/manage/Contents/Contents.jsx +4 -1
- package/src/components/manage/Contents/ContentsBreadcrumbs.stories.jsx +46 -0
- package/src/components/manage/Contents/ContentsPropertiesModal.jsx +85 -52
- package/src/components/manage/Contents/ContentsUploadModal.jsx +230 -323
- package/src/components/manage/Contents/ContentsUploadModal.stories.jsx +56 -0
- package/src/components/manage/Controlpanels/AddonsControlpanel.jsx +323 -441
- package/src/components/manage/Controlpanels/Aliases.jsx +452 -580
- package/src/components/manage/Controlpanels/Aliases.stories.jsx +74 -0
- package/src/components/manage/Controlpanels/ContentTypeSchema.jsx +1 -0
- package/src/components/manage/Controlpanels/Controlpanel.jsx +41 -2
- package/src/components/manage/Controlpanels/Controlpanel.test.jsx +55 -24
- package/src/components/manage/Controlpanels/DatabaseInformation.jsx +162 -229
- package/src/components/manage/Controlpanels/Groups/RenderGroups.jsx +74 -122
- package/src/components/manage/Controlpanels/UndoControlpanel.jsx +3 -3
- package/src/components/manage/Controlpanels/Users/UserGroupMembershipListing.jsx +28 -12
- package/src/components/manage/Controlpanels/Users/UserGroupMembershipMatrix.jsx +12 -4
- package/src/components/manage/Display/Display.jsx +92 -148
- package/src/components/manage/Display/Display.stories.jsx +46 -0
- package/src/components/manage/Edit/Edit.jsx +2 -4
- package/src/components/manage/Form/Form.jsx +85 -20
- package/src/components/manage/Form/InlineForm.jsx +2 -4
- package/src/components/manage/Form/ModalForm.jsx +1 -1
- package/src/components/manage/History/History.jsx +1 -1
- package/src/components/manage/Pluggable/Pluggable.test.js +1 -1
- package/src/components/manage/Preferences/ChangePassword.jsx +94 -172
- package/src/components/manage/Preferences/ChangePassword.stories.jsx +41 -0
- package/src/components/manage/Preferences/PersonalInformation.jsx +50 -115
- package/src/components/manage/Preferences/PersonalPreferences.jsx +46 -100
- package/src/components/manage/Preferences/PersonalPreferences.stories.jsx +48 -0
- package/src/components/manage/Toolbar/More.jsx +308 -399
- package/src/components/manage/Toolbar/Toolbar.jsx +1 -1
- package/src/components/manage/Widgets/ArrayWidget.jsx +2 -2
- package/src/components/manage/Widgets/DatetimeWidget.jsx +121 -175
- package/src/components/manage/Widgets/ImageWidget.jsx +6 -5
- package/src/components/manage/Widgets/RecurrenceWidget/EndField.jsx +7 -1
- package/src/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.jsx +80 -31
- package/src/components/manage/Widgets/ReferenceWidget.jsx +134 -210
- package/src/components/theme/Register/Register.jsx +70 -142
- package/src/components/theme/Register/Register.stories.jsx +49 -0
- package/src/components/theme/Search/Search.jsx +13 -5
- package/src/components/theme/Tags/Tags.jsx +19 -10
- package/src/components/theme/Tags/Tags.test.jsx +9 -11
- package/src/components/theme/View/AlbumView.jsx +122 -167
- package/src/components/theme/View/LinkView.jsx +4 -0
- package/src/components/theme/View/LinkView.test.jsx +2 -0
- package/src/components/theme/View/View.jsx +0 -13
- package/src/components/theme/View/View.test.jsx +0 -3
- package/src/config/ControlPanels.js +49 -43
- package/src/config/Widgets.jsx +1 -1
- package/src/config/config.test.js +1 -0
- package/src/config/index.js +23 -2
- package/src/config/slots.js +12 -0
- package/src/config/validation.ts +155 -0
- package/src/helpers/Blocks/Blocks.js +12 -7
- package/src/helpers/Blocks/Blocks.test.js +15 -0
- package/src/helpers/Blocks/cloneBlocks.ts +1 -1
- package/src/helpers/Extensions/withBlockExtensions.jsx +1 -1
- package/src/helpers/FormValidation/FormValidation.jsx +128 -172
- package/src/helpers/FormValidation/FormValidation.test.js +836 -8
- package/src/helpers/FormValidation/validators.ts +203 -0
- package/src/helpers/MessageLabels/MessageLabels.js +28 -0
- package/src/helpers/Url/Url.test.js +19 -6
- package/src/helpers/Url/urlRegex.js +1 -1
- package/src/helpers/User/User.js +1 -1
- package/src/helpers/index.js +2 -0
- package/src/hooks/client/useClient.js +1 -1
- package/src/middleware/api.js +4 -2
- package/src/middleware/index.js +1 -0
- package/src/middleware/userSessionReset.js +46 -0
- package/src/store.js +2 -0
- package/test-setup-config.jsx +10 -0
- package/theme/themes/default/modules/embed.variables +1 -1
- package/theme/themes/pastanaga/collections/form.overrides +34 -0
- package/theme/themes/pastanaga/extras/blocks.less +6 -0
- package/theme/themes/pastanaga/extras/sidebar.less +4 -0
- package/theme/themes/pastanaga/extras/toolbar.less +10 -3
- package/tsconfig.declarations.json +3 -2
- package/types/components/index.d.ts +0 -1
- package/types/components/manage/Actions/Actions.stories.d.ts +8 -0
- package/types/components/manage/Blocks/Block/Order/Order.d.ts +2 -1
- package/types/components/manage/Blocks/LeadImage/Edit.d.ts +14 -5
- package/types/components/manage/Blocks/Search/widgets/SelectMetadataField.d.ts +0 -5
- package/types/components/manage/Blocks/ToC/Edit.d.ts +1 -6
- package/types/components/manage/Blocks/Video/Edit.d.ts +1 -1
- package/types/components/manage/Blocks/Video/Edit.stories.d.ts +8 -0
- package/types/components/manage/Contents/ContentsBreadcrumbs.stories.d.ts +8 -0
- package/types/components/manage/Contents/ContentsUploadModal.d.ts +14 -2
- package/types/components/manage/Contents/ContentsUploadModal.stories.d.ts +8 -0
- package/types/components/manage/Contents/index.d.ts +1 -1
- package/types/components/manage/Controlpanels/AddonsControlpanel.d.ts +2 -2
- package/types/components/manage/Controlpanels/Aliases.d.ts +2 -2
- package/types/components/manage/Controlpanels/Aliases.stories.d.ts +8 -0
- package/types/components/manage/Controlpanels/DatabaseInformation.d.ts +2 -2
- package/types/components/manage/Controlpanels/Groups/RenderGroups.d.ts +10 -5
- package/types/components/manage/Controlpanels/index.d.ts +4 -4
- package/types/components/manage/Display/Display.stories.d.ts +8 -0
- package/types/components/manage/Preferences/ChangePassword.d.ts +2 -2
- package/types/components/manage/Preferences/ChangePassword.stories.d.ts +8 -0
- package/types/components/manage/Preferences/PersonalInformation.d.ts +7 -2
- package/types/components/manage/Preferences/PersonalPreferences.d.ts +5 -1
- package/types/components/manage/Preferences/PersonalPreferences.stories.d.ts +8 -0
- package/types/components/manage/Toolbar/More.d.ts +8 -5
- package/types/components/manage/Widgets/DatetimeWidget.d.ts +0 -85
- package/types/components/manage/Widgets/DatetimeWidget.stories.d.ts +0 -1
- package/types/components/manage/Widgets/ReferenceWidget.d.ts +27 -2
- package/types/components/manage/Widgets/index.d.ts +1 -1
- package/types/components/theme/Register/Register.d.ts +2 -2
- package/types/components/theme/Register/Register.stories.d.ts +9 -0
- package/types/components/theme/Tags/Tags.d.ts +15 -7
- package/types/components/theme/View/AlbumView.d.ts +3 -17
- package/types/config/ControlPanels.d.ts +8 -0
- package/types/config/RichTextEditor/ToHTML.d.ts +1 -1
- package/types/config/Widgets.d.ts +3 -3
- package/types/config/slots.d.ts +21 -0
- package/types/config/validation.d.ts +3 -0
- package/types/helpers/Blocks/Blocks.d.ts +6 -0
- package/types/helpers/Extensions/withBlockExtensions.d.ts +1 -1
- package/types/helpers/FormValidation/FormValidation.d.ts +2 -0
- package/types/helpers/FormValidation/validators.d.ts +29 -0
- package/types/helpers/MessageLabels/MessageLabels.d.ts +36 -0
- package/types/helpers/User/User.d.ts +1 -1
- package/types/helpers/index.d.ts +2 -2
- package/types/middleware/index.d.ts +1 -0
- package/types/middleware/userSessionReset.d.ts +5 -0
- package/src/components/theme/SocialSharing/SocialSharing.jsx +0 -48
- package/src/components/theme/SocialSharing/SocialSharing.test.jsx +0 -14
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { injectIntl } from 'react-intl';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import AliasesComponent from './Aliases';
|
|
4
|
+
import { RealStoreWrapper as Wrapper } from '@plone/volto/storybook';
|
|
5
|
+
|
|
6
|
+
const IntlAliasesComponent = injectIntl(AliasesComponent);
|
|
7
|
+
|
|
8
|
+
function StoryComponent(args) {
|
|
9
|
+
return (
|
|
10
|
+
<Wrapper
|
|
11
|
+
customStore={{
|
|
12
|
+
aliases: {
|
|
13
|
+
add: {
|
|
14
|
+
loaded: false,
|
|
15
|
+
loading: false,
|
|
16
|
+
error: null,
|
|
17
|
+
},
|
|
18
|
+
remove: {
|
|
19
|
+
loaded: false,
|
|
20
|
+
loading: false,
|
|
21
|
+
error: null,
|
|
22
|
+
},
|
|
23
|
+
get: {
|
|
24
|
+
loading: false,
|
|
25
|
+
loaded: true,
|
|
26
|
+
error: null,
|
|
27
|
+
},
|
|
28
|
+
items: [
|
|
29
|
+
{
|
|
30
|
+
datetime: '2022-05-16T11:52:35+00:00',
|
|
31
|
+
manual: true,
|
|
32
|
+
path: '/eventsalias',
|
|
33
|
+
'redirect-to': '/events',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
datetime: '2022-05-17T09:38:19+00:00',
|
|
37
|
+
manual: true,
|
|
38
|
+
path: '/eventsgreatalias',
|
|
39
|
+
'redirect-to': '/events',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
datetime: '2022-05-17T09:38:35+00:00',
|
|
43
|
+
manual: true,
|
|
44
|
+
path: '/eventsincredible',
|
|
45
|
+
'redirect-to': '/events',
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
intl: {
|
|
50
|
+
locale: 'en',
|
|
51
|
+
messages: {},
|
|
52
|
+
},
|
|
53
|
+
}}
|
|
54
|
+
>
|
|
55
|
+
<div id="toolbar" style={{ display: 'none' }} />
|
|
56
|
+
<IntlAliasesComponent {...args} location={{ pathname: '/blog' }} />
|
|
57
|
+
</Wrapper>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const Aliases = StoryComponent.bind({});
|
|
62
|
+
|
|
63
|
+
export default {
|
|
64
|
+
title: 'Internal Components/ControlPanels/Aliases',
|
|
65
|
+
component: Aliases,
|
|
66
|
+
decorators: [
|
|
67
|
+
(Story) => (
|
|
68
|
+
<div className="ui segment form attached" style={{ width: '900px' }}>
|
|
69
|
+
<Story />
|
|
70
|
+
</div>
|
|
71
|
+
),
|
|
72
|
+
],
|
|
73
|
+
argTypes: {},
|
|
74
|
+
};
|
|
@@ -8,7 +8,11 @@ import PropTypes from 'prop-types';
|
|
|
8
8
|
import { connect } from 'react-redux';
|
|
9
9
|
import { compose } from 'redux';
|
|
10
10
|
import { withRouter } from 'react-router-dom';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
Helmet,
|
|
13
|
+
tryParseJSON,
|
|
14
|
+
extractInvariantErrors,
|
|
15
|
+
} from '@plone/volto/helpers';
|
|
12
16
|
import { createPortal } from 'react-dom';
|
|
13
17
|
import { Button, Container } from 'semantic-ui-react';
|
|
14
18
|
import { defineMessages, injectIntl } from 'react-intl';
|
|
@@ -44,6 +48,10 @@ const messages = defineMessages({
|
|
|
44
48
|
id: 'Info',
|
|
45
49
|
defaultMessage: 'Info',
|
|
46
50
|
},
|
|
51
|
+
error: {
|
|
52
|
+
id: 'Error',
|
|
53
|
+
defaultMessage: 'Error',
|
|
54
|
+
},
|
|
47
55
|
});
|
|
48
56
|
|
|
49
57
|
/**
|
|
@@ -93,7 +101,7 @@ class Controlpanel extends Component {
|
|
|
93
101
|
super(props);
|
|
94
102
|
this.onCancel = this.onCancel.bind(this);
|
|
95
103
|
this.onSubmit = this.onSubmit.bind(this);
|
|
96
|
-
this.state = { isClient: false };
|
|
104
|
+
this.state = { isClient: false, error: null };
|
|
97
105
|
}
|
|
98
106
|
|
|
99
107
|
/**
|
|
@@ -113,6 +121,36 @@ class Controlpanel extends Component {
|
|
|
113
121
|
* @returns {undefined}
|
|
114
122
|
*/
|
|
115
123
|
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
124
|
+
if (this.props.updateRequest.loading && nextProps.updateRequest.error) {
|
|
125
|
+
const message =
|
|
126
|
+
nextProps.updateRequest.error?.response?.body?.error?.message ||
|
|
127
|
+
nextProps.updateRequest.error?.response?.body?.message ||
|
|
128
|
+
nextProps.updateRequest.error?.response?.text ||
|
|
129
|
+
'';
|
|
130
|
+
|
|
131
|
+
const error =
|
|
132
|
+
new DOMParser().parseFromString(message, 'text/html')?.all?.[0]
|
|
133
|
+
?.textContent || message;
|
|
134
|
+
|
|
135
|
+
const errorsList = tryParseJSON(error);
|
|
136
|
+
let invariantErrors = [];
|
|
137
|
+
if (Array.isArray(errorsList)) {
|
|
138
|
+
invariantErrors = extractInvariantErrors(errorsList);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
this.setState({ error: error });
|
|
142
|
+
|
|
143
|
+
if (invariantErrors.length > 0) {
|
|
144
|
+
toast.error(
|
|
145
|
+
<Toast
|
|
146
|
+
error
|
|
147
|
+
title={this.props.intl.formatMessage(messages.error)}
|
|
148
|
+
content={invariantErrors.join(' - ')}
|
|
149
|
+
/>,
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
116
154
|
if (this.props.updateRequest.loading && nextProps.updateRequest.loaded) {
|
|
117
155
|
toast.info(
|
|
118
156
|
<Toast
|
|
@@ -162,6 +200,7 @@ class Controlpanel extends Component {
|
|
|
162
200
|
title={this.props.controlpanel.title}
|
|
163
201
|
schema={filterControlPanelsSchema(this.props.controlpanel)}
|
|
164
202
|
formData={this.props.controlpanel.data}
|
|
203
|
+
requestError={this.state.error}
|
|
165
204
|
onSubmit={this.onSubmit}
|
|
166
205
|
onCancel={this.onCancel}
|
|
167
206
|
hideActions
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
1
|
+
import { render, waitFor, screen } from '@testing-library/react';
|
|
3
2
|
import configureStore from 'redux-mock-store';
|
|
4
3
|
import { Provider } from 'react-intl-redux';
|
|
5
4
|
import { MemoryRouter, Route } from 'react-router-dom';
|
|
@@ -8,32 +7,40 @@ import Controlpanel from './Controlpanel';
|
|
|
8
7
|
|
|
9
8
|
const mockStore = configureStore();
|
|
10
9
|
|
|
11
|
-
jest.mock('
|
|
10
|
+
jest.mock('../Form/Form', () =>
|
|
11
|
+
jest.fn(({ requestError }) => (
|
|
12
|
+
<div id="form">
|
|
13
|
+
{requestError ? `requestError : ${requestError}` : null}
|
|
14
|
+
</div>
|
|
15
|
+
)),
|
|
16
|
+
);
|
|
12
17
|
jest.mock('../Toolbar/Toolbar', () => jest.fn(() => <div id="Portal" />));
|
|
13
18
|
|
|
19
|
+
const store = mockStore({
|
|
20
|
+
controlpanels: {
|
|
21
|
+
controlpanel: {
|
|
22
|
+
'@id': 'http://localhost:8080/Plone/@controlpanels/date-and-time',
|
|
23
|
+
title: 'Date and Time',
|
|
24
|
+
schema: {
|
|
25
|
+
fieldsets: [],
|
|
26
|
+
properties: [],
|
|
27
|
+
},
|
|
28
|
+
data: {},
|
|
29
|
+
},
|
|
30
|
+
update: {
|
|
31
|
+
loading: false,
|
|
32
|
+
loaded: true,
|
|
33
|
+
error: { response: { body: { message: null } } },
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
intl: {
|
|
37
|
+
locale: 'en',
|
|
38
|
+
messages: {},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
14
42
|
describe('Controlpanel', () => {
|
|
15
43
|
it('renders a controlpanel component', () => {
|
|
16
|
-
const store = mockStore({
|
|
17
|
-
controlpanels: {
|
|
18
|
-
controlpanel: {
|
|
19
|
-
'@id': 'http://localhost:8080/Plone/@controlpanels/date-and-time',
|
|
20
|
-
title: 'Date and Time',
|
|
21
|
-
schema: {
|
|
22
|
-
fieldsets: [],
|
|
23
|
-
properties: [],
|
|
24
|
-
},
|
|
25
|
-
data: {},
|
|
26
|
-
},
|
|
27
|
-
update: {
|
|
28
|
-
loading: false,
|
|
29
|
-
loaded: true,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
intl: {
|
|
33
|
-
locale: 'en',
|
|
34
|
-
messages: {},
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
44
|
const { container } = render(
|
|
38
45
|
<Provider store={store}>
|
|
39
46
|
<MemoryRouter initialEntries={['/controlpanel/date-and-time']}>
|
|
@@ -45,4 +52,28 @@ describe('Controlpanel', () => {
|
|
|
45
52
|
|
|
46
53
|
expect(container).toMatchSnapshot();
|
|
47
54
|
});
|
|
55
|
+
it('renders a controlpanel component with error', async () => {
|
|
56
|
+
const { container, rerender } = render(
|
|
57
|
+
<Provider store={store}>
|
|
58
|
+
<MemoryRouter initialEntries={['/controlpanel/date-and-time']}>
|
|
59
|
+
<Route path={'/controlpanel/:id'} component={Controlpanel} />
|
|
60
|
+
<div id="toolbar"></div>
|
|
61
|
+
</MemoryRouter>
|
|
62
|
+
</Provider>,
|
|
63
|
+
);
|
|
64
|
+
store.getState().controlpanels.update.loading = true;
|
|
65
|
+
store.getState().controlpanels.update.error.response.body.message =
|
|
66
|
+
"[{'message': 'Twitter username should not include the \"@\" prefix character.', 'field': 'twitter_username', 'error': 'ValidationError'}]";
|
|
67
|
+
|
|
68
|
+
rerender(
|
|
69
|
+
<Provider store={store}>
|
|
70
|
+
<MemoryRouter initialEntries={['/controlpanel/date-and-time']}>
|
|
71
|
+
<Route path={'/controlpanel/:id'} component={Controlpanel} />
|
|
72
|
+
<div id="toolbar"></div>
|
|
73
|
+
</MemoryRouter>
|
|
74
|
+
</Provider>,
|
|
75
|
+
);
|
|
76
|
+
await waitFor(() => screen.findByText(/Twitter/i));
|
|
77
|
+
expect(container).toMatchSnapshot();
|
|
78
|
+
});
|
|
48
79
|
});
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*/
|
|
5
|
-
import React, { Component } from 'react';
|
|
6
|
-
import PropTypes from 'prop-types';
|
|
7
|
-
import { connect } from 'react-redux';
|
|
8
|
-
import { compose } from 'redux';
|
|
9
|
-
import { Link } from 'react-router-dom';
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useDispatch, useSelector } from 'react-redux';
|
|
3
|
+
import { Link, useLocation } from 'react-router-dom';
|
|
10
4
|
import { createPortal } from 'react-dom';
|
|
11
5
|
import { Container, Divider, Message, Segment, Table } from 'semantic-ui-react';
|
|
12
|
-
import { FormattedMessage, defineMessages,
|
|
6
|
+
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
|
|
13
7
|
|
|
14
8
|
import { getDatabaseInformation } from '@plone/volto/actions';
|
|
15
9
|
import { Helmet } from '@plone/volto/helpers';
|
|
10
|
+
import { useClient } from '@plone/volto/hooks';
|
|
16
11
|
import { Icon, Toolbar } from '@plone/volto/components';
|
|
17
12
|
import backSVG from '@plone/volto/icons/back.svg';
|
|
18
13
|
|
|
@@ -27,228 +22,166 @@ const messages = defineMessages({
|
|
|
27
22
|
},
|
|
28
23
|
});
|
|
29
24
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
* @property {Object} propTypes Property types.
|
|
39
|
-
* @static
|
|
40
|
-
*/
|
|
41
|
-
static propTypes = {
|
|
42
|
-
getDatabaseInformation: PropTypes.func.isRequired,
|
|
43
|
-
};
|
|
25
|
+
const DatabaseInformation = () => {
|
|
26
|
+
const intl = useIntl();
|
|
27
|
+
const dispatch = useDispatch();
|
|
28
|
+
const { pathname } = useLocation();
|
|
29
|
+
const isClient = useClient();
|
|
30
|
+
const databaseInformation = useSelector(
|
|
31
|
+
(state) => state.controlpanels.databaseinformation,
|
|
32
|
+
);
|
|
44
33
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
* @param {Object} props Component properties
|
|
49
|
-
* @constructs DiffComponent
|
|
50
|
-
*/
|
|
51
|
-
constructor(props) {
|
|
52
|
-
super(props);
|
|
53
|
-
this.state = { isClient: false };
|
|
54
|
-
}
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
dispatch(getDatabaseInformation());
|
|
36
|
+
}, [dispatch]);
|
|
55
37
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
* @returns {string} Markup for the component.
|
|
70
|
-
*/
|
|
71
|
-
render() {
|
|
72
|
-
return this.props.databaseInformation ? (
|
|
73
|
-
<Container id="database-page" className="controlpanel-database">
|
|
74
|
-
<Helmet
|
|
75
|
-
title={this.props.intl.formatMessage(messages.databaseInformation)}
|
|
76
|
-
/>
|
|
77
|
-
<Segment.Group raised>
|
|
78
|
-
<Segment className="primary">
|
|
79
|
-
<FormattedMessage
|
|
80
|
-
id="Database Information"
|
|
81
|
-
defaultMessage="Database Information"
|
|
82
|
-
/>
|
|
83
|
-
</Segment>
|
|
84
|
-
<Segment>
|
|
85
|
-
<Message>
|
|
38
|
+
return databaseInformation ? (
|
|
39
|
+
<Container id="database-page" className="controlpanel-database">
|
|
40
|
+
<Helmet title={intl.formatMessage(messages.databaseInformation)} />
|
|
41
|
+
<Segment.Group raised>
|
|
42
|
+
<Segment className="primary">
|
|
43
|
+
<FormattedMessage
|
|
44
|
+
id="Database Information"
|
|
45
|
+
defaultMessage="Database Information"
|
|
46
|
+
/>
|
|
47
|
+
</Segment>
|
|
48
|
+
<Segment>
|
|
49
|
+
<Message>
|
|
50
|
+
<Message.Header>
|
|
86
51
|
<FormattedMessage
|
|
87
|
-
id="
|
|
88
|
-
defaultMessage="
|
|
52
|
+
id="Database main"
|
|
53
|
+
defaultMessage="Database main"
|
|
89
54
|
/>
|
|
90
|
-
</Message>
|
|
91
|
-
</
|
|
92
|
-
<
|
|
93
|
-
<
|
|
94
|
-
<
|
|
95
|
-
<
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
<
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
{this.props.databaseInformation.cache_length}
|
|
156
|
-
</Table.Cell>
|
|
157
|
-
</Table.Row>
|
|
158
|
-
<Table.Row>
|
|
159
|
-
<Table.Cell>
|
|
160
|
-
<FormattedMessage
|
|
161
|
-
id="Target memory size per cache in bytes"
|
|
162
|
-
defaultMessage="Target memory size per cache in bytes"
|
|
163
|
-
/>
|
|
164
|
-
</Table.Cell>
|
|
165
|
-
<Table.Cell>
|
|
166
|
-
{this.props.databaseInformation.cache_length_bytes}
|
|
167
|
-
</Table.Cell>
|
|
168
|
-
</Table.Row>
|
|
169
|
-
</Table.Body>
|
|
170
|
-
</Table>
|
|
171
|
-
</Segment>
|
|
172
|
-
<Segment>
|
|
173
|
-
<Divider />
|
|
174
|
-
|
|
175
|
-
<Message>
|
|
176
|
-
<Message.Header>
|
|
177
|
-
<FormattedMessage
|
|
178
|
-
id="Total number of objects in each cache"
|
|
179
|
-
defaultMessage="Total number of objects in each cache"
|
|
180
|
-
/>
|
|
181
|
-
</Message.Header>
|
|
182
|
-
</Message>
|
|
183
|
-
<Table celled padded>
|
|
184
|
-
<Table.Header>
|
|
185
|
-
<Table.Row>
|
|
186
|
-
<Table.HeaderCell>
|
|
187
|
-
<FormattedMessage
|
|
188
|
-
id="Cache Name"
|
|
189
|
-
defaultMessage="Cache Name"
|
|
190
|
-
/>
|
|
191
|
-
</Table.HeaderCell>
|
|
192
|
-
<Table.HeaderCell>
|
|
193
|
-
<FormattedMessage
|
|
194
|
-
id="Number of active objects"
|
|
195
|
-
defaultMessage="Number of active objects"
|
|
196
|
-
/>
|
|
197
|
-
</Table.HeaderCell>
|
|
198
|
-
<Table.HeaderCell>
|
|
199
|
-
<FormattedMessage
|
|
200
|
-
id="Total active and non-active objects"
|
|
201
|
-
defaultMessage="Total active and non-active objects"
|
|
202
|
-
/>
|
|
203
|
-
</Table.HeaderCell>
|
|
204
|
-
</Table.Row>
|
|
205
|
-
</Table.Header>
|
|
206
|
-
{this.props.databaseInformation.cache_detail_length.map(
|
|
207
|
-
(item) => (
|
|
208
|
-
<Table.Row>
|
|
209
|
-
<Table.Cell>{item.connection}</Table.Cell>
|
|
210
|
-
<Table.Cell>{item.ngsize}</Table.Cell>
|
|
211
|
-
<Table.Cell>{item.size}</Table.Cell>
|
|
212
|
-
</Table.Row>
|
|
213
|
-
),
|
|
214
|
-
)}
|
|
215
|
-
</Table>
|
|
216
|
-
</Segment>
|
|
217
|
-
</Segment.Group>
|
|
55
|
+
</Message.Header>
|
|
56
|
+
</Message>
|
|
57
|
+
<Table celled padded columns="2">
|
|
58
|
+
<Table.Body>
|
|
59
|
+
<Table.Row>
|
|
60
|
+
<Table.Cell>
|
|
61
|
+
<FormattedMessage
|
|
62
|
+
id="Database Location"
|
|
63
|
+
defaultMessage="Database Location"
|
|
64
|
+
/>
|
|
65
|
+
</Table.Cell>
|
|
66
|
+
<Table.Cell>{databaseInformation.db_name}</Table.Cell>
|
|
67
|
+
</Table.Row>
|
|
68
|
+
<Table.Row>
|
|
69
|
+
<Table.Cell>
|
|
70
|
+
<FormattedMessage
|
|
71
|
+
id="Database Size"
|
|
72
|
+
defaultMessage="Database Size"
|
|
73
|
+
/>
|
|
74
|
+
</Table.Cell>
|
|
75
|
+
<Table.Cell>{databaseInformation.database_size}</Table.Cell>
|
|
76
|
+
</Table.Row>
|
|
77
|
+
<Table.Row>
|
|
78
|
+
<Table.Cell>
|
|
79
|
+
<FormattedMessage
|
|
80
|
+
id="Total number of objects in the database"
|
|
81
|
+
defaultMessage="Total number of objects in the database"
|
|
82
|
+
/>
|
|
83
|
+
</Table.Cell>
|
|
84
|
+
<Table.Cell>{databaseInformation.db_size}</Table.Cell>
|
|
85
|
+
</Table.Row>
|
|
86
|
+
<Table.Row>
|
|
87
|
+
<Table.Cell>
|
|
88
|
+
<FormattedMessage
|
|
89
|
+
id="Total number of objects in memory from all caches"
|
|
90
|
+
defaultMessage="Total number of objects in memory from all caches"
|
|
91
|
+
/>
|
|
92
|
+
</Table.Cell>
|
|
93
|
+
<Table.Cell>{databaseInformation.cache_size}</Table.Cell>
|
|
94
|
+
</Table.Row>
|
|
95
|
+
<Table.Row>
|
|
96
|
+
<Table.Cell>
|
|
97
|
+
<FormattedMessage
|
|
98
|
+
id="Target number of objects in memory per cache"
|
|
99
|
+
defaultMessage="Target number of objects in memory per cache"
|
|
100
|
+
/>
|
|
101
|
+
</Table.Cell>
|
|
102
|
+
<Table.Cell>{databaseInformation.cache_length}</Table.Cell>
|
|
103
|
+
</Table.Row>
|
|
104
|
+
<Table.Row>
|
|
105
|
+
<Table.Cell>
|
|
106
|
+
<FormattedMessage
|
|
107
|
+
id="Target memory size per cache in bytes"
|
|
108
|
+
defaultMessage="Target memory size per cache in bytes"
|
|
109
|
+
/>
|
|
110
|
+
</Table.Cell>
|
|
111
|
+
<Table.Cell>
|
|
112
|
+
{databaseInformation.cache_length_bytes}
|
|
113
|
+
</Table.Cell>
|
|
114
|
+
</Table.Row>
|
|
115
|
+
</Table.Body>
|
|
116
|
+
</Table>
|
|
117
|
+
</Segment>
|
|
118
|
+
<Segment>
|
|
119
|
+
<Divider />
|
|
218
120
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
121
|
+
<Message>
|
|
122
|
+
<Message.Header>
|
|
123
|
+
<FormattedMessage
|
|
124
|
+
id="Total number of objects in each cache"
|
|
125
|
+
defaultMessage="Total number of objects in each cache"
|
|
126
|
+
/>
|
|
127
|
+
</Message.Header>
|
|
128
|
+
</Message>
|
|
129
|
+
<Table celled padded>
|
|
130
|
+
<Table.Header>
|
|
131
|
+
<Table.Row>
|
|
132
|
+
<Table.HeaderCell>
|
|
133
|
+
<FormattedMessage
|
|
134
|
+
id="Cache Name"
|
|
135
|
+
defaultMessage="Cache Name"
|
|
136
|
+
/>
|
|
137
|
+
</Table.HeaderCell>
|
|
138
|
+
<Table.HeaderCell>
|
|
139
|
+
<FormattedMessage
|
|
140
|
+
id="Number of active objects"
|
|
141
|
+
defaultMessage="Number of active objects"
|
|
142
|
+
/>
|
|
143
|
+
</Table.HeaderCell>
|
|
144
|
+
<Table.HeaderCell>
|
|
145
|
+
<FormattedMessage
|
|
146
|
+
id="Total active and non-active objects"
|
|
147
|
+
defaultMessage="Total active and non-active objects"
|
|
148
|
+
/>
|
|
149
|
+
</Table.HeaderCell>
|
|
150
|
+
</Table.Row>
|
|
151
|
+
</Table.Header>
|
|
152
|
+
{databaseInformation.cache_detail_length.map((item) => (
|
|
153
|
+
<Table.Row>
|
|
154
|
+
<Table.Cell>{item.connection}</Table.Cell>
|
|
155
|
+
<Table.Cell>{item.ngsize}</Table.Cell>
|
|
156
|
+
<Table.Cell>{item.size}</Table.Cell>
|
|
157
|
+
</Table.Row>
|
|
158
|
+
))}
|
|
159
|
+
</Table>
|
|
160
|
+
</Segment>
|
|
161
|
+
</Segment.Group>
|
|
162
|
+
{isClient &&
|
|
163
|
+
createPortal(
|
|
164
|
+
<Toolbar
|
|
165
|
+
pathname={pathname}
|
|
166
|
+
hideDefaultViewButtons
|
|
167
|
+
inner={
|
|
168
|
+
<>
|
|
169
|
+
<Link to="/controlpanel" className="item">
|
|
170
|
+
<Icon
|
|
171
|
+
name={backSVG}
|
|
172
|
+
aria-label={intl.formatMessage(messages.back)}
|
|
173
|
+
className="contents circled"
|
|
174
|
+
size="30px"
|
|
175
|
+
title={intl.formatMessage(messages.back)}
|
|
176
|
+
/>
|
|
177
|
+
</Link>
|
|
178
|
+
</>
|
|
179
|
+
}
|
|
180
|
+
/>,
|
|
181
|
+
document.getElementById('toolbar'),
|
|
182
|
+
)}
|
|
183
|
+
</Container>
|
|
184
|
+
) : null;
|
|
185
|
+
};
|
|
244
186
|
|
|
245
|
-
export default
|
|
246
|
-
injectIntl,
|
|
247
|
-
connect(
|
|
248
|
-
(state, props) => ({
|
|
249
|
-
databaseInformation: state.controlpanels.databaseinformation,
|
|
250
|
-
pathname: props.location.pathname,
|
|
251
|
-
}),
|
|
252
|
-
{ getDatabaseInformation },
|
|
253
|
-
),
|
|
254
|
-
)(DatabaseInformation);
|
|
187
|
+
export default DatabaseInformation;
|