generated from coulomb/repo-seed
Some checks failed
Test / test (push) Has been cancelled
Delivers the hub registry discovery UI, widget pattern library, governance template library, and marketplace dashboard. Key changes: - Schema: widget_patterns (widget_type FK to registry), widget_pattern_versions, pattern_adoptions, governance_templates (categories JSONB, validated at controller), governance_template_clones — all GAAF-compliant, no bare TEXT type discriminators - Migration: 1743897600-ihf-phase10-hub-registry.sql - HubRegistry controller + views: browsable view over hub_capability_manifests, hub_health_snapshots, hubs with per-hub GAAF compliance indicator - WidgetPatterns controller + views: publish, version, adopt; adoption triggers manifest amendment draft when new types are introduced - GovernanceTemplates controller + views: CRUD, clone with category validation against annotation_category_registry - MarketplaceDashboard controller + view: full-text search, widget-type filter, sort, trending panel, autoRefresh - API v2: /api/v2/hub-registry, /api/v2/widget-patterns (+ adopt endpoint) - OpenAPI spec updated with Phase 10 paths - GAAF scorecard: Customization 2.5 → 3.2; overall 3.41 → 3.56 (Strong) - CLAUDE.md: Phase 10 complete; active workplan → Phase 11 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
161 lines
6.9 KiB
Haskell
161 lines
6.9 KiB
Haskell
module Web.View.MarketplaceDashboard.Show where
|
|
|
|
import Web.Types
|
|
import Generated.Types
|
|
import IHP.Prelude
|
|
import IHP.ViewPrelude
|
|
import Data.Aeson (Value(..), decode, encode)
|
|
import qualified Data.ByteString.Lazy.Char8 as BL
|
|
|
|
type PatternRow = (WidgetPattern, Int) -- pattern + adopter_count
|
|
type TemplateRow = (GovernanceTemplate, Int) -- template + clone_count
|
|
type TrendingRow = (Id WidgetPattern, Text, Text, Int) -- id, name, widget_type, recent_adoptions
|
|
|
|
data ShowView = ShowView
|
|
{ patterns :: ![PatternRow]
|
|
, templates :: ![TemplateRow]
|
|
, trending :: ![TrendingRow]
|
|
, widgetTypeOptions :: ![(Text, Text)] -- (name, label)
|
|
, searchQuery :: !(Maybe Text)
|
|
, selectedType :: !(Maybe Text)
|
|
, sortOrder :: !Text
|
|
}
|
|
|
|
instance View ShowView where
|
|
html ShowView { .. } = [hsx|
|
|
<div class="flex items-center justify-between mb-6">
|
|
<div>
|
|
<h1 class="text-2xl font-semibold">Marketplace</h1>
|
|
<p class="text-sm text-gray-500 mt-1">
|
|
Discover and adopt reusable widget patterns and governance templates.
|
|
<a href={HubRegistryAction} class="ml-2 text-indigo-600 hover:underline">Hub Registry →</a>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
{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}
|
|
|
|
<div class="grid grid-cols-2 gap-8">
|
|
<div>
|
|
<h2 class="text-lg font-semibold mb-3">
|
|
Widget Patterns
|
|
<span class="text-sm font-normal text-gray-400 ml-1">({tshow (length patterns)})</span>
|
|
</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}
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<h2 class="text-lg font-semibold mb-3">
|
|
Governance Templates
|
|
<span class="text-sm font-normal text-gray-400 ml-1">({tshow (length templates)})</span>
|
|
</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}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|]
|
|
|
|
searchBar :: Maybe Text -> Maybe Text -> Text -> [(Text, Text)] -> Html
|
|
searchBar mSearch mWType sortOrder wtOptions = [hsx|
|
|
<form method="GET" action={MarketplaceDashboardAction} class="mb-6 flex items-end gap-3">
|
|
<div class="flex-1">
|
|
<label class="block text-xs text-gray-500 mb-1">Search</label>
|
|
<input type="text" name="q" value={fromMaybe "" mSearch}
|
|
placeholder="Search patterns and templates..."
|
|
class="w-full border border-gray-300 rounded px-3 py-2 text-sm" />
|
|
</div>
|
|
<div>
|
|
<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>
|
|
|])}
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="block text-xs text-gray-500 mb-1">Sort</label>
|
|
<select name="sort" class="border border-gray-300 rounded px-3 py-2 text-sm">
|
|
<option value="adopted" selected={sortOrder == "adopted"}>Most adopted</option>
|
|
<option value="recent" selected={sortOrder == "recent"}>Recently published</option>
|
|
<option value="alpha" selected={sortOrder == "alpha"}>Alphabetical</option>
|
|
</select>
|
|
</div>
|
|
<button type="submit"
|
|
class="text-sm bg-indigo-600 text-white px-4 py-2 rounded hover:bg-indigo-700">
|
|
Search
|
|
</button>
|
|
</form>
|
|
|]
|
|
|
|
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 }}
|
|
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}
|
|
</div>
|
|
|]
|
|
|
|
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 }}
|
|
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}
|
|
<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>
|
|
|])}
|
|
</div>
|
|
</div>
|
|
|]
|
|
|
|
renderTrendingChip :: TrendingRow -> Html
|
|
renderTrendingChip (patternId, name, widgetType, count) = [hsx|
|
|
<a href={ShowWidgetPatternAction { widgetPatternId = 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>
|
|
<span class="font-mono text-xs text-gray-400">{widgetType}</span>
|
|
<span class="text-xs text-indigo-600">{tshow count} adoptions</span>
|
|
</a>
|
|
|]
|
|
|
|
jsonArrayTexts :: Value -> [Text]
|
|
jsonArrayTexts val = case decode (encode val) of
|
|
Just (arr :: [Text]) -> arr
|
|
Nothing -> []
|