Repository navigation
Dropdowns for Vehicle Components - #272
Conversation
58530d6 to
87e33d4
Compare
|
Thanks Francisco. I have rebased it and corrected the LF and the commit message. |
|
This pull request introduces several new features and improvements related to component templates in the Backend Changes:
Frontend Changes:
Configuration Changes:
|
There was a problem hiding this comment.
Pull Request Overview
This pull request adds support for vehicle component templates by allowing users to save configurations as templates and select them from a dropdown.
- Introduces new functions in the backend to load and save component templates.
- Enhances the frontend component editor with dropdown buttons and associated controls to apply and save templates.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| ardupilot_methodic_configurator/backend_filesystem_vehicle_components.py | Added functions to load and save component templates from a dedicated JSON file. |
| ardupilot_methodic_configurator/frontend_tkinter_component_editor_base.py | Added UI elements and logic (dropdown buttons, template controls, and menu events) for managing component templates. |
Comments suppressed due to low confidence (2)
ardupilot_methodic_configurator/frontend_tkinter_component_editor_base.py:128
- [nitpick] Consider renaming the key 'manager' to a more descriptive name, such as 'vehicle_components_manager', to improve clarity about its purpose.
self.template_controls = {"buttons": {}, "current_menu": None, "manager": VehicleComponents()}
ardupilot_methodic_configurator/frontend_tkinter_component_editor_base.py:274
- [nitpick] The check for 'hasattr(self, "current_dropdown_menu")' is inconsistent with storing the dropdown menu in 'self.template_controls["current_menu"]'; consider using a consistent attribute name for clarity.
if hasattr(self, "current_dropdown_menu") and self.template_controls["current_menu"]:
|
I fixed the pylint and mypy issues, but intoduced a regression when applying templates, sorry. I will have to take a look at it later. Have no more time today. |
c315f94 to
eeeae70
Compare
|
Refractored the code and added pytests |
There was a problem hiding this comment.
Pull Request Overview
This pull request adds support for saving and selecting vehicle component templates via dropdown menus and updates the GUI and backend logic to support this new functionality. Key changes include:
- Introducing a new ComponentTemplateManager class with methods to add template controls and manage template file IO.
- Adding tests for the ComponentTemplateManager and updating component editor functionality to integrate template selection.
- Updating the backend filesystem module to support loading and saving of vehicle component templates.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_frontend_tkinter_component_template_manager.py | New tests for the component template manager functionality |
| ardupilot_methodic_configurator/frontend_tkinter_component_template_manager.py | Implementation of template controls and dropdown functions |
| tests/test_frontend_tkinter_component_editor_base.py | Updates to tests for widget setup and template controls integration |
| ardupilot_methodic_configurator/backend_filesystem_vehicle_components.py | Enhancements to load and save vehicle component templates |
| ardupilot_methodic_configurator/frontend_tkinter_component_editor_base.py | Integration of template manager and updates to widget population logic |
| ardupilot_methodic_configurator/frontend_tkinter_component_editor.py | Override of template name derivation and various editor enhancements |
Comments suppressed due to low confidence (1)
ardupilot_methodic_configurator/frontend_tkinter_component_editor.py:786
- There appear to be duplicate implementations of the 'derive_initial_template_name' method in this class. Consider consolidating the logic to prevent potential inconsistencies.
def derive_initial_template_name(self, component_data: dict[str, Any]) -> str:
| menu.post(x, y) | ||
|
|
||
| self.current_menu = menu | ||
|
|
There was a problem hiding this comment.
[nitpick] The 'close_menu' function uses 'close_handler_id' which is assigned after the function definition. Consider adding a comment or restructuring the code to make the closure of 'close_handler_id' clearer.
| # Bind the close_menu function to the Button-1 event and store the handler ID | |
| close_handler_id = self.root.bind("<Button-1>", close_menu, add="+") |
|
|
||
| new_template = {"name": template_name, "data": component_data} | ||
|
|
||
| for i, template in enumerate(templates[component_name]): |
There was a problem hiding this comment.
[nitpick] When a template with the same name exists, the function returns immediately if the user does not confirm an overwrite. Consider providing feedback to the user in the non-confirmed case or revisiting the control flow to ensure clear communication.
There was a problem hiding this comment.
Pull Request Overview
This PR adds dropdown functionality for vehicle component templates and improves template management by integrating new backend and frontend code while extending test coverage for these features.
- Introduces and refines ComponentTemplateManager for handling template saving, loading and UI controls.
- Enhances VehicleComponents template I/O methods in the backend.
- Expands test coverage for component template and editor behaviors.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_frontend_tkinter_component_template_manager.py | New tests covering template manager functionality. |
| ardupilot_methodic_configurator/backend_filesystem_vehicle_components.py | Updates to load and save component templates with proper merging logic. |
| ardupilot_methodic_configurator/frontend_tkinter_component_template_manager.py | New ComponentTemplateManager implementation for the GUI. |
| tests/test_frontend_tkinter_component_editor_base.py | Additional tests for widget and template control functions. |
| ardupilot_methodic_configurator/frontend_tkinter_component_editor_base.py | Integration of template_manager into the editor base; minor refactoring. |
| ardupilot_methodic_configurator/frontend_tkinter_component_editor.py | Updated derive_initial_template_name and component editor enhancements. |
Comments suppressed due to low confidence (2)
ardupilot_methodic_configurator/frontend_tkinter_component_editor_base.py:125
- The call to __display_component_editor_usage_instructions is executed immediately instead of being scheduled. Use a lambda or pass the function reference without calling it; for example: self.root.after(10, lambda: self.__display_component_editor_usage_instructions(self.root)).
self.root.after(10, self.__display_component_editor_usage_instructions(self.root)) # type: ignore[arg-type]
ardupilot_methodic_configurator/frontend_tkinter_component_template_manager.py:214
- The close_menu function references close_handler_id from an outer scope that’s declared after its definition. Consider declaring close_handler_id (e.g., by initializing it to None before defining close_menu) to ensure proper closure capture.
def close_menu(_: tk.Event) -> None:
9d4c5ec to
97d8d38
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a feature that enables users to save a vehicle component configuration as a template and select from a list of pre-defined system and user templates via dropdown controls. The key changes include:
- Adding new methods in backend_filesystem_vehicle_components.py to load, merge, and save system and user templates.
- Implementing a new ComponentTemplateManager class in the Tkinter frontend to handle template dropdowns and saving actions.
- Extending test coverage and updating architectural documentation to reflect these template management capabilities.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| ardupilot_methodic_configurator/backend_filesystem_vehicle_components.py | Introduced methods to load system/user templates and manage template saving logic. |
| tests/test_frontend_tkinter_component_template_manager.py | Added extensive tests to verify saving, updating, and applying component templates. |
| ardupilot_methodic_configurator/frontend_tkinter_component_template_manager.py | Developed UI functions for rendering dropdown buttons and saving templates. |
| tests/test_frontend_tkinter_component_editor_base.py | Added tests for widget creation and integration of the new template controls. |
| ARCHITECTURE.md | Updated requirements to document the new template management feature. |
| ardupilot_methodic_configurator/frontend_tkinter_component_editor_base.py & ardupilot_methodic_configurator/frontend_tkinter_component_editor.py | Integrated template management into the component editor UI via new callbacks and controls. |
Comments suppressed due to low confidence (3)
ardupilot_methodic_configurator/backend_filesystem_vehicle_components.py:92
- [nitpick] Consider renaming the 'user_modified' flag to a more descriptive name such as 'is_user_modified' for improved clarity.
user_template["user_modified"] = True
ardupilot_methodic_configurator/frontend_tkinter_component_template_manager.py:135
- Ensure that template entries always include a valid 'name' to avoid unexpected sorting orders when defaulting to an empty string.
component_templates = sorted(component_templates, key=lambda x: x.get("name", "").lower())
ardupilot_methodic_configurator/frontend_tkinter_component_editor_base.py:199
- Double-check that using 'key in self.data.get("Components", {})' reliably identifies components for template controls; consider adding explicit component type validation to ensure proper behavior.
if is_toplevel and key in self.data.get("Components", {}):
25e63e3 to
83e1322
Compare
You can now pick and compose the components that your vehicle uses from this "database"
31f4fbf to
506d302
Compare
…verwriting user defined component templates
…ture Adds a command line switch that allows saving component templates to the system file to distribute them via git to other users.
506d302 to
1faea0d
Compare
amilcarlucas
left a comment
There was a problem hiding this comment.
look good, I'll merge this now.
Please do add some more templates later
There was a problem hiding this comment.
Pull Request Overview
This pull request adds a new feature that lets users save vehicle component configurations as templates and easily select them via dropdown controls. Key changes include:
- New methods in the backend for loading, merging, and saving system and user component templates.
- A new ComponentTemplateManager class (and associated UI controls) for managing template selection and saving.
- Updates to tests, CLI argument parsing, and architecture documentation to support the new template functionality.
Reviewed Changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| ardupilot_methodic_configurator/backend_filesystem_vehicle_components.py | Added methods for loading and saving component templates with support for system and user templates. |
| ardupilot_methodic_configurator/frontend_tkinter_component_template_manager.py | Introduced a new template manager class to display dropdowns and save buttons for component templates. |
| tests/test_frontend_tkinter_component_template_manager.py | Extended test coverage for new template functionalities. |
| tests/test_frontend_tkinter_component_editor_base.py | Added tests for retrieving component data from GUI and integrating template controls. |
| ARCHITECTURE.md | Updated to reflect the new template-based component management feature. |
| Various files (backend_filesystem.py, frontend_tkinter_component_editor.py, update_vehicle_templates.py, etc.) | Updated constructor arguments and CLI parsers to include the new “save_component_to_system_templates” flag. |
Files not reviewed (1)
- tests/test_backend_filesystem.py: Language not supported
Comments suppressed due to low confidence (2)
ardupilot_methodic_configurator/frontend_tkinter_component_editor.py:786
- [nitpick] The derive_initial_template_name method in ComponentEditorWindow returns a default template name based on manufacturer and model, which differs from the base implementation returning an empty string. Consider consolidating the logic for template name derivation to ensure consistent behavior across editors.
def derive_initial_template_name(self, component_data: dict[str, Any]) -> str:
ardupilot_methodic_configurator/backend_filesystem.py:797
- [nitpick] The help message for '--save-component-to-system-templates' could explicitly mention that its default value is False for better clarity.
parser.add_argument("--save-component-to-system-templates", action="store_true", ...
This pull request allows the user to save a vehicle component to a template and select it directly from a pre-defined set of common vehicle components.
For each vehicle component, a dropdown arrow is present as well as a button to allow to save the current filled component.
The current
vehicle_components_template.jsonis empty but could be filled with common components.