ADR-013 Phase 4: core-router surgery (plugin top-level routes)

This commit is contained in:
2026-07-18 23:26:39 -04:00
parent fd2ab0ab1c
commit a9274d71e8
5 changed files with 63 additions and 42 deletions

View File

@@ -7,9 +7,13 @@ import { loadEnabledPlugins, isPluginEnabled } from '../composables/enabledPlugi
import { useToast } from '../composables/toast'
import { getFacilityName } from '../utils/siteSettings'
// Auto-discover all route modules from routes/ directory
// Auto-discover all route modules from routes/ directory. A module's default
// export is AppLayout child routes; an optional `toplevel` export is full-screen
// routes (kiosk, print pages) that live OUTSIDE AppLayout. Both let a plugin own
// its routes, so pruning the plugin removes them with no core edit (ADR-013).
const routeModules = import.meta.glob('./routes/*.js', { eager: true })
const rawChildren = Object.values(routeModules).flatMap(m => m.default)
const pluginTopLevel = Object.values(routeModules).flatMap(m => m.toplevel || [])
// Gather the settings pages (spread across plugin route files) and nest them
// under a single two-pane shell so the grouped rail stays put while the right
@@ -66,21 +70,11 @@ const routes = [
name: 'shopfloor',
component: () => import('../views/ShopfloorDashboard.vue')
},
{
// Touch kiosk for taking 3D-printed parts: scan bin, scan badge, keypad.
// Open on purpose - see the decision record in the printedparts proposal.
path: '/parts-kiosk',
name: 'parts-kiosk',
component: () => import('../views/printedparts/PartsKiosk.vue'),
meta: { plugin: 'printedparts' }
},
{
path: '/tv',
name: 'tv',
component: () => import('../views/TVDashboard.vue'),
meta: { plugin: 'slides' }
},
// Print pages (standalone, no sidebar/header)
// Plugin-owned full-screen routes (kiosk, TV, plugin print pages) are
// contributed by each plugin's route file via its `toplevel` export.
...pluginTopLevel,
// Core print pages (standalone, no sidebar/header) - span multiple asset
// types or are core-owned, so they stay here.
{
path: '/print/machine-badge/:id',
name: 'print-machine-badge',
@@ -100,32 +94,6 @@ const routes = [
name: 'print-asset-label-batch',
component: () => import('../views/print/AssetLabelBatch.vue')
},
{
path: '/print/printer-qr',
name: 'print-printer-qr-batch',
component: () => import('../views/print/PrinterQRBatch.vue'),
meta: { plugin: 'printers' }
},
{
path: '/print/printer-qr/:id',
name: 'print-printer-qr-single',
component: () => import('../views/print/PrinterQRSingle.vue'),
meta: { plugin: 'printers' }
},
{
path: '/print/usb-labels',
name: 'print-usb-labels',
component: () => import('../views/print/USBLabelBatch.vue'),
meta: { plugin: 'usb' }
},
{
// Unlike the other print pages this one requires login: it lists the
// whole catalog, which is printedparts.view-gated at the API.
path: '/print/printedparts-labels',
name: 'print-printedparts-labels',
component: () => import('../views/print/PrintedPartsLabels.vue'),
meta: { requiresAuth: true, plugin: 'printedparts' }
},
{
path: '/',
component: AppLayout,

View File

@@ -39,3 +39,23 @@ export default [
meta: { requiresAuth: true, requiresAdmin: true, plugin: 'printedparts' }
}
]
// Full-screen routes (outside AppLayout), collected by the router's `toplevel`
// pass so pruning printedparts removes them without a core edit (ADR-013).
export const toplevel = [
{
// Touch kiosk for taking 3D-printed parts: scan bin, scan badge, keypad.
// Open on purpose - see the decision record in the printedparts proposal.
path: '/parts-kiosk',
name: 'parts-kiosk',
component: () => import('../../views/printedparts/PartsKiosk.vue'),
meta: { plugin: 'printedparts' }
},
{
// Requires login: lists the whole catalog, printedparts.view-gated at the API.
path: '/print/printedparts-labels',
name: 'print-printedparts-labels',
component: () => import('../../views/print/PrintedPartsLabels.vue'),
meta: { requiresAuth: true, plugin: 'printedparts' }
}
]

View File

@@ -40,3 +40,18 @@ export default [
meta: { requiresAuth: true, requiresAdmin: true, plugin: 'printers' }
}
]
export const toplevel = [
{
path: '/print/printer-qr',
name: 'print-printer-qr-batch',
component: () => import('../../views/print/PrinterQRBatch.vue'),
meta: { plugin: 'printers' }
},
{
path: '/print/printer-qr/:id',
name: 'print-printer-qr-single',
component: () => import('../../views/print/PrinterQRSingle.vue'),
meta: { plugin: 'printers' }
}
]

View File

@@ -0,0 +1,9 @@
export const toplevel = [
{
path: '/tv',
name: 'tv',
component: () => import('../../views/TVDashboard.vue'),
meta: { plugin: 'slides' }
}
]

View File

@@ -27,3 +27,12 @@ export default [
meta: { requiresAuth: true, plugin: 'usb' }
}
]
export const toplevel = [
{
path: '/print/usb-labels',
name: 'print-usb-labels',
component: () => import('../../views/print/USBLabelBatch.vue'),
meta: { plugin: 'usb' }
}
]