Files
inter-hub/Web/View/WidgetAdapterSpecs/Index.hs
Bernd Worsch 32bb003f3b feat(P6/T04): WidgetAdapterSpecsController, registry, widget adapter integration
CRUD for WidgetAdapterSpec (index, show, new/create, edit/update — status+notes only
after creation). Widget new/edit forms expose optional adapter_spec_id select.
Widget show page renders adapter badge with link to spec. Widgets controller
fetches adapter spec for show action.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-29 21:14:57 +00:00

83 lines
3.2 KiB
Haskell

module Web.View.WidgetAdapterSpecs.Index where
import Web.Types
import Generated.Types
import IHP.Prelude
import IHP.ViewPrelude
import Application.Helper.View (adapterStatusBadge)
data IndexView = IndexView
{ specs :: ![WidgetAdapterSpec]
, envelopes :: ![EnvelopeEmissionContract]
, reportings :: ![InteractionReportingContract]
}
instance View IndexView where
html IndexView { .. } = [hsx|
<div class="flex items-center justify-between mb-6">
<div>
<h1 class="text-2xl font-semibold">Widget Adapter Specs</h1>
<p class="text-sm text-gray-500 mt-1">
Register adapters that allow non-IHP UI frameworks to participate in IHF.
</p>
</div>
<a href={NewWidgetAdapterSpecAction}
class="bg-indigo-600 text-white text-sm px-4 py-2 rounded hover:bg-indigo-700">
+ Register Adapter
</a>
</div>
<div class="flex gap-4 mb-5 text-sm">
<a href={EnvelopeEmissionContractsAction}
class="text-gray-500 hover:text-gray-800">Envelope Contracts ({length envelopes})</a>
<a href={InteractionReportingContractsAction}
class="text-gray-500 hover:text-gray-800">Reporting Contracts ({length reportings})</a>
</div>
{if null specs
then [hsx|<p class="text-sm text-gray-400">No adapter specs registered yet.</p>|]
else renderTable specs}
|]
renderTable :: [WidgetAdapterSpec] -> Html
renderTable specs = [hsx|
<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-600">Name</th>
<th class="text-left px-4 py-3 font-medium text-gray-600">Framework</th>
<th class="text-left px-4 py-3 font-medium text-gray-600">Version</th>
<th class="text-left px-4 py-3 font-medium text-gray-600">Status</th>
<th class="text-left px-4 py-3 font-medium text-gray-600">Created</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100">
{forEach specs renderRow}
</tbody>
</table>
</div>
|]
renderRow :: WidgetAdapterSpec -> Html
renderRow s = [hsx|
<tr class="hover:bg-gray-50">
<td class="px-4 py-3">
<a href={ShowWidgetAdapterSpecAction { widgetAdapterSpecId = s.id }}
class="font-medium text-indigo-600 hover:underline">{s.name}</a>
</td>
<td class="px-4 py-3">
<span class="bg-purple-100 text-purple-800 text-xs px-2 py-0.5 rounded font-medium">
{s.framework}
</span>
</td>
<td class="px-4 py-3 text-gray-600 font-mono text-xs">{s.version}</td>
<td class="px-4 py-3">
<span class={adapterStatusBadge s.status <> " text-xs px-2 py-0.5 rounded font-medium"}>
{s.status}
</span>
</td>
<td class="px-4 py-3 text-gray-400 text-xs">{show s.createdAt}</td>
</tr>
|]