generated from coulomb/repo-seed
feat(P2+P3): IHF Phase 2 complete; register Phase 3 workplan
Phase 2 — Structured Feedback and Triage (IHUB-WP-0002): - Schema: annotation_threads, requirement_candidates, triage_states, reviewer_assignments; annotations extended with severity + thread_id - AnnotationThreadsController: create threads, assign annotations - RequirementCandidatesController: CRUD, escalation, triage lifecycle, reviewer assignment, my-queue - Annotation severity (low/medium/high/critical) with Tailwind color cues - TriageDashboardAction on HubsController with autoRefresh - Integration tests (T01–T09), SCOPE.md updated, docs/phase2-summary.md Phase 3 — Governance and Decision Linkage (IHUB-WP-0003): - Workplan registered: 9 tasks, State Hub workstream 5f201ee3 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
55
Web/View/RequirementCandidates/Edit.hs
Normal file
55
Web/View/RequirementCandidates/Edit.hs
Normal file
@@ -0,0 +1,55 @@
|
||||
module Web.View.RequirementCandidates.Edit where
|
||||
|
||||
import Web.Types
|
||||
import Generated.Types
|
||||
import IHP.Prelude
|
||||
import IHP.ViewPrelude
|
||||
|
||||
data EditView = EditView
|
||||
{ candidate :: !RequirementCandidate
|
||||
, widgets :: ![Widget]
|
||||
, threads :: ![AnnotationThread]
|
||||
}
|
||||
|
||||
instance View EditView where
|
||||
html EditView { .. } = [hsx|
|
||||
<div class="mb-6 flex items-center gap-2 text-sm text-gray-500">
|
||||
<a href={RequirementCandidatesAction} class="hover:text-gray-700">Candidates</a>
|
||||
<span>/</span>
|
||||
<a href={ShowRequirementCandidateAction { requirementCandidateId = candidate.id }}
|
||||
class="hover:text-gray-700">{candidate.title}</a>
|
||||
<span>/</span>
|
||||
<span>Edit</span>
|
||||
</div>
|
||||
<div class="max-w-lg">
|
||||
<h1 class="text-2xl font-semibold mb-6">Edit Candidate</h1>
|
||||
{renderForm candidate widgets threads}
|
||||
</div>
|
||||
|]
|
||||
|
||||
renderForm :: RequirementCandidate -> [Widget] -> [AnnotationThread] -> Html
|
||||
renderForm candidate widgets threads = formFor candidate [hsx|
|
||||
{(textField #title) { fieldLabel = "Title" }}
|
||||
{(textareaField #description) { fieldLabel = "Description" }}
|
||||
{selectField #sourceWidgetId (widgetOptions widgets)}
|
||||
{selectField #sourceThreadId (threadOptions threads)}
|
||||
{selectField #category categoryOptions}
|
||||
{submitButton}
|
||||
|]
|
||||
|
||||
widgetOptions :: [Widget] -> [(Text, Text)]
|
||||
widgetOptions = map (\w -> (w.name, show w.id))
|
||||
|
||||
threadOptions :: [AnnotationThread] -> [(Text, Text)]
|
||||
threadOptions threads = ("None", "") : map (\t -> (t.title, show t.id)) threads
|
||||
|
||||
categoryOptions :: [(Text, Text)]
|
||||
categoryOptions =
|
||||
[ ("Friction", "friction")
|
||||
, ("Defect", "defect")
|
||||
, ("Wish", "wish")
|
||||
, ("Policy Concern", "policy_concern")
|
||||
, ("Documentation Gap", "doc_gap")
|
||||
, ("Trust", "trust")
|
||||
, ("Other", "other")
|
||||
]
|
||||
116
Web/View/RequirementCandidates/Index.hs
Normal file
116
Web/View/RequirementCandidates/Index.hs
Normal file
@@ -0,0 +1,116 @@
|
||||
module Web.View.RequirementCandidates.Index where
|
||||
|
||||
import Web.Types
|
||||
import Generated.Types
|
||||
import IHP.Prelude
|
||||
import IHP.ViewPrelude
|
||||
|
||||
data IndexView = IndexView
|
||||
{ candidates :: ![RequirementCandidate]
|
||||
, assignments :: ![ReviewerAssignment]
|
||||
, users :: ![User]
|
||||
, widgets :: ![Widget]
|
||||
, mStatusFilter :: !(Maybe Text)
|
||||
}
|
||||
|
||||
instance View IndexView where
|
||||
html IndexView { .. } = [hsx|
|
||||
<div class="flex items-center justify-between mb-6">
|
||||
<h1 class="text-2xl font-semibold">Requirement Candidates</h1>
|
||||
<div class="flex gap-2">
|
||||
<a href={MyQueueAction}
|
||||
class="text-sm border border-gray-300 px-3 py-1.5 rounded hover:bg-gray-50">
|
||||
My Queue
|
||||
</a>
|
||||
<a href={NewRequirementCandidateAction}
|
||||
class="bg-indigo-600 text-white text-sm font-medium px-4 py-2 rounded hover:bg-indigo-700">
|
||||
New Candidate
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-2 mb-4 flex-wrap">
|
||||
{renderFilterPills mStatusFilter}
|
||||
</div>
|
||||
|
||||
{if null candidates
|
||||
then [hsx|<p class="text-sm text-gray-500">No candidates found.</p>|]
|
||||
else [hsx|
|
||||
<div class="bg-white rounded-lg border border-gray-200 overflow-hidden">
|
||||
<table class="w-full text-sm">
|
||||
<thead class="bg-gray-50 border-b border-gray-200">
|
||||
<tr>
|
||||
<th class="text-left px-4 py-3 font-medium text-gray-700">Title</th>
|
||||
<th class="text-left px-4 py-3 font-medium text-gray-700">Widget</th>
|
||||
<th class="text-left px-4 py-3 font-medium text-gray-700">Category</th>
|
||||
<th class="text-left px-4 py-3 font-medium text-gray-700">Status</th>
|
||||
<th class="text-left px-4 py-3 font-medium text-gray-700">Reviewer</th>
|
||||
<th class="text-left px-4 py-3 font-medium text-gray-700">Created</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{forEach candidates (renderRow assignments users widgets)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|]}
|
||||
|]
|
||||
|
||||
renderFilterPills :: Maybe Text -> Html
|
||||
renderFilterPills current = [hsx|
|
||||
{renderPill Nothing current "All"}
|
||||
{renderPill (Just "open") current "Open"}
|
||||
{renderPill (Just "in_review") current "In Review"}
|
||||
{renderPill (Just "accepted") current "Accepted"}
|
||||
{renderPill (Just "rejected") current "Rejected"}
|
||||
{renderPill (Just "deferred") current "Deferred"}
|
||||
|]
|
||||
|
||||
renderPill :: Maybe Text -> Maybe Text -> Text -> Html
|
||||
renderPill target current label =
|
||||
let isActive = target == current
|
||||
baseClass = "text-xs px-3 py-1.5 rounded-full border "
|
||||
cls = if isActive
|
||||
then baseClass <> "bg-indigo-600 text-white border-indigo-600"
|
||||
else baseClass <> "border-gray-300 text-gray-600 hover:bg-gray-50"
|
||||
url = case target of
|
||||
Nothing -> pathTo RequirementCandidatesAction
|
||||
Just s -> pathTo RequirementCandidatesAction <> "?status=" <> s
|
||||
in [hsx|<a href={url} class={cls}>{label}</a>|]
|
||||
|
||||
renderRow :: [ReviewerAssignment] -> [User] -> [Widget] -> RequirementCandidate -> Html
|
||||
renderRow assignments users widgets c =
|
||||
let mAssignment = find (\ra -> ra.candidateId == c.id) assignments
|
||||
mReviewer = mAssignment >>= \ra -> find (\u -> u.id == ra.userId) users
|
||||
mWidget = find (\w -> w.id == c.sourceWidgetId) widgets
|
||||
in [hsx|
|
||||
<tr class="border-b border-gray-100 hover:bg-gray-50">
|
||||
<td class="px-4 py-3">
|
||||
<a href={ShowRequirementCandidateAction { requirementCandidateId = c.id }}
|
||||
class="font-medium text-indigo-600 hover:text-indigo-800">
|
||||
{c.title}
|
||||
</a>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-gray-500 text-xs">
|
||||
{maybe "—" (.name) mWidget}
|
||||
</td>
|
||||
<td class="px-4 py-3">
|
||||
<span class="text-xs bg-gray-100 text-gray-600 px-2 py-0.5 rounded">{c.category}</span>
|
||||
</td>
|
||||
<td class="px-4 py-3">
|
||||
<span class={statusClass c.status <> " text-xs px-2 py-0.5 rounded"}>{c.status}</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-gray-500 text-xs">
|
||||
{maybe "Unassigned" (.name) mReviewer}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-gray-400 text-xs">{show c.createdAt}</td>
|
||||
</tr>
|
||||
|]
|
||||
|
||||
statusClass :: Text -> Text
|
||||
statusClass "open" = "bg-blue-100 text-blue-700"
|
||||
statusClass "in_review" = "bg-yellow-100 text-yellow-800"
|
||||
statusClass "accepted" = "bg-green-100 text-green-800"
|
||||
statusClass "rejected" = "bg-red-100 text-red-800"
|
||||
statusClass "deferred" = "bg-gray-100 text-gray-600"
|
||||
statusClass _ = "bg-gray-100 text-gray-600"
|
||||
52
Web/View/RequirementCandidates/New.hs
Normal file
52
Web/View/RequirementCandidates/New.hs
Normal file
@@ -0,0 +1,52 @@
|
||||
module Web.View.RequirementCandidates.New where
|
||||
|
||||
import Web.Types
|
||||
import Generated.Types
|
||||
import IHP.Prelude
|
||||
import IHP.ViewPrelude
|
||||
|
||||
data NewView = NewView
|
||||
{ candidate :: !RequirementCandidate
|
||||
, widgets :: ![Widget]
|
||||
, threads :: ![AnnotationThread]
|
||||
}
|
||||
|
||||
instance View NewView where
|
||||
html NewView { .. } = [hsx|
|
||||
<div class="mb-6 flex items-center gap-2 text-sm text-gray-500">
|
||||
<a href={RequirementCandidatesAction} class="hover:text-gray-700">Candidates</a>
|
||||
<span>/</span>
|
||||
<span>New</span>
|
||||
</div>
|
||||
<div class="max-w-lg">
|
||||
<h1 class="text-2xl font-semibold mb-6">New Requirement Candidate</h1>
|
||||
{renderForm candidate widgets threads}
|
||||
</div>
|
||||
|]
|
||||
|
||||
renderForm :: RequirementCandidate -> [Widget] -> [AnnotationThread] -> Html
|
||||
renderForm candidate widgets threads = formFor candidate [hsx|
|
||||
{(textField #title) { fieldLabel = "Title" }}
|
||||
{(textareaField #description) { fieldLabel = "Description" }}
|
||||
{selectField #sourceWidgetId (widgetOptions widgets)}
|
||||
{selectField #sourceThreadId (threadOptions threads)}
|
||||
{selectField #category categoryOptions}
|
||||
{submitButton}
|
||||
|]
|
||||
|
||||
widgetOptions :: [Widget] -> [(Text, Text)]
|
||||
widgetOptions = map (\w -> (w.name, show w.id))
|
||||
|
||||
threadOptions :: [AnnotationThread] -> [(Text, Text)]
|
||||
threadOptions threads = ("None", "") : map (\t -> (t.title, show t.id)) threads
|
||||
|
||||
categoryOptions :: [(Text, Text)]
|
||||
categoryOptions =
|
||||
[ ("Friction", "friction")
|
||||
, ("Defect", "defect")
|
||||
, ("Wish", "wish")
|
||||
, ("Policy Concern", "policy_concern")
|
||||
, ("Documentation Gap", "doc_gap")
|
||||
, ("Trust", "trust")
|
||||
, ("Other", "other")
|
||||
]
|
||||
176
Web/View/RequirementCandidates/Show.hs
Normal file
176
Web/View/RequirementCandidates/Show.hs
Normal file
@@ -0,0 +1,176 @@
|
||||
module Web.View.RequirementCandidates.Show where
|
||||
|
||||
import Web.Types
|
||||
import Generated.Types
|
||||
import IHP.Prelude
|
||||
import IHP.ViewPrelude
|
||||
|
||||
data ShowView = ShowView
|
||||
{ candidate :: !RequirementCandidate
|
||||
, widget :: !Widget
|
||||
, triageStates :: ![TriageState]
|
||||
, mAssignment :: !(Maybe ReviewerAssignment)
|
||||
, users :: ![User]
|
||||
, mSourceAnnotation :: !(Maybe Annotation)
|
||||
, mSourceThread :: !(Maybe AnnotationThread)
|
||||
}
|
||||
|
||||
instance View ShowView where
|
||||
html ShowView { .. } = [hsx|
|
||||
<div class="mb-6 flex items-center gap-2 text-sm text-gray-500">
|
||||
<a href={RequirementCandidatesAction} class="hover:text-gray-700">Candidates</a>
|
||||
<span>/</span>
|
||||
<span>{candidate.title}</span>
|
||||
</div>
|
||||
|
||||
<div class="max-w-3xl space-y-6">
|
||||
<!-- Header card -->
|
||||
<div class="bg-white rounded-lg border border-gray-200 px-6 py-5">
|
||||
<div class="flex items-start justify-between mb-3">
|
||||
<h1 class="text-2xl font-semibold">{candidate.title}</h1>
|
||||
<div class="flex gap-2 ml-4">
|
||||
<a href={EditRequirementCandidateAction { requirementCandidateId = candidate.id }}
|
||||
class="text-sm border border-gray-300 px-3 py-1.5 rounded hover:bg-gray-50">
|
||||
Edit
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-2 mb-3">
|
||||
<span class={statusClass candidate.status <> " text-xs px-2 py-0.5 rounded font-medium"}>
|
||||
{candidate.status}
|
||||
</span>
|
||||
<span class="text-xs bg-gray-100 text-gray-600 px-2 py-0.5 rounded">
|
||||
{candidate.category}
|
||||
</span>
|
||||
<span class="text-xs text-gray-400">
|
||||
Widget: {widget.name}
|
||||
</span>
|
||||
</div>
|
||||
<p class="text-sm text-gray-700 leading-relaxed">{candidate.description}</p>
|
||||
</div>
|
||||
|
||||
<!-- Source -->
|
||||
<div class="bg-white rounded-lg border border-gray-200 px-6 py-4">
|
||||
<h2 class="text-sm font-semibold text-gray-700 mb-3">Source</h2>
|
||||
{renderSource mSourceAnnotation mSourceThread}
|
||||
</div>
|
||||
|
||||
<!-- Triage actions -->
|
||||
<div class="bg-white rounded-lg border border-gray-200 px-6 py-4">
|
||||
<h2 class="text-sm font-semibold text-gray-700 mb-3">Triage</h2>
|
||||
{renderTriageActions candidate}
|
||||
</div>
|
||||
|
||||
<!-- Reviewer assignment -->
|
||||
<div class="bg-white rounded-lg border border-gray-200 px-6 py-4">
|
||||
<h2 class="text-sm font-semibold text-gray-700 mb-3">Reviewer</h2>
|
||||
{renderReviewerSection candidate mAssignment users}
|
||||
</div>
|
||||
|
||||
<!-- Triage history -->
|
||||
<div class="bg-white rounded-lg border border-gray-200 px-6 py-4">
|
||||
<h2 class="text-sm font-semibold text-gray-700 mb-3">Triage History</h2>
|
||||
{if null triageStates
|
||||
then [hsx|<p class="text-sm text-gray-400">No triage actions recorded yet.</p>|]
|
||||
else [hsx|
|
||||
<ol class="space-y-2">
|
||||
{forEach triageStates renderTriageRow}
|
||||
</ol>
|
||||
|]}
|
||||
</div>
|
||||
</div>
|
||||
|]
|
||||
|
||||
renderSource :: Maybe Annotation -> Maybe AnnotationThread -> Html
|
||||
renderSource Nothing Nothing = [hsx|<p class="text-sm text-gray-400">No source linked.</p>|]
|
||||
renderSource (Just a) _ = [hsx|
|
||||
<div class="text-sm">
|
||||
<p class="text-gray-500 mb-1">Source annotation:</p>
|
||||
<p class="text-gray-700 italic">"{a.body}"</p>
|
||||
</div>
|
||||
|]
|
||||
renderSource Nothing (Just t) = [hsx|
|
||||
<div class="text-sm">
|
||||
<p class="text-gray-500 mb-1">Source thread:</p>
|
||||
<a href={ShowAnnotationThreadAction { annotationThreadId = t.id }}
|
||||
class="text-indigo-600 hover:text-indigo-800">{t.title}</a>
|
||||
</div>
|
||||
|]
|
||||
|
||||
renderTriageActions :: RequirementCandidate -> Html
|
||||
renderTriageActions c = [hsx|
|
||||
<div class="flex flex-wrap gap-2">
|
||||
{forEach (allowedNextStatuses c.status) (renderTriageButton c.id)}
|
||||
</div>
|
||||
|]
|
||||
|
||||
allowedNextStatuses :: Text -> [Text]
|
||||
allowedNextStatuses "open" = ["in_review"]
|
||||
allowedNextStatuses "in_review" = ["accepted", "rejected", "deferred"]
|
||||
allowedNextStatuses "deferred" = ["in_review"]
|
||||
allowedNextStatuses _ = []
|
||||
|
||||
renderTriageButton :: Id RequirementCandidate -> Text -> Html
|
||||
renderTriageButton candidateId newStatus = [hsx|
|
||||
<form method="POST" action={UpdateTriageStatusAction { requirementCandidateId = candidateId }}
|
||||
class="inline">
|
||||
{hiddenField "authenticity_token"}
|
||||
<input type="hidden" name="status" value={newStatus} />
|
||||
<button type="submit" class={triageButtonClass newStatus}>
|
||||
→ {newStatus}
|
||||
</button>
|
||||
</form>
|
||||
|]
|
||||
|
||||
triageButtonClass :: Text -> Text
|
||||
triageButtonClass "accepted" = "text-sm px-3 py-1.5 rounded border bg-green-50 border-green-300 text-green-800 hover:bg-green-100"
|
||||
triageButtonClass "rejected" = "text-sm px-3 py-1.5 rounded border bg-red-50 border-red-300 text-red-800 hover:bg-red-100"
|
||||
triageButtonClass "deferred" = "text-sm px-3 py-1.5 rounded border bg-gray-50 border-gray-300 text-gray-700 hover:bg-gray-100"
|
||||
triageButtonClass _ = "text-sm px-3 py-1.5 rounded border bg-yellow-50 border-yellow-300 text-yellow-800 hover:bg-yellow-100"
|
||||
|
||||
renderReviewerSection :: RequirementCandidate -> Maybe ReviewerAssignment -> [User] -> Html
|
||||
renderReviewerSection candidate mAssignment users = [hsx|
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="text-sm text-gray-600">
|
||||
{case mAssignment of
|
||||
Nothing -> [hsx|<span class="text-gray-400">Unassigned</span>|]
|
||||
Just ra -> [hsx|<span>{reviewerName ra users}</span>|]}
|
||||
</div>
|
||||
<form method="POST" action={AssignReviewerAction { requirementCandidateId = candidate.id }}
|
||||
class="flex items-center gap-2">
|
||||
{hiddenField "authenticity_token"}
|
||||
<select name="userId" class="text-sm border border-gray-300 rounded px-2 py-1">
|
||||
{forEach users (\u -> [hsx|<option value={show u.id}>{u.name}</option>|])}
|
||||
</select>
|
||||
<button type="submit"
|
||||
class="text-sm bg-indigo-600 text-white px-3 py-1 rounded hover:bg-indigo-700">
|
||||
Assign
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|]
|
||||
|
||||
reviewerName :: ReviewerAssignment -> [User] -> Text
|
||||
reviewerName ra users =
|
||||
maybe "Unknown" (.name) (find (\u -> u.id == ra.userId) users)
|
||||
|
||||
renderTriageRow :: TriageState -> Html
|
||||
renderTriageRow ts = [hsx|
|
||||
<li class="flex items-start gap-3 text-sm">
|
||||
<span class={statusClass ts.status <> " text-xs px-2 py-0.5 rounded mt-0.5 shrink-0"}>
|
||||
{ts.status}
|
||||
</span>
|
||||
<div>
|
||||
{maybe mempty (\n -> [hsx|<p class="text-gray-700">{n}</p>|]) ts.notes}
|
||||
<p class="text-xs text-gray-400">{show ts.changedAt}</p>
|
||||
</div>
|
||||
</li>
|
||||
|]
|
||||
|
||||
statusClass :: Text -> Text
|
||||
statusClass "open" = "bg-blue-100 text-blue-700"
|
||||
statusClass "in_review" = "bg-yellow-100 text-yellow-800"
|
||||
statusClass "accepted" = "bg-green-100 text-green-800"
|
||||
statusClass "rejected" = "bg-red-100 text-red-800"
|
||||
statusClass "deferred" = "bg-gray-100 text-gray-600"
|
||||
statusClass _ = "bg-gray-100 text-gray-600"
|
||||
Reference in New Issue
Block a user