Skip to content

Commit

Permalink
Merge pull request #13 from eea/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
avoinea committed Jun 12, 2023
2 parents e3a909e + c442f84 commit 26d2184
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 38 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,24 @@ 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.2.0](https://github.com/eea/volto-quote-block/compare/1.1.0...1.2.0) - 12 June 2023

#### :house: Internal changes


#### :hammer_and_wrench: Others

- Release 1.2.0 [Alin Voinea - [`f62c6bb`](https://github.com/eea/volto-quote-block/commit/f62c6bb04096ce36aa76bb73e92f2a8d71ae7ee3)]
- test: jest should look for addons in node_modules Refs #253277 [valentinab25 - [`693df9f`](https://github.com/eea/volto-quote-block/commit/693df9fff1f0feb438cf95837416b7a406f8395e)]
- test: add cypress test for basic functionality and demo gif to README - refs #253277 [ana-oprea - [`c0ec0f7`](https://github.com/eea/volto-quote-block/commit/c0ec0f7dd552c75bb54a61af13c37810dd5a2648)]
- test: Fix test config, coverage Refs #253277 [valentinab25 - [`b34456e`](https://github.com/eea/volto-quote-block/commit/b34456ebfaa3df66164487d37cfcba1f18fb6bb1)]
- update getFieldURL function [Miu Razvan - [`49e4bd7`](https://github.com/eea/volto-quote-block/commit/49e4bd73b11d5f2a08444a4550d32fb243d79f97)]
- refactoring [tedw87 - [`fad035e`](https://github.com/eea/volto-quote-block/commit/fad035e7487e7e4b9190c2f85e425b0cfcc4ddd6)]
- use getFieldURL function for image source [tedw87 - [`f93b977`](https://github.com/eea/volto-quote-block/commit/f93b9771d609f4006142d481ecd817b088f91683)]
### [1.1.0](https://github.com/eea/volto-quote-block/compare/1.0.1...1.1.0) - 27 March 2023

#### :hammer_and_wrench: Others

- Release 1.1.0 [Alin Voinea - [`452733e`](https://github.com/eea/volto-quote-block/commit/452733e7d001533ec7081d3031b3f937e105842d)]
- test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`20470a4`](https://github.com/eea/volto-quote-block/commit/20470a452c91a7f8cee537958ddafa6481c5a098)]
### [1.0.1](https://github.com/eea/volto-quote-block/compare/1.0.0...1.0.1) - 16 November 2022

Expand Down
3 changes: 2 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pipeline {
environment {
GIT_NAME = "volto-quote-block"
NAMESPACE = "@eeacms"
SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,prod-www.eea.europa.eu,circularity.eea.europa.eu,forest.eea.europa.eu,demo-kitkat.dev2aws.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,biodiversity.europa.eu,climate-adapt.eea.europa.eu,climate-energy.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu,www.eea.europa.eu-ims,www.eea.europa.eu-en"
SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,forest.eea.europa.eu,clmsdemo.devel6cph.eea.europa.eu,water.europa.eu-marine,biodiversity.europa.eu,climate-adapt.eea.europa.eu,climate-energy.eea.europa.eu,climate-advisory-board.devel4cph.eea.europa.eu,climate-advisory-board.europa.eu,www.eea.europa.eu-ims,www.eea.europa.eu-en,industry.eea.europa.eu"
DEPENDENCIES = ""
VOLTO = ""
}
Expand Down Expand Up @@ -188,6 +188,7 @@ pipeline {
def nodeJS = tool 'NodeJS';
withSonarQubeEnv('Sonarqube') {
sh '''sed -i "s#/opt/frontend/my-volto-project/src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
sh '''sed -i "s#src/addons/${GIT_NAME}/##g" xunit-reports/coverage/lcov.info'''
sh "export PATH=${scannerHome}/bin:${nodeJS}/bin:$PATH; sonar-scanner -Dsonar.javascript.lcov.reportPaths=./xunit-reports/coverage/lcov.info,./cypress-coverage/coverage/lcov.info -Dsonar.sources=./src -Dsonar.projectKey=$GIT_NAME-$BRANCH_NAME -Dsonar.projectVersion=$BRANCH_NAME-$BUILD_NUMBER"
sh '''try=2; while [ \$try -gt 0 ]; do curl -s -XPOST -u "${SONAR_AUTH_TOKEN}:" "${SONAR_HOST_URL}api/project_tags/set?project=${GIT_NAME}-${BRANCH_NAME}&tags=${SONARQUBE_TAGS},${BRANCH_NAME}" > set_tags_result; if [ \$(grep -ic error set_tags_result ) -eq 0 ]; then try=0; else cat set_tags_result; echo "... Will retry"; sleep 60; try=\$(( \$try - 1 )); fi; done'''
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

## Features

Demo GIF
![Quote Block](https://github.com/eea/volto-quote-block/raw/docs/docs/volto-quote.gif)

## Getting started

Expand Down
29 changes: 0 additions & 29 deletions cypress/e2e/01-block-basics.cy.js

This file was deleted.

35 changes: 35 additions & 0 deletions cypress/e2e/01-quote-block-basics.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { slateBeforeEach, slateAfterEach } from '../support/e2e';

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

it('Add Block: Quote', () => {
// Change page title
cy.clearSlateTitle();
cy.getSlateTitle().type('Volto Quote Block Demo');

cy.get('.documentFirstHeading').contains('Volto Quote Block Demo');

cy.getSlate().click();

// Add block
cy.get('.ui.basic.icon.button.block-add-button').first().click();
cy.get('.blocks-chooser .title').contains('Text').click();
cy.get('.content.active.text .button.quote')
.contains('Quote')
.click({ force: true });

cy.get('.quote div[role="textbox"]')
.click()
.type('lorem ipsum dolor sit amet');

// 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('Volto Quote Block Demo');
cy.get('.quote').contains('lorem ipsum dolor sit amet');
});
});
Binary file added docs/volto-quote.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions jest-addon.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ module.exports = {
'!src/**/*.d.ts',
],
moduleNameMapper: {
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
'@plone/volto/cypress': '<rootDir>/node_modules/@plone/volto/cypress',
'@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
'@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
'@package/(.*)$': '<rootDir>/src/$1',
'@root/(.*)$': '<rootDir>/src/$1',
'@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
'@eeacms/(.*?)/(.*)$': '<rootDir>/src/addons/$1/src/$2',
'@eeacms/(.*?)/(.*)$': '<rootDir>/node_modules/@eeacms/$1/src/$2',
'@plone/volto-slate':
'<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
'~/(.*)$': '<rootDir>/src/$1',
'load-volto-addons':
'<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
},
transform: {
'^.+\\.js(x)?$': 'babel-jest',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-quote-block",
"version": "1.1.0",
"version": "1.2.0",
"description": "@eeacms/volto-quote-block: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand Down
6 changes: 4 additions & 2 deletions src/Blocks/Quote/variations/TestimonialQuote.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { connect } from 'react-redux';
import { Grid, Card, Image } from 'semantic-ui-react';
import config from '@plone/volto/registry';
import { flattenToAppURL, isInternalURL } from '@plone/volto/helpers';
import { isInternalURL, flattenToAppURL } from '@plone/volto/helpers';
import SlateEditor from '@plone/volto-slate/editor/SlateEditor';
import { handleKey } from '@plone/volto-slate/blocks/Text/keyboard';
import {
Expand All @@ -13,6 +13,7 @@ import {
createSlateParagraph,
serializeText,
} from '@eeacms/volto-quote-block/helpers';
import { getFieldURL } from '@eeacms/volto-quote-block/helpers';
import Quote from './DefaultQuote';

import DefaultImageSVG from '@plone/volto/components/manage/Blocks/Listing/default-image.svg';
Expand All @@ -33,7 +34,8 @@ const Testimonial = (props) => {
onChangeBlock,
onSelectBlock,
} = props;
const { value, source, extra, image, title } = data;
const { value, source, extra, title } = data;
const image = getFieldURL(data.image);

const withBlockProperties = React.useCallback(
(editor) => {
Expand Down
20 changes: 19 additions & 1 deletion src/helpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
import { isArray } from 'lodash';
import isArray from 'lodash/isArray';
import isObject from 'lodash/isObject';
import isString from 'lodash/isString';
import config from '@plone/volto/registry';
import { serializeNodes } from '@plone/volto-slate/editor/render';
import { isInternalURL, flattenToAppURL } from '@plone/volto/helpers';

export const getFieldURL = (data) => {
let url = data;
const _isObject = data && isObject(data) && !isArray(data);
if (_isObject && data['@type'] === 'URL') {
url = data['value'] ?? data['url'] ?? data['href'] ?? data;
} else if (_isObject) {
url = data['@id'] ?? data['url'] ?? data['href'] ?? data;
}
if (isArray(data)) {
url = data.map((item) => getFieldURL(item));
}
if (isString(url) && isInternalURL(url)) return flattenToAppURL(url);
return url;
};

export const createSlateParagraph = (text) => {
return isArray(text) ? text : config.settings.slate.defaultValue();
Expand Down

0 comments on commit 26d2184

Please sign in to comment.