[BootstrapAdminUi] Add custom stimulus controller
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 45
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
Description
Description
When using the BootstrapAdminUi bundle out of the box, it is a nice DX to not have to install and configure Symfony Stimulus Bundle and care that it exists at all.
At some point, when needed to add custom Stimulus controllers, we tried with what it seems a "standard Symfony way" by adding Symfony Stimulus Bundle.
For completeness, we chose AssetMapper to handle assets.
Consequences are there are two started Stimulus apps: one by BootstrapAdminUi and the other is the custom one with Stimulus Bundle.
So all requests made by live components are made twice.
Additional context
By overriding the template of the sylius_admin.base#javascripts hook, we may avoid the load of the asset bundles/syliusbootstrapadminui/app.js.
It avoids the start of the Stimulus app by BootstrapAdminUi but other features like the ones provided by https://github.com/Sylius/Stack/tree/8fcb13f517662e7aa0cb24453dcd2e721a4af0eb/src/BootstrapAdminUi/assets/scripts are broken.
How to reproduce
- Follow https://stack.sylius.com/getting-started.
- Install Symfony Stimulus Bundle
- Go on an admin page where there is a live component.
- Trigger an action (either live action or update a model or emit an event etc..)
- Check the number of AJAX requests with the profiler
Possible solutions
Before proposing a patch, I'd like to have feedback on how to address this.
Maybe I missed something somewhere 🤔
-
BootstrapAdminUi may stop starting a Stimulus app.
It will imply that users will have to do it themselves like with Stimulus Bundle.
It seems fairly simple for a user to do it. In another hand it increases the number of dependencies a user have to handle. -
BootstrapAdminUi may propose a way to allow users to chose if it should start a Stimulus app or not.
It may increase the complexity of maintenance of BootstrapAdminUi.
It will keep the nice DX allowing people to not care about the Stimulus part if they don't need to. -
BootstrapAdminUi may propose to reuse it's started Stimulus app in order to register custom controllers with it.
Users won't be able to use the default behavior of the Stimulus Bundle which register the controllers automagically.
Others "admin UI theme" may chose to do the same to ease life of users.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the BootstrapAdminUi asset entry point at src/BootstrapAdminUi/assets/app.js and the scripts under src/BootstrapAdminUi/assets/scripts. Reproduce the duplicate AJAX requests after installing Symfony Stimulus Bundle and inspect the sylius_admin.base#javascripts hook. Done means a decided integration supports custom Stimulus controllers without breaking BootstrapAdminUi features or starting live components twice.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- developer-experience, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100