Skip to content

Commit

Permalink
Merge pull request #13 from codesyntax/fixes
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
erral authored Jan 2, 2025
2 parents 64c326d + c90958d commit 1be3cdb
Show file tree
Hide file tree
Showing 25 changed files with 1,824 additions and 1,805 deletions.
2 changes: 1 addition & 1 deletion mrs.developer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"package": "@plone/volto",
"url": "git@github.com:plone/volto.git",
"https": "https://github.com/plone/volto.git",
"tag": "18.1.0"
"tag": "18.4.0"
}
}
26 changes: 3 additions & 23 deletions packages/volto-featured-block/locales/de/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,9 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. Default: "Edit"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Edit image"
msgstr ""

#. Default: "Edit or remove image"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Edit or remove image"
msgstr ""

#. Default: "Remove"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Remove image"
msgstr ""

#. Default: "Upload or select an image"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Upload image"
msgstr ""

#. Default: "Uploading file"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Uploading file"
#. Default: "Featured block"
#: components/Blocks/FeaturedBlock/messages
msgid "featuredBlock"
msgstr ""

#. Default: "Description"
Expand Down
26 changes: 3 additions & 23 deletions packages/volto-featured-block/locales/en/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,9 @@ msgstr ""
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. Default: "Edit"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Edit image"
msgstr ""

#. Default: "Edit or remove image"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Edit or remove image"
msgstr ""

#. Default: "Remove"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Remove image"
msgstr ""

#. Default: "Upload or select an image"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Upload image"
msgstr ""

#. Default: "Uploading file"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Uploading file"
#. Default: "Featured block"
#: components/Blocks/FeaturedBlock/messages
msgid "featuredBlock"
msgstr ""

#. Default: "Description"
Expand Down
26 changes: 3 additions & 23 deletions packages/volto-featured-block/locales/es/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,9 @@ msgstr ""
"X-Is-Fallback-For: es-ar es-bo es-cl es-co es-cr es-do es-ec es-es es-sv es-gt es-hn es-mx es-ni es-pa es-py es-pe es-pr es-us es-uy es-ve\n"
"X-Generator: Poedit 2.2.1\n"

#. Default: "Edit"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Edit image"
msgstr ""

#. Default: "Edit or remove image"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Edit or remove image"
msgstr ""

#. Default: "Remove"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Remove image"
msgstr ""

#. Default: "Upload or select an image"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Upload image"
msgstr ""

#. Default: "Uploading file"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Uploading file"
#. Default: "Featured block"
#: components/Blocks/FeaturedBlock/messages
msgid "featuredBlock"
msgstr ""

#. Default: "Description"
Expand Down
26 changes: 3 additions & 23 deletions packages/volto-featured-block/locales/pt_BR/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,9 @@ msgstr ""
"Preferred-Encodings: utf-8\n"
"Domain: volto\n"

#. Default: "Edit"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Edit image"
msgstr ""

#. Default: "Edit or remove image"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Edit or remove image"
msgstr ""

#. Default: "Remove"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Remove image"
msgstr ""

#. Default: "Upload or select an image"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Upload image"
msgstr ""

#. Default: "Uploading file"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Uploading file"
#. Default: "Featured block"
#: components/Blocks/FeaturedBlock/messages
msgid "featuredBlock"
msgstr ""

#. Default: "Description"
Expand Down
28 changes: 4 additions & 24 deletions packages/volto-featured-block/locales/volto.pot
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Plone\n"
"POT-Creation-Date: 2024-11-13T17:47:26.619Z\n"
"POT-Creation-Date: 2024-12-29T15:08:29.901Z\n"
"Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
"Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
"Content-Type: text/plain; charset=utf-8\n"
Expand All @@ -13,29 +13,9 @@ msgstr ""
"Preferred-Encodings: utf-8\n"
"Domain: volto\n"

#. Default: "Edit"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Edit image"
msgstr ""

#. Default: "Edit or remove image"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Edit or remove image"
msgstr ""

#. Default: "Remove"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Remove image"
msgstr ""

#. Default: "Upload or select an image"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Upload image"
msgstr ""

#. Default: "Uploading file"
#: components/Blocks/FeaturedBlock/FeaturedImageEditor
msgid "Uploading file"
#. Default: "Featured block"
#: components/Blocks/FeaturedBlock/messages
msgid "featuredBlock"
msgstr ""

#. Default: "Description"
Expand Down
4 changes: 4 additions & 0 deletions packages/volto-featured-block/news/13.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Remove barrel imports @erral
Add inline docs @erral
Remove definition of variations (use withBlockExtensions) @erral
Remove unneeded files @erral
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Taken from @kitconcept/volto-highlight-block
import { flattenToAppURL } from '@plone/volto/helpers';
import { flattenToAppURL } from '@plone/volto/helpers/Url/Url';
export const FeaturedBlockDataAdapter = ({
block,
data,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
import { BlockDataForm } from '@plone/volto/components/manage/Form';
import SidebarPortal from '@plone/volto/components/manage/Sidebar/SidebarPortal';
import withBlockExtensions from '@plone/volto/helpers/Extensions/withBlockExtensions';
import React from 'react';
import FeaturedSchema from './FeaturedSchema';
import { SidebarPortal, BlockDataForm } from '@plone/volto/components';
import config from '@plone/volto/registry';
import { getSelectedVariation } from './utils';
import messages from './messages';
import { useSelector } from 'react-redux';
import messages from './messages';

const FeaturedBlockEdit = (props) => {
const { block, blocksConfig, data, onChangeBlock, selected, intl } = props;
const variations = config.blocks.blocksConfig['csFeatured'].variations;
const {
block,
blocksConfig,
data,
onChangeBlock,
selected,
intl,
variation,
} = props;

const { variationId, BodyTemplate } = getSelectedVariation(variations, data);
const BodyTemplate = variation.template;
// Use the dataAdapter defined in the block configuration
// this way we can adapt the information coming from the imagewidget
// on the first moment when we select or upload the image using this widget
// this data adapter makes the properties `image_field`, `image_scales` and `url`
// available right away in the block `data`, and this way we can easily interact
// with the variations of the block to see the image rendered correctly
const dataAdapter = blocksConfig[data['@type']].dataAdapter;
const schema = blocksConfig[data['@type']].blockSchema;
const request = useSelector((state) => state.content.subrequests[block]);
const content = request?.data;

React.useEffect(() => {
onChangeBlock(block, {
...data,
variation: variationId,
});
/* eslint-disable-next-line */
}, []);
return (
<>
<BodyTemplate
Expand All @@ -32,7 +38,7 @@ const FeaturedBlockEdit = (props) => {
<SidebarPortal selected={selected}>
<BlockDataForm
title={intl.formatMessage(messages.featuredBlock)}
schema={FeaturedSchema(config, intl)}
schema={schema({ ...props })}
onChangeField={(id, value, item) => {
dataAdapter({
block,
Expand All @@ -53,4 +59,5 @@ const FeaturedBlockEdit = (props) => {
);
};

export default FeaturedBlockEdit;
// the withBlockExtensions call will make variations available out of the box
export default withBlockExtensions(FeaturedBlockEdit);
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import React from 'react';
import config from '@plone/volto/registry';
import withBlockExtensions from '@plone/volto/helpers/Extensions/withBlockExtensions';
import cx from 'classnames';
import { withBlockExtensions } from '@plone/volto/helpers';
import { getSelectedVariation } from './utils';
import React from 'react';

const FeaturedBlockView = (props) => {
const { data, className = '', style } = props;

const variations = config.blocks.blocksConfig['csFeatured'].variations;

const { variationId, BodyTemplate } = getSelectedVariation(variations, data);
const { data, variation, className = '', style } = props;

const BodyTemplate = variation.template;
return (
<div
className={cx(
`block featured-block featured-block-${variationId}`,
`block featured-block featured-block-${variation.id}`,
className,
)}
style={style}
Expand All @@ -23,4 +18,5 @@ const FeaturedBlockView = (props) => {
</div>
);
};
// the withBlockExtensions call will make variations available out of the box
export default withBlockExtensions(FeaturedBlockView);
Original file line number Diff line number Diff line change
@@ -1,33 +1,16 @@
import messages from './messages';
const FeaturedSchema = (config, intl) => {
const variationsConfig = config.blocks.blocksConfig['csFeatured'].variations;
const variations = Object.keys(variationsConfig).map((variation) => [
variationsConfig[variation].id,
variationsConfig[variation].title,
]);

const FeaturedSchema = ({ intl }) => {
return {
title: 'Featured',
fieldsets: [
{
id: 'default',
title: 'Default',
fields: [
'variation',
'title',
'description',
'url',
'href',
'hrefText',
],
fields: ['title', 'description', 'url', 'href', 'hrefText'],
},
],
properties: {
variation: {
title: intl.formatMessage(messages.variation),
type: 'choice',
choices: [...variations],
},
title: {
title: intl.formatMessage(messages.featuredTitle),
type: 'string',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import { Button } from 'semantic-ui-react';
import { ConditionalLink } from '@plone/volto/components';

export const BannerFeaturedView = (props) => {
const { data, isEditMode } = props;
return (
<div
className="banner-top-main"
style={{
backgroundImage: `url(${data?.url}/@@images/image)`,
}}
>
<div className="banner-top-main-block-title">
{data.title && (
<h2>
<ConditionalLink
to={data?.href?.[0]?.['@id']}
condition={!isEditMode}
>
{data?.title}
</ConditionalLink>
</h2>
)}
{data.description && <h3>{data?.description} </h3>}
{data.hrefText && (
<Button
as="a"
size="large"
href={'' + data?.link?.[0]?.['@id']}
primary
>
{data.hrefText}
</Button>
)}
</div>
</div>
);
};
Loading

0 comments on commit 1be3cdb

Please sign in to comment.