Skip to content

Commit

Permalink
Merge pull request #92 from eea/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
avoinea authored Aug 26, 2024
2 parents b93e6cd + 0a1d03e commit 31f56e5
Show file tree
Hide file tree
Showing 14 changed files with 373 additions and 92 deletions.
30 changes: 8 additions & 22 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ 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).

### [2.2.0](https://github.com/eea/volto-eea-website-policy/compare/2.1.1...2.2.0) - 26 August 2024

#### :rocket: New Features

- feat: context navigation portlet - refs #270999 [ichim-david - [`ca045b4`](https://github.com/eea/volto-eea-website-policy/commit/ca045b464c16aa5f1107204138e2ebfadf8669e3)]

#### :hammer_and_wrench: Others

### [2.1.1](https://github.com/eea/volto-eea-website-policy/compare/2.1.0...2.1.1) - 30 May 2024

#### :house: Internal changes
Expand All @@ -12,12 +20,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### :hammer_and_wrench: Others

- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`c297b9e`](https://github.com/eea/volto-eea-website-policy/commit/c297b9efe743ad1f95ab662007a2186b5f042f4c)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`b11c055`](https://github.com/eea/volto-eea-website-policy/commit/b11c055d0a41c89a60f70875124994ba52772e48)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`a77d04e`](https://github.com/eea/volto-eea-website-policy/commit/a77d04e9f1e4d6b8657e09fd1a2bcde66499f77f)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`12c6e92`](https://github.com/eea/volto-eea-website-policy/commit/12c6e92e4157896bf812dbbd8996c754b491d3ea)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`0aa866d`](https://github.com/eea/volto-eea-website-policy/commit/0aa866dc6fb5f4226a99a3e192a958af60385185)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`7517f96`](https://github.com/eea/volto-eea-website-policy/commit/7517f96d82efd6a7ddaa746c81a51997583363f6)]
### [2.1.0](https://github.com/eea/volto-eea-website-policy/compare/2.0.0...2.1.0) - 9 May 2024

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

- Release 2.1.0 [alin - [`da22af4`](https://github.com/eea/volto-eea-website-policy/commit/da22af436092236d7ef6e8568e3eca4813d517b5)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`9a5d706`](https://github.com/eea/volto-eea-website-policy/commit/9a5d7064e829622e2627c616c4ca1ce71511dfcb)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`f8b40e9`](https://github.com/eea/volto-eea-website-policy/commit/f8b40e961138efc4090d0ab45a5689905c672b15)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`4ab2144`](https://github.com/eea/volto-eea-website-policy/commit/4ab2144e02291d98064b001d9eb40417da4d1795)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`5af4642`](https://github.com/eea/volto-eea-website-policy/commit/5af464227c6695c7e2d3ccd9f240c2a5071bfefa)]
## [2.0.0](https://github.com/eea/volto-eea-website-policy/compare/1.15.0...2.0.0) - 22 April 2024

#### :rocket: New Features
Expand Down Expand Up @@ -103,7 +101,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### :hammer_and_wrench: Others

- test: [JENKINS] fail with logs on coverage [valentinab25 - [`5cf68f8`](https://github.com/eea/volto-eea-website-policy/commit/5cf68f8db34448d10fe993d16541ad9732434cc8)]
### [1.12.0-beta.1](https://github.com/eea/volto-eea-website-policy/compare/1.11.1...1.12.0-beta.1) - 12 January 2024

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

- Release 1.11.0 [Alin Voinea - [`3249160`](https://github.com/eea/volto-eea-website-policy/commit/3249160422c6c6e0cf14823b614f8885101a847a)]
- test: [JENKINS] Use java17 for sonarqube scanner [valentinab25 - [`8beb7e7`](https://github.com/eea/volto-eea-website-policy/commit/8beb7e7a12cbc314e56e4b1aceab5ef8d00ca6f3)]
- test: [JENKINS] Run cypress in started frontend container [valentinab25 - [`12d3da1`](https://github.com/eea/volto-eea-website-policy/commit/12d3da12e9a3b0882cf55efe2d40f3032724d41b)]
- test: [JENKINS] Add cpu limit on cypress docker [valentinab25 - [`0af0764`](https://github.com/eea/volto-eea-website-policy/commit/0af076467120ed9a80c697931e869837b92a0a4c)]
- test: [JENKINS] Increase shm-size to cypress docker [valentinab25 - [`8662e3e`](https://github.com/eea/volto-eea-website-policy/commit/8662e3e5fc3640d678ce320eb8856a37d419306c)]
- test: [JENKINS] Improve cypress time [valentinab25 - [`ef1074f`](https://github.com/eea/volto-eea-website-policy/commit/ef1074fdf968cafdf476d4ee4951eb18ebac048a)]
### [1.10.0](https://github.com/eea/volto-eea-website-policy/compare/1.9.2...1.10.0) - 2 November 2023

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

#### :house: Internal changes

- chore: [JENKINS] Refactor automated testing [valentinab25 - [`8b1b422`](https://github.com/eea/volto-eea-website-policy/commit/8b1b42297b46d9fb7325589b3bd043233c0d66e9)]
- chore: husky, lint-staged use fixed versions [valentinab25 - [`44ac62e`](https://github.com/eea/volto-eea-website-policy/commit/44ac62e6f8b7e5b7d57edfbf82812c91dc5d6bba)]
- chore:volto 16 in tests, update docs, fix stylelint overrides [valentinab25 - [`b9a46d8`](https://github.com/eea/volto-eea-website-policy/commit/b9a46d85a64739188a3df9e8cbe645418b5d8b0a)]

Expand Down Expand Up @@ -258,7 +249,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

- Release 1.5.0 [Alin Voinea - [`a3dea8e`](https://github.com/eea/volto-eea-website-policy/commit/a3dea8ea15cb8d2a876dc10da926ece3a5707ea9)]
- test(Jenkinsfile): Use latest stable volto for testing [Alin Voinea - [`a8f7123`](https://github.com/eea/volto-eea-website-policy/commit/a8f712364187f9638886667c249fa102cb49b5c0)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`124a8f8`](https://github.com/eea/volto-eea-website-policy/commit/124a8f8ad4ced507aeec27012d725f2e2b977e08)]
### [1.4.0](https://github.com/eea/volto-eea-website-policy/compare/1.3.4...1.4.0) - 21 February 2023

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

- Release 1.1.0 [Alin Voinea - [`0291b3b`](https://github.com/eea/volto-eea-website-policy/commit/0291b3bb7b4c6ab09ca98728885cea4051eac8e3)]
- yarn 3 [Alin Voinea - [`593aa58`](https://github.com/eea/volto-eea-website-policy/commit/593aa58eaa4d28aced0603b7f7dd125c857a6f54)]
### [1.0.4](https://github.com/eea/volto-eea-website-policy/compare/1.0.3...1.0.4) - 22 November 2022

#### :nail_care: Enhancements
Expand Down Expand Up @@ -384,7 +373,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### :hammer_and_wrench: Others

- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`d153f54`](https://github.com/eea/volto-eea-website-policy/commit/d153f54e55e918fa4746e05488c734624eaf14a9)]
### [0.4.0](https://github.com/eea/volto-eea-website-policy/compare/0.3.3...0.4.0) - 19 September 2022

#### :hammer_and_wrench: Others
Expand Down Expand Up @@ -460,7 +448,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
- format index.js [Andrei Grigore - [`db4481a`](https://github.com/eea/volto-eea-website-policy/commit/db4481aeeba59a769272659f33278c902fc69bec)]
- Update index.js [Alexandru Ghica - [`dc09886`](https://github.com/eea/volto-eea-website-policy/commit/dc0988640a76a9914381b120f58bb61a9ab1eb39)]
- Added externalRoutes [Alexandru Ghica - [`b68135b`](https://github.com/eea/volto-eea-website-policy/commit/b68135b013fafa93a41ea602ea2fad30879abe0f)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`575cca6`](https://github.com/eea/volto-eea-website-policy/commit/575cca674602ca2e1c2a41300c47ba594ff49aa0)]
### [0.1.1](https://github.com/eea/volto-eea-website-policy/compare/0.1.0...0.1.1) - 4 March 2022

#### :hammer_and_wrench: Others
Expand All @@ -473,5 +460,4 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### :hammer_and_wrench: Others

- yarn bootstrap [Alin Voinea - [`9b4d197`](https://github.com/eea/volto-eea-website-policy/commit/9b4d197cbc7992566cb36524d190078d5ad21a44)]
- Initial commit [Alin Voinea - [`3800692`](https://github.com/eea/volto-eea-website-policy/commit/3800692f7a4de6460815bd6061facacb986cbef0)]
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pipeline {
BACKEND_PROFILES = "eea.kitkat:testing"
BACKEND_ADDONS = ""
VOLTO = "17"
VOLTO16_BREAKING_CHANGES = "no"
VOLTO16_BREAKING_CHANGES = "yes"
IMAGE_NAME = BUILD_TAG.toLowerCase()
}

Expand Down
46 changes: 34 additions & 12 deletions cypress/e2e/01-block-basics.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ describe('Blocks Tests', () => {
beforeEach(slateBeforeEach);
afterEach(slateAfterEach);

it('Add Block: Empty', () => {
it('Add Navigation Block', () => {
// Change page title
cy.clearSlateTitle();
cy.getSlateTitle().type('My Add-on Page');
Expand All @@ -13,23 +13,45 @@ describe('Blocks Tests', () => {

cy.getSlate().click();

// Add block
// Add Navigation 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();
cy.get('.blocks-chooser .contextNavigation').click();
cy.get('#field-name').type('Nav title');
cy.get(
'.field-wrapper-includeTop > .grid > :nth-child(1) > .twelve > .wrapper > .ui > label',
).click();
// cy.get(
// '.field-wrapper-currentFolderOnly > .grid > :nth-child(1) > .twelve > .wrapper > .ui > label',
// ).click();
cy.get(
'.field-wrapper-no_icons > .grid > :nth-child(1) > .twelve > .wrapper > .ui > label',
).click();
cy.get(
'.field-wrapper-no_thumbs > .grid > :nth-child(1) > .twelve > .wrapper > .ui > label',
).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.get('.context-navigation-header').contains('Nav title');

// Edit to select Accordion variation
cy.get('.toolbar-actions .edit').click();
cy.get('.block-editor-contextNavigation').click();
cy.get(
'#sidebar-properties .field-wrapper-variation .react-select__value-container',
).click();
cy.get('.field-wrapper-variation .react-select__option')
.contains('Accordion')
.click();

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');

cy.get('#toolbar-more').click();
cy.get('.state-select .react-select-container')
.click()
.contains('Publish')
.click({ force: true });
cy.get('.accordion-header').contains('Nav title');
cy.get('.accordion-header').click();
});
});
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-eea-website-policy",
"version": "2.1.1",
"version": "2.2.0",
"description": "@eeacms/volto-eea-website-policy: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand All @@ -17,10 +17,12 @@
"url": "git@github.com:eea/volto-eea-website-policy.git"
},
"addons": [
"@eeacms/volto-block-toc",
"@eeacms/volto-widget-dataprovenance",
"@plone-collective/volto-authomatic"
],
"dependencies": {
"@eeacms/volto-block-toc": "*",
"@eeacms/volto-widget-dataprovenance": "*",
"@plone-collective/volto-authomatic": "*"
},
Expand Down
48 changes: 31 additions & 17 deletions src/components/Blocks/ContextNavigation/ContextNavigationEdit.jsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,45 @@
import React from 'react';
import { EditSchema } from './schema';
import { InlineForm, SidebarPortal } from '@plone/volto/components';
import { SidebarPortal } from '@plone/volto/components';
import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm';

import ContextNavigationView from './ContextNavigationView';

const ContextNavigationFillView = (props) => {
const schema = EditSchema();
const ContextNavigationFillEdit = (props) => {
const contentTypes = props.properties?.['@components']?.types;
const availableTypes = React.useMemo(
() => contentTypes?.map((type) => [type.id, type.title || type.name]),
[contentTypes],
);

const schema = React.useMemo(
() => EditSchema({ availableTypes }),
[availableTypes],
);

return (
<>
<h3>Context navigation</h3>
<ContextNavigationView {...props} />{' '}
<SidebarPortal selected={props.selected}>
{props.selected && (
<InlineForm
title={schema.title}
schema={schema}
formData={props.data}
onChangeField={(id, value) => {
props.onChangeBlock(props.block, {
...props.data,
[id]: value,
});
}}
/>
)}
<BlockDataForm
schema={schema}
title={schema.title}
onChangeField={(id, value) => {
props.onChangeBlock(props.block, {
...props.data,
[id]: value,
});
}}
onChangeBlock={props.onChangeBlock}
formData={props.data}
block={props.block}
navRoot={props.navRoot}
contentType={props.contentType}
/>
</SidebarPortal>
</>
);
};

export default ContextNavigationFillView;
export default ContextNavigationFillEdit;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import ContextNavigationEdit from './ContextNavigationEdit';
import { Router } from 'react-router-dom';
import { Provider } from 'react-intl-redux';
import configureStore from 'redux-mock-store';
import { createMemoryHistory } from 'history';
import '@testing-library/jest-dom/extend-expect';

Expand All @@ -12,12 +14,13 @@ jest.mock('@plone/volto/components', () => ({
<input id="test" onChange={onChangeField} />
</div>
),
SidebarPortal: ({ children }) => (
<div>
<div>SidebarPortal</div>
{children}
</div>
),
SidebarPortal: ({ children, selected }) =>
selected ? (
<div>
<div>SidebarPortal</div>
{children}
</div>
) : null,
}));

jest.mock('@plone/volto/components/theme/Navigation/ContextNavigation', () => {
Expand All @@ -29,27 +32,48 @@ jest.mock('@plone/volto/components/theme/Navigation/ContextNavigation', () => {
};
});

jest.mock('@plone/volto/helpers', () => ({
withBlockExtensions: jest.fn((Component) => Component),
emptyBlocksForm: jest.fn(),
getBlocksLayoutFieldname: () => 'blocks_layout',
withVariationSchemaEnhancer: jest.fn((Component) => Component),
}));

const mockStore = configureStore();
const store = mockStore({
intl: {
locale: 'en',
messages: {},
},
});

describe('ContextNavigationEdit', () => {
it('renders corectly', () => {
const history = createMemoryHistory();
const { getByText, queryByText } = render(
<Router history={history}>
<ContextNavigationEdit />
</Router>,
<Provider store={store}>
<Router history={history}>
<ContextNavigationEdit selected={false} />
</Router>
,
</Provider>,
);

expect(getByText('Context navigation')).toBeInTheDocument();
expect(getByText('ConnectedContextNavigation')).toBeInTheDocument();
expect(queryByText('InlineForm')).toBeNull();
expect(getByText('SidebarPortal')).toBeInTheDocument();
expect(queryByText('SidebarPortal')).toBeNull();
});

it('renders corectly', () => {
const history = createMemoryHistory();
const { container, getByText } = render(
<Router history={history}>
<ContextNavigationEdit selected={true} onChangeBlock={() => {}} />
</Router>,
<Provider store={store}>
<Router history={history}>
<ContextNavigationEdit selected={true} onChangeBlock={() => {}} />
</Router>
,
</Provider>,
);

expect(getByText('Context navigation')).toBeInTheDocument();
Expand Down
17 changes: 7 additions & 10 deletions src/components/Blocks/ContextNavigation/ContextNavigationView.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import React from 'react';
import ConnectedContextNavigation from '@plone/volto/components/theme/Navigation/ContextNavigation';
import { flattenToAppURL } from '@plone/volto/helpers';
import { flattenToAppURL, withBlockExtensions } from '@plone/volto/helpers';
import DefaultTemplate from './variations/Default';

const ContextNavigationView = ({ data = {} }) => {
const ContextNavigationView = (props = {}) => {
const { variation, data = {} } = props;
const navProps = { ...data };
const root_path = data?.root_node?.[0]?.['@id'];
if (root_path) navProps['root_path'] = flattenToAppURL(root_path);

return (
<>
<ConnectedContextNavigation params={navProps} />
</>
);
const Renderer = variation?.view ?? DefaultTemplate;
return <Renderer params={navProps} />;
};

export default ContextNavigationView;
export default withBlockExtensions(ContextNavigationView);
Loading

0 comments on commit 31f56e5

Please sign in to comment.