Platform v2 step 1.7 (APPS_PLATFORM D-3, D-20, D-21, D-22, §5.2).
- Alembic replaces create_all + _run_migrations. 0001_cloud_baseline is
exactly the v1 production schema (incl. the dead menu_hours_en/_gr), checked
against a frozen fixture; schema.py refuses an unstamped v1 DB, so prod is
stamped once at cutover (DEPLOYMENT_GUIDE Part 6)
- 0002_v2_licensing: sites.modules (JSON), sites.module_catalog(_at),
plan_presets; existing sites get every module v1 had (KDS unlimited); the
same map is seeded as preset "Everything (v1 sites)"; dead columns dropped
- license token v: 2 with a normalized `modules` map
- heartbeat v2: request {version, local_ip, module_catalog} (catalogue stored
per site); response {license_token, latest_version, waiter_domain,
site_numeric_id} - the unsigned v1 license fields are gone
- sites API: create with a preset, PUT /{id}/modules (validated),
POST /{id}/apply-preset/{preset}; /api/presets CRUD
- sysadmin panel: Licensed modules card per site (built from the reported
catalogue, fallback list), preset picker on register, Presets page
- .dockerignore: local *.db, .env and tests no longer baked into the image
- tests (new): baseline = v1, unstamped refused, stamp+upgrade of a v1 DB,
drift, token v2 shape/signature, module edits, presets; CL-2/CL-7 rules
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
100 lines
4.3 KiB
React
100 lines
4.3 KiB
React
// Edits a license module map: { key: { limits?: {name: int|null}, exp?: ISO } } (APPS_PLATFORM §5.1).
|
|
// Core modules are always licensed and aren't shown. A limit field left empty uses the
|
|
// module's licensed default; "∞" sends null (unlimited). Expiry is optional, per module.
|
|
import { KIND_LABELS } from '../moduleCatalog'
|
|
|
|
function LimitInput({ limit, value, onChange }) {
|
|
const unlimited = value === null
|
|
const shown = value === undefined || value === null ? '' : String(value)
|
|
const fallback = limit.licensed_default === null || limit.licensed_default === undefined ? '∞' : limit.licensed_default
|
|
return (
|
|
<label className="flex items-center gap-1.5 text-xs text-gray-400">
|
|
<span className="font-mono">{limit.key}</span>
|
|
<input
|
|
type="number" min="0" disabled={unlimited} value={shown} placeholder={`default ${fallback}`}
|
|
onChange={e => onChange(e.target.value === '' ? undefined : Math.max(0, parseInt(e.target.value, 10) || 0))}
|
|
className="w-24 bg-gray-800 border border-gray-700 rounded px-2 py-1 text-gray-200 disabled:opacity-40"
|
|
/>
|
|
<button type="button" onClick={() => onChange(unlimited ? undefined : null)}
|
|
className={`px-1.5 py-0.5 rounded border ${unlimited ? 'border-cyan-500 text-cyan-300' : 'border-gray-700 text-gray-500'}`}
|
|
title="Unlimited">∞</button>
|
|
</label>
|
|
)
|
|
}
|
|
|
|
export default function ModuleMapEditor({ catalog, value, onChange }) {
|
|
const map = value || {}
|
|
const groups = ['feature', 'app', 'integration']
|
|
|
|
function setEntry(key, entry) {
|
|
const next = { ...map }
|
|
if (entry === undefined) delete next[key]
|
|
else next[key] = entry
|
|
onChange(next)
|
|
}
|
|
|
|
function setLimit(key, name, v) {
|
|
const entry = { ...(map[key] || {}) }
|
|
const limits = { ...(entry.limits || {}) }
|
|
if (v === undefined) delete limits[name]
|
|
else limits[name] = v
|
|
if (Object.keys(limits).length) entry.limits = limits
|
|
else delete entry.limits
|
|
setEntry(key, entry)
|
|
}
|
|
|
|
function setExp(key, date) {
|
|
const entry = { ...(map[key] || {}) }
|
|
if (date) entry.exp = `${date}T23:59:59+00:00`
|
|
else delete entry.exp
|
|
setEntry(key, entry)
|
|
}
|
|
|
|
return (
|
|
<div className="space-y-4">
|
|
{groups.map(kind => {
|
|
const mods = catalog.filter(m => m.kind === kind)
|
|
if (!mods.length) return null
|
|
return (
|
|
<div key={kind}>
|
|
<div className="text-[11px] uppercase tracking-wider text-gray-500 mb-2">{KIND_LABELS[kind]}</div>
|
|
<div className="space-y-1.5">
|
|
{mods.map(m => {
|
|
const on = m.key in map
|
|
const entry = map[m.key] || {}
|
|
return (
|
|
<div key={m.key} className={`rounded-lg border px-3 py-2 ${on ? 'border-cyan-800 bg-cyan-950/30' : 'border-gray-800'}`}>
|
|
<div className="flex items-center justify-between gap-3 flex-wrap">
|
|
<label className="flex items-center gap-2 text-sm text-gray-200 cursor-pointer">
|
|
<input type="checkbox" checked={on} onChange={e => setEntry(m.key, e.target.checked ? {} : undefined)} />
|
|
<span>{m.name}</span>
|
|
<span className="font-mono text-[11px] text-gray-500">{m.key}</span>
|
|
</label>
|
|
{on && (
|
|
<label className="flex items-center gap-1.5 text-xs text-gray-400">
|
|
expires
|
|
<input type="date" value={entry.exp ? entry.exp.slice(0, 10) : ''}
|
|
onChange={e => setExp(m.key, e.target.value)}
|
|
className="bg-gray-800 border border-gray-700 rounded px-2 py-1 text-gray-200" />
|
|
</label>
|
|
)}
|
|
</div>
|
|
{on && (m.limits || []).length > 0 && (
|
|
<div className="flex gap-4 flex-wrap mt-2 pl-6">
|
|
{m.limits.map(l => (
|
|
<LimitInput key={l.key} limit={l} value={entry.limits?.[l.key]}
|
|
onChange={v => setLimit(m.key, l.key, v)} />
|
|
))}
|
|
</div>
|
|
)}
|
|
</div>
|
|
)
|
|
})}
|
|
</div>
|
|
</div>
|
|
)
|
|
})}
|
|
</div>
|
|
)
|
|
}
|