flask-menu
flask-menu copied to clipboard
config: add config-variable for setting menus
:heart: Thank you for your contribution!
Description
Adds a config-variable for customizing menus via config.
Checklist
Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:
- [x] I'm aware of the code of conduct.
- [x] I've created logical separate commits and followed the commit message format.
- [x] I've added relevant test cases.
- [x] I've added relevant documentation.
- [x] I've marked translation strings (for relevant code).
- [x] I've followed the CSS/JS and React guidelines (for relevant code).
- [x] I've followed the web accessibility guidelines (for relevant code).
- [x] I've followed the user interface guidelines (for relevant code).
- [x] I've identified the copyright holder(s) and updated copyright headers for touched files (>15 lines contributions).
- [x] I've NOT included third-party code (copy/pasted source code or new dependencies).
Third-party code
If you've added third-party code (copy/pasted or new dependencies), please reach out to an architect.
Reminder
By using GitHub, you have already agreed to the GitHub’s Terms of Service including that:
- You license your contribution under the same terms as the current repository’s license.
- You agree that you have the right to license your contribution under the current repository’s license.
@martinobersteiner thanks a lot for the PRs for configuring Flask-Menu across InvenioRDM. After some discussions on how the menu customization story should look like, we realized there are bigger architectural concerns.
Still, to unblock these PRs and the ability to customize menus, we can do the following:
- Keep the configuration-based overriding behaviour local to each RDM module (i.e. what's done in https://github.com/inveniosoftware/invenio-app-rdm/pull/2577/files)
- Use specific config variables in each module that defines menus. That would be
COMMUNITY_MENU_OVERIDDES,USER_DASHBOARD_MENU_OEVERRIDES, etc.- In practice that means, that we just rename and split the
FLASK_MENUtoCOMMUNITY_MENU_OVERIDDES,USER_DASHBOARD_MENU_OEVERRIDES, etc.
- In practice that means, that we just rename and split the
- Later on consolidate the code in Flask-Menu
The fully integrated solution to be implemented in Flask-Menu would be:
- Setting the
FLASK_MENUconfig variable should also mean change of behavior in Flask-Menu. I.e. right now, the variable is not used in any part of the code in this module. - The config should be affecting either...
- ...the
MenuNode.register(...)method, i.e. before setting any of the attributes (order,text, etc.), theFLASK_MENUconfig should be taken into account for the currently registered menu entry - ...all the property getters of
MenuNode, i.e.order,text, etc. should first lookup in theFLASK_MENUconfig if their values are overridden.
- ...the
- Given the new behavior described above,
FLASK_MENUshould probably be renamed toMENU_OVERRIDES