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 #92 from eea/develop
Release
- Loading branch information
Showing
14 changed files
with
373 additions
and
92 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
48 changes: 31 additions & 17 deletions
48
src/components/Blocks/ContextNavigation/ContextNavigationEdit.jsx
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 |
---|---|---|
@@ -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; |
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
17 changes: 7 additions & 10 deletions
17
src/components/Blocks/ContextNavigation/ContextNavigationView.jsx
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 |
---|---|---|
@@ -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); |
Oops, something went wrong.