Skip to main content

Crate gize_admin

Crate gize_admin 

Source
Expand description

Admin UI generator for Gize (ADR-006).

gize make admin generates a separate Vite + React + TypeScript SPA under admin/, driven by the manifest. The app is data-driven: resources_ts emits one descriptor (fields, relationships and a Zod schema) per resource from gize.toml, and generic components render List/Create/Edit/Delete for any of them. It talks to the backend through a Vite dev proxy (/api → the API), so no CORS or backend changes are needed.

The UI is a token-based design system (light + dark theme) with a Django-inspired layout: an app shell, a changelist with search/filters/pagination/bulk actions, and a slide-over drawer form. Templates are Rust functions returning file contents.

Functions§

api_ts
admin/src/api.ts — a tiny typed fetch client that attaches the JWT and hits /api.
app_tsx
admin/src/App.tsx — the app shell (topbar, sidebar, drawer, toasts, theme toggle).
auth_tsx
admin/src/auth.tsx — token storage hook and the branded login screen.
env_example
admin/.env.example.
gitignore
admin/.gitignore.
icons_tsx
admin/src/icons.tsx — a small inline SVG icon set.
index_html
admin/index.html. Sets the theme before first paint to avoid a flash.
main_tsx
admin/src/main.tsx.
package_json
admin/package.json — the SPA’s dependencies and scripts.
resource_form_tsx
admin/src/ResourceForm.tsx — the drawer form (fieldsets, typed inputs, FK selects).
resource_tsx
admin/src/Resource.tsx — the changelist (search, filters, pagination, bulk actions).
resources_ts
admin/src/resources.ts — the descriptors generated from the manifest (ADR-006): one entry per resource with its editable fields (each field carrying its kind, and a ref target for foreign keys) and a Zod schema mirroring the backend validation.
styles_css
admin/src/styles.css — the token-based design system (light + dark).
theme_ts
admin/src/theme.ts — light/dark theme helpers (persisted, system-aware).
toast_tsx
admin/src/toast.tsx — a lightweight toast (event-based, no context wiring).
tsconfig
admin/tsconfig.json.
vite_config
admin/vite.config.ts — React, and a dev proxy so /api/* reaches the backend.