Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select Block from iframe and its config appear in sidebar #51

Merged
merged 20 commits into from
Jun 22, 2024

Conversation

MAX-786
Copy link
Member

@MAX-786 MAX-786 commented Jun 17, 2024

Fixes #23

I am thinking to use volto's block engine to render these blocks behind the iframe and set the selected prop based on the block clicked in iframe.

I setup a redux state 'selectedBlock', so that whenever a block is clicked which have an attribute 'data-block-uid={}', it will dispatch a action and its uid is stored in selectedBlock.

First, hide the Edit Form by setting it's display to none so that iframe is shown inplace of blocks. So we can still use the Edit component to open block's settings.
Then, In Block Edit component, use the redux state 'selectedBlock' which contains 'uid' of a clicked block. We need to find a way to set this.props.seletected to true whenever this.state.selectedBlock.uid matches with this.props.id.

@MAX-786
Copy link
Member Author

MAX-786 commented Jun 17, 2024

I am thinking to use volto's block engine to render these blocks behind the iframe and set the selected prop based on the block clicked in iframe.

AFAIK See This BlocksForm renders the blocks in Volto and Block Edit component handles displaying the selected block's settings in the sidebar. So to update Sidebar, what if we use This Block Edit Component to set this.props.selected to true whenever this.state.selectedBlock.uid matches with this.props.id.

@JeffersonBledsoe
Copy link
Member

I am thinking to use volto's block engine to render these blocks behind the iframe and set the selected prop based on the block clicked in iframe.

AFAIK See This BlocksForm renders the blocks in Volto and Block Edit component handles displaying the selected block's settings in the sidebar. So to update Sidebar, what if we use This Block Edit Component to set this.props.selected to true whenever this.state.selectedBlock.uid matches with this.props.id.

As discussed in this weeks sprint planning, this works fine as all of the sidebar updating logic is kept in this component. As long as the actual rendering of the block is disabled (and any other potential side-effects the component may have), it should be fine to re-use this component for now.
An argument could be made that this logic should be split up and moved to another file in core Volto.

@MAX-786 MAX-786 marked this pull request as ready for review June 17, 2024 21:07
README.md Outdated Show resolved Hide resolved
@JeffersonBledsoe JeffersonBledsoe changed the base branch from title-real-time-update to main June 19, 2024 12:53
Copy link
Member

@JeffersonBledsoe JeffersonBledsoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still needs the automatic subscription when blocks are changed or the page is changed. I'll review more closely once that is in place

hydra.js Outdated Show resolved Hide resolved
@MAX-786 MAX-786 linked an issue Jun 20, 2024 that may be closed by this pull request
3 tasks
Copy link
Member

@djay djay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you removing enableBlockClickListener() later or now?

README.md Outdated Show resolved Hide resolved
MAX-786 and others added 2 commits June 20, 2024 14:07
Co-authored-by: Dylan Jay <software@pretaweb.com>
@MAX-786
Copy link
Member Author

MAX-786 commented Jun 20, 2024

are you removing enableBlockClickListener() later or now?

done

@JeffersonBledsoe
Copy link
Member

@MAX-786 It's a little difficult to see what's changed in the Edit shadow, but I think it's all good apart from the few comments I left

If you have the time, it would be great if you could make a PR to core Volto with the setSelectedBlock changes!

@MAX-786
Copy link
Member Author

MAX-786 commented Jun 20, 2024

@MAX-786 It's a little difficult to see what's changed in the Edit shadow, but I think it's all good apart from the few comments I left

nothing major. let me point them out

# Conflicts:
#	README.md
#	hydra.js
#	packages/volto-hydra/src/components/Iframe/View.jsx
@JeffersonBledsoe
Copy link
Member

@MAX-786 All fine on the changes in the Edit shadow then. I've merged #49 into main and brought the changes into this PR. Can you check this PR over again with your frontend and fix up the comments I'd left please all good? We're good to use the GitHub Squash & Merge then as I resolved the conflicts with the other branches

@MAX-786
Copy link
Member Author

MAX-786 commented Jun 20, 2024

fix up the comments I'd left please all good? We're good to use the GitHub Squash & Merge then as I resolved the conflicts with the other branches

Yep I'll fix them up right now, u mean the previous ones tho, right?

@JeffersonBledsoe
Copy link
Member

@MAX-786 Yes, I've merged the changes from #49 into this one (and also into #60 )

@MAX-786
Copy link
Member Author

MAX-786 commented Jun 21, 2024

@djay @JeffersonBledsoe LGTM!

@MAX-786 MAX-786 merged commit 5920a9a into main Jun 22, 2024
1 check passed
@MAX-786 MAX-786 deleted the select-blocks-from-iframe branch June 22, 2024 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

I can Click on a block in preview to see its configuration appear in sidepanel
3 participants