From 909c85cd2b64646edaaa8e3c19f5cd4e51a13fad Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Tue, 12 Mar 2024 14:25:07 -0700 Subject: [PATCH] view_actions plugin hook, closes #2297 --- datasette/hookspecs.py | 5 +++++ datasette/templates/table.html | 6 +++--- datasette/views/table.py | 30 ++++++++++++++++++------------ docs/plugin_hooks.rst | 26 +++++++++++++++++++++++++- tests/fixtures.py | 1 + tests/plugins/my_plugin.py | 12 ++++++++++++ tests/test_plugins.py | 26 +++++++++++++++++++++----- 7 files changed, 85 insertions(+), 21 deletions(-) diff --git a/datasette/hookspecs.py b/datasette/hookspecs.py index 5a8439b4..6ce1e85e 100644 --- a/datasette/hookspecs.py +++ b/datasette/hookspecs.py @@ -145,6 +145,11 @@ def table_actions(datasette, actor, database, table, request): """Links for the table actions menu""" +@hookspec +def view_actions(datasette, actor, database, view, request): + """Links for the view actions menu""" + + @hookspec def query_actions(datasette, actor, database, query_name, request, sql, params): """Links for the query and canned query actions menu""" diff --git a/datasette/templates/table.html b/datasette/templates/table.html index 1d328366..505335d6 100644 --- a/datasette/templates/table.html +++ b/datasette/templates/table.html @@ -24,17 +24,17 @@ -{% set links = table_actions() %}{% if links %} +{% set links = actions() %}{% if links %}