generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from eea/develop
Release
- Loading branch information
Showing
44 changed files
with
1,028 additions
and
1,630 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
import BlockDataForm from '@plone/volto/components/manage/Form/BlockDataForm'; | ||
import { SidebarPortal } from '@plone/volto/components'; | ||
import View from './View'; | ||
import getSchema from './schema'; | ||
|
||
const Edit = (props) => { | ||
const schema = React.useMemo(() => getSchema(props), [props]); | ||
|
||
return ( | ||
<React.Fragment> | ||
<View {...props} mode="edit" /> | ||
<SidebarPortal selected={props.selected}> | ||
<BlockDataForm | ||
block={props.block} | ||
schema={schema} | ||
title={schema.title} | ||
onChangeField={(id, value) => { | ||
props.onChangeBlock(props.block, { | ||
...props.data, | ||
[id]: value, | ||
}); | ||
}} | ||
formData={props.data} | ||
/> | ||
</SidebarPortal> | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
export default Edit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React from 'react'; | ||
import { PrivacyProtection } from '@eeacms/volto-embed'; | ||
import Tableau from '@eeacms/volto-tableau/Tableau/Tableau'; | ||
|
||
import { flattenToAppURL } from '@plone/volto/helpers'; | ||
import { getContent } from '@plone/volto/actions'; | ||
|
||
import { connect } from 'react-redux'; | ||
import { compose } from 'redux'; | ||
|
||
const View = (props) => { | ||
const data = props.data; | ||
const { data_provenance, tableau_visualization } = | ||
props.tableau_visualization_data || {}; | ||
const tableau_vis_url = flattenToAppURL(data.tableau_vis_url || ''); | ||
|
||
React.useEffect(() => { | ||
if (tableau_vis_url) { | ||
props.getContent(tableau_vis_url, null, props.id); | ||
} | ||
// eslint-disable-next-line | ||
}, [tableau_vis_url]); | ||
|
||
return ( | ||
<div className="embed-container"> | ||
<PrivacyProtection | ||
{...props} | ||
data={{ ...data, url: tableau_visualization?.url }} | ||
> | ||
{!tableau_vis_url && ( | ||
<div>Please select a visualization from block editor.</div> | ||
)} | ||
{!!tableau_vis_url && ( | ||
<> | ||
{!tableau_visualization?.url && props.mode === 'edit' && ( | ||
<div>Url is not set in the visualization</div> | ||
)} | ||
{!!tableau_visualization?.url && ( | ||
<Tableau | ||
data={tableau_visualization} | ||
with_sources={true} | ||
with_download={true} | ||
with_share={true} | ||
sources={data_provenance.data || []} | ||
/> | ||
)} | ||
</> | ||
)} | ||
</PrivacyProtection> | ||
</div> | ||
); | ||
}; | ||
|
||
export default compose( | ||
connect( | ||
(state, props) => ({ | ||
tableau_visualization_data: state.content.subrequests?.[props.id]?.data, | ||
}), | ||
{ | ||
getContent, | ||
}, | ||
), | ||
)(React.memo(View)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import EmbedTableauVisualizatonEdit from './Edit'; | ||
import EmbedTableauVisualizatonView from './View'; | ||
|
||
import sliderSVG from '@plone/volto/icons/slider.svg'; | ||
|
||
export default (config) => { | ||
config.blocks.blocksConfig.embed_tableau_visualization = { | ||
id: 'embed_tableau_visualization', | ||
title: 'Embed EEA Tableau visualization', | ||
icon: sliderSVG, | ||
group: 'common', | ||
edit: EmbedTableauVisualizatonEdit, | ||
view: EmbedTableauVisualizatonView, | ||
restricted: false, | ||
mostUsed: false, | ||
sidebarTab: 1, | ||
blocks: {}, | ||
security: { | ||
addPermission: [], | ||
view: [], | ||
}, | ||
breakpoints: { | ||
desktop: [Infinity, 982], | ||
tablet: [981, 768], | ||
mobile: [767, 0], | ||
}, | ||
}; | ||
|
||
return config; | ||
}; |
Oops, something went wrong.