generated from coulomb/repo-seed
feat(T02-T11): IHF Phase 1 schema, controllers, views, and helpers
- Schema: hubs, widgets, widget_versions, interaction_events (append-only trigger), annotations, users — single migration file - Web layer: Types, Routes, FrontController with auth + AutoRefresh layout - Controllers: Hubs (CRUD), Widgets (CRUD + versioning), InteractionEvents (JSON capture, canonical event_type validation), Annotations (threaded, append-only) - Sessions controller for IHP auth - Views: Hubs (index/show/new/edit), Widgets (index/show/new/edit), Annotations (index/new), Sessions (login) - widgetEnvelope helper with full data-* governance attributes - Integration tests: Hub CRUD, Widget versioning, event capture, append-only guard, annotation threading, validation Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
69
Web/View/Widgets/Index.hs
Normal file
69
Web/View/Widgets/Index.hs
Normal file
@@ -0,0 +1,69 @@
|
||||
module Web.View.Widgets.Index where
|
||||
|
||||
import Web.Types
|
||||
import Generated.Types
|
||||
import IHP.Prelude
|
||||
import IHP.ViewPrelude
|
||||
|
||||
data IndexView = IndexView
|
||||
{ widgets :: ![Widget]
|
||||
, hubs :: ![Hub]
|
||||
}
|
||||
|
||||
instance View IndexView where
|
||||
html IndexView { .. } = [hsx|
|
||||
<div class="flex items-center justify-between mb-6">
|
||||
<h1 class="text-2xl font-semibold">Widgets</h1>
|
||||
<a href={NewWidgetAction}
|
||||
class="bg-indigo-600 text-white text-sm font-medium px-4 py-2 rounded hover:bg-indigo-700">
|
||||
Register Widget
|
||||
</a>
|
||||
</div>
|
||||
<div class="bg-white rounded-lg border border-gray-200 overflow-hidden">
|
||||
<table class="w-full text-sm">
|
||||
<thead class="bg-gray-50 border-b border-gray-200">
|
||||
<tr>
|
||||
<th class="text-left px-4 py-3 font-medium text-gray-700">Name</th>
|
||||
<th class="text-left px-4 py-3 font-medium text-gray-700">Hub</th>
|
||||
<th class="text-left px-4 py-3 font-medium text-gray-700">Type</th>
|
||||
<th class="text-left px-4 py-3 font-medium text-gray-700">Status</th>
|
||||
<th class="text-left px-4 py-3 font-medium text-gray-700">Version</th>
|
||||
<th class="px-4 py-3"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{forEach widgets (renderWidget hubs)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|]
|
||||
|
||||
renderWidget :: [Hub] -> Widget -> Html
|
||||
renderWidget hubs w = [hsx|
|
||||
<tr class="border-b border-gray-100 hover:bg-gray-50">
|
||||
<td class="px-4 py-3">
|
||||
<a href={ShowWidgetAction { widgetId = w.id }}
|
||||
class="font-medium text-indigo-600 hover:text-indigo-800">
|
||||
{w.name}
|
||||
</a>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-gray-500">{hubName hubs w.hubId}</td>
|
||||
<td class="px-4 py-3 text-gray-500">{w.widgetType}</td>
|
||||
<td class="px-4 py-3">
|
||||
<span class="inline-block px-2 py-0.5 rounded text-xs bg-green-100 text-green-800">
|
||||
{w.status}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-gray-500 text-xs">v{show w.version}</td>
|
||||
<td class="px-4 py-3 text-right">
|
||||
<a href={EditWidgetAction { widgetId = w.id }}
|
||||
class="text-gray-500 hover:text-gray-700 text-xs">Edit</a>
|
||||
</td>
|
||||
</tr>
|
||||
|]
|
||||
|
||||
hubName :: [Hub] -> Id Hub -> Text
|
||||
hubName hubs hubId =
|
||||
case find (\h -> h.id == hubId) hubs of
|
||||
Just h -> h.name
|
||||
Nothing -> "—"
|
||||
Reference in New Issue
Block a user