mirror of
https://github.com/simonw/datasette.git
synced 2026-07-11 10:04:35 +02:00
Support for <button> items in action menus
Closes #2782 Animated demo: https://github.com/simonw/datasette/pull/2781#issuecomment-4703303274
This commit is contained in:
parent
3f7d389caf
commit
4ce2888e79
7 changed files with 179 additions and 20 deletions
|
|
@ -357,15 +357,30 @@ def menu_links(datasette, actor, request):
|
|||
|
||||
|
||||
@hookimpl
|
||||
def table_actions(datasette, database, table, actor):
|
||||
def table_actions(datasette, database, table, actor, request):
|
||||
if actor:
|
||||
return [
|
||||
actions = [
|
||||
{
|
||||
"href": datasette.urls.instance(),
|
||||
"label": f"Database: {database}",
|
||||
},
|
||||
{"href": datasette.urls.instance(), "label": f"Table: {table}"},
|
||||
]
|
||||
if request.args.get("_button"):
|
||||
actions.append(
|
||||
{
|
||||
"type": "button",
|
||||
"label": "Plugin button",
|
||||
"description": "Runs JavaScript from a plugin",
|
||||
"attrs": {
|
||||
"aria-label": "Plugin button for {}".format(table),
|
||||
"data-plugin-action": "plugin-button",
|
||||
"data-database": database,
|
||||
"data-table": table,
|
||||
},
|
||||
}
|
||||
)
|
||||
return actions
|
||||
|
||||
|
||||
@hookimpl
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue