-
-
Notifications
You must be signed in to change notification settings - Fork 644
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
Navigation menu plus plugin hook #1064
Comments
I used a datasette/datasette/templates/base.html Lines 16 to 36 in 0d7ac76
I added a bit of JavaScript so that clicking outside the menu would close it: datasette/datasette/templates/base.html Lines 59 to 74 in 0d7ac76
|
Tips for making this accessible: https://css-tricks.com/accessible-svgs/ |
So what should go in this menu? If the user is logged in as root, I'll link to the various debug pages. If they're not logged in at all I don't think the menu should appear. If they are logged in as anyone, it should display to give them access to the "log out" button. Plugins can add links to it. If those plugins add links, the menu will display. |
How should the plugin hook work? Here's the first version of the HTML: <div class="nav-menu-inner">
<ul>
<li><a href="{{ urls.instance() }}">Home</a></li>
<li><a href="{{ urls.path('/-/plugins') }}">Installed plugins</a></li>
<li><a href="{{ urls.path('/-/versions') }}">Software versions</a></li>
<li><a href="{{ urls.path('/-/metadata') }}">Metadata</a></li>
{% if show_logout %}
<form action="{{ urls.logout() }}" method="post">
<input type="hidden" name="csrftoken" value="{{ csrftoken() }}">
<button class="button-as-link">Log out</button>
</form>{% endif %}
</ul>
</div> |
Should plugins be able to add forms like the logout form here, or should they be restricted to adding navigation links? I can't think of a reason a plugin would need to add a form. The logout form is a special case to protect against logout-csrf attacks. So I think plugins get to return a list of dictionaries, each with a return [{
"label": "Upload CSVs",
"href": datasette.urls.path("/-/upload-csvs")
}] But... is there an argument for returning headings, to divide up the menu? I think so. I also like the idea that a default plugin checks for the |
Or... plugins could return HTML - maybe optionally using helper functions to generate common HTML such that plugins which use the helpers can have their HTML modified in the future. |
Plugins returning HTML makes more sense for some of the other areas that plugins will be able to inject content - e.g. injecting content on the table or row page above the table. If I'm going to have that as a pattern though it may make sense to use HTML here, since that will be consistent with other places that plugins can inject additional content. |
I'm torn on this one. I think I have a very slight preference for plugins returning structured objects as opposed to HTML. Less likely to regret that choice in the future? |
I'm going to go with a list of |
Needed for #690. Prototype in 0d7ac76
The text was updated successfully, but these errors were encountered: