feat(manager): remove the KDS page; app cards lead to pairing a screen (platform-v2 3.2d)
- Deleted pages/KdsPage.jsx, its /kds route, nav entry and text: the kitchen display runs only on paired screens (D-25). - Apps: cards of apps that run on a screen get "Set up a screen" (core.devices.manage) → /devices?pair=<app>, which opens the pair dialog on that app. - manager.mjs: no "Open" on the KDS card, "Set up a screen" lands on the pair dialog, /kds is gone; the module-off rule stays covered by the Notes checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,9 +12,6 @@ import client from './api/client'
|
||||
import LoginPage from './pages/LoginPage'
|
||||
import SetupWizard from './pages/SetupWizard'
|
||||
|
||||
// Standalone (no shell)
|
||||
import KdsPage from './pages/KdsPage'
|
||||
|
||||
// Operation
|
||||
import DashboardPage from './pages/DashboardPage'
|
||||
import TablesPage from './pages/TablesPage'
|
||||
@@ -140,7 +137,6 @@ export default function App() {
|
||||
<Route element={<ManagerRoot />}>
|
||||
<Route path="/setup" element={<SetupWizard />} />
|
||||
<Route path="/login" element={<SetupGuard><LoginPage /></SetupGuard>} />
|
||||
<Route path="/kds" element={<RequireAuth><RouteGuard><KdsPage /></RouteGuard></RequireAuth>} />
|
||||
|
||||
<Route path="/" element={<RequireAuth><LiveProvider><AppLayout /></LiveProvider></RequireAuth>}>
|
||||
<Route index element={<Navigate to="/dashboard" replace />} />
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,7 @@
|
||||
// - Per-app settings (3.1a): each app's device_app.config fields are rendered by
|
||||
// DeviceConfigFields in the pair and edit dialogs and sent as `config`.
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import { useSearchParams } from 'react-router-dom'
|
||||
import toast from 'react-hot-toast'
|
||||
import { MonitorSmartphone, Plus } from 'lucide-react'
|
||||
import { errorMessage, parseError } from '@xenia/api'
|
||||
@@ -52,6 +53,15 @@ export default function DevicesPage() {
|
||||
useEffect(() => { load() }, [load])
|
||||
|
||||
const apps = useMemo(() => (modules || []).filter(m => m.device_app), [modules])
|
||||
|
||||
// /devices?pair=<app> (Apps → "Set up a screen", 3.2d): open the pair dialog on that app
|
||||
const [params, setParams] = useSearchParams()
|
||||
const pairApp = params.get('pair')
|
||||
useEffect(() => {
|
||||
if (!pairApp || !modules) return
|
||||
setDialog({ kind: 'pair', app: pairApp })
|
||||
setParams({}, { replace: true })
|
||||
}, [pairApp, modules, setParams])
|
||||
const appOn = key => !!apps.find(a => a.key === key)?.effective
|
||||
const usage = useMemo(() => (devices && modules ? deviceUsage(devices, modules) : {}), [devices, modules])
|
||||
const appName = key => t(`modules:${key}.name`, { defaultValue: key })
|
||||
@@ -159,7 +169,7 @@ export default function DevicesPage() {
|
||||
</label>
|
||||
|
||||
{dialog?.kind === 'pair' && (
|
||||
<PairDialog apps={apps} usage={usage} devices={live} appName={appName} limitLabel={limitLabel}
|
||||
<PairDialog apps={apps} usage={usage} devices={live} appName={appName} limitLabel={limitLabel} initialApp={dialog.app}
|
||||
onClose={() => setDialog(null)}
|
||||
onPair={body => act(() => client.post('/api/devices', body), t('devices.paired', { name: body.name }))} />
|
||||
)}
|
||||
@@ -200,11 +210,11 @@ function useSubmit(fn) {
|
||||
return { busy, error, run }
|
||||
}
|
||||
|
||||
function PairDialog({ apps, usage, devices, appName, limitLabel, onClose, onPair }) {
|
||||
function PairDialog({ apps, usage, devices, appName, limitLabel, initialApp, onClose, onPair }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const usable = apps.filter(a => a.effective)
|
||||
const [code, setCode] = useState('')
|
||||
const [appKey, setAppKey] = useState(usable.find(a => hasRoom(usage, a.key))?.key || usable[0]?.key || '')
|
||||
const [appKey, setAppKey] = useState(usable.find(a => a.key === initialApp)?.key || usable.find(a => hasRoom(usage, a.key))?.key || usable[0]?.key || '')
|
||||
const [name, setName] = useState('')
|
||||
const [mode, setMode] = useState('')
|
||||
const [link, setLink] = useState('')
|
||||
|
||||
@@ -13,8 +13,9 @@ import { Button, Dialog, EmptyState, Spinner, Switch } from '@xenia/ui'
|
||||
import client from '../../api/client'
|
||||
import { moduleState, stoppedBy } from './modulesLogic'
|
||||
|
||||
// Modules with a page in the manager: the card gets an "Open" button
|
||||
const OPEN_PATH = { kds: '/kds', caller_id: '/apps/phone' }
|
||||
// Modules with a page in the manager: the card gets an "Open" button. Apps that run on a paired
|
||||
// screen (the KDS since 3.2d) get "Set up a screen" instead → Devices, pair dialog on that app.
|
||||
const OPEN_PATH = { caller_id: '/apps/phone' }
|
||||
|
||||
export function AppsPage() {
|
||||
const { t } = useTranslation('manager')
|
||||
@@ -118,6 +119,7 @@ function ModulesPage({ kinds, intro }) {
|
||||
|
||||
function ModuleCard({ m, modules, canManage, busy, onToggle }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const canPair = useCan('core.devices.manage')
|
||||
const navigate = useNavigate()
|
||||
const name = t(`modules:${m.key}.name`)
|
||||
const state = moduleState(m)
|
||||
@@ -164,6 +166,9 @@ function ModuleCard({ m, modules, canManage, busy, onToggle }) {
|
||||
{OPEN_PATH[m.key] && state === 'on' && (
|
||||
<div><Button size="sm" variant="secondary" onClick={() => navigate(OPEN_PATH[m.key])}>{t('modules.open')}</Button></div>
|
||||
)}
|
||||
{m.device_app && state === 'on' && canPair && (
|
||||
<div><Button size="sm" variant="secondary" onClick={() => navigate(`/devices?pair=${m.key}`)}>{t('modules.setUpScreen')}</Button></div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { pageFor } from './nav'
|
||||
/**
|
||||
* Guards whatever route is showing by its path, with the same rules as the sidebar
|
||||
* (shell/nav.js): module off → "this feature is turned off"; key missing → "no access".
|
||||
* Mounted around the layout's <Outlet> (and /kds), so a new page only needs a nav entry.
|
||||
* Mounted around the layout's <Outlet>, so a new page only needs a nav entry.
|
||||
*/
|
||||
export default function RouteGuard({ children }) {
|
||||
const { pathname } = useLocation()
|
||||
|
||||
@@ -106,7 +106,6 @@ export const NAV_BOTTOM = [
|
||||
// Pages that aren't in the sidebar but still have a title and a guard
|
||||
const EXTRA = [
|
||||
{ to: '/apps/phone', label: 'nav.phone', parent: 'nav.integrations', module: 'caller_id', perm: DASH },
|
||||
{ to: '/kds', label: 'nav.kds', module: 'kds', perm: DASH },
|
||||
{ prefix: '/orders/', label: 'nav.order', module: 'ordering', perm: DASH },
|
||||
]
|
||||
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
"phone": "Τηλέφωνο",
|
||||
"settings": "Ρυθμίσεις",
|
||||
"order": "Παραγγελία",
|
||||
"kds": "Οθόνη κουζίνας",
|
||||
"soon": "σύντομα",
|
||||
"integrations": "Συνδέσεις",
|
||||
"license": "Άδεια",
|
||||
@@ -104,7 +103,8 @@
|
||||
"confirmOffBody": "Όσο είναι κλειστό, σταματούν να λειτουργούν και: {{list}}.",
|
||||
"turnOff": "Απενεργοποίηση",
|
||||
"changed": "{{name}}: {{state}}",
|
||||
"readOnly": "Μόνο όποιος έχει δικαίωμα διαχείρισης εφαρμογών μπορεί να τα αλλάξει."
|
||||
"readOnly": "Μόνο όποιος έχει δικαίωμα διαχείρισης εφαρμογών μπορεί να τα αλλάξει.",
|
||||
"setUpScreen": "Ρύθμιση οθόνης"
|
||||
},
|
||||
"licensePage": {
|
||||
"status": "Κατάσταση",
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
"phone": "Phone",
|
||||
"settings": "Settings",
|
||||
"order": "Order",
|
||||
"kds": "Kitchen display",
|
||||
"soon": "soon",
|
||||
"integrations": "Integrations",
|
||||
"license": "License",
|
||||
@@ -104,7 +103,8 @@
|
||||
"confirmOffBody": "These stop working too while it's off: {{list}}.",
|
||||
"turnOff": "Turn off",
|
||||
"changed": "{{name}} is now {{state}}",
|
||||
"readOnly": "Only someone with permission to manage apps can change these."
|
||||
"readOnly": "Only someone with permission to manage apps can change these.",
|
||||
"setUpScreen": "Set up a screen"
|
||||
},
|
||||
"licensePage": {
|
||||
"status": "Status",
|
||||
|
||||
+11
-10
@@ -150,7 +150,16 @@ try {
|
||||
r.check('apps: turning off Ordering first lists what stops with it', ['Kitchen display', 'Waiter app', 'Pricing'].every(n => stopped.includes(n)), stopped)
|
||||
await page.getByRole('dialog').getByRole('button', { name: 'Cancel' }).click()
|
||||
r.check('apps: Cancel leaves Ordering on', await card('ordering').getAttribute('data-state') === 'on')
|
||||
r.check('apps: a card with a page has "Open" (KDS)', await card('kds').getByRole('button', { name: 'Open' }).count() === 1)
|
||||
// 3.2d: the KDS lives on paired screens only; its card leads to pairing one
|
||||
r.check('apps: the KDS card has no "Open" (no KDS page in the manager)', await card('kds').getByRole('button', { name: 'Open' }).count() === 0)
|
||||
await card('kds').getByRole('button', { name: 'Set up a screen' }).click()
|
||||
await page.getByLabel('App to run').waitFor({ timeout: 8000 }).catch(() => {})
|
||||
r.check('apps: "Set up a screen" → Devices with the pair dialog on the kitchen display',
|
||||
new URL(page.url()).pathname === '/devices' && await page.getByLabel('App to run').inputValue().catch(() => '') === 'kds', page.url())
|
||||
await page.getByRole('dialog').getByRole('button', { name: 'Cancel' }).click()
|
||||
await page.goto(`${APP}/kds`)
|
||||
await sleep(1500)
|
||||
r.check('apps: /kds is no longer a manager page', await page.getByTestId('app-kds').count() === 0 && !(await page.content()).includes('kds-board'))
|
||||
|
||||
// ── 2.6c: Integrations and License ─────────────────────────────────────────
|
||||
await page.goto(`${APP}/integrations`)
|
||||
@@ -256,16 +265,8 @@ try {
|
||||
await page.getByTestId('lock-screen').count() === 0 && new URL(page.url()).pathname === '/dashboard'
|
||||
&& await page.evaluate(() => localStorage.getItem('manager_token')) === tokenBeforeLock)
|
||||
|
||||
// ── A module turned off: /kds shows the "turned off" screen ────────────────
|
||||
// ("a module turned off shows its page as turned off" is checked with Notes above; the KDS page went in 3.2d)
|
||||
const mgr = await page.evaluate(() => localStorage.getItem('manager_token'))
|
||||
await api('PUT', '/api/platform/modules/kds', { token: mgr, body: { enabled: false } })
|
||||
await page.goto(`${APP}/kds`)
|
||||
await sleep(2000)
|
||||
r.check('kds off → "feature turned off" screen', await page.locator('.x-empty__title').count() === 1, await page.locator('body').innerText().then(t => t.slice(0, 80)))
|
||||
await api('PUT', '/api/platform/modules/kds', { token: mgr, body: { enabled: true } })
|
||||
await page.goto(`${APP}/kds`)
|
||||
await sleep(2000)
|
||||
r.check('kds on again → the KDS renders', await page.locator('.x-empty__title').count() === 0)
|
||||
|
||||
// ── 2.6b: five wrong PINs on the lock screen end the session ───────────────
|
||||
await page.goto(`${APP}/dashboard`)
|
||||
|
||||
Reference in New Issue
Block a user