sections: plugin_hooks:plugin-hook-table-actions
This data as json
id | page | ref | title | content | breadcrumbs | references |
---|---|---|---|---|---|---|
plugin_hooks:plugin-hook-table-actions | plugin_hooks | plugin-hook-table-actions | table_actions(datasette, actor, database, table, request) | datasette - Datasette class You can use this to access plugin configuration options via datasette.plugin_config(your_plugin_name) , or to execute SQL queries. actor - dictionary or None The currently authenticated actor . database - string The name of the database. table - string The name of the table. request - Request object or None The current HTTP request. This can be None if the request object is not available. This hook allows table actions to be displayed in a menu accessed via an action icon at the top of the table page. It should return a list of {"href": "...", "label": "..."} menu items. It can alternatively return an async def awaitable function which returns a list of menu items. This example adds a new table action if the signed in user is "root" : from datasette import hookimpl @hookimpl def table_actions(datasette, actor, database, table): if actor and actor.get("id") == "root": return [ { "href": datasette.urls.path( "/-/edit-schema/{}/{}".format( database, table ) ), "label": "Edit schema for this table", } ] Example: datasette-graphql | ["Plugin hooks"] | [{"href": "https://datasette.io/plugins/datasette-graphql", "label": "datasette-graphql"}] |