Skip to content

Commit

Permalink
Merge pull request #39 from eea/develop
Browse files Browse the repository at this point in the history
Improve code quality
  • Loading branch information
razvanMiu authored Jan 25, 2023
2 parents 8187851 + f2f0bef commit 580f02d
Show file tree
Hide file tree
Showing 15 changed files with 161 additions and 66 deletions.
24 changes: 9 additions & 15 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ 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).

### [1.0.2](https://github.com/eea/volto-block-image-cards/compare/1.0.1...1.0.2) - 25 January 2023

#### :hammer_and_wrench: Others

- change username for cypress tests [Miu Razvan - [`534feca`](https://github.com/eea/volto-block-image-cards/commit/534fecadd05da50f344e556f75988abb37cb187a)]
- add cypress test [Miu Razvan - [`0d12987`](https://github.com/eea/volto-block-image-cards/commit/0d12987f01678929397d8443a643ea02029a3b70)]
- eslint fix [Miu Razvan - [`d306b48`](https://github.com/eea/volto-block-image-cards/commit/d306b48f099c92ac24440ae72df1424d4ae8e84e)]
- update [Miu Razvan - [`25f6440`](https://github.com/eea/volto-block-image-cards/commit/25f6440e7e26e0df8d4fd227d9e4d9a095cff74d)]
- test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`210bb59`](https://github.com/eea/volto-block-image-cards/commit/210bb591a1ab2688d6ee614535c718ca974103f0)]
### [1.0.1](https://github.com/eea/volto-block-image-cards/compare/1.0.0...1.0.1) - 16 November 2022

#### :hammer_and_wrench: Others
Expand All @@ -19,8 +28,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

- Prepare 1.0.0 release [Miu Razvan - [`283992f`](https://github.com/eea/volto-block-image-cards/commit/283992f1ec4767a43ed3c311e9df1958c429821e)]
- use volto 16 alpha 14 for cypress [Andrei Grigore - [`e0d147d`](https://github.com/eea/volto-block-image-cards/commit/e0d147d5af6d28419b426c32837831d0c7f91549)]
- Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`33ebd41`](https://github.com/eea/volto-block-image-cards/commit/33ebd41cda6680037ecb3aa24a683ed414a2663b)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`1d508f3`](https://github.com/eea/volto-block-image-cards/commit/1d508f3399adbef25b255c2aa5c3a55d7f15f870)]
### [0.6.5](https://github.com/eea/volto-block-image-cards/compare/0.6.4...0.6.5) - 31 July 2022

#### :nail_care: Enhancements
Expand All @@ -36,7 +43,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### :hammer_and_wrench: Others

- Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`78c4423`](https://github.com/eea/volto-block-image-cards/commit/78c4423f2e976dccf8a8656b0b08dbc3d70a362c)]
### [0.6.3](https://github.com/eea/volto-block-image-cards/compare/0.6.2...0.6.3) - 23 June 2022

### [0.6.2](https://github.com/eea/volto-block-image-cards/compare/0.6.1...0.6.2) - 22 June 2022
Expand Down Expand Up @@ -79,7 +85,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- Fix slick carousel wrong width calculation inside flexbox [kreafox - [`14e5f96`](https://github.com/eea/volto-block-image-cards/commit/14e5f96c89a644d21b82b3bc4032ea10fbb21cd9)]
- Refactor Carousel [kreafox - [`a1d2ed5`](https://github.com/eea/volto-block-image-cards/commit/a1d2ed5e46839fc12f51cb8b87b8fb0314fb3554)]
- Add a placeholder if cards are missing [kreafox - [`2211ecb`](https://github.com/eea/volto-block-image-cards/commit/2211ecb95a34f61956a0d950e6bc197408d09e14)]
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`169560f`](https://github.com/eea/volto-block-image-cards/commit/169560f27524e8d0cadcb29d3f75bd21fca724ee)]
### [0.2.0](https://github.com/eea/volto-block-image-cards/compare/0.1.11...0.2.0) - 9 March 2022

#### :rocket: New Features
Expand All @@ -89,7 +94,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
#### :hammer_and_wrench: Others

- add exports to displays and widgets [Miu Razvan - [`712362a`](https://github.com/eea/volto-block-image-cards/commit/712362ae4ef2dc3c9d7e0c111a8e8fb0bee2a0a4)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`178a36a`](https://github.com/eea/volto-block-image-cards/commit/178a36a1f10d162ff6e8f8c0b348953fe4d9f519)]
- bump to 0.2.x version [Miu Razvan - [`5d22bdc`](https://github.com/eea/volto-block-image-cards/commit/5d22bdcaebf58a20023906b27f7d9fd18202dd02)]
### [0.1.11](https://github.com/eea/volto-block-image-cards/compare/0.1.10...0.1.11) - 4 January 2022

Expand All @@ -104,7 +108,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### :hammer_and_wrench: Others

- Add Sonarqube tag using freshwater-frontend addons list [EEA Jenkins - [`f860947`](https://github.com/eea/volto-block-image-cards/commit/f860947ba3529f03d3a8c2701b9dc9d82ba901d3)]
### [0.1.7](https://github.com/eea/volto-block-image-cards/compare/0.1.6...0.1.7) - 14 December 2021

#### :hammer_and_wrench: Others
Expand All @@ -119,25 +122,17 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- Refs #142010 - Optimize Volto-addons gitflow pipelines [valentinab25 - [`6c4d897`](https://github.com/eea/volto-block-image-cards/commit/6c4d897d02bc4d691cba15b92d918c3abcec6f07)]
- Adjust layout on smaller screen sizes [kreafox - [`b349225`](https://github.com/eea/volto-block-image-cards/commit/b3492257a2f9d6fd4b908e3b8407e584ee96faa7)]
- Add default carousel display view [kreafox - [`e1a54af`](https://github.com/eea/volto-block-image-cards/commit/e1a54af412dd52c50bb4b71009a748af9c994073)]
- Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`b867e0c`](https://github.com/eea/volto-block-image-cards/commit/b867e0c8df94a7867b4422633d325ec7eea3d392)]
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`87279fc`](https://github.com/eea/volto-block-image-cards/commit/87279fc23d908f3a92cc9b499837752293dbe616)]
- Add Sonarqube tag using forests-frontend addons list [EEA Jenkins - [`ab67a9a`](https://github.com/eea/volto-block-image-cards/commit/ab67a9aa09a77531001bf98a58e9d0af84f11d6c)]
### [0.1.4](https://github.com/eea/volto-block-image-cards/compare/0.1.3...0.1.4) - 1 October 2021

#### :hammer_and_wrench: Others

- Add Sonarqube tag using sustainability-frontend addons list [EEA Jenkins - [`89e7ca9`](https://github.com/eea/volto-block-image-cards/commit/89e7ca907c51a040fea5924304b4751680b7cbbd)]
- Add Sonarqube tag using ims-frontend addons list [EEA Jenkins - [`168f82d`](https://github.com/eea/volto-block-image-cards/commit/168f82da52647a53331bb7d2c5a6c53f48f35769)]
- Add Sonarqube tag using climate-energy-frontend addons list [EEA Jenkins - [`af11533`](https://github.com/eea/volto-block-image-cards/commit/af115336dbd0922790f4c9a51d5601b3d37eba1b)]
### [0.1.3](https://github.com/eea/volto-block-image-cards/compare/0.1.2...0.1.3) - 27 August 2021

#### :hammer_and_wrench: Others

- yarn i18n [Alin Voinea - [`f9dc209`](https://github.com/eea/volto-block-image-cards/commit/f9dc209b0f04e1e425e974e1441456a31a5ab532)]
- Update scripts: i18n, test [Alin Voinea - [`7d22fc2`](https://github.com/eea/volto-block-image-cards/commit/7d22fc2c312b2227ae56bbad6431b6f747168636)]
- Fixes [kreafox - [`7853bf0`](https://github.com/eea/volto-block-image-cards/commit/7853bf0312b0b97e09d220093231fb0bb1f6b35c)]
- Don't break if unknown template [Tiberiu Ichim - [`f75b6ef`](https://github.com/eea/volto-block-image-cards/commit/f75b6ef2f2661e1447c98fb825ef5f195e9756ef)]
- Add Sonarqube tag using frontend addons list [EEA Jenkins - [`b70356d`](https://github.com/eea/volto-block-image-cards/commit/b70356d457f094d922130b241906e9a51ba07ad7)]
- Add templates edit view [kreafox - [`994c8fb`](https://github.com/eea/volto-block-image-cards/commit/994c8fb17da0ac1fe00cc6f4ee000a4f99d7e149)]
- Update dependency [razvanMiu - [`9488235`](https://github.com/eea/volto-block-image-cards/commit/9488235d064cb20bcc297d46724bfacc35e4bdd6)]
- Updated dependencies [razvanMiu - [`79b35ee`](https://github.com/eea/volto-block-image-cards/commit/79b35eeda6dfc15242bb2eaf04d9ab8b5c4f7dea)]
Expand Down Expand Up @@ -190,7 +185,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- Refs #126375 added AttachedImageWidget.jsx: [David Ichim - [`f6fbe2e`](https://github.com/eea/volto-block-image-cards/commit/f6fbe2ed959c5cf43d3b19cf43300fbc21e855d6)]
- Refs #126375 run stylelint fix on less [David Ichim - [`62d02e8`](https://github.com/eea/volto-block-image-cards/commit/62d02e87ac23105255988f04cb49e19e59831285)]
- Refs #126375 use volto-slate in generated app [David Ichim - [`8ff127f`](https://github.com/eea/volto-block-image-cards/commit/8ff127f15fc0f9c6b63fcb9219cf4988672eab55)]
- Refs #126375 add yarn.lock file [David Ichim - [`4d4acb9`](https://github.com/eea/volto-block-image-cards/commit/4d4acb996ba68a20cac7464408b12c2d92afacd7)]
- Refs #126375 prettier fix for missing , [David Ichim - [`8aa6464`](https://github.com/eea/volto-block-image-cards/commit/8aa64647277ae5314aefa658b44d2d988160b795)]
- Refs #126375 prettier fix with single quotes [David Ichim - [`7544e5e`](https://github.com/eea/volto-block-image-cards/commit/7544e5e6d6fdf84c4ae02183e4daf6e9b35c745f)]
- Refs #126375 prettier fix and add volto-slate as addons to package [David Ichim - [`1eefe4d`](https://github.com/eea/volto-block-image-cards/commit/1eefe4d3945757297babd63b6777b6e236201fa9)]
Expand Down
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ pipeline {
environment {
GIT_NAME = "volto-block-image-cards"
NAMESPACE = "@eeacms"
SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu,climate-energy.eea.europa.eu,www.eea.europa.eu-ims,sustainability.eionet.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,circularity.eea.europa.eu,prod-www.eea.europa.eu,water.europa.eu-marine"
SONARQUBE_TAGS = "volto.eea.europa.eu,biodiversity.europa.eu,climate-energy.eea.europa.eu,www.eea.europa.eu-ims,sustainability.eionet.europa.eu,forest.eea.europa.eu,clms.land.copernicus.eu,industry.eea.europa.eu,water.europa.eu-freshwater,demo-www.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,circularity.eea.europa.eu,prod-www.eea.europa.eu,water.europa.eu-marine,demo-kitkat.dev2aws.eea.europa.eu,climate-adapt.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu"
DEPENDENCIES = ""
VOLTO = "alpha"
VOLTO = ""
}

stages {
Expand Down
1 change: 1 addition & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = defineConfig({
setupNodeEvents(on, config) {
// e2e testing node events setup code
require('@cypress/code-coverage/task')(on, config);
require('cypress-fail-fast/plugin')(on, config);
return config;
},
baseUrl: 'http://localhost:3000',
Expand Down
12 changes: 3 additions & 9 deletions cypress/e2e/01-block-basics.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,17 @@ describe('Blocks Tests', () => {

it('Add Block: Empty', () => {
// Change page title
cy.get('[contenteditable=true]').first().clear();

cy.get('[contenteditable=true]').first().type('My Add-on Page');

cy.clearSlateTitle();
cy.getSlateTitle().type('My Add-on Page');
cy.get('.documentFirstHeading').contains('My Add-on Page');

cy.get('[contenteditable=true]').first().type('{enter}');

cy.getSlate().click();
// Add block
cy.get('.ui.basic.icon.button.block-add-button').first().click();
cy.get('.blocks-chooser .title').contains('Media').click();
cy.get('.content.active.media .button.image').contains('Image').click();

// Save
cy.get('#toolbar-save').click();
cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page');

// then the page view should contain our changes
cy.contains('My Add-on Page');
cy.get('.block.image');
Expand Down
52 changes: 52 additions & 0 deletions cypress/e2e/02-block-image-cards.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { slateBeforeEach, slateAfterEach } from '../support/e2e';

describe('Blocks Tests', () => {
beforeEach(slateBeforeEach);
afterEach(slateAfterEach);

it('Add image cards block: Empty', () => {
// Add block
cy.getSlate().click();
cy.get('.ui.basic.icon.button.block-add-button').first().click();
cy.get('.blocks-chooser .title').contains('Common').click();
cy.get('.content.active.common .button.imagecards')
.contains('Image Cards')
.click({ force: true });
// Save
cy.get('#toolbar-save').click();
cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page');
// then the page view should contain our changes
// cy.get('.block.imagecards');
});

it('Add image cards block: Round tile', () => {
// Add block
cy.getSlate().click();
cy.get('.ui.basic.icon.button.block-add-button').first().click();
cy.get('.blocks-chooser .title').contains('Common').click();
cy.get('.content.active.common .button.imagecards')
.contains('Image Cards')
.click({ force: true });
// Select round tile display
cy.get('#sidebar .field-wrapper-display .react-select__control').click();
cy.get('#sidebar .field-wrapper-display .react-select__menu div')
.contains('Round Tile')
.click();
// Add Round Tile 1
cy.get('#sidebar .add-item-button-wrapper').click();
cy.get('.ui.accordion .active.content #field-title-0-cards-0').type(
'Round Tile 1',
);
// Add Round Tile 2
cy.get('#sidebar .add-item-button-wrapper').click();
cy.get('.ui.accordion .active.content #field-title-0-cards-1').type(
'Round Tile 2',
);
// Save
cy.get('#toolbar-save').click();
cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page');
// then the page view should contain our changes
cy.get('.card .card-title').contains('Round Tile 1');
cy.get('.card .card-title').contains('Round Tile 2');
});
});
62 changes: 57 additions & 5 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/* eslint no-console: ["error", { allow: ["log"] }] */

const SLATE_SELECTOR = '.content-area .slate-editor [contenteditable=true]';
const SLATE_TITLE_SELECTOR = '.block.inner.title [contenteditable="true"]';

// --- AUTOLOGIN -------------------------------------------------------------
Cypress.Commands.add('autologin', () => {
let api_url, user, password;
Expand Down Expand Up @@ -376,20 +379,54 @@ Cypress.Commands.add(
},
);

Cypress.Commands.add('getSlateEditorAndType', (type) => {
cy.get('.content-area .slate-editor [contenteditable=true]')
Cypress.Commands.add('getSlate', ({ createNewSlate = true } = {}) => {
let slate;
cy.getIfExists(
SLATE_SELECTOR,
() => {
slate = cy.get(SLATE_SELECTOR).last();
},
() => {
if (createNewSlate) {
cy.get('.block.inner').last().type('{moveToEnd}{enter}');
}
slate = cy.get(SLATE_SELECTOR, { timeout: 10000 }).last();
},
);
return slate;
});

Cypress.Commands.add('clearSlate', (selector) => {
return cy
.get(selector)
.focus()
.click()
.wait(1000)
.type(type);
.type('{selectAll}')
.wait(1000)
.type('{backspace}');
});

Cypress.Commands.add('getSlateTitle', () => {
return cy.get(SLATE_TITLE_SELECTOR, {
timeout: 10000,
});
});

Cypress.Commands.add('clearSlateTitle', () => {
return cy.clearSlate(SLATE_TITLE_SELECTOR);
});

Cypress.Commands.add('setSlateSelection', (subject, query, endQuery) => {
cy.get('.slate-editor.selected [contenteditable=true]')
.focus()
.click()
.setSelection(subject, query, endQuery)
.wait(1000);
.wait(1000); // this wait is needed for the selection change to be detected after
});

Cypress.Commands.add('getSlateEditorAndType', (type) => {
cy.getSlate().focus().click().type(type);
});

Cypress.Commands.add('setSlateCursor', (subject, query, endQuery) => {
Expand All @@ -401,7 +438,9 @@ Cypress.Commands.add('setSlateCursor', (subject, query, endQuery) => {
});

Cypress.Commands.add('clickSlateButton', (button) => {
cy.get(`.slate-inline-toolbar .button-wrapper a[title="${button}"]`).click();
cy.get(`.slate-inline-toolbar .button-wrapper a[title="${button}"]`, {
timeout: 10000,
}).click({ force: true }); //force click is needed to ensure the button in visible in view.
});

Cypress.Commands.add('toolbarSave', () => {
Expand Down Expand Up @@ -483,3 +522,16 @@ Cypress.Commands.add('store', () => {
Cypress.Commands.add('settings', (key, value) => {
return cy.window().its('settings');
});

Cypress.Commands.add(
'getIfExists',
(selector, successAction = () => {}, failAction = () => {}) => {
cy.get('body').then((body) => {
if (body.find(selector).length > 0 && successAction) {
successAction();
} else if (failAction) {
failAction();
}
});
},
);
3 changes: 3 additions & 0 deletions cypress/support/e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import './commands';
//Generate code-coverage
import '@cypress/code-coverage/support';

// Fail Fast
import 'cypress-fail-fast';

export const slateBeforeEach = (contentType = 'Document') => {
cy.autologin();
cy.createContent({
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-block-image-cards",
"version": "1.0.1",
"version": "1.0.2",
"description": "volto-block-image-cards: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand Down Expand Up @@ -29,9 +29,10 @@
"slick-carousel": "^1.8.1"
},
"devDependencies": {
"@plone/scripts": "*",
"@cypress/code-coverage": "^3.10.0",
"@plone/scripts": "*",
"babel-plugin-transform-class-properties": "^6.24.1",
"cypress-fail-fast": "^5.0.1",
"md5": "^2.3.0"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/ImageCards/CommonAssets/schema.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

// See https://react-slick.neostack.com/docs/api
export const CommonCarouselschemaExtender = ({ data, schema, intl }) => {
export const CommonCarouselschemaExtender = ({ data }) => {
return {
fieldsets: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/ImageCards/ImageCardsEdit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const tweakSchema = (schema, data) => {
const CardsEdit = (props) => {
const { selected, onChangeBlock, data = {}, block } = props;
const basicSchema = ImageCardSchema(props);
const schema = tweakSchema(basicSchema, props.data, props.intl);
const schema = tweakSchema(basicSchema, props.data);

return (
<>
Expand Down
19 changes: 3 additions & 16 deletions src/ImageCards/ResponsiveContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,10 @@ class ResponsiveContainer extends Component {
}
};

renderChildren(props) {
renderChildren() {
const { containerWidth, containerHeight } = this.state;

const {
aspect,
width,
height,
// minWidth,
// minHeight,
maxHeight,
children,
} = this.props;
const { aspect, width, height, children } = this.props;

let calculatedWidth = isPercent(width) ? containerWidth : asNumber(width);
let calculatedHeight = isPercent(height)
Expand All @@ -111,11 +103,6 @@ class ResponsiveContainer extends Component {
// But we should also take height into consideration
calculatedWidth = calculatedHeight * aspect;
}

// if maxHeight is set, overwrite if calculatedHeight is greater than maxHeight
if (maxHeight && calculatedHeight > maxHeight) {
calculatedHeight = maxHeight;
}
}
return __CLIENT__ ? children({ parentWidth: calculatedWidth }) : children;
}
Expand Down Expand Up @@ -143,7 +130,7 @@ class ResponsiveContainer extends Component {
...style,
}}
>
{this.renderChildren(this.props)}
{this.renderChildren()}
<ReactResizeDetector
handleWidth
handleHeight
Expand Down
8 changes: 6 additions & 2 deletions src/ImageCards/displays/Cards.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ const Cards = (props) => {
</>
);

return cards && cards.length > 0 ? (
if (!cards?.length && editable) {
return <Message>No image cards</Message>;
}

return cards?.length ? (
<div className={cx('ui fluid cards', gridSize)}>
{cards.map((item) => (
<Card
Expand All @@ -71,7 +75,7 @@ const Cards = (props) => {
))}
</div>
) : (
<>{editable ? <Message>No image cards</Message> : ''}</>
''
);
};

Expand Down
Loading

0 comments on commit 580f02d

Please sign in to comment.