generated from coulomb/repo-seed
Some checks failed
Test / test (push) Has been cancelled
Implements IHUB-WP-0009: closes four GAAF-2026 gaps before domain hub work begins. - TypeRegistry helper + controllers/views (hub_kind, hub_capability_manifest) - HubCapabilityManifest entity with validation and registry linkage - ARCHITECTURE-LAYERS.md + CI-enforced boundary contracts - Alembic migration 1743724800, fitness tests (Test/Architecture/) - GAAF spec, Operational Architecture spec, domain hub extension guide - Updates to CLAUDE.md, SCOPE.md, Schema.sql, Routes, FrontController, Types state_hub_sync: pending (tunnel was STALE at completion time; run fix-consistency) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
78 lines
3.6 KiB
Haskell
78 lines
3.6 KiB
Haskell
module Web.View.HubCapabilityManifests.Index where
|
|
|
|
import Web.Types
|
|
import Generated.Types
|
|
import IHP.Prelude
|
|
import IHP.ViewPrelude
|
|
import Data.Aeson (Value(..))
|
|
import qualified Data.Vector as V
|
|
|
|
data IndexView = IndexView
|
|
{ manifests :: ![HubCapabilityManifest]
|
|
, hubs :: ![Hub]
|
|
}
|
|
|
|
instance View IndexView where
|
|
html IndexView { .. } = [hsx|
|
|
<div class="flex items-center justify-between mb-6">
|
|
<div>
|
|
<h1 class="text-2xl font-semibold">Hub Capability Manifests</h1>
|
|
<p class="text-sm text-gray-500 mt-1">Extension registrations for domain and shared hubs</p>
|
|
</div>
|
|
<a href={NewHubCapabilityManifestAction}
|
|
class="bg-indigo-600 text-white text-sm font-medium px-4 py-2 rounded hover:bg-indigo-700">
|
|
New Manifest
|
|
</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">Hub</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">Widget Types</th>
|
|
<th class="text-left px-4 py-3 font-medium text-gray-700">Event Types</th>
|
|
<th class="text-left px-4 py-3 font-medium text-gray-700">Categories</th>
|
|
<th class="text-left px-4 py-3 font-medium text-gray-700">Scopes</th>
|
|
<th class="text-left px-4 py-3 font-medium text-gray-700">Activated</th>
|
|
<th class="px-4 py-3"></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{forEach manifests (renderRow hubs)}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|]
|
|
|
|
renderRow :: [Hub] -> HubCapabilityManifest -> Html
|
|
renderRow hubs m = [hsx|
|
|
<tr class="border-b border-gray-100 hover:bg-gray-50">
|
|
<td class="px-4 py-3 font-medium">{hubName hubs m.hubId}</td>
|
|
<td class="px-4 py-3">{statusBadge m.status}</td>
|
|
<td class="px-4 py-3 text-gray-500 text-xs">{jsonCount m.declaredWidgetTypes}</td>
|
|
<td class="px-4 py-3 text-gray-500 text-xs">{jsonCount m.declaredEventTypes}</td>
|
|
<td class="px-4 py-3 text-gray-500 text-xs">{jsonCount m.declaredAnnotationCategories}</td>
|
|
<td class="px-4 py-3 text-gray-500 text-xs">{jsonCount m.declaredPolicyScopes}</td>
|
|
<td class="px-4 py-3 text-gray-400 text-xs">{maybe "—" show m.activatedAt}</td>
|
|
<td class="px-4 py-3 text-right text-xs">
|
|
<a href={ShowHubCapabilityManifestAction { hubCapabilityManifestId = m.id }}
|
|
class="text-indigo-600 hover:text-indigo-800">View</a>
|
|
</td>
|
|
</tr>
|
|
|]
|
|
|
|
hubName :: [Hub] -> Id Hub -> Text
|
|
hubName hubs i = maybe "Unknown" (.name) (find (\h -> h.id == i) hubs)
|
|
|
|
statusBadge :: Text -> Html
|
|
statusBadge "active" = [hsx|<span class="px-2 py-0.5 rounded text-xs bg-green-100 text-green-800">active</span>|]
|
|
statusBadge "draft" = [hsx|<span class="px-2 py-0.5 rounded text-xs bg-amber-100 text-amber-800">draft</span>|]
|
|
statusBadge "retired" = [hsx|<span class="px-2 py-0.5 rounded text-xs bg-gray-100 text-gray-500">retired</span>|]
|
|
statusBadge s = [hsx|<span class="px-2 py-0.5 rounded text-xs bg-gray-100 text-gray-600">{s}</span>|]
|
|
|
|
jsonCount :: Value -> Text
|
|
jsonCount (Array v) | V.null v = "0"
|
|
| otherwise = tshow (V.length v)
|
|
jsonCount _ = "0"
|