Skip to content

Commit

Permalink
Merge branch 'main' into referencewidget-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
davisagli authored Aug 29, 2024
2 parents 029c6f5 + a1120fb commit ffcd7ea
Show file tree
Hide file tree
Showing 35 changed files with 453 additions and 308 deletions.
8 changes: 7 additions & 1 deletion docs/source/configuration/settings-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,13 @@ controlpanels
The group can be one of the default groups 'General', 'Content', 'Security', 'Add-on Configuration', 'Users and Groups' or a custom group.
filterControlPanelsSchema
A schema factory for a control panel. It is used internally, to tweak the schemas provided by the controlpanel endpoint, to make them fit for Volto.
A schema factory for a control panel.
It is used internally, to tweak the schemas provided by the `@controlpanels` endpoint, making them fit for Volto.
It uses the `unwantedControlPanelsFields` setting.
unwantedControlPanelsFields
Control panels' fields that are not used in Volto.
It is used internally by the `filterControlPanelsSchema` function.
errorHandlers
A list of error handlers that will be called when there is an unhandled exception. Each error handler is a function that
Expand Down
2 changes: 1 addition & 1 deletion docs/source/contributing/install-docker.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Install [Docker Desktop](https://docs.docker.com/get-docker/) for your operating system.
Install [Docker Desktop](https://docs.docker.com/get-started/get-docker/) for your operating system.
Docker Desktop includes all Docker tools.

```{note}
Expand Down
4 changes: 4 additions & 0 deletions docs/source/upgrade-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@ schema: {
// rest of the form definition...
```

### Tags in slot

The `Tags` component has been moved to the `belowContent` slot.
It now receives the `content` property instead of the `tags` property.

(volto-upgrade-guide-17.x.x)=

Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions packages/volto/news/4819.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add setting `unwantedControlPanelsFields` and use it in the function `filterControlPanelsSchema`. @wesleybl
1 change: 1 addition & 0 deletions packages/volto/news/5044.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Refactor Preference/Change Password from class to functional component. @Tishasoumya-02
1 change: 1 addition & 0 deletions packages/volto/news/5971.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix `initialValue` block setting. @wesleybl
1 change: 1 addition & 0 deletions packages/volto/news/6071.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
When user changes location, set the `userSession.token` value based on cookie. This fixes the login status not being properly determined by the application. @tiberiu-ichim
1 change: 1 addition & 0 deletions packages/volto/news/6232.internal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Revert rename of `.gitkeep`. @stevepiercy
2 changes: 2 additions & 0 deletions packages/volto/news/6248.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The schema for the `ContentsPropertiesModal` can be enhanced using the `contentPropertiesSchemaEnhancer` setting.
Also, the properties form is now prepopulated with values if all selected items share the same value. @davisagli
1 change: 1 addition & 0 deletions packages/volto/news/6258.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix `TypeError: values[0] is undefined` in Contents properties modal. @davisagli
1 change: 1 addition & 0 deletions packages/volto/news/6262.documentation
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix redirect to Docker documentation. @stevepiercy
1 change: 1 addition & 0 deletions packages/volto/news/6269.breaking
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Move `Tags` component to the slot `belowContent`. @wesleybl
1 change: 1 addition & 0 deletions packages/volto/news/6273.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix error in `SortOn` component when no sort is selected. @davisagli
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import { Icon } from '@plone/volto/components';
import {
applyBlockInitialValue,
getBlocksFieldname,
blockHasValue,
buildStyleClassNamesFromData,
buildStyleObjectFromData,
Expand Down Expand Up @@ -111,7 +113,21 @@ const EditBlockWrapper = (props) => {
if (blockHasValue(data)) {
onSelectBlock(onInsertBlock(id, value));
} else {
onChangeBlock(id, value);
const blocksFieldname = getBlocksFieldname(properties);
const newFormData = applyBlockInitialValue({
id,
value,
blocksConfig,
formData: {
...properties,
[blocksFieldname]: {
...properties[blocksFieldname],
[id]: value || null,
},
},
});
const newValue = newFormData[blocksFieldname][id];
onChangeBlock(id, newValue);
}
}}
onMutateBlock={onMutateBlock}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const SortOn = (props) => {

const showSelectField = sortOnOptions.length > 1;
if (!showSelectField && !activeSortOn) {
return;
return null;
}
const value = {
value: activeSortOn || intl.formatMessage(messages.noSelection),
Expand Down
3 changes: 3 additions & 0 deletions packages/volto/src/components/manage/Contents/Contents.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1532,6 +1532,9 @@ class Contents extends Component {
onCancel={this.onPropertiesCancel}
onOk={this.onPropertiesOk}
items={this.state.selected}
values={map(this.state.selected, (id) =>
find(this.state.items, { '@id': id }),
).filter((item) => item)}
/>
{this.state.showWorkflow && (
<ContentsWorkflowModal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React, { useEffect } from 'react';
import { useEffect } from 'react';
import PropTypes from 'prop-types';
import { useDispatch, useSelector } from 'react-redux';
import { isEmpty, map } from 'lodash';
import { defineMessages, useIntl } from 'react-intl';

import { usePrevious } from '@plone/volto/helpers';
import { cloneDeepSchema } from '@plone/volto/helpers/Utils/Utils';
import { updateContent } from '@plone/volto/actions';
import { ModalForm } from '@plone/volto/components/manage/Form';
import config from '@plone/volto/registry';

const messages = defineMessages({
properties: {
Expand Down Expand Up @@ -65,26 +67,103 @@ const messages = defineMessages({
});

const ContentsPropertiesModal = (props) => {
const { onCancel, onOk, open, items } = props;
const { onCancel, onOk, open, items, values } = props;
const intl = useIntl();
const dispatch = useDispatch();
const request = useSelector((state) => state.content.update);
const prevrequestloading = usePrevious(request.loading);

const baseSchema = {
fieldsets: [
{
id: 'default',
title: intl.formatMessage(messages.default),
fields: [
'effective',
'expires',
'rights',
'creators',
'exclude_from_nav',
],
},
],
properties: {
effective: {
description: intl.formatMessage(messages.effectiveDescription),
title: intl.formatMessage(messages.effectiveTitle),
type: 'string',
widget: 'datetime',
},
expires: {
description: intl.formatMessage(messages.expiresDescription),
title: intl.formatMessage(messages.expiresTitle),
type: 'string',
widget: 'datetime',
},
rights: {
description: intl.formatMessage(messages.rightsDescription),
title: intl.formatMessage(messages.rightsTitle),
type: 'string',
widget: 'textarea',
},
creators: {
description: intl.formatMessage(messages.creatorsDescription),
title: intl.formatMessage(messages.creatorsTitle),
type: 'array',
},
exclude_from_nav: {
description: intl.formatMessage(messages.excludeFromNavDescription),
title: intl.formatMessage(messages.excludeFromNavTitle),
type: 'boolean',
},
},
required: [],
};
const schemaEnhancer = config.settings.contentPropertiesSchemaEnhancer;
let schema = schemaEnhancer
? schemaEnhancer({
schema: cloneDeepSchema(baseSchema),
intl,
})
: baseSchema;

const initialData = {};
if (values?.length) {
for (const name of Object.keys(schema.properties)) {
const firstValue = values[0][name];
// should not show floor or ceiling dates
if (
(name === 'effective' && firstValue && firstValue <= '1970') ||
(name === 'expires' && firstValue && firstValue >= '2499')
) {
continue;
}
if (values.every((item) => item[name] === firstValue)) {
initialData[name] = firstValue;
}
}
}

useEffect(() => {
if (prevrequestloading && request.loaded) {
onOk();
}
}, [onOk, prevrequestloading, request.loaded]);

const onSubmit = (data) => {
if (isEmpty(data)) {
let changes = {};
for (const name of Object.keys(data)) {
if (data[name] !== initialData[name]) {
changes[name] = data[name];
}
}
if (isEmpty(changes)) {
onOk();
} else {
dispatch(
updateContent(
items,
map(items, () => data),
map(items, () => changes),
),
);
}
Expand All @@ -97,54 +176,8 @@ const ContentsPropertiesModal = (props) => {
onSubmit={onSubmit}
onCancel={onCancel}
title={intl.formatMessage(messages.properties)}
schema={{
fieldsets: [
{
id: 'default',
title: intl.formatMessage(messages.default),
fields: [
'effective',
'expires',
'rights',
'creators',
'exclude_from_nav',
],
},
],
properties: {
effective: {
description: intl.formatMessage(messages.effectiveDescription),
title: intl.formatMessage(messages.effectiveTitle),
type: 'string',
widget: 'datetime',
},
expires: {
description: intl.formatMessage(messages.expiresDescription),
title: intl.formatMessage(messages.expiresTitle),
type: 'string',
widget: 'datetime',
},
rights: {
description: intl.formatMessage(messages.rightsDescription),
title: intl.formatMessage(messages.rightsTitle),
type: 'string',
widget: 'textarea',
},
creators: {
description: intl.formatMessage(messages.creatorsDescription),
title: intl.formatMessage(messages.creatorsTitle),
type: 'array',
},
exclude_from_nav: {
description: intl.formatMessage(
messages.excludeFromNavDescription,
),
title: intl.formatMessage(messages.excludeFromNavTitle),
type: 'boolean',
},
},
required: [],
}}
schema={schema}
formData={initialData}
/>
)
);
Expand Down
Loading

0 comments on commit ffcd7ea

Please sign in to comment.