mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 09:38:54 +00:00
feat(plugins): plugins can add POI categories to the map and answer them
A new manifest capability poiCategories (up to 4, icon from an allow-list, strict #rrggbb color) and the hook poiCategoryProvider.getPois behind the hook:poi-category-provider permission. GET /api/plugin-pois in the plugin contributions module answers them in the /api/maps/pois shape, with search_plugin_pois as the MCP twin. plugin: ids no longer count as Google place ids. SDK 1.8.0 carries the types, validation and docs. On the map, one hook merges the built-in categories with the ones active plugins declare, and the pill shows the plugin chips after a divider on desktop and phone, scrolling sideways instead of shrinking a chip below its touch target. A plugin chip searches through a repo that refuses offline and parses the answer strictly. Its pins, on Leaflet and GL, use the category's own icon and color, both checked again before they reach any markup, and the hover card lists the plugin's details as escaped text. A plugin POI can be added as a place like any other. The admin panels on desktop and phone show a chip for the new permission and the categories a plugin would add, from one shared module. Addresses discussion #1781.
This commit is contained in:
@@ -63,6 +63,46 @@ describe('PluginsFeedController', () => {
|
||||
expect(profiles.every(p => p.label.length <= 40)).toBe(true);
|
||||
});
|
||||
|
||||
describe('poiCategories (#1781)', () => {
|
||||
const cat = { id: 'trailheads', label: 'Trailheads', labels: { de: 'Wanderparkplätze' }, icon: 'Signpost', color: '#2f855a' };
|
||||
const granted = JSON.stringify(['hook:poi-category-provider']);
|
||||
|
||||
it('serves them only alongside the recorded hook:poi-category-provider grant', () => {
|
||||
rows.value = [
|
||||
row({ id: 'granted', capabilities: JSON.stringify({ poiCategories: [cat] }), granted_permissions: granted }),
|
||||
row({ id: 'ungranted', capabilities: JSON.stringify({ poiCategories: [cat] }) }),
|
||||
row({ id: 'searchOnly', capabilities: JSON.stringify({ poiCategories: [cat] }), granted_permissions: JSON.stringify(['hook:search-provider']) }),
|
||||
];
|
||||
const { plugins } = c.list();
|
||||
expect(plugins.find(p => p.id === 'granted')?.poiCategories).toEqual([cat]);
|
||||
expect(plugins.find(p => p.id === 'ungranted')?.poiCategories).toBeUndefined();
|
||||
expect(plugins.find(p => p.id === 'searchOnly')?.poiCategories).toBeUndefined();
|
||||
});
|
||||
|
||||
it('re-validates a hand-edited row: bad colour, icon or id dropped, duplicates and the fifth one gone', () => {
|
||||
rows.value = [row({
|
||||
capabilities: JSON.stringify({
|
||||
poiCategories: [
|
||||
{ ...cat, color: '#fff;background:url(https://tracker.example)' },
|
||||
{ ...cat, id: 'x', icon: 'Skull' },
|
||||
{ ...cat, id: '../x' },
|
||||
{ ...cat, id: 'ok', label: 'Water \u{1F6B0}' },
|
||||
{ ...cat, id: 'ok' },
|
||||
{ ...cat, id: 'late' },
|
||||
],
|
||||
}),
|
||||
granted_permissions: granted,
|
||||
})];
|
||||
// The first four entries are the ones read (the cap), and only one of them survives.
|
||||
expect(c.list().plugins[0].poiCategories).toEqual([{ ...cat, id: 'ok', label: 'Water' }]);
|
||||
});
|
||||
|
||||
it('omits the field when nothing survives', () => {
|
||||
rows.value = [row({ capabilities: JSON.stringify({ poiCategories: [{ ...cat, color: 'red' }] }), granted_permissions: granted })];
|
||||
expect(c.list().plugins[0]).not.toHaveProperty('poiCategories');
|
||||
});
|
||||
});
|
||||
|
||||
it('flags geolocation only when the grant is recorded', () => {
|
||||
rows.value = [
|
||||
row({ id: 'granted', granted_permissions: JSON.stringify(['geolocation:read']) }),
|
||||
|
||||
Reference in New Issue
Block a user