Skip to content

Conversation

@piyushdev04
Copy link
Contributor

Modified JsonSchemaWidget media property to load advanced assets only when advanced_mode=True. CommandSchemaWidget now skips loading unnecessary JS/CSS. Verified config forms load assets, commands do not.

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Closes #525.

Please open a new issue if there isn't an existing issue yet.

Description of Changes

  • Updated JsonSchemaWidget.media property to conditionally load advanced editor assets (advanced-mode.js, tomorrow_night_bright.js, advanced-mode.css) only when advanced_mode=True.
  • CommandSchemaWidget overrides advanced_mode=False, so these assets are not loaded for command forms, improving page performance.
  • Verified that configuration forms (templates, devices) still load the advanced editor as expected.
  • Verified that command forms (Connection → Commands) no longer load advanced editor assets.

@coderabbitai
Copy link

coderabbitai bot commented Jan 17, 2026

📝 Walkthrough

Walkthrough

The JsonSchemaWidget.media property in openwisp_controller/config/widgets.py was changed to stop hard‑coding advanced editor assets in the base media. The base media now includes JS: jsonschema-ui.js, admin/jquery.init.js, widget.js, utils.js; and CSS: config/css/lib/jsonschema-ui.css. If advanced_mode is truthy, advanced-mode.js and tomorrow_night_bright.js are prepended to the JS list and config/css/lib/advanced-mode.css is appended to the CSS list. DeviceGroupJsonSchemaWidget continues to extend the base media and appends devicegroup.css. No public signatures changed and the render path is unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title '[admin] Avoid loading advanced editor for commands #525' directly and specifically summarizes the main change: preventing advanced editor assets from loading for commands while referencing the related issue.
Description check ✅ Passed The description includes all key template sections: completed checklist items, issue reference (#525), and detailed change descriptions covering the conditional asset loading implementation and verification.
Linked Issues check ✅ Passed The PR fully addresses issue #525's objective of avoiding advanced editor asset loading for commands while preserving it for configuration forms, with verification provided.
Out of Scope Changes check ✅ Passed All changes are narrowly focused on conditionally loading advanced editor assets based on the advanced_mode flag, directly addressing the linked issue #525 without extraneous modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 328f8b2 and 07efb68.

📒 Files selected for processing (1)
  • openwisp_controller/config/widgets.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • openwisp_controller/config/widgets.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Python==3.11 | django~=5.1.0
  • GitHub Check: Python==3.13 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=5.1.0
  • GitHub Check: Python==3.12 | django~=4.2.0
  • GitHub Check: Python==3.10 | django~=4.2.0
  • GitHub Check: Python==3.12 | django~=5.2.0
  • GitHub Check: Python==3.10 | django~=5.1.0
  • GitHub Check: Python==3.13 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=5.2.0
  • GitHub Check: Python==3.11 | django~=4.2.0
  • GitHub Check: Python==3.10 | django~=5.2.0

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 17, 2026
@piyushdev04 piyushdev04 force-pushed the issues/525-disable-advanced-editor-for-commands branch from 2fa65d6 to 772f78a Compare January 17, 2026 18:44
@piyushdev04 piyushdev04 changed the title [change] Avoid loading advanced editor for commands #525 [admin] Avoid loading advanced editor for commands #525 Jan 17, 2026
@piyushdev04 piyushdev04 force-pushed the issues/525-disable-advanced-editor-for-commands branch from bb31b27 to 328f8b2 Compare January 17, 2026 19:15
@coveralls
Copy link

coveralls commented Jan 17, 2026

Coverage Status

coverage: 98.642% (+0.001%) from 98.641%
when pulling 07efb68 on piyushdev04:issues/525-disable-advanced-editor-for-commands
into cbdb3c6 on openwisp:master.

Copy link
Member

@nemesifier nemesifier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're changing the class without changing anything else?

@piyushdev04
Copy link
Contributor Author

yes i changed the base class so asset loading depends on advanced_mode. since subclasses already set this flag, they automatically get the correct behavior without any other changes.

Modified JsonSchemaWidget media property to load advanced assets
only when advanced_mode=True. CommandSchemaWidget now skips loading
unnecessary JS/CSS. Verified config forms load assets, commands do not.

Closes openwisp#525
Modified JsonSchemaWidget media property to load advanced assets
only when advanced_mode=True. CommandSchemaWidget now skips loading
unnecessary JS/CSS. Verified config forms load assets, commands do not.

Closes openwisp#525
@piyushdev04 piyushdev04 force-pushed the issues/525-disable-advanced-editor-for-commands branch from 328f8b2 to 07efb68 Compare January 25, 2026 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[change] Avoid loading advanced editor for commands

3 participants