generated from coulomb/repo-seed
fix(WP-0014): pre-flight compilation fixes, Tailwind pipeline, and admin seed
A2 — Compilation fixes: - Remove inline FK constraints from Schema.sql; IHP schema compiler cannot parse them. Add 1744329600-restore-fk-constraints.sql migration to restore referential integrity at the DB level. - Rename `#label` → `#label_` throughout to avoid clash with Haskell built-in. - Fix `hub.id == hid` UUID comparisons to use `toUUID hub.id`. - Replace non-existent `setStatus`/`respondJson` calls with `renderJsonWithStatusCode` throughout Api controllers. - Fix qualified package import for `cryptohash-sha256` in Auth.hs. - Add `CanSelect (Text, Text)` instance in Helper.View. - Refactor HSX inline lambdas to named helper functions in 100+ views (GHC cannot infer types for anonymous functions inside quasi-quoted HSX). - Fix missing imports (IHP.QueryBuilder, IHP.Fetch, Web.Routes, Only, etc.) across helpers and controllers. - Remove duplicate `diffUTCTime` definition in BottleneckDetector. - Change `createEventForHub` return type from `IO ResponseReceived` to `IO ()`. - Seed type-registry vocabulary via 1744502400-seed-type-registries.sql (moved from Schema.sql where IHP does not execute INSERT statements). A3 — Tailwind build pipeline: - Add `tailwindcss` to flake.nix native packages. - Uncomment `tailwind.exec` process in devenv shell config. - Add tailwind/tailwind.config.js (scans Web/View/**/*.hs). - Add tailwind/app.css with @tailwind directives. A4 — Admin user seed: - Add 1744416000-seed-admin-user.sql: inserts admin@inter-hub.local with bcrypt-hashed password admin1234! (cost 10). - Add .env.example documenting all required environment variables and default admin credentials. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import Web.Types
|
||||
import Generated.Types
|
||||
import IHP.Prelude
|
||||
import IHP.ViewPrelude
|
||||
import Web.Routes ()
|
||||
import qualified Data.List as List
|
||||
|
||||
data FederatedGovernanceDashboardView = FederatedGovernanceDashboardView
|
||||
@@ -80,7 +81,7 @@ instance View FederatedGovernanceDashboardView where
|
||||
-- ── Panel 2: Routing activity ─────────────────────────────────────
|
||||
activeRulesCount = length rules
|
||||
routedCount = length routedCandidates
|
||||
hubName hid = maybe (show hid) (.name) (find (\h -> h.id == hid) hubs)
|
||||
hubName hid = maybe (show hid) (.name) (find (\h -> toUUID h.id == hid) hubs)
|
||||
|
||||
panel2Routing = [hsx|
|
||||
<div class="bg-white rounded-lg border border-gray-200 p-5">
|
||||
@@ -99,29 +100,34 @@ instance View FederatedGovernanceDashboardView where
|
||||
<div class="text-xs text-gray-500">routed (30 days)</div>
|
||||
</div>
|
||||
</div>
|
||||
{if null rules
|
||||
then [hsx|<p class="text-xs text-gray-400">No active routing rules.</p>|]
|
||||
else [hsx|
|
||||
<div class="space-y-1">
|
||||
{forEach (take 5 rules) renderRuleRow}
|
||||
</div>
|
||||
|]}
|
||||
{renderRulesSection rules}
|
||||
</div>
|
||||
|]
|
||||
|
||||
renderRulesSection :: [HubRoutingRule] -> Html
|
||||
renderRulesSection [] = [hsx|<p class="text-xs text-gray-400">No active routing rules.</p>|]
|
||||
renderRulesSection rs = [hsx|
|
||||
<div class="space-y-1">
|
||||
{forEach (take 5 rs) renderRuleRow}
|
||||
</div>
|
||||
|]
|
||||
|
||||
renderRuleRow :: HubRoutingRule -> Html
|
||||
renderRuleRow r = [hsx|
|
||||
<div class="flex items-center gap-2 text-xs text-gray-600">
|
||||
<span class="font-medium">{hubName r.sourceHubId}</span>
|
||||
<span class="text-gray-400">→</span>
|
||||
<span class="font-medium">{hubName r.targetHubId}</span>
|
||||
{maybe mempty (\c -> [hsx|<span class="text-gray-400">({c})</span>|]) r.matchCategory}
|
||||
{maybe mempty renderMatchCategory r.matchCategory}
|
||||
</div>
|
||||
|]
|
||||
|
||||
renderMatchCategory :: Text -> Html
|
||||
renderMatchCategory c = [hsx|<span class="text-gray-400">({c})</span>|]
|
||||
|
||||
-- ── Panel 3: Policy compliance ────────────────────────────────────
|
||||
activeOverlaysCount = length overlays
|
||||
decisionIdsWithPolicy = List.nub $ map (.requirementId) allPolicies
|
||||
decisionIdsWithPolicy = List.nub $ map (Just . (.decisionId)) allPolicies
|
||||
coveredDecisions = length $ filter (\d -> Just d.id `elem` decisionIdsWithPolicy) allDecisions
|
||||
totalDecisions = length allDecisions
|
||||
policyPct :: Int
|
||||
@@ -145,15 +151,7 @@ instance View FederatedGovernanceDashboardView where
|
||||
<div class="text-xs text-gray-500">decision coverage</div>
|
||||
</div>
|
||||
</div>
|
||||
{if null overlays
|
||||
then [hsx|<p class="text-xs text-gray-400">No active policy overlays.</p>|]
|
||||
else [hsx|
|
||||
<div class="space-y-1">
|
||||
{forEach overlays \o -> [hsx|
|
||||
<div class="text-xs text-gray-600 truncate">{o.title}</div>
|
||||
|]}
|
||||
</div>
|
||||
|]}
|
||||
{renderOverlaysList overlays}
|
||||
</div>
|
||||
|]
|
||||
|
||||
@@ -161,7 +159,7 @@ instance View FederatedGovernanceDashboardView where
|
||||
hubsWithStewards = List.nub (map (.hubId) stewards)
|
||||
stewardedCount = length hubsWithStewards
|
||||
totalHubs = length hubs
|
||||
hubsWithNoSteward = filter (\h -> h.id `notElem` hubsWithStewards) hubs
|
||||
hubsWithNoSteward = filter (\h -> toUUID h.id `notElem` hubsWithStewards) hubs
|
||||
|
||||
panel4Stewardship = [hsx|
|
||||
<div class="bg-white rounded-lg border border-gray-200 p-5">
|
||||
@@ -180,26 +178,13 @@ instance View FederatedGovernanceDashboardView where
|
||||
<div class="text-xs text-gray-500">hubs unassigned</div>
|
||||
</div>
|
||||
</div>
|
||||
{if null hubsWithNoSteward
|
||||
then [hsx|<p class="text-xs text-green-600">All hubs have active stewards.</p>|]
|
||||
else [hsx|
|
||||
<div>
|
||||
<p class="text-xs text-gray-500 mb-1">Hubs without stewards:</p>
|
||||
<div class="flex flex-wrap gap-1">
|
||||
{forEach hubsWithNoSteward \h -> [hsx|
|
||||
<span class="text-xs bg-amber-100 text-amber-700 px-2 py-0.5 rounded">
|
||||
{h.name}
|
||||
</span>
|
||||
|]}
|
||||
</div>
|
||||
</div>
|
||||
|]}
|
||||
{renderUnstewarded hubsWithNoSteward}
|
||||
</div>
|
||||
|]
|
||||
|
||||
-- ── Panel 5: Archive activity ─────────────────────────────────────
|
||||
archiveByType = List.sortBy (\a b -> compare (fst a) (fst b))
|
||||
$ map (\grp -> (fst (head grp), length grp))
|
||||
$ map (\grp -> ((head grp).subjectType, length grp))
|
||||
$ List.groupBy (\a b -> a.subjectType == b.subjectType)
|
||||
$ List.sortBy (\a b -> compare a.subjectType b.subjectType) recentArchives
|
||||
|
||||
@@ -210,20 +195,50 @@ instance View FederatedGovernanceDashboardView where
|
||||
<a href={ArchiveRecordsAction}
|
||||
class="text-xs text-blue-600 hover:underline">All records →</a>
|
||||
</div>
|
||||
{if null recentArchives
|
||||
then [hsx|<p class="text-sm text-gray-400">No artifacts archived in the last 90 days.</p>|]
|
||||
else [hsx|
|
||||
<div class="flex items-center gap-3 mb-2">
|
||||
<div class="text-3xl font-bold text-gray-900">{show (length recentArchives)}</div>
|
||||
<div class="text-xs text-gray-500">total archived artifacts</div>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
{forEach archiveByType \(typ, cnt) -> [hsx|
|
||||
<span class="text-sm bg-amber-50 border border-amber-200 text-amber-800 px-3 py-1 rounded">
|
||||
{typ}: {show cnt}
|
||||
</span>
|
||||
|]}
|
||||
</div>
|
||||
|]}
|
||||
{renderArchiveActivity recentArchives archiveByType}
|
||||
</div>
|
||||
|]
|
||||
|
||||
renderOverlaysList :: [FederatedPolicyOverlay] -> Html
|
||||
renderOverlaysList [] = [hsx|<p class="text-xs text-gray-400">No active policy overlays.</p>|]
|
||||
renderOverlaysList overlays = [hsx|
|
||||
<div class="space-y-1">
|
||||
{forEach overlays renderOverlayTitle}
|
||||
</div>
|
||||
|]
|
||||
|
||||
renderOverlayTitle :: FederatedPolicyOverlay -> Html
|
||||
renderOverlayTitle o = [hsx|<div class="text-xs text-gray-600 truncate">{o.title}</div>|]
|
||||
|
||||
renderUnstewarded :: [Hub] -> Html
|
||||
renderUnstewarded [] = [hsx|<p class="text-xs text-green-600">All hubs have active stewards.</p>|]
|
||||
renderUnstewarded hs = [hsx|
|
||||
<div>
|
||||
<p class="text-xs text-gray-500 mb-1">Hubs without stewards:</p>
|
||||
<div class="flex flex-wrap gap-1">
|
||||
{forEach hs renderUnstewardedHub}
|
||||
</div>
|
||||
</div>
|
||||
|]
|
||||
|
||||
renderUnstewardedHub :: Hub -> Html
|
||||
renderUnstewardedHub h = [hsx|<span class="text-xs bg-amber-100 text-amber-700 px-2 py-0.5 rounded">{h.name}</span>|]
|
||||
|
||||
renderArchiveActivity :: [ArchiveRecord] -> [(Text, Int)] -> Html
|
||||
renderArchiveActivity [] _ = [hsx|<p class="text-sm text-gray-400">No artifacts archived in the last 90 days.</p>|]
|
||||
renderArchiveActivity archives byType = [hsx|
|
||||
<div class="flex items-center gap-3 mb-2">
|
||||
<div class="text-3xl font-bold text-gray-900">{show (length archives)}</div>
|
||||
<div class="text-xs text-gray-500">total archived artifacts</div>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
{forEach byType renderArchiveTypeChip}
|
||||
</div>
|
||||
|]
|
||||
|
||||
renderArchiveTypeChip :: (Text, Int) -> Html
|
||||
renderArchiveTypeChip (typ, cnt) = [hsx|
|
||||
<span class="text-sm bg-amber-50 border border-amber-200 text-amber-800 px-3 py-1 rounded">
|
||||
{typ}: {show cnt}
|
||||
</span>
|
||||
|]
|
||||
|
||||
Reference in New Issue
Block a user