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:
2026-04-04 09:55:12 +00:00
parent ffd5fbb900
commit f1978c3888
147 changed files with 2710 additions and 2075 deletions

View File

@@ -4,6 +4,7 @@ import Web.Types
import Generated.Types
import IHP.Prelude
import IHP.ViewPrelude
import Web.Routes ()
import Data.Aeson (Value(..), decode, encode)
import qualified Data.ByteString.Lazy.Char8 as BL
@@ -35,18 +36,7 @@ instance View ShowView where
{searchBar searchQuery selectedType sortOrder widgetTypeOptions}
{if not (null trending)
then [hsx|
<div class="mb-6">
<h2 class="text-sm font-semibold text-gray-600 uppercase tracking-wide mb-3">
Trending (last 30 days)
</h2>
<div class="flex flex-wrap gap-2">
{forEach trending renderTrendingChip}
</div>
</div>
|]
else mempty}
{renderTrendingSection trending}
<div class="grid grid-cols-2 gap-8">
<div>
@@ -56,9 +46,7 @@ instance View ShowView where
</h2>
<div class="space-y-2">
{forEach patterns renderPatternRow}
{if null patterns
then [hsx|<p class="text-sm text-gray-400">No patterns match your search.</p>|]
else mempty}
{if null patterns then noPatternsMsg else mempty}
</div>
</div>
<div>
@@ -68,9 +56,7 @@ instance View ShowView where
</h2>
<div class="space-y-2">
{forEach templates renderTemplateRow}
{if null templates
then [hsx|<p class="text-sm text-gray-400">No templates match your search.</p>|]
else mempty}
{if null templates then noTemplatesMsg else mempty}
</div>
</div>
</div>
@@ -89,9 +75,7 @@ searchBar mSearch mWType sortOrder wtOptions = [hsx|
<label class="block text-xs text-gray-500 mb-1">Widget Type</label>
<select name="widgetType" class="border border-gray-300 rounded px-3 py-2 text-sm font-mono">
<option value="">All types</option>
{forEach wtOptions (\(n, l) -> [hsx|
<option value={n} selected={mWType == Just n}>{l}</option>
|])}
{forEach wtOptions (renderWtOption mWType)}
</select>
</div>
<div>
@@ -113,14 +97,14 @@ renderPatternRow :: PatternRow -> Html
renderPatternRow (pattern, adopterCount) = [hsx|
<div class="bg-white rounded border border-gray-200 p-3 hover:border-indigo-200">
<div class="flex items-center justify-between">
<a href={ShowWidgetPatternAction { widgetPatternId = pattern.id }}
<a href={ShowWidgetPatternAction (pattern.id)}
class="font-medium text-sm text-indigo-700 hover:underline">
{pattern.name}
</a>
<span class="text-xs text-gray-400">{tshow adopterCount} adopters</span>
</div>
<span class="font-mono text-xs text-gray-400">{pattern.widgetType}</span>
{maybe mempty (\d -> [hsx|<p class="text-xs text-gray-500 mt-1 truncate">{d}</p>|]) pattern.description}
{maybe mempty renderPatternDesc pattern.description}
</div>
|]
@@ -128,24 +112,22 @@ renderTemplateRow :: TemplateRow -> Html
renderTemplateRow (template, cloneCount) = [hsx|
<div class="bg-white rounded border border-gray-200 p-3 hover:border-indigo-200">
<div class="flex items-center justify-between">
<a href={ShowGovernanceTemplateAction { governanceTemplateId = template.id }}
<a href={ShowGovernanceTemplateAction (template.id)}
class="font-medium text-sm text-indigo-700 hover:underline">
{template.name}
</a>
<span class="text-xs text-gray-400">{tshow cloneCount} clones</span>
</div>
{maybe mempty (\d -> [hsx|<p class="text-xs text-gray-500 mt-1 truncate">{d}</p>|]) template.description}
{maybe mempty renderPatternDesc template.description}
<div class="mt-1 flex flex-wrap gap-1">
{forEach (jsonArrayTexts template.categories) (\c -> [hsx|
<span class="px-1.5 py-0.5 rounded text-xs bg-blue-50 text-blue-600 font-mono">{c}</span>
|])}
{forEach (jsonArrayTexts template.categories) renderCategoryChip}
</div>
</div>
|]
renderTrendingChip :: TrendingRow -> Html
renderTrendingChip (patternId, name, widgetType, count) = [hsx|
<a href={ShowWidgetPatternAction { widgetPatternId = patternId }}
<a href={ShowWidgetPatternAction (patternId)}
class="flex items-center gap-1.5 px-3 py-1.5 bg-white rounded border border-gray-200 \
\text-sm hover:border-indigo-300">
<span class="font-medium">{name}</span>
@@ -158,3 +140,31 @@ jsonArrayTexts :: Value -> [Text]
jsonArrayTexts val = case decode (encode val) of
Just (arr :: [Text]) -> arr
Nothing -> []
renderTrendingSection :: [TrendingRow] -> Html
renderTrendingSection [] = mempty
renderTrendingSection rows = [hsx|
<div class="mb-6">
<h2 class="text-sm font-semibold text-gray-600 uppercase tracking-wide mb-3">
Trending (last 30 days)
</h2>
<div class="flex flex-wrap gap-2">
{forEach rows renderTrendingChip}
</div>
</div>
|]
noPatternsMsg :: Html
noPatternsMsg = [hsx|<p class="text-sm text-gray-400">No patterns match your search.</p>|]
noTemplatesMsg :: Html
noTemplatesMsg = [hsx|<p class="text-sm text-gray-400">No templates match your search.</p>|]
renderPatternDesc :: Text -> Html
renderPatternDesc d = [hsx|<p class="text-xs text-gray-500 mt-1 truncate">{d}</p>|]
renderCategoryChip :: Text -> Html
renderCategoryChip c = [hsx|<span class="px-1.5 py-0.5 rounded text-xs bg-blue-50 text-blue-600 font-mono">{c}</span>|]
renderWtOption :: Maybe Text -> (Text, Text) -> Html
renderWtOption mWType (n, l) = [hsx|<option value={n} selected={mWType == Just n}>{l}</option>|]