Trang Admin
Admin page vẫn là primitive page, nhưng được đặt trong phần quản trị workspace. Dùng nó cho cấu hình và vận hành app, không phải workflow thường ngày của member.
contributes:
ui:
- id: reports-admin
kind: nativeModule
surface: page
slot: admin.workspace.tab
sectionId: reports
label: Reports settings
route: /admin/reports/*
roles: [OWNER, ADMIN]
module:
entry: dist/ui/app.js
export: ReportsAdmin
styles: dist/ui/app.cssslot quyết định nơi Core mount page; Core vẫn truyền route/subroute như workspace page và phần nội dung do app sở hữu. Khai báo roles và vẫn kiểm tra authorization ở app backend vì việc ẩn UI không phải security boundary.
import { useAppFetch } from '@sota/platform';
export function ReportsAdmin() {
const appFetch = useAppFetch();
async function save() {
const response = await appFetch('/settings', {
method: 'PUT',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ enabled: true }),
});
if (!response.ok) throw new Error('Could not save settings');
}
return <button type="button" onClick={save}>Enable reports</button>;
}