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 13, 2023
2 parents eeb32ef + ee547c1 commit d2a9457
Show file tree
Hide file tree
Showing 18 changed files with 485 additions and 96 deletions.
35 changes: 27 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,43 @@ 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).

### [0.3.1](https://github.com/eea/volto-nextcloud-video-block/compare/0.3.0...0.3.1) - 29 March 2023
### [0.4.0](https://github.com/eea/volto-nextcloud-video-block/compare/0.3.1...0.4.0) - 13 June 2023

#### :nail_care: Enhancements
#### :rocket: New Features

- feat: add cypress test for basic functionality - refs #252543 [ana-oprea - [`d4bbe97`](https://github.com/eea/volto-nextcloud-video-block/commit/d4bbe97886a02087968ff6cadb5479913fe2c37e)]
- feat: add possibility to add language subtitles - refs #253430 [dobri1408 - [`1b1c58c`](https://github.com/eea/volto-nextcloud-video-block/commit/1b1c58c3cfb75277ccf857e3e6f7f7e0ceba4f9a)]

#### :bug: Bug Fixes

- fix: Warning srclang vs srcLang [Alin Voinea - [`b2227ab`](https://github.com/eea/volto-nextcloud-video-block/commit/b2227abe62885cf57520d6bdb280287792102c68)]

- refactor(NextCloudEmbed.jsx): use flattenToAppURL function instead of direct url manipulation [Miu Razvan - [`590ac40`](https://github.com/eea/volto-nextcloud-video-block/commit/590ac40e21ad71fcf24071b61129426c0399f164)]
#### :hammer_and_wrench: Others

- remove warning [Dobricean Ioan Dorian - [`2a05251`](https://github.com/eea/volto-nextcloud-video-block/commit/2a0525190f112dd7cdcb3b882347e2e630c525bd)]
- add object-widget addon [Dobricean Ioan Dorian - [`e70fbc7`](https://github.com/eea/volto-nextcloud-video-block/commit/e70fbc7f2316c1c82b4945e59d05663dcba6da5e)]
- add object-widget addon [Dobricean Ioan Dorian - [`e4f0e08`](https://github.com/eea/volto-nextcloud-video-block/commit/e4f0e08841b114cc769e9eb69a38cb172088a614)]
- put volto-object-widget as dependency [Dobricean Ioan Dorian - [`a4b9901`](https://github.com/eea/volto-nextcloud-video-block/commit/a4b99011474ac6ebba7fc0c7c158bb33a50a498e)]
- test: Use latest stable Volto in Makefile [Alin Voinea - [`3a34f9a`](https://github.com/eea/volto-nextcloud-video-block/commit/3a34f9a80dce0dc7fdff144abc81419ebcb55406)]
- remove eea config [Dobricean Ioan Dorian - [`dca54e3`](https://github.com/eea/volto-nextcloud-video-block/commit/dca54e38e4bdf8bfe99e22ec64cd83e1b1c4bd2b)]
- remove eea config [Dobricean Ioan Dorian - [`495071e`](https://github.com/eea/volto-nextcloud-video-block/commit/495071e61196a551ce7deab189473b097a6f7c21)]
- make nextblock have default lang [Dobricean Ioan Dorian - [`47b54cd`](https://github.com/eea/volto-nextcloud-video-block/commit/47b54cd8e2042c5ae58f9d43c6fe4961d7d92048)]
- fix cypress tests [Dobricean Ioan Dorian - [`93880cb`](https://github.com/eea/volto-nextcloud-video-block/commit/93880cb6030cf1a50b0754cc1351ebb53f9e421c)]
- Release 0.4.0 [Alin Voinea - [`158d7a3`](https://github.com/eea/volto-nextcloud-video-block/commit/158d7a33bb5bce60c48af36e5810b01fd29992bd)]
- test: add unit tests for Body, NextCloudVideoView, NextCloudEmbed - refs #253277 [ana-oprea - [`e21c9dd`](https://github.com/eea/volto-nextcloud-video-block/commit/e21c9dded8b8a30062dabdaf92fd44395cb5eb61)]
- test: jest should look for addons in node_modules Refs #253277 [valentinab25 - [`db00e0c`](https://github.com/eea/volto-nextcloud-video-block/commit/db00e0c80f4c8df87fb51958b5fd39836f705c05)]
- test: Fix test config, coverage Refs #253277 [valentinab25 - [`983cc70`](https://github.com/eea/volto-nextcloud-video-block/commit/983cc701d747b05300c838f69c79242fda3349af)]
- clean up [Miu Razvan - [`5f7892a`](https://github.com/eea/volto-nextcloud-video-block/commit/5f7892aef352facb7f3552c6bf9f5219b1426c8f)]
- refactor code [tedw87 - [`372d579`](https://github.com/eea/volto-nextcloud-video-block/commit/372d57993276386befa998a237cef5910d30a32f)]
### [0.3.1](https://github.com/eea/volto-nextcloud-video-block/compare/0.3.0...0.3.1) - 29 March 2023

#### :hammer_and_wrench: Others

- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`651eb88`](https://github.com/eea/volto-nextcloud-video-block/commit/651eb88fb27cf0e51c0b75aa5ab082b3fbda0f90)]
### [0.3.0](https://github.com/eea/volto-nextcloud-video-block/compare/0.2.0...0.3.0) - 15 March 2023

#### :hammer_and_wrench: Others

- Release 0.3.0 [Alin Voinea - [`6dfd307`](https://github.com/eea/volto-nextcloud-video-block/commit/6dfd307b49edcc6ac9aa32fe8d89527c75a0e31c)]
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`240b696`](https://github.com/eea/volto-nextcloud-video-block/commit/240b696ce279dcfd68b44cb6918776b3fa97147a)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`0f94a58`](https://github.com/eea/volto-nextcloud-video-block/commit/0f94a58ea918675b2a775eebd8a4fa1b4fcdbb62)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`a720438`](https://github.com/eea/volto-nextcloud-video-block/commit/a7204382b8a891d172a3086142319af3771acd49)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`002119c`](https://github.com/eea/volto-nextcloud-video-block/commit/002119cf10ce0a56cec89187659a976571a5936e)]
### [0.2.0](https://github.com/eea/volto-nextcloud-video-block/compare/0.1.0...0.2.0) - 1 March 2023

#### :rocket: New Features
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-nextcloud-video-block"
NAMESPACE = "@eeacms"
SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,www.eea.europa.eu-en,climate-advisory-board.europa.eu,clmsdemo.devel6cph.eea.europa.eu"
SONARQUBE_TAGS = "volto.eea.europa.eu,demo-www.eea.europa.eu,www.eea.europa.eu-en,climate-advisory-board.europa.eu,clmsdemo.devel6cph.eea.europa.eu,climate-adapt.eea.europa.eu,biodiversity.europa.eu,water.europa.eu-marine,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
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ start-backend-docker: ## Starts a Docker-based backend

.PHONY: test
test: ## Run jest tests
docker pull plone/volto-addon-ci:alpha
docker run -it --rm -e NAMESPACE="@eeacms" -e GIT_NAME="${DIR}" -e RAZZLE_JEST_CONFIG=jest-addon.config.js -v "$$(pwd):/opt/frontend/my-volto-project/src/addons/${DIR}" -e CI="true" plone/volto-addon-ci:alpha
docker pull plone/volto-addon-ci
docker run -it --rm -e NAMESPACE="@eeacms" -e GIT_NAME="${DIR}" -e RAZZLE_JEST_CONFIG=jest-addon.config.js -v "$$(pwd):/opt/frontend/my-volto-project/src/addons/${DIR}" -e CI="true" plone/volto-addon-ci

.PHONY: test-update
test-update: ## Update jest tests snapshots
docker pull plone/volto-addon-ci:alpha
docker run -it --rm -e NAMESPACE="@eeacms" -e GIT_NAME="${DIR}" -e RAZZLE_JEST_CONFIG=jest-addon.config.js -v "$$(pwd):/opt/frontend/my-volto-project/src/addons/${DIR}" -e CI="true" plone/volto-addon-ci:alpha yarn test src/addons/${DIR}/src --watchAll=false -u
docker pull plone/volto-addon-ci
docker run -it --rm -e NAMESPACE="@eeacms" -e GIT_NAME="${DIR}" -e RAZZLE_JEST_CONFIG=jest-addon.config.js -v "$$(pwd):/opt/frontend/my-volto-project/src/addons/${DIR}" -e CI="true" plone/volto-addon-ci yarn test src/addons/${DIR}/src --watchAll=false -u

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

This file was deleted.

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

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

it('Add Block: Video link', () => {
// Intercept cmshare request
cy.intercept('GET', 'https://cmshare.eea.europa.eu//download').as(
'cmshare',
);

// Change page title
cy.clearSlateTitle();
cy.getSlateTitle().type('Volto NextCloud Video Demo');
cy.get('.documentFirstHeading').contains('Volto NextCloud Video Demo');
cy.getSlate().click();

// Add block
cy.get('.ui.basic.icon.button.block-add-button').first().click();
cy.get(".blocks-chooser .ui.form .field.searchbox input[type='text']").type(
'video (NextCloud)',
);
cy.get('.nextCloudVideo').click();

// Check if error message is not displayed
cy.get('.ui.error.message').should('not.exist');

// Add youtube video link and check if it is valid
cy.get('.block.video .toolbar-inner .ui.input').type(
'https://www.youtube.com/',
);
cy.get('.block.video .toolbar-inner .ui.buttons .ui.basic.primary').click();
cy.get('.ui.error.message').should('exist');

// Delete the link and check if the error message is not displayed
cy.get('.block.video .toolbar-inner .ui.buttons .ui.basic.cancel').click();
cy.get('.ui.error.message').should('not.exist');

// Add cmshare video link and check if it is valid
cy.get('.block.video .toolbar-inner .ui.input').type(
'https://cmshare.eea.europa.eu/',
);
cy.get('.block.video .toolbar-inner .ui.buttons .ui.basic.primary').click();
cy.get('.ui.error.message').should('not.exist');

// Wait for cmshare request
cy.wait('@cmshare');

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

// The page view should contain our changes
cy.contains('Volto NextCloud Video Demo');
cy.get('.block.video');
});
});
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
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-nextcloud-video-block",
"version": "0.3.1",
"version": "0.4.0",
"description": "@eeacms/volto-nextcloud-video-block: Volto add-on to embed Videos from NextCloud",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand All @@ -12,10 +12,16 @@
"plone",
"react"
],
"addons": [
"@eeacms/volto-object-widget"
],
"repository": {
"type": "git",
"url": "git@github.com:eea/volto-nextcloud-video-block.git"
},
"dependencies": {
"@eeacms/volto-object-widget": "*"
},
"devDependencies": {
"@cypress/code-coverage": "^3.10.0",
"@plone/scripts": "*",
Expand Down
17 changes: 10 additions & 7 deletions src/NextCloud/Body.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import { isInternalURL, flattenToAppURL } from '@plone/volto/helpers';
import { isInternalURL } from '@plone/volto/helpers';
import { getFieldURL } from '@eeacms/volto-nextcloud-video-block/helpers';
import players from './players';

/**
Expand All @@ -15,10 +16,12 @@ import players from './players';
* @extends Component
*/
const Body = ({ data }) => {
let placeholder = data.preview_image
? isInternalURL(data.preview_image)
? `${flattenToAppURL(data.preview_image)}/@@images/image`
: data.preview_image
const previewImage = getFieldURL(data.preview_image);
const url = getFieldURL(data.url);
let placeholder = previewImage
? isInternalURL(previewImage)
? `${previewImage}/@@images/image`
: previewImage
: null;

const ref = React.createRef();
Expand Down Expand Up @@ -52,7 +55,7 @@ const Body = ({ data }) => {
const SelectedPlayerComponent = allowedPlayersList.reduce(
(acc, currentPlayerName) => {
// eslint-disable-next-line no-unused-expressions
const result = data.url?.match(currentPlayerName)
const result = url?.match(currentPlayerName)
? allowedPlayers[currentPlayerName]
: acc;
return result;
Expand All @@ -62,7 +65,7 @@ const Body = ({ data }) => {

return (
<>
{data.url && (
{url && (
<div
className={cx('video-inner', {
'full-width': data.align === 'full',
Expand Down
68 changes: 68 additions & 0 deletions src/NextCloud/Body.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import React from 'react';
import renderer from 'react-test-renderer';
import Body from './Body';
import { isInternalURL } from '@plone/volto/helpers';
import { getFieldURL } from '@eeacms/volto-nextcloud-video-block/helpers';

jest.mock('@eeacms/volto-nextcloud-video-block/helpers', () => ({
getFieldURL: jest.fn(),
}));

jest.mock('@plone/volto/helpers', () => ({
isInternalURL: jest.fn(),
flattenToAppURL: jest.fn(),
withBlockExtensions: jest.fn((Component) => Component),
}));

jest.mock('./players', () => ({
nextCloud: jest.fn(() => <div>NextCloud Player</div>),
}));

describe('Body', () => {
it('renders correctly', () => {
const props = {
data: {
url: 'nextCloud',
align: 'full',
preview_image: '/path/to/image',
},
};

const component = renderer.create(<Body {...props} />);
const json = component.toJSON();
expect(json).toMatchSnapshot();
});

it('renders the correct player based on the url', () => {
const props = {
data: {
url: 'nextCloud',
align: 'full',
preview_image: '/path/to/image',
},
};

isInternalURL.mockReturnValue(true);
getFieldURL.mockReturnValue('/path/to/video');

const component = renderer.create(<Body {...props} />);
expect(component.toJSON().props.className).toContain('video-inner');
});

it('renders the correct player based on the url', () => {
const props = {
data: {
url: 'nextCloud',
align: 'full',
preview_image: '/path/to/image',
},
};

isInternalURL.mockReturnValue(false);
getFieldURL.mockReturnValue('nextCloud');

const component = renderer.create(<Body {...props} />);

expect(component.toJSON().props.className).toContain('video-inner');
});
});
21 changes: 12 additions & 9 deletions src/NextCloud/NextCloudVideoEdit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@
*/

import React, { Component } from 'react';
import { compose } from 'redux';
import { isEqual } from 'lodash';
import cx from 'classnames';
import PropTypes from 'prop-types';
import { defineMessages, injectIntl } from 'react-intl';
import { Button, Input, Message } from 'semantic-ui-react';
import cx from 'classnames';
import { isEqual } from 'lodash';

import config from '@plone/volto/registry';
import { Icon, SidebarPortal } from '@plone/volto/components';
import { withBlockExtensions, isInternalURL } from '@plone/volto/helpers';
import { getFieldURL } from '@eeacms/volto-nextcloud-video-block/helpers';
import VideoSidebar from './VideoSidebar';
import clearSVG from '@plone/volto/icons/clear.svg';
import Body from './Body';

import aheadSVG from '@plone/volto/icons/ahead.svg';
import clearSVG from '@plone/volto/icons/clear.svg';
import videoBlockSVG from '@plone/volto/components/manage/Blocks/Video/block-video.svg';
import Body from './Body';
import { withBlockExtensions, isInternalURL } from '@plone/volto/helpers';
import { compose } from 'redux';
import config from '@plone/volto/registry';

const messages = defineMessages({
VideoFormDescription: {
Expand Down Expand Up @@ -73,7 +75,7 @@ class Edit extends Component {
...(config?.blocks?.blocksConfig?.nextCloudVideo?.whiteList || []),
];
this.state = {
url: props.data?.url || '',
url: getFieldURL(props.data?.url) || '',
valid: true,
};
}
Expand Down Expand Up @@ -170,6 +172,7 @@ class Edit extends Component {
const placeholder =
data.placeholder ||
this.props.intl.formatMessage(messages.VideoBlockInputPlaceholder);

return (
<div
className={cx(
Expand All @@ -181,7 +184,7 @@ class Edit extends Component {
data.align,
)}
>
{data.url && this.state.valid ? (
{getFieldURL(data.url) && this.state.valid ? (
<Body data={data} isEditMode={true} />
) : (
<center>
Expand Down

0 comments on commit d2a9457

Please sign in to comment.