mirror of
https://github.com/simonw/datasette.git
synced 2026-09-26 20:04:08 +02:00
* ruff>=0.16.0 See https://astral.sh/blog/ruff-v0.16.0 * uv run ruff check . --fix --unsafe-fixes * Ruff fixes by Claude Code Opus 5
29 lines
861 B
Python
29 lines
861 B
Python
from datasette import hookimpl
|
|
from datasette.resources import TableResource
|
|
|
|
|
|
@hookimpl
|
|
def table_actions(datasette, actor, database, table, request):
|
|
async def inner():
|
|
db = datasette.get_database(database)
|
|
if not db.is_mutable:
|
|
return []
|
|
if not await datasette.allowed(
|
|
action="alter-table",
|
|
resource=TableResource(database=database, table=table),
|
|
actor=actor,
|
|
):
|
|
return []
|
|
return [
|
|
{
|
|
"type": "button",
|
|
"label": "Alter table",
|
|
"description": "Change columns and primary key for this table.",
|
|
"attrs": {
|
|
"aria-label": f"Alter table {table}",
|
|
"data-table-action": "alter-table",
|
|
},
|
|
}
|
|
]
|
|
|
|
return inner
|