-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat 2130 - ability to add PageBuilder Content Type Configs dynamically #2131
feat 2130 - ability to add PageBuilder Content Type Configs dynamically #2131
Conversation
|
…ows to dynamically add new configs for PageBuilder
a80b9a7
to
33bdfb1
Compare
This is a great idea. Can you add an example to the pull request description of how you would call this new API from a third-party system? |
@zetlen, done |
@sirugh, @davemacaulay, @jimbo, @zetlen Hello guys, is there a chance you could review this MR and leave your comments about what should be improved or help it move on to the next steps with merging in? |
@vchirkov thanks for the contribution and making Page Builder better in PWA Studio! I'm a big fan of all core aspects using the API we provide. What do you think in regard of making all of the existing core content types use the same API as you're providing here? Doing this leads me to also ask at what point should we call |
Can be done, but I don't see the big benefit for this. Anyway, original set of components is required for normal functioning of PageBuilder itself and will always be available. So I would call initial set "Default Config" and use
Our intention is to use it at run time, when based on some conditions we add or mutate default config with new aggregators and components. We are going to make a custom Provider component, that is going to handle this logic on application start. This solution closes all our current limitations, is relatively simple and extendable in future. Interface is simple but incapsulates implementation and can be reimplemented in any required way under the hood (if changing current approach would be required). What do you think? |
@vchirkov I agree with the default config part. However, I'm also a strong advocate of using an API you implement within the core product, otherwise it's harder for others to determine how to use this API within code. Though I'm not passionate about it to require the change here as I think having a default config does make sense. Apart from that sounds good to me, I'll want @zetlen to comment before we move ahead with this! Thanks again for your hard work on this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our extensibility plan prefers build-time resolution to runtime. We're not completely opposed to a runtime extension point like setContentTypeConfig
, though. We know that some use case may come along where we need to run extension dispatch on the user's device. In our own backlog, that use case hasn't come along yet. And for your needs, I can't tell from your explanation why it needs to be at runtime, instead of an extension point that inserts additional type configs at build.
Our intention is to use it at run time, when based on some conditions we add or mutate default config with new aggregators and components. We are going to make a custom Provider component, that is going to handle this logic on application start.
As default config is created instantly on first module require, developer doesn't need to worry about the initialization sequence like he would have to in case of dynamic adding default Page builder entities.
Would the "some conditions" vary based on the logged-in user or other data in the HTTP request? If so, then maybe that's a use case for setContentTypeConfig
. If not, then I'd like to explore how we could inline your additional content types into the build by exposing a "target" (like in #2137) that modifies PageBuilder asset code.
That's the clarification I need from you, @vchirkov. In general, I'm very grateful to you for working on framework-level extensibility concepts. Please don't stop! And as for this PR itself: If this suits your needs, I want you to use it. I don't think it conflicts with #2137 as code, but as an approach, it might need to change to be merged into our PageBuilder module.
Hi @zetlen, thanks a lot for such detailed description. Now I understand your position much better and did a deeper investigation into BuildBus concept.
There are three usecases we are working on right now:
And one major complication, that makes it much harder for us to use BuildBus:
Possible alternatives we considered, that include build time approach:
In the end we decided, that dynamic modification of default config is the easiest and the most transparent way of dealing with our requirements. |
…or-page-builder' into feat/2130/setContentTypeConfig-for-page-builder
238af5b
@zetlen, @davemacaulay |
@vchirkov Thanks for your patience. You've been very responsive on this ticket. On the other hand, we have let it lie fallow here on the core team, partly because we've been busy defining the parameters of our extension framework in the first place, and deciding what runtime operations need to be necessary. I think we should pass this code through another round of review (@davemacaulay and @sirugh and @jimbo perhaps) and then strongly consider merging it. Why to do itI'm very receptive to concerns about changing app configuration and content without doing another rebuild and push. Eventually, our ideal architecture will allow incremental rebuilds of the app, and once those rebuilds are available and cheap, we'd want to do most of our configuration changes that way. But until then, it's reasonable to want to change app behavior based on environmental settings. This use case clinches it for me:
Your goal is to use the same bundled application on different stores. Different stores may have different PageBuilder default configurations. Not all of the PageBuilder configuration is embedded into actual PageBuilder content, so there is a clear place where you may need to mutate PageBuilder configuration at load time. This use case is less persuasive to me:
Right now, we do hardcode the MAGENTO_BACKEND_URL into the app under some circumstances. That can change, though; and if we make it more dynamic, we can then say that the backend configuration is driven entirely by environment variables, and you could in fact deploy the same app on different websites today simply by changing MAGENTO_BACKEND_URL. And finally, this use case brings up a question for me:
When offline, the Apollo client uses its local cache to simulate request responses. If the user was logged in before, they should see the same content and data that was already cached. If you're designing an offline mode that doesn't use Apollo cache, or tries to simulate responses by other means, then I suppose you'd have to reimplement user state. You shouldn't have to do that, though; please let us know if Apollo local cache is not suiting your purposes. |
Thanks James, sorry for the long answer, missed the notification. @zetlen, regarding you last question, you are absolutely right and I tried to say the same, just didn't express myself well. What I tried to say is that one of possible alternatives potentially could be to return different pagebuilder config from server, but as you said that won't work because of apollo cache. |
Hello, gents, As I see according to ci bot all checks have passed. |
I'm going to move this into "Ready for QA" status so that @dpatil-magento can run our full regression suite on it! Thank you @vchirkov |
@zetlen, thanks for your help! |
Description
PageBuilder/config.js
provides two methods:getContentTypeConfig(contentType)
andsetContentTypeConfig(contentType, config)
instead of only getter. This allows to add PageBuilder Content Type Configs dynamically.When you need to add new content type, you just call setter with proper params
And then call PageBuilder in the place you expect it to be rendered:
Related Issue
Closes #2130.
Acceptance
Verification Stakeholders
Specification
Verification Steps
two new tests added to
config.spec.js
.Screenshots / Screen Captures (if appropriate)
Checklist