From 29fe13952299e3265a49aacf9875e3a164af7e58 Mon Sep 17 00:00:00 2001
From: dana-cfc4 <56276248+dana-cfc4@users.noreply.github.com>
Date: Wed, 21 Jun 2023 15:22:01 +0300
Subject: [PATCH 1/3] test: Fix issues identified by Sonarqube refs #254220
---
src/PreviewImage.js | 9 ----
src/blocks/Listing/index.js | 1 -
.../Listing/layout-templates/Carousel.jsx | 1 -
.../Listing/layout-templates/Gallery.jsx | 41 -------------------
src/blocks/Listing/schema.js | 38 -----------------
src/blocks/Teaser/index.js | 3 --
src/blocks/Teaser/schema.js | 2 -
.../UniversalCard/UniversalCard.jsx | 3 --
.../UniversalCard/fragments/CardMeta.jsx | 1 -
9 files changed, 99 deletions(-)
diff --git a/src/PreviewImage.js b/src/PreviewImage.js
index bcda9e34..42b3f4d1 100644
--- a/src/PreviewImage.js
+++ b/src/PreviewImage.js
@@ -65,13 +65,4 @@ function PreviewImage(props) {
);
}
-// PreviewImage.propTypes = {
-// size: PropTypes.string,
-// item: PropTypes.shape({
-// '@id': PropTypes.string.isRequired,
-// image_field: PropTypes.string,
-// title: PropTypes.string.isRequired,
-// }),
-// };
-
export default PreviewImage;
diff --git a/src/blocks/Listing/index.js b/src/blocks/Listing/index.js
index b72684a4..e6fc031f 100644
--- a/src/blocks/Listing/index.js
+++ b/src/blocks/Listing/index.js
@@ -1,4 +1,3 @@
-// import { addStyling } from '@plone/volto/helpers';
import UniversalCard from '@eeacms/volto-listing-block/components/UniversalCard/UniversalCard';
import { composeSchema } from '@eeacms/volto-listing-block/schema-utils';
diff --git a/src/blocks/Listing/layout-templates/Carousel.jsx b/src/blocks/Listing/layout-templates/Carousel.jsx
index 24217e29..7193996a 100644
--- a/src/blocks/Listing/layout-templates/Carousel.jsx
+++ b/src/blocks/Listing/layout-templates/Carousel.jsx
@@ -127,7 +127,6 @@ const CardsCarousel = ({ block, items, ...rest }) => {
CardsCarousel.schemaEnhancer = (args) => {
const { schema } = args;
- // const schema = UniversalCard.schemaEnhancer(args);
schema.fieldsets.splice(1, 0, {
id: 'carousel',
diff --git a/src/blocks/Listing/layout-templates/Gallery.jsx b/src/blocks/Listing/layout-templates/Gallery.jsx
index d07dbacb..95e4bd90 100644
--- a/src/blocks/Listing/layout-templates/Gallery.jsx
+++ b/src/blocks/Listing/layout-templates/Gallery.jsx
@@ -28,9 +28,6 @@ const Gallery = ({
};
Gallery.schemaEnhancer = ({ schema }) => {
- // const schema = UniversalCard.schemaEnhancer(args);
- // schema.fieldsets[0].fields.push('gridSize');
-
schema.fieldsets.splice(1, 0, {
id: 'cardsGallery',
title: 'Gallery',
@@ -60,41 +57,3 @@ Gallery.propTypes = {
};
export default Gallery;
-
-// const makeTextBody = (item) => (
-//
-//
-// {hasDate && item.effective && (
-//
-// {moment(item.effective).format('ll')}
-//
-// )}
-//
-// {item.title ? item.title : item.id}
-// {hasDescription && (
-//
-// {item.description}
-//
-// )}
-//
-// );
-//
-// const makeImage = (item) => {
-// return (
-//
-//
-//
-// );
-// };
-//
-//
-// {makeImage(item)}
-// {makeTextBody(item)}
-//
-
-// import PreviewImage from '@eeacms/volto-listing-block/PreviewImage';
-// import { ConditionalLink } from '@plone/volto/components';
-// import { Card } from 'semantic-ui-react';
-// import cx from 'classnames';
-// styles,
-// itemModel,
diff --git a/src/blocks/Listing/schema.js b/src/blocks/Listing/schema.js
index e8b8b09a..91ed3a4a 100644
--- a/src/blocks/Listing/schema.js
+++ b/src/blocks/Listing/schema.js
@@ -9,44 +9,6 @@ const ALIGN_INFO_MAP = {
center: [alignCenterSVG, 'Center'],
};
-// export const setBasicStylingSchema = (args) => {
-// const { schema, intl } = args;
-// schema.properties.styles.schema = {
-// fieldsets: [
-// {
-// id: 'styling',
-// title: 'Styling',
-// fields: ['theme', 'inverted', 'rounded'],
-// },
-// ],
-// properties: {
-// theme: {
-// title: intl.formatMessage(messages.Theme),
-// description: intl.formatMessage(messages.ThemeHelp),
-// choices: [
-// ['', intl.formatMessage(messages.ThemeDefault)],
-// ['primary', intl.formatMessage(messages.ThemePrimary)],
-// ['secondary', intl.formatMessage(messages.ThemeSecondary)],
-// ['tertiary', intl.formatMessage(messages.ThemeTertiary)],
-// ],
-// },
-// inverted: {
-// title: intl.formatMessage(messages.Inverted),
-// description: intl.formatMessage(messages.InvertedHelp),
-// type: 'boolean',
-// },
-// rounded: {
-// title: intl.formatMessage(messages.Rounded),
-// description: intl.formatMessage(messages.RoundedHelp),
-// type: 'boolean',
-// },
-// },
-// required: [],
-// };
-
-// return schema;
-// };
-
const CallToActionSchema = ({ formData }) => {
return {
fieldsets: [
diff --git a/src/blocks/Teaser/index.js b/src/blocks/Teaser/index.js
index 9668e98e..06a02db0 100644
--- a/src/blocks/Teaser/index.js
+++ b/src/blocks/Teaser/index.js
@@ -1,10 +1,7 @@
import { composeSchema } from '@eeacms/volto-listing-block/schema-utils';
-// import { addStyling } from '@plone/volto/helpers';
-
import TeaserCardTemplate from './Card';
import { adjustTeaserSchema } from './schema';
import UniversalCard from '@eeacms/volto-listing-block/components/UniversalCard/UniversalCard';
-// import { setBasicStylingSchema } from '../Listing/schema';
export default (config) => {
if (config.blocks.blocksConfig.teaser) {
diff --git a/src/blocks/Teaser/schema.js b/src/blocks/Teaser/schema.js
index cf5433a1..0221c776 100644
--- a/src/blocks/Teaser/schema.js
+++ b/src/blocks/Teaser/schema.js
@@ -1,6 +1,4 @@
export const adjustTeaserSchema = ({ schema }) => {
- // const fieldset = schema.fieldsets.find(({fields}) => fields?.indexOf('title') > -1);
-
// make the title required for accessibility reasons
if (schema.properties?.title && schema.required?.indexOf('title') === -1) {
schema.required.push('title');
diff --git a/src/components/UniversalCard/UniversalCard.jsx b/src/components/UniversalCard/UniversalCard.jsx
index ec250f5c..be3d137c 100644
--- a/src/components/UniversalCard/UniversalCard.jsx
+++ b/src/components/UniversalCard/UniversalCard.jsx
@@ -2,10 +2,7 @@ import config from '@plone/volto/registry';
import { resolveExtension } from '@plone/volto/helpers/Extensions/withBlockExtensions';
import { Item } from './model';
import cx from 'classnames';
-
-// import { getVoltoStyles } from '@eeacms/volto-listing-block/schema-utils';
import { buildStyleClassNamesFromData } from '@plone/volto/helpers';
-//
import schemaEnhancer from './schema';
function UniversalCard(props) {
diff --git a/src/components/UniversalCard/fragments/CardMeta.jsx b/src/components/UniversalCard/fragments/CardMeta.jsx
index 806cf9c0..7ff691aa 100644
--- a/src/components/UniversalCard/fragments/CardMeta.jsx
+++ b/src/components/UniversalCard/fragments/CardMeta.jsx
@@ -9,7 +9,6 @@ const CardMeta = (props) => {
const locale = config.settings.dateLocale || 'en-gb';
const showDate = itemModel.hasDate !== false && EffectiveDate !== 'None';
const showMeta = !!(head_title || (itemModel?.hasMetaType && item['@type']));
- // const show = showDate || showMeta;
// TODO:
From b9626e1b16b476bf7129c234ec301762b1d482a6 Mon Sep 17 00:00:00 2001
From: laszlocseh
Date: Thu, 6 Jul 2023 15:43:34 +0300
Subject: [PATCH 2/3] Fix cases when image_field is null
---
src/PreviewImage.js | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/PreviewImage.js b/src/PreviewImage.js
index 42b3f4d1..9545b5d1 100644
--- a/src/PreviewImage.js
+++ b/src/PreviewImage.js
@@ -7,7 +7,9 @@ import { flattenToAppURL } from '@plone/volto/helpers';
import DefaultImageSVG from './default-image.svg';
const getSrc = (item, size) =>
- flattenToAppURL(`${item['@id']}/@@images/${item.image_field}/${size}`);
+ flattenToAppURL(
+ `${item['@id']}/@@images/${item.image_field || 'image'}/${size}`,
+ );
// TODO: do we still need volto-depiction compatibility?
// import DefaultImageSVG from '@plone/volto/components/manage/Blocks/Listing/default-image.svg';
From b1dd763d2c9ca710c2d8db0548d62d7eb83f129e Mon Sep 17 00:00:00 2001
From: EEA Jenkins <@users.noreply.github.com>
Date: Wed, 19 Jul 2023 09:47:01 +0000
Subject: [PATCH 3/3] Automated release 4.2.2
---
CHANGELOG.md | 6 ++++++
package.json | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 358f8459..320db05e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. Dates are d
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
+### [4.2.2](https://github.com/eea/volto-listing-block/compare/4.2.1...4.2.2) - 19 July 2023
+
+#### :hammer_and_wrench: Others
+
+- Fix cases when image_field is null [laszlocseh - [`b9626e1`](https://github.com/eea/volto-listing-block/commit/b9626e1b16b476bf7129c234ec301762b1d482a6)]
+- test: Fix issues identified by Sonarqube refs #254220 [dana-cfc4 - [`29fe139`](https://github.com/eea/volto-listing-block/commit/29fe13952299e3265a49aacf9875e3a164af7e58)]
### [4.2.1](https://github.com/eea/volto-listing-block/compare/4.2.0...4.2.1) - 13 June 2023
#### :bug: Bug Fixes
diff --git a/package.json b/package.json
index f9eff584..8390df31 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-listing-block",
- "version": "4.2.1",
+ "version": "4.2.2",
"description": "@eeacms/volto-listing-block: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",