feat(topology): add personal/global scope to lab templates
Labs can now be marked as Personal or Global when creating or editing. Personal topologies are visible only to the owner and admins; others cannot see, book, or edit them. Global topologies are visible to all but editable only by the creator, admins, or legacy (migrated) labs. - DB: idempotent ALTER TABLE adds scope + ownerId columns to labs - API: POST sets ownerId from JWT; PUT/DELETE enforce ownership (403 for unauthorized edits; legacy ownerId='' remains freely editable) - Types: LabTemplate extended with scope and ownerId fields - LabTemplates UI: sectioned list (My / Global / Others' Personal), Personal/Global toggle in form, Lock/Globe badges on cards, edit+delete buttons hidden for non-owners - BookingCalendar: personal labs filtered from selects/quick booking, optgroup grouping for Global vs Personal in topology dropdown - Light mode: add missing bg-slate-950/50 and border-slate-800/50 overrides so the Global badge renders correctly
This commit is contained in:
@ -99,6 +99,10 @@ db.exec(`
|
||||
);
|
||||
`);
|
||||
|
||||
// Idempotent migrations — SQLite throws on duplicate column; the catch makes them safe to re-run.
|
||||
try { db.prepare("ALTER TABLE labs ADD COLUMN scope TEXT NOT NULL DEFAULT 'global'").run(); } catch {}
|
||||
try { db.prepare("ALTER TABLE labs ADD COLUMN ownerId TEXT NOT NULL DEFAULT ''").run(); } catch {}
|
||||
|
||||
// Seed default settings — INSERT OR IGNORE writes a key only if it is absent.
|
||||
const DEFAULT_SETTINGS: Record<string, string> = {
|
||||
azure_enabled: 'false',
|
||||
|
||||
Reference in New Issue
Block a user