generated from coulomb/repo-seed
fix(WP-0017/E4): Layer 3 error fixes — round 2 (18 files)
Fixes 46 compile errors across 18 controllers and views: - BridgeResponse missing from explicit import lists (Widgets, RequirementCandidates, DecisionRecords, AgentDelegations) — dot-notation HasField resolution fails without the type in scope under DuplicateRecordFields - unId not in IHP v1.5 — replaced all fmap (Id . unId) with fmap coerce - respondWith not in IHP — replaced with plain redirectTo in 5 controllers - [hubId] list param to sqlQuery — replaced with (Only hubId) tuple - deleteWhere not in IHP — replaced with query/filterWhere/fetch/deleteRecords - fill @'["label"] mismatch — field is label_ in generated types, not label - PersistUUID/toUUID (persistent-style) — replaced with (Only id) - intercalate + jsonArrayTexts ambiguity in GovernanceTemplates — hid Index import, removed local duplicates, added Data.Text (intercalate) - Int16 not in scope in AntifragilityDashboard — changed to Int (score :: Int) - typeArraySection type mismatch in HubCapabilityManifests/Edit — unified to [Text] - renderForm arity mismatch — added action param to DecisionRecords/New.renderForm - Missing qualified Data.Aeson import in AdaptiveThresholds - Missing ?request::Request constraint in Api/V2/WidgetPatterns.renderJsonWithStatus Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,9 +24,9 @@ instance View NewView where
|
||||
</div>
|
||||
|]
|
||||
|
||||
renderForm :: HasPath action => DecisionRecord -> [Requirement] -> [RequirementCandidate] -> [User] -> action -> Html
|
||||
renderForm record requirements candidates users submitAction = [hsx|
|
||||
<form method="POST" action={pathTo submitAction} class="bg-white rounded-lg border border-gray-200 px-6 py-5 space-y-4">
|
||||
renderForm :: DecisionRecord -> [Requirement] -> [RequirementCandidate] -> [User] -> DecisionRecordsController -> Html
|
||||
renderForm record requirements candidates users formAction = [hsx|
|
||||
<form method="POST" action={formAction} class="bg-white rounded-lg border border-gray-200 px-6 py-5 space-y-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Title</label>
|
||||
<input type="text" name="title" value={record.title}
|
||||
|
||||
@@ -6,7 +6,6 @@ import IHP.Prelude
|
||||
import IHP.ViewPrelude
|
||||
import Web.Routes ()
|
||||
import Data.Aeson (Value(..), encode, decode)
|
||||
import qualified Data.Vector as V
|
||||
import qualified Data.ByteString.Lazy.Char8 as BL
|
||||
|
||||
data EditView = EditView
|
||||
@@ -51,10 +50,10 @@ instance View EditView where
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{typeArraySection "Declared Widget Types" "declaredWidgetTypes" manifest.declaredWidgetTypes widgetTypeEntries}
|
||||
{typeArraySection "Declared Event Types" "declaredEventTypes" manifest.declaredEventTypes eventTypeEntries}
|
||||
{typeArraySection2 "Declared Annotation Categories" "declaredAnnotationCategories" manifest.declaredAnnotationCategories categoryEntries}
|
||||
{typeArraySection3 "Declared Policy Scopes" "declaredPolicyScopes" manifest.declaredPolicyScopes policyScopeEntries}
|
||||
{typeArraySection "Declared Widget Types" "declaredWidgetTypes" manifest.declaredWidgetTypes (map (.name) widgetTypeEntries)}
|
||||
{typeArraySection "Declared Event Types" "declaredEventTypes" manifest.declaredEventTypes (map (.name) eventTypeEntries)}
|
||||
{typeArraySection "Declared Annotation Categories" "declaredAnnotationCategories" manifest.declaredAnnotationCategories (map (.name) categoryEntries)}
|
||||
{typeArraySection "Declared Policy Scopes" "declaredPolicyScopes" manifest.declaredPolicyScopes (map (.name) policyScopeEntries)}
|
||||
|
||||
<div class="flex gap-3">
|
||||
<button type="submit"
|
||||
@@ -77,8 +76,8 @@ renderActivateLink mid = [hsx|
|
||||
|]
|
||||
|
||||
-- | Render a JSON array text area with available registry options shown below.
|
||||
typeArraySection :: Text -> Text -> Value -> [WidgetTypeRegistry] -> Html
|
||||
typeArraySection title fieldName val entries = [hsx|
|
||||
typeArraySection :: Text -> Text -> Value -> [Text] -> Html
|
||||
typeArraySection title fieldName val names = [hsx|
|
||||
<div class="bg-white rounded-lg border border-gray-200 p-5">
|
||||
<h2 class="text-sm font-semibold text-gray-700 mb-1">{title}</h2>
|
||||
<p class="text-xs text-gray-500 mb-2">
|
||||
@@ -89,35 +88,7 @@ typeArraySection title fieldName val entries = [hsx|
|
||||
class="w-full border border-gray-300 rounded px-3 py-2 text-sm font-mono"
|
||||
rows="3">{valueText val}</textarea>
|
||||
<p class="text-xs text-gray-400 mt-1">
|
||||
Registered: {intercalate ", " (map (.name) entries)}
|
||||
</p>
|
||||
</div>
|
||||
|]
|
||||
|
||||
typeArraySection2 :: Text -> Text -> Value -> [AnnotationCategoryRegistry] -> Html
|
||||
typeArraySection2 title fieldName val entries = [hsx|
|
||||
<div class="bg-white rounded-lg border border-gray-200 p-5">
|
||||
<h2 class="text-sm font-semibold text-gray-700 mb-1">{title}</h2>
|
||||
<p class="text-xs text-gray-500 mb-2">JSON array of annotation category names.</p>
|
||||
<textarea name={fieldName}
|
||||
class="w-full border border-gray-300 rounded px-3 py-2 text-sm font-mono"
|
||||
rows="3">{valueText val}</textarea>
|
||||
<p class="text-xs text-gray-400 mt-1">
|
||||
Registered: {intercalate ", " (map (.name) entries)}
|
||||
</p>
|
||||
</div>
|
||||
|]
|
||||
|
||||
typeArraySection3 :: Text -> Text -> Value -> [PolicyScopeRegistry] -> Html
|
||||
typeArraySection3 title fieldName val entries = [hsx|
|
||||
<div class="bg-white rounded-lg border border-gray-200 p-5">
|
||||
<h2 class="text-sm font-semibold text-gray-700 mb-1">{title}</h2>
|
||||
<p class="text-xs text-gray-500 mb-2">JSON array of policy scope names.</p>
|
||||
<textarea name={fieldName}
|
||||
class="w-full border border-gray-300 rounded px-3 py-2 text-sm font-mono"
|
||||
rows="3">{valueText val}</textarea>
|
||||
<p class="text-xs text-gray-400 mt-1">
|
||||
Registered: {intercalate ", " (map (.name) entries)}
|
||||
Registered: {joinNames names}
|
||||
</p>
|
||||
</div>
|
||||
|]
|
||||
@@ -135,7 +106,7 @@ renderReadOnlyWarning manifest
|
||||
valueText :: Value -> Text
|
||||
valueText v = cs (BL.unpack (encode v))
|
||||
|
||||
intercalate :: Text -> [Text] -> Text
|
||||
intercalate _ [] = ""
|
||||
intercalate _ [x] = x
|
||||
intercalate sep (x:xs) = x <> sep <> intercalate sep xs
|
||||
joinNames :: [Text] -> Text
|
||||
joinNames [] = ""
|
||||
joinNames [x] = x
|
||||
joinNames (x:xs) = x <> ", " <> joinNames xs
|
||||
|
||||
@@ -94,23 +94,23 @@ instance View AntifragilityDashboardView where
|
||||
</div>
|
||||
|]
|
||||
where
|
||||
deployedIds = map (.id) allDeployments
|
||||
openGaps = filter (\d -> any (\r -> r.decisionId == d.id) allImplRefs
|
||||
&& not (any (\dp -> dp.decisionId == d.id) allDeployments))
|
||||
allDecisions
|
||||
recentDeploys = take 20 (sortByDesc (.deployedAt) allDeployments)
|
||||
regressedWidgets = filter (\w -> w.id `elem` regressionWidgetIds) widgets
|
||||
avgScoreText
|
||||
| null allEvaluations = "—"
|
||||
| otherwise =
|
||||
let avg = fromIntegral (sum (map (.score) allEvaluations)) / fromIntegral (length allEvaluations) :: Double
|
||||
in show (round avg :: Int) <> "/5"
|
||||
improvedPctText
|
||||
| null allSignals = "—"
|
||||
| otherwise =
|
||||
let improved = length (filter (\s -> s.signalType == "improved") allSignals)
|
||||
pct = (fromIntegral improved * 100 `div` length allSignals) :: Int
|
||||
in show pct <> "%"
|
||||
deployedIds = map (.id) allDeployments
|
||||
openGaps = filter (\d -> any (\r -> r.decisionId == d.id) allImplRefs
|
||||
&& not (any (\dp -> dp.decisionId == d.id) allDeployments))
|
||||
allDecisions
|
||||
recentDeploys = take 20 (sortByDesc (.deployedAt) allDeployments)
|
||||
regressedWidgets = filter (\w -> w.id `elem` regressionWidgetIds) widgets
|
||||
avgScoreText
|
||||
| null allEvaluations = "—"
|
||||
| otherwise =
|
||||
let avg = fromIntegral (sum (map (.score) allEvaluations)) / fromIntegral (length allEvaluations) :: Double
|
||||
in show (round avg :: Int) <> "/5"
|
||||
improvedPctText
|
||||
| null allSignals = "—"
|
||||
| otherwise =
|
||||
let improved = length (filter (\s -> s.signalType == "improved") allSignals)
|
||||
pct = (fromIntegral improved * 100 `div` length allSignals) :: Int
|
||||
in show pct <> "%"
|
||||
|
||||
sortByDesc :: Ord b => (a -> b) -> [a] -> [a]
|
||||
sortByDesc f = sortBy (\a b -> compare (f b) (f a))
|
||||
@@ -171,7 +171,7 @@ signalDot "neutral" = "inline-block w-2 h-2 rounded-full bg-gray-400"
|
||||
signalDot "inconclusive" = "inline-block w-2 h-2 rounded-full bg-yellow-400"
|
||||
signalDot _ = "inline-block w-2 h-2 rounded-full bg-gray-300"
|
||||
|
||||
renderEvalBadge :: Int16 -> Html
|
||||
renderEvalBadge :: Int -> Html
|
||||
renderEvalBadge score = [hsx|
|
||||
<span class={scoreClass score <> " text-xs px-2 py-0.5 rounded font-medium"}>
|
||||
{show score}/5
|
||||
@@ -269,7 +269,7 @@ outcomeClass "merged" = "bg-indigo-100 text-indigo-800"
|
||||
outcomeClass "reframed" = "bg-orange-100 text-orange-800"
|
||||
outcomeClass _ = "bg-gray-100 text-gray-600"
|
||||
|
||||
scoreClass :: Int16 -> Text
|
||||
scoreClass :: Int -> Text
|
||||
scoreClass n
|
||||
| n <= 2 = "bg-red-100 text-red-800"
|
||||
| n == 3 = "bg-yellow-100 text-yellow-800"
|
||||
|
||||
Reference in New Issue
Block a user