- 
                Notifications
    
You must be signed in to change notification settings  - Fork 32
 
🎨 [Frontend] Enh: Lazy load templates #7647
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
🎨 [Frontend] Enh: Lazy load templates #7647
Conversation
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.
Pull Request Overview
This PR refactors the way templates are loaded by delaying their fetching until needed and converting the Templates store from a singleton to a static class. Key changes include:
- Modifying the Templates store to use static methods with caching and promise‐based fetching.
 - Updating UI components (TemplatesList, TemplateBrowser, NewStudies, NewPlusMenu, etc.) to work asynchronously with the new Templates API.
 - Minor adjustments in test files and other resource browsers to incorporate lazy loading and improved asynchronous handling.
 
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
| File | Description | 
|---|---|
| tests/e2e/tests/startupCalls.js | Commented out tests for Tasks and Templates were adjusted. | 
| services/static-webserver/client/source/class/osparc/study/Conversations.js | Returned the promise from the fetch call for addMessage. | 
| services/static-webserver/client/source/class/osparc/store/Templates.js | Changed the class design from a singleton to a static class with promise‐based fetching and caching. | 
| (Other UI components) | Updated calls to Templates methods to use the new static async API. | 
Comments suppressed due to low confidence (3)
tests/e2e/tests/startupCalls.js:68
- [nitpick] There are tests for Tasks and Templates that have been commented out. If these tests are no longer needed, consider removing them or adding a clarifying comment so future maintainers understand the intent.
 
-      /*
services/static-webserver/client/source/class/osparc/store/Templates.js:18
- Converting the Templates class from a singleton to a static class changes how 'this' is used inside its methods. Ensure that all static methods correctly reference and update class-level variables (such as __templates and __templatesPromisesCached) as intended in the framework.
 
qx.Class.define("osparc.store.Templates", { type: "static",
services/static-webserver/client/source/class/osparc/study/Conversations.js:93
- The added return statement now ensures the fetch promise is propagated; please confirm that all its callers are updated to handle the asynchronous result appropriately.
 
return osparc.data.Resources.fetch("conversations", "addMessage", params)
| 
           @Mergifyio queue  | 
    
          
 ✅ The pull request has been merged automaticallyThe pull request has been merged automatically at 5a1666d  | 
    
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.
thanks!
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.
👍
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.
👍
          
 | 
    



What do these changes do?
All templates were loaded at start up, adding some extra calls (
/templatesand their/services) that were not necessary, except for the TI products that do require the templates for the New Plans button.This PR improves that logic and should speed up the start up process and relieve the webserver a bit. This change will be more noticeable in those deployments that have many templates.
S4L:

osparc:

tip:

Related issue/s
How to test
Dev-ops