Patch #42515
openIntroduce Stimulus and reimplement partial quote feature
0%
Description
This patch introduces Stimulus, a JavaScript framework within the Rails ecosystem, and reimplements the partial quote feature added in #41294 using Stimulus.
Why introduce Stimulus?¶
Here's why I propose introducing Stimulus:
- The current frontend JavaScript is becoming too complex and harder to develop. application.js is getting large, and everything operates in the global scope.
- It will make it easier to begin the migration from jQuery UI, which is no longer being developed. Stimulus helps create UI components in vanilla Rails, and many third-party components are also available.
- Stimulus works well with Turbo, which is a strong candidate to replace the deprecated rails-ujs, making future adoption smoother.
- Introducing a modern environment can revitalize Redmine development and simply make development more enjoyable.
As a next step after introducing Stimulus, I plan to migrate the tooltip implementation to Stimulus to further reduce the dependency on jQuery UI.
Implementation¶
- importmap-rails was also introduced to install Stimulus and its necessary libraries.
bin/rails stimulus:install
creates app/javascript/application.js by default. To avoid conflicts with the existing app/assets/application.js, I renamed the new file to main.js.- turndown, which is used for the partial quote feature, is now also installed via importmap-rails.
- I confirmed that CI builds pass and all system tests are successful.
Files
Related issues
Updated by Katsuya HIDAKA 2 days ago
Implementation
- bin/rails stimulus:install creates app/javascript/application.js by default. To avoid conflicts with the existing app/assets/application.js, I renamed the new file to main.js.
Regarding the above, similar to the patch in #42510, it might be better to rename the existing app/assets/application.js to application-legacy.js. This could also serve as an explicit message to encourage migration to implementations using Stimulus or migration from app/assets/application.js.
Updated by Katsuya HIDAKA 2 days ago
- File 0004-Add-license-headers-to-added-JavaScript-files.patch 0004-Add-license-headers-to-added-JavaScript-files.patch added
- File 0003-Rename-app-assets-application.js-to-application-legacy.js-keeping-app-javascript-application.js-default.patch 0003-Rename-app-assets-application.js-to-application-legacy.js-keeping-app-javascript-application.js-default.patch added
I have added two patch files:
- 0003: Rename app/assets/application.js to application-legacy.js (keeping app/javascript/application.js default)
- 0004: Add license headers to added JavaScript files
Updated by Marius BĂLTEANU about 20 hours ago
- Related to Feature #42510: Evaluate the option to add Stimulus as a Javascript framework added
Updated by Marius BĂLTEANU about 19 hours ago
Thanks for your work and for the patches.
Let's discuss the integration of Stimulus in #42510 and then we can get back to this.