Skip to content

Commit

Permalink
Merge master into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
razvanMiu committed Nov 11, 2021
2 parents 253ec54 + 99e4b83 commit 7b40b54
Show file tree
Hide file tree
Showing 21 changed files with 384 additions and 27 deletions.
44 changes: 40 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,58 @@ 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.1.2](https://github.com/eea/volto-industry-theme/compare/1.1.1...1.1.2)

- Update [`c401cba`](https://github.com/eea/volto-industry-theme/commit/c401cba934c92060bd5d119c1d9320a5f6432ca2)

#### [1.1.1](https://github.com/eea/volto-industry-theme/compare/1.1.0...1.1.1)

> 8 November 2021
- Wrap text in dropdown [`0f27d89`](https://github.com/eea/volto-industry-theme/commit/0f27d89c52daf59f588eeed4d285d2dea3bc68ae)
- Release 1.1.1 [`b5758f8`](https://github.com/eea/volto-industry-theme/commit/b5758f82d2ab811960e3ff3cc29bad56838cfb79)

#### [1.1.0](https://github.com/eea/volto-industry-theme/compare/1.0.1...1.1.0)

> 8 November 2021
- Customize TableauBlock from volto-tableau [`8d220be`](https://github.com/eea/volto-industry-theme/commit/8d220bebefa6ebef0019bfcae7fa973c1bf8dee5)
- Release 1.1.0 [`ceeb1b9`](https://github.com/eea/volto-industry-theme/commit/ceeb1b9bcb7eadcb579c072ac302e9021f1ba57b)

#### [1.0.1](https://github.com/eea/volto-industry-theme/compare/1.0.0...1.0.1)

> 2 November 2021
- Release 1.0.1 [`aebec02`](https://github.com/eea/volto-industry-theme/commit/aebec028f0e92e100924c9a1e74bab4feca2be0d)
- Lint fix [`ddc100d`](https://github.com/eea/volto-industry-theme/commit/ddc100d697a546b22c75b5479818e534140bd45e)

### [1.0.0](https://github.com/eea/volto-industry-theme/compare/0.1.2...1.0.0)

> 2 November 2021
- Release 1.0.0 [`dc0632f`](https://github.com/eea/volto-industry-theme/commit/dc0632fe56303bdb2b392207140b5151e69f5652)
- Update [`7b0d95b`](https://github.com/eea/volto-industry-theme/commit/7b0d95bba9152a4bd817ad492a8f3a9bc964f01e)

#### [0.1.2](https://github.com/eea/volto-industry-theme/compare/0.1.1...0.1.2)

> 2 November 2021
- Enables cypress tests -> don't wait for breadcrumbs [`#3`](https://github.com/eea/volto-industry-theme/pull/3)
- Update [`3c681b9`](https://github.com/eea/volto-industry-theme/commit/3c681b9cb4790f37ef149efd5aa8b55ea4161656)
- Enables cypress tests -> don't wait for breadcrumbs [`972e593`](https://github.com/eea/volto-industry-theme/commit/972e5931504f2e0ab866b5c5f8d2b9e1bb5053b9)
- Automated release 0.1.2 [`462ff59`](https://github.com/eea/volto-industry-theme/commit/462ff592b09c63b9298115ee3e9046c39f0022f0)

#### [0.1.1](https://github.com/eea/volto-industry-theme/compare/0.1.0...0.1.1)

> 1 November 2021
- Added eprtr blocks and more [`#2`](https://github.com/eea/volto-industry-theme/pull/2)
- Commented cypress [`80eb317`](https://github.com/eea/volto-industry-theme/commit/80eb317730e92feef27316f87ba4f6080e5fa7fd)
- Use latest addons versions [`384cd34`](https://github.com/eea/volto-industry-theme/commit/384cd34d51b8debb1444cb241576149e4abfe432)
- Theme override [`c31ef7e`](https://github.com/eea/volto-industry-theme/commit/c31ef7e694b310508bace3b43a6ea2db142b7a54)
- Stylelint fix [`19ef60c`](https://github.com/eea/volto-industry-theme/commit/19ef60c117e427fa7f1df4ced8a9686e88b19c72)
- Improved Header & Footer [`cdbedcf`](https://github.com/eea/volto-industry-theme/commit/cdbedcf4cc75f71c8c892042db2d814f210348f0)
- Theme override [`c31ef7e`](https://github.com/eea/volto-industry-theme/commit/c31ef7e694b310508bace3b43a6ea2db142b7a54)
- Run bootstrap [`16b42cc`](https://github.com/eea/volto-industry-theme/commit/16b42cc3b48907fb0c803f256b549c034ca90d96)
- Commented cypress [`80eb317`](https://github.com/eea/volto-industry-theme/commit/80eb317730e92feef27316f87ba4f6080e5fa7fd)
- Automated release 0.1.1 [`f53985a`](https://github.com/eea/volto-industry-theme/commit/f53985ad593bc6edc743c2d3f2897b81e5db2ca7)
- Use latest addons versions [`384cd34`](https://github.com/eea/volto-industry-theme/commit/384cd34d51b8debb1444cb241576149e4abfe432)

#### 0.1.0

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-industry-theme",
"version": "1.1.3",
"version": "1.1.2",
"description": "@eeacms/volto-industry-theme: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand Down
10 changes: 6 additions & 4 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import installPollutantIndex from './manage/Blocks/PollutantIndex';
/*--- Custom connected blocks ---*/
import installCustomConnectedList from './manage/Blocks/List';
import installCustomConnectedSelect from './manage/Blocks/Select';
import installCustomTableau from './manage/Blocks/TableauBlock';
/*--- App extras ---*/
import installAppExtras from './theme/AppExtras';

Expand All @@ -48,10 +49,11 @@ const installCustomViews = (config) => {
};

const installCustomConnectedBlocks = (config) => {
return [installCustomConnectedList, installCustomConnectedSelect].reduce(
(acc, apply) => apply(acc),
config,
);
return [
installCustomConnectedList,
installCustomConnectedSelect,
installCustomTableau,
].reduce((acc, apply) => apply(acc), config);
};

const installEprtrSpecificBlocks = (config) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/manage/Blocks/FiltersBlock/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const providerSchema = {
},
url: {
title: 'Provider url',
widget: 'object_by_path',
widget: 'url',
},
},
required: [],
Expand Down
6 changes: 6 additions & 0 deletions src/components/manage/Blocks/FiltersBlock/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@
text-overflow: ellipsis;
white-space: nowrap;
}

.menu {
.text {
white-space: pre-wrap !important;
}
}
}

.actions {
Expand Down
2 changes: 1 addition & 1 deletion src/components/manage/Blocks/IndustryDataTable/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default () => ({
properties: {
link: {
title: 'Site details path',
widget: 'object_by_path',
widget: 'url',
},
},
required: [],
Expand Down
2 changes: 1 addition & 1 deletion src/components/manage/Blocks/IndustryMap/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const providerSchema = {
},
url: {
title: 'Provider url',
widget: 'object_by_path',
widget: 'url',
},
},
required: [],
Expand Down
2 changes: 1 addition & 1 deletion src/components/manage/Blocks/List/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const getSchema = (props) => {
properties: {
url: {
title: 'Url',
widget: 'object_by_path',
widget: 'url',
},
value: {
title: 'Value',
Expand Down
5 changes: 4 additions & 1 deletion src/components/manage/Blocks/NavigationBlock/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ const View = ({ location, data, navigation }) => {
<Menu className="navigation-block">
<MenuWrapper data={data}>
{items.map((item) => (
<Menu.Item key={item.url} active={pathname === getBaseUrl(item.url)}>
<Menu.Item
key={item.url}
active={pathname.includes(getBaseUrl(item.url))}
>
<UniversalLink
href={`${item.url}${location.search}`}
ignoreScroll={data.ignoreScroll}
Expand Down
2 changes: 1 addition & 1 deletion src/components/manage/Blocks/NavigationBlock/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default {
properties: {
parent: {
title: 'Parent',
widget: 'object_by_path',
widget: 'url',
},
pages: {
title: 'Pages',
Expand Down
9 changes: 7 additions & 2 deletions src/components/manage/Blocks/NavigationBlock/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,19 @@
> .ui.menu.navigation-block {
@textColor: var(--text-color, @blue);
height: 100%;
border: 1px solid @textColor;
// border: 2px solid @textColor;
border-radius: 2em;

.item {
flex: 1;
justify-content: center;
padding: 0;
margin: -1px;
margin: 0;
margin-top: 0 !important;
margin-right: 0 !important;
margin-bottom: 0 !important;
margin-left: 0 !important;
background: #fff;
border-radius: 0;
transition: background-color 0.2s ease-in-out;

Expand Down
12 changes: 7 additions & 5 deletions src/components/manage/Blocks/PollutantIndex/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,13 @@ const View = ({ providers_data, query, setQuery, ...props }) => {
const pollutantsOptions = React.useMemo(() => {
const { index_pollutants } = providers_data;
return (
index_pollutants?.pollutantId?.map((_, index) => ({
key: index_pollutants.code[index],
value: index_pollutants.pollutantId[index],
text: index_pollutants.name[index],
})) || []
index_pollutants?.pollutantId
?.map((_, index) => ({
key: index_pollutants.code[index],
value: index_pollutants.pollutantId[index],
text: index_pollutants.name[index],
}))
?.filter((opt) => opt.value !== null) || []
);
}, [providers_data]);

Expand Down
2 changes: 1 addition & 1 deletion src/components/manage/Blocks/PollutantIndex/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const providerSchema = {
},
url: {
title: 'Provider url',
widget: 'object_by_path',
widget: 'url',
},
},
required: [],
Expand Down
2 changes: 1 addition & 1 deletion src/components/manage/Blocks/Select/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const getSchema = (props) => {
properties: {
url: {
title: 'Url',
widget: 'object_by_path',
widget: 'url',
},
value: {
title: 'Value',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const getSchema = (props) => {
properties: {
pathname: {
title: 'Parent pathname',
widget: 'object_by_path',
widget: 'url',
},
pages: {
title: 'Pages',
Expand Down
2 changes: 1 addition & 1 deletion src/components/manage/Blocks/SiteTableau/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export default (config, provider_keys = []) => ({
},
provider_url: {
title: 'Data provider',
widget: 'object_by_path',
widget: 'url',
},
allowedParams: {
title: 'Allowed params',
Expand Down
32 changes: 32 additions & 0 deletions src/components/manage/Blocks/TableauBlock/Edit.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import { SidebarPortal } from '@plone/volto/components';
import InlineForm from '@plone/volto/components/manage/Form/InlineForm';
import config from '@plone/volto/registry';
import getSchema from './schema';
import View from './View';

const Edit = (props) => {
const [schema] = React.useState(getSchema(config));

return (
<>
<View {...props} mode="edit" />

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

export default Edit;
109 changes: 109 additions & 0 deletions src/components/manage/Blocks/TableauBlock/View.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import React from 'react';
import { connect } from 'react-redux';
import { compose } from 'redux';
import { withRouter } from 'react-router';
import Tableau from '@eeacms/volto-tableau/Tableau/View';
import config from '@plone/volto/registry';
import { getLatestTableauVersion } from 'tableau-api-js';
import qs from 'querystring';
import '@eeacms/volto-tableau/less/tableau.less';

const getDevice = (config, width) => {
const breakpoints = config.blocks.blocksConfig.tableau_block.breakpoints;
let device = 'default';
Object.keys(breakpoints).forEach((breakpoint) => {
if (
width <= breakpoints[breakpoint][0] &&
width >= breakpoints[breakpoint][1]
) {
device = breakpoint;
}
});
return device;
};

const View = (props) => {
const [error, setError] = React.useState(null);
const [loaded, setLoaded] = React.useState(null);
const [mounted, setMounted] = React.useState(false);
const [extraFilters, setExtraFilters] = React.useState({});
const { data = {}, query = {}, screen = {} } = props;
const {
breakpointUrls = [],
urlParameters = [],
title = null,
description = null,
autoScale = false,
} = data;
const version =
props.data.version ||
config.settings.tableauVersion ||
getLatestTableauVersion();
const device = getDevice(config, screen.page?.width || Infinity);
const breakpointUrl = breakpointUrls.filter(
(breakpoint) => breakpoint.device === device,
)[0]?.url;
const url = breakpointUrl || data.url;

React.useEffect(() => {
setMounted(true);
/* eslint-disable-next-line */
}, []);

React.useEffect(() => {
const newExtraFilters = { ...extraFilters };
urlParameters.forEach((element) => {
if (element.field && typeof query[element.urlParam] !== 'undefined') {
newExtraFilters[element.field] = query[element.urlParam];
} else if (newExtraFilters[element.field]) {
delete newExtraFilters[element.field];
}
});
setExtraFilters(newExtraFilters);
/* eslint-disable-next-line */
}, [JSON.stringify(query), JSON.stringify(urlParameters)]);

return mounted ? (
<div className="tableau-block">
{props.mode === 'edit' ? (
<div className="tableau-info">
<h3 className="tableau-version">== Tableau {version} ==</h3>
{!props.data.url ? <p className="tableau-error">URL required</p> : ''}
{error ? <p className="tableau-error">{error}</p> : ''}
</div>
) : (
''
)}
{loaded && title ? <h3 className="tableau-title">{title}</h3> : ''}
{loaded && description ? (
<p className="tableau-description">{description}</p>
) : (
''
)}
<Tableau
{...props}
canUpdateUrl={!breakpointUrl}
extraFilters={extraFilters}
extraOptions={{ device: autoScale ? 'desktop' : device }}
error={error}
loaded={loaded}
setError={setError}
setLoaded={setLoaded}
version={version}
url={url}
/>
</div>
) : (
''
);
};

export default compose(
connect((state, props) => ({
query: {
...(qs.parse(state.router.location?.search?.replace('?', '')) || {}),
...(state.query?.search || {}),
},
screen: state.screen,
})),
)(withRouter(View));
Loading

0 comments on commit 7b40b54

Please sign in to comment.