Files
inter-hub/Web/View/WidgetAdapterSpecs/New.hs
Bernd Worsch ce42607fca fix(WP-0014/A2): close remaining pure-param and structural compilation errors
Convert all remaining `<- paramOrNothing / param / paramOrDefault /
currentUserOrNothing` monadic binds to `let` — these functions are pure
(ImplicitParams-based) in IHP v1.5, so `<-` is a type error in an IO
do-block.

Controllers fixed:
  AgentDelegations, AiGovernancePolicies, Annotations, ApiConsumers,
  CollectiveProposals, DecisionRecords, DeploymentRecords,
  HubCapabilityManifests, HubRoutingRules, InstitutionalKnowledge,
  OutcomeCorrelations, RequirementCandidates, TypeRegistries,
  WebhookSubscriptions, Widgets,
  Api/V2/{Annotations,InteractionEvents,Token}

WebhookSubscriptions: remove orphaned `Right () ->` case arm that was
left inside a bare `unless` block (structural parse error).

Also carries forward all in-progress fixes from the working tree:
  helpers (AgentBridge, ApiRateLimit, BottleneckDetector,
            CrossHubPropagation, FrictionScore),
  views (CanSelect instances, HSX lambda extraction, formFor wrappers),
  env/build (envrc GHCi perms, flake.nix Tailwind + GHC resource limits,
             static/app.css additional Tailwind output).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-10 01:14:08 +00:00

93 lines
3.6 KiB
Haskell

module Web.View.WidgetAdapterSpecs.New where
import Web.Types
import Generated.Types
import IHP.Prelude
import IHP.ViewPrelude
import Web.Routes ()
data NewView = NewView
{ spec :: !WidgetAdapterSpec
, envelopes :: ![EnvelopeEmissionContract]
, reportings :: ![InteractionReportingContract]
}
instance View NewView where
html NewView { .. } = [hsx|
<div class="mb-4">
<a href={WidgetAdapterSpecsAction} class="text-sm text-gray-500 hover:text-gray-800">
Adapter Specs
</a>
</div>
<h1 class="text-2xl font-semibold mb-6">Register Adapter Spec</h1>
{renderForm spec envelopes reportings}
|]
renderForm :: WidgetAdapterSpec -> [EnvelopeEmissionContract] -> [InteractionReportingContract] -> Html
renderForm spec envelopes reportings = formFor spec [hsx|
<div class="bg-white rounded-lg border border-gray-200 p-6 space-y-5 max-w-lg">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Name <span class="text-red-500">*</span></label>
{textField #name}
<p class="text-xs text-gray-400 mt-1">Unique identifier, e.g. react-18, vue-3, web-component</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Framework <span class="text-red-500">*</span></label>
{textField #framework}
<p class="text-xs text-gray-400 mt-1">e.g. react, vue, angular, vanilla</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Version <span class="text-red-500">*</span></label>
{textField #version}
<p class="text-xs text-gray-400 mt-1">Adapter spec version, e.g. 1.0</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Envelope Contract</label>
<select name="envelopeContractId" class="w-full border border-gray-200 rounded px-3 py-2 text-sm">
<option value=""> None </option>
{forEach envelopes renderEnvelopeOption}
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Reporting Contract</label>
<select name="reportingContractId" class="w-full border border-gray-200 rounded px-3 py-2 text-sm">
<option value=""> None </option>
{forEach reportings renderReportingOption}
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Status</label>
<select name="status" class="w-full border border-gray-200 rounded px-3 py-2 text-sm">
<option value="draft">draft</option>
<option value="active">active</option>
<option value="deprecated">deprecated</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Notes</label>
{textareaField #notes}
</div>
<div class="flex gap-3">
{submitButton}
<a href={WidgetAdapterSpecsAction}
class="text-sm text-gray-500 border border-gray-200 rounded px-4 py-2 hover:border-gray-400">
Cancel
</a>
</div>
</div>
|]
renderEnvelopeOption :: EnvelopeEmissionContract -> Html
renderEnvelopeOption e = [hsx|<option value={tshow e.id}>v{e.contractVersion}</option>|]
renderReportingOption :: InteractionReportingContract -> Html
renderReportingOption r = [hsx|<option value={tshow r.id}>v{r.contractVersion}</option>|]