Skip to content

Commit

Permalink
Merge pull request #68 from eea/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
alecghica authored Oct 10, 2023
2 parents 8a003c6 + 8b14ee1 commit 9e7eaea
Show file tree
Hide file tree
Showing 17 changed files with 348 additions and 28 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ 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.1.44](https://github.com/eea/volto-climate-advisory-board-policy/compare/0.1.43...0.1.44) - 10 October 2023

#### :house: Internal changes

- chore:volto 16 in tests, update docs, fix stylelint overrides [valentinab25 - [`aa99fde`](https://github.com/eea/volto-climate-advisory-board-policy/commit/aa99fdeec7fb723c3289f63273d5bf69c9e10053)]

#### :hammer_and_wrench: Others

- import spotlight theme [Cretu Mihaela - [`a266acc`](https://github.com/eea/volto-climate-advisory-board-policy/commit/a266acc2450fa9af101f182f972c9bfd40214ca5)]
- fix cypress [Cretu Mihaela - [`9d075ec`](https://github.com/eea/volto-climate-advisory-board-policy/commit/9d075ecd24d044521468ab5e8705fc90a0e0b1bf)]
- fix cypress [Cretu Mihaela - [`a5e41ef`](https://github.com/eea/volto-climate-advisory-board-policy/commit/a5e41ef4c9de3aa5a9cfdc1f66244eeef6d560a7)]
- fix cypress [Cretu Mihaela - [`f8bbdcc`](https://github.com/eea/volto-climate-advisory-board-policy/commit/f8bbdcc8b0aa2a27c1fca39585bad908b73875e1)]
- add cypress test to increase coverage [Cretu Mihaela - [`aedc5b3`](https://github.com/eea/volto-climate-advisory-board-policy/commit/aedc5b36c7711428144e35ba14588f48c173602a)]
- remove duplicated code [Cretu Mihaela - [`8dad4dd`](https://github.com/eea/volto-climate-advisory-board-policy/commit/8dad4dd0000786381980982c9931ca20809e7acf)]
- fix cypress [Cretu Mihaela - [`431679c`](https://github.com/eea/volto-climate-advisory-board-policy/commit/431679cb68b07237ad67c3197d82be87389b9b3e)]
- fix eslint [Cretu Mihaela - [`d44ddcf`](https://github.com/eea/volto-climate-advisory-board-policy/commit/d44ddcfe15d6388f8f1d52899af8d955b13a26cc)]
- code cleanup [Cretu Mihaela - [`dd22fbd`](https://github.com/eea/volto-climate-advisory-board-policy/commit/dd22fbddff749e2f8ba758be487fb7e011a861d2)]
### [0.1.43](https://github.com/eea/volto-climate-advisory-board-policy/compare/0.1.42...0.1.43) - 28 September 2023

### [0.1.42](https://github.com/eea/volto-climate-advisory-board-policy/compare/0.1.41...0.1.42) - 20 September 2023
Expand Down
13 changes: 6 additions & 7 deletions DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@

1. Go to http://localhost:3000

1. Happy hacking!
1. Initialize git hooks

```Bash
cd src/addons/volto-climate-advisory-board-policy/
yarn prepare
```

1. Happy hacking!

### Or add @eeacms/volto-climate-advisory-board-policy to your Volto project

Before starting make sure your development environment is properly set. See [Volto Developer Documentation](https://docs.voltocms.com/getting-started/install/)
Expand All @@ -48,18 +50,15 @@ Before starting make sure your development environment is properly set. See [Vol

1. Install

yarn develop
make develop
yarn

1. Start backend

docker pull plone
docker run -d --name plone -p 8080:8080 -e SITE=Plone -e PROFILES="profile-plone.restapi:blocks" plone
docker run --pull always -it --rm --name plone -p 8080:8080 -e SITE=Plone plone/plone-backend

...wait for backend to setup and start - `Ready to handle requests`:

docker logs -f plone

...you can also check http://localhost:8080/Plone

1. Start frontend
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pipeline {
NAMESPACE = "@eeacms"
SONARQUBE_TAGS = "volto.eea.europa.eu,climate-advisory-board.europa.eu"
DEPENDENCIES = ""
VOLTO = ""
VOLTO = "16"
}

stages {
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ stylelint: ## Stylelint

.PHONY: stylelint-overrides
stylelint-overrides:
$(NODE_MODULES)/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides'
$(NODE_MODULES)/.bin/stylelint --custom-syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides'

.PHONY: stylelint-fix
stylelint-fix: ## Fix stylelint
$(NODE_MODULES)/stylelint/bin/stylelint.js --allow-empty-input 'src/**/*.{css,less}' --fix
$(NODE_MODULES)/.bin/stylelint --syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' --fix
$(NODE_MODULES)/.bin/stylelint --custom-syntax less --allow-empty-input 'theme/**/*.overrides' 'src/**/*.overrides' --fix

.PHONY: prettier
prettier: ## Prettier
Expand Down
28 changes: 14 additions & 14 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,55 +20,55 @@ You need to first install the [release-it](https://github.com/release-it/release
```
npm install -g release-it
```

Release-it uses the configuration written in the [`.release-it.json`](./.release-it.json) file located in the root of the repository.

Release-it is a tool that automates 4 important steps in the release process:

1. Version increase in `package.json` ( increased from the current version in `package.json`)
2. `CHANGELOG.md` automatic generation from commit messages ( grouped by releases )
3. GitHub release on the commit with the changelog and package.json modification on the develop branch
4. NPM release ( by default it's disabled, but can be enabled in the configuration file )

To configure the authentification, you need to export GITHUB_TOKEN for [GitHub](https://github.com/settings/tokens)
To configure the authentification, you need to export GITHUB_TOKEN for [GitHub](https://github.com/settings/tokens)

```
export GITHUB_TOKEN=XXX-XXXXXXXXXXXXXXXXXXXXXX
```

To configure npm, you can use the `npm login` command or use a configuration file with a TOKEN :

```
echo "//registry.npmjs.org/:_authToken=YYYYYYYYYYYYYYYYYYYYYYYYYYYYYY" > .npmrc
```

#### Using release-it tool

There are 3 yarn scripts that can be run to do the release

##### yarn release-beta

Automatically calculates and presents 3 beta versions - patch, minor and major for you to choose ( or Other for manual input).
Automatically calculates and presents 3 beta versions - patch, minor and major for you to choose ( or Other for manual input).

```
? Select increment (next version):
❯ prepatch (0.1.1-beta.0)
preminor (0.2.0-beta.0)
premajor (1.0.0-beta.0)
Other, please specify...
? Select increment (next version):
❯ prepatch (0.1.1-beta.0)
preminor (0.2.0-beta.0)
premajor (1.0.0-beta.0)
Other, please specify...
```

##### yarn release-major-beta

Same as `yarn release-beta`, but with premajor version pre-selected.

##### yarn release

Generic command, does not automatically add the `beta` to version, but you can still manually write it if you choose Other.

#### Important notes

> Do not use release-it tool on master branch, the commit on CHANGELOG.md file and the version increase in the package.json file can't be done without a PULL REQUEST.
> Do not use release-it tool on master branch, the commit on CHANGELOG.md file and the version increase in the package.json file can't be done without a PULL REQUEST.
> Do not keep Pull Requests from develop to master branches open when you are doing beta releases from the develop branch. As long as a PR to master is open, an automatic script will run on every commit and will update both the version and the changelog to a production-ready state - ( MAJOR.MINOR.PATCH mandatory format for version).
24 changes: 24 additions & 0 deletions cypress/e2e/01-block-basics.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,28 @@ describe('Blocks Tests', () => {
cy.contains('My Add-on Page');
cy.get('.block.image');
});

it('Add Hero Block', () => {
// Change page title
cy.clearSlateTitle();
cy.getSlateTitle().type('My Add-on Page');
cy.get('.documentFirstHeading').contains('My Add-on Page');
cy.getSlate().click();

// Add block
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.hero').contains('Hero').click({ force: true });

// Configure block
cy.getSlate().click().type('Hero Block');

// 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('.hero-block');
});
});
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-climate-advisory-board-policy",
"version": "0.1.43",
"version": "0.1.44",
"description": "@eeacms/volto-climate-advisory-board-policy: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency",
Expand Down
2 changes: 1 addition & 1 deletion src/components/manage/Blocks/Hero/Edit.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { BodyClass } from '@plone/volto/helpers';
import HeroEdit from '@eeacms/volto-hero-block/components/Blocks/Hero/Edit';
import HeroEdit from './HeroEdit';

const Edit = (props) => {
return (
Expand Down
24 changes: 24 additions & 0 deletions src/components/manage/Blocks/Hero/HeroCopyright.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import { Icon } from 'semantic-ui-react';
import Copyright from '@eeacms/volto-hero-block/components/Blocks/Hero/Copyright';

const HeroCopyright = ({
copyright,
copyrightIcon,
copyrightPosition,
copyrightPrefix,
}) => {
return copyright ? (
<Copyright copyrightPosition={copyrightPosition}>
<Copyright.Prefix>{copyrightPrefix}</Copyright.Prefix>
<Copyright.Icon>
<Icon className={copyrightIcon} />
</Copyright.Icon>
<Copyright.Text>{copyright}</Copyright.Text>
</Copyright>
) : (
''
);
};

export default HeroCopyright;
158 changes: 158 additions & 0 deletions src/components/manage/Blocks/Hero/HeroEdit.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
import React, { useCallback, useMemo } from 'react';
import { connect } from 'react-redux';
import { compose } from 'redux';
import isFunction from 'lodash/isFunction';
import config from '@plone/volto/registry';
import { BlockDataForm, SidebarPortal } from '@plone/volto/components';
import { BodyClass } from '@plone/volto/helpers';
import SlateEditor from '@plone/volto-slate/editor/SlateEditor';
import { handleKey } from '@plone/volto-slate/blocks/Text/keyboard';
import {
uploadContent,
saveSlateBlockSelection,
} from '@plone/volto-slate/actions';

import { defineMessages, injectIntl } from 'react-intl';
import { createSlateHeader } from '@eeacms/volto-hero-block/helpers';
import Hero from '@eeacms/volto-hero-block/components/Blocks/Hero/Hero';
import Banner from '@eeacms/volto-eea-design-system/ui/Banner/Banner';
import HeroMetadata from './HeroMetadata';
import HeroCopyright from './HeroCopyright';

const messages = defineMessages({
published: {
id: 'Published',
defaultMessage: 'Published',
},
});

const Edit = (props) => {
const { slate } = config.settings;
const {
data = {},
block = null,
selected = false,
index,
properties,
onChangeBlock,
onSelectBlock,
intl,
} = props;
const metadata = props.metadata || props.properties;
const { hidePublishingDate } = props.data;
const { text, copyright, copyrightIcon, copyrightPosition } = data;
const copyrightPrefix = config.blocks.blocksConfig.hero.copyrightPrefix || '';
const schema = React.useMemo(() => {
const blockSchema = config.blocks.blocksConfig.hero.schema;
if (isFunction(blockSchema)) {
return blockSchema(props);
}
return blockSchema;
}, [props]);

// Set dates
const getDate = useCallback(
(hidden, key) => {
return !hidden && metadata[key] ? metadata[key] : null;
},
[metadata],
);

const publishingDate = useMemo(
() => getDate(hidePublishingDate, 'effective'),
[getDate, hidePublishingDate],
);

const withBlockProperties = React.useCallback(
(editor) => {
editor.getBlockProps = () => props;
return editor;
},
[props],
);

const handleFocus = React.useCallback(() => {
if (!selected) {
onSelectBlock(block);
}
}, [onSelectBlock, selected, block]);

return (
<>
<BodyClass className="with-hero-block" />
<Hero {...data}>
<Hero.Text {...data}>
<SlateEditor
index={index}
properties={properties}
extensions={slate.textblockExtensions}
renderExtensions={[withBlockProperties]}
value={createSlateHeader(text)}
onChange={(text) => {
onChangeBlock(block, {
...data,
text,
});
}}
block={block}
onFocus={handleFocus}
onKeyDown={handleKey}
selected={selected}
placeholder="Add text..."
slateSettings={slate}
/>
</Hero.Text>
<Hero.Meta>
<Banner.MetadataField
type="date"
label={intl.formatMessage(messages.published)}
value={publishingDate}
/>
</Hero.Meta>
<Hero.Meta {...data}>
<HeroMetadata {...data} />
</Hero.Meta>
<HeroCopyright
copyright={copyright}
copyrightIcon={copyrightIcon}
copyrightPosition={copyrightPosition}
copyrightPrefix={copyrightPrefix}
/>
</Hero>

<SidebarPortal selected={selected}>
<BlockDataForm
block={block}
schema={schema}
title={schema.title}
onChangeField={(id, value) => {
onChangeBlock(block, {
...data,
[id]: value,
});
}}
formData={data}
/>
</SidebarPortal>
</>
);
};

export default compose(
connect(
(state, props) => {
const blockId = props.block;
return {
defaultSelection: blockId
? state.slate_block_selections?.[blockId]
: null,
uploadRequest: state.upload_content?.[props.block]?.upload || {},
uploadedContent: state.upload_content?.[props.block]?.data || {},
};
},
{
uploadContent,
saveSlateBlockSelection, // needed as editor blockProps
},
),
)(injectIntl(Edit));
Loading

0 comments on commit 9e7eaea

Please sign in to comment.