flask-menu icon indicating copy to clipboard operation
flask-menu copied to clipboard

config: add config-variable for setting menus

Open martinobersteiner opened this issue 1 year ago • 1 comments

: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:

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:

  1. You license your contribution under the same terms as the current repository’s license.
  2. You agree that you have the right to license your contribution under the current repository’s license.

martinobersteiner avatar Apr 09 '24 10:04 martinobersteiner

@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_MENU to COMMUNITY_MENU_OVERIDDES, USER_DASHBOARD_MENU_OEVERRIDES, etc.
  • Later on consolidate the code in Flask-Menu

The fully integrated solution to be implemented in Flask-Menu would be:

  • Setting the FLASK_MENU config 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.), the FLASK_MENU config 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 the FLASK_MENU config if their values are overridden.
  • Given the new behavior described above, FLASK_MENU should probably be renamed to MENU_OVERRIDES

slint avatar Apr 16 '24 09:04 slint