Skip to content

Commit

Permalink
Merge pull request #12 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 ef7aafe + 4a4db21 commit fa50bde
Show file tree
Hide file tree
Showing 10 changed files with 105 additions and 36 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,22 @@ 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-tags-block/compare/1.1.0...1.2.0) - 12 June 2023

#### :house: Internal changes


#### :hammer_and_wrench: Others

- Release 1.2.0 [Alin Voinea - [`7b7f93e`](https://github.com/eea/volto-tags-block/commit/7b7f93ec54a8a8e93c27e9185afbc5eb4d4a2e89)]
- test: jest should look for addons in node_modules Refs #253277 [valentinab25 - [`b0490a7`](https://github.com/eea/volto-tags-block/commit/b0490a7beac8191d8a7690932b6c8ecf7b945581)]
- test: Add cypress test for basic functionality and demo gif to README - refs #253277 [ana-oprea - [`631ad32`](https://github.com/eea/volto-tags-block/commit/631ad32bc58b639edf4399d2cfbb19162aaf8ef5)]
- test: Fix test config, coverage Refs #253277 [valentinab25 - [`a7f50dc`](https://github.com/eea/volto-tags-block/commit/a7f50dccad8b5d7daeca9618b1355808eed95bba)]
- other: update getFieldURL [Miu Razvan - [`0e6d945`](https://github.com/eea/volto-tags-block/commit/0e6d945d0491b5c9aeedd74af15dafd732bbb5d5)]
### [1.1.0](https://github.com/eea/volto-tags-block/compare/1.0.2...1.1.0) - 27 March 2023

#### :hammer_and_wrench: Others

- Release 1.1.0 [Alin Voinea - [`f6bff18`](https://github.com/eea/volto-tags-block/commit/f6bff18aab98ebe50c6ecbdb2631a73a88bab481)]
- test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`7b1576e`](https://github.com/eea/volto-tags-block/commit/7b1576e6af644222ea2a02e83a5b6422592f7318)]
### [1.0.2](https://github.com/eea/volto-tags-block/compare/1.0.1...1.0.2) - 13 December 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-tags-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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
## Features

![Tags Block](https://github.com/eea/volto-tags-block/raw/develop/docs/tags-block.png)
![Tags Block Demo](https://github.com/eea/volto-tags-block/raw/docs/docs/volto-tags.gif)

## Getting started

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

This file was deleted.

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

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

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

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

cy.getSlate().click();

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

// Add tag
cy.get('.button').contains('Add Tag item').click();
cy.get('#field-category-0-items-0').type('test 1');
cy.get('#field-href-1-items-0').type('/cypress/my-page/page-1');

cy.get('.button').contains('Add Tag item').click();
cy.get('#field-category-0-items-1').type('test 2');
cy.get('#field-href-1-items-1').type('/cypress/my-page/page-1');
cy.get('label[for="field-openLinkInNewTab-2-items-1"]').click();

cy.get('textarea#field-title').type('Tags Demo');

// 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 Tags Block Demo');
cy.get('.tags');
cy.get('.tags-title').contains('Tags Demo');
cy.get('.tags .tags-content .tag').contains('test 1');
cy.get('.tags .tags-content .tag').contains('test 2');
cy.get('.tags .tags-content a[target="_blank"].tag').contains('test 2');

cy.createContent({
contentType: 'Document',
contentId: 'page-1',
contentTitle: 'Page 1',
path: 'cypress/my-page',
});

cy.visit('cypress/my-page/page-1');
cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page/page-1');

cy.visit('cypress/my-page');
cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page');

cy.get('.tags .tags-content .tag').contains('test 1').click();
cy.url().should('eq', Cypress.config().baseUrl + '/cypress/my-page/page-1');

cy.contains('Page 1');
});
});
Binary file added docs/volto-tags.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-tags-block",
"version": "1.1.0",
"version": "1.2.0",
"description": "@eeacms/volto-tags-block: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand Down
5 changes: 3 additions & 2 deletions src/Tags/Tags.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import cx from 'classnames';
import { UniversalLink } from '@plone/volto/components';
import { Icon } from 'semantic-ui-react';
import { UniversalLink } from '@plone/volto/components';
import { getFieldURL } from '@eeacms/volto-tags-block/helpers';

function TagList({ children, position }) {
return <div className={cx('eea tags', position)}>{children}</div>;
Expand All @@ -19,7 +20,7 @@ TagList.Tag = ({ children, href, openLinkInNewTab, showTagIcon }) => {
return (
<UniversalLink
className="tag"
href={href}
href={getFieldURL(href)}
openLinkInNewTab={openLinkInNewTab}
>
{showTagIcon && <Icon className={`icon`} name="hashtag" />}
Expand Down
19 changes: 19 additions & 0 deletions src/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import isArray from 'lodash/isArray';
import isObject from 'lodash/isObject';
import isString from 'lodash/isString';
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;
};

0 comments on commit fa50bde

Please sign in to comment.