mirror of
https://github.com/simonw/datasette.git
synced 2026-05-28 04:46:18 +02:00
Remove source and source_key columns from JumpSQL
Refs https://github.com/simonw/datasette/pull/2732#issuecomment-4527290391
This commit is contained in:
parent
c73ed1ee4e
commit
cef6aa85b6
6 changed files with 9 additions and 35 deletions
|
|
@ -66,12 +66,10 @@ def jump_items_sql(datasette, actor, request):
|
|||
label=label,
|
||||
url=datasette.urls.path(path),
|
||||
description=description,
|
||||
source="datasette.default_debug_menu",
|
||||
sort_key=70 + index,
|
||||
search_text=f"debug {label} {description}",
|
||||
item_type="debug",
|
||||
)
|
||||
for index, (path, label, description) in enumerate(DEBUG_MENU_ITEMS)
|
||||
for path, label, description in DEBUG_MENU_ITEMS
|
||||
]
|
||||
|
||||
return inner
|
||||
|
|
|
|||
|
|
@ -29,8 +29,6 @@ def jump_items_sql(datasette, actor, request):
|
|||
'database', parent
|
||||
) AS url,
|
||||
parent AS search_text,
|
||||
10 AS sort_key,
|
||||
'datasette' AS source,
|
||||
NULL AS display_name
|
||||
FROM allowed_databases
|
||||
""",
|
||||
|
|
@ -51,8 +49,6 @@ def jump_items_sql(datasette, actor, request):
|
|||
'table', allowed_tables.child
|
||||
) AS url,
|
||||
allowed_tables.parent || ' ' || allowed_tables.child AS search_text,
|
||||
CASE WHEN catalog_views.view_name IS NULL THEN 20 ELSE 25 END AS sort_key,
|
||||
'datasette' AS source,
|
||||
NULL AS display_name
|
||||
FROM allowed_tables
|
||||
LEFT JOIN catalog_views
|
||||
|
|
@ -76,8 +72,6 @@ def jump_items_sql(datasette, actor, request):
|
|||
'query', allowed_queries.child
|
||||
) AS url,
|
||||
allowed_queries.parent || ' ' || allowed_queries.child AS search_text,
|
||||
30 AS sort_key,
|
||||
'datasette' AS source,
|
||||
NULL AS display_name
|
||||
FROM allowed_queries
|
||||
""",
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@ class JumpSQL:
|
|||
label: str,
|
||||
url: str,
|
||||
description: str = "Menu item",
|
||||
source: str = "datasette",
|
||||
sort_key: int = 50,
|
||||
search_text: str | None = None,
|
||||
display_name: str | None = None,
|
||||
item_type: str = "menu",
|
||||
|
|
@ -35,8 +33,6 @@ class JumpSQL:
|
|||
:description AS description,
|
||||
:url AS url,
|
||||
:search_text AS search_text,
|
||||
:sort_key AS sort_key,
|
||||
:source AS source,
|
||||
:display_name AS display_name
|
||||
""",
|
||||
params={
|
||||
|
|
@ -45,8 +41,6 @@ class JumpSQL:
|
|||
"description": description,
|
||||
"url": url,
|
||||
"search_text": search_text,
|
||||
"sort_key": sort_key,
|
||||
"source": source,
|
||||
"display_name": display_name,
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -993,8 +993,6 @@ class JumpView(BaseView):
|
|||
description,
|
||||
url,
|
||||
search_text,
|
||||
sort_key,
|
||||
source,
|
||||
display_name
|
||||
FROM (
|
||||
{fragment_sql}
|
||||
|
|
@ -1016,7 +1014,13 @@ class JumpView(BaseView):
|
|||
WHEN lower(COALESCE(display_name, label)) LIKE lower(:q || '%') THEN 1
|
||||
ELSE 2
|
||||
END,
|
||||
sort_key,
|
||||
CASE type
|
||||
WHEN 'database' THEN 10
|
||||
WHEN 'table' THEN 20
|
||||
WHEN 'view' THEN 25
|
||||
WHEN 'query' THEN 30
|
||||
ELSE 50
|
||||
END,
|
||||
length(COALESCE(display_name, label)),
|
||||
label
|
||||
LIMIT 101
|
||||
|
|
|
|||
|
|
@ -1916,12 +1916,6 @@ The SQL query must return these columns:
|
|||
``search_text``
|
||||
Text that should be searched by the ``?q=`` parameter.
|
||||
|
||||
``sort_key``
|
||||
A numeric value used to order results.
|
||||
|
||||
``source``
|
||||
A string identifying the plugin that supplied the result.
|
||||
|
||||
``display_name``
|
||||
A human-readable label for the result, or ``NULL``. Datasette returns this as ``display_name`` in the JSON API, and the jump menu shows it as the primary readable label with ``name`` shown underneath.
|
||||
|
||||
|
|
@ -1943,8 +1937,6 @@ This example adds a "Plugin dashboard" result for signed-in users:
|
|||
description="Review plugin status and configuration.",
|
||||
url="/-/plugin-dashboard",
|
||||
search_text="plugin dashboard",
|
||||
sort_key=80,
|
||||
source="my-plugin",
|
||||
display_name="Plugin dashboard",
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -147,8 +147,6 @@ async def test_jump_sql_menu_item_helper(ds_for_jump):
|
|||
label="Plugin dashboard",
|
||||
url="/-/plugin-dashboard",
|
||||
description="Plugin tool",
|
||||
source="test-plugin",
|
||||
sort_key=70,
|
||||
search_text="dashboard plugin",
|
||||
display_name="Plugin Dashboard",
|
||||
item_type="plugin",
|
||||
|
|
@ -162,8 +160,6 @@ async def test_jump_sql_menu_item_helper(ds_for_jump):
|
|||
"description": "Plugin tool",
|
||||
"url": "/-/plugin-dashboard",
|
||||
"search_text": "dashboard plugin",
|
||||
"sort_key": 70,
|
||||
"source": "test-plugin",
|
||||
"display_name": "Plugin Dashboard",
|
||||
}
|
||||
|
||||
|
|
@ -200,7 +196,7 @@ async def test_debug_menu_items_are_in_jump_for_debug_menu_permission():
|
|||
}
|
||||
assert all(descriptions_by_name.values())
|
||||
assert descriptions_by_name["Databases"] == (
|
||||
"List of databases known to this Datasette instance"
|
||||
"List of databases known to this Datasette instance."
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -228,8 +224,6 @@ async def test_jump_uses_plugin_sql_with_namespaced_parameters(ds_for_jump):
|
|||
'Plugin supplied item' AS description,
|
||||
'/-/plugin-dashboard' AS url,
|
||||
'plugin dashboard ' || :actor_id AS search_text,
|
||||
80 AS sort_key,
|
||||
'test-plugin' AS source,
|
||||
'Plugin dashboard for ' || :actor_id AS display_name
|
||||
""",
|
||||
params={"actor_id": actor["id"] if actor else "anonymous"},
|
||||
|
|
@ -275,8 +269,6 @@ async def test_jump_resolves_url_descriptors_from_sql(ds_for_jump):
|
|||
'table', 'comments'
|
||||
) AS url,
|
||||
'table descriptor comments' AS search_text,
|
||||
80 AS sort_key,
|
||||
'test-plugin' AS source,
|
||||
NULL AS display_name
|
||||
""")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue