Skip to content
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

config: add config-variable for setting menus #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

martinobersteiner
Copy link

❤️ 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.

@@ -44,6 +47,10 @@ def url_preprocessor(route, args):
g._menu_kwargs = args
g._menu_route = route

def init_config(self, app):
"Initialize configuration."
app.config["FLASK_MENU"] = config.FLASK_MENU
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: to follow the convention in other modules

Suggested change
app.config["FLASK_MENU"] = config.FLASK_MENU
app.config.setdefault("FLASK_MENU", getattr(config, "FLASK_MENU"))

@slint
Copy link
Member

slint commented Apr 16, 2024

@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

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.

3 participants