module Web.View.ArchiveRecords.LineageInspector where import Web.Types import Generated.Types import IHP.Prelude import IHP.ViewPrelude import Web.Routes () data LineageInspectorView = LineageInspectorView { widget :: !Widget , events :: ![InteractionEvent] , annotations :: ![Annotation] , candidates :: ![RequirementCandidate] , requirements :: ![Requirement] , decisions :: ![DecisionRecord] , deployments :: ![DeploymentRecord] , signals :: ![OutcomeSignal] , mArchive :: !(Maybe ArchiveRecord) } instance View LineageInspectorView where html LineageInspectorView { .. } = [hsx|
{widget.name} /

Lineage Inspector

{if widget.isArchived then archivedBadge else mempty}

Full traceability chain for this widget.

{renderChainStep "1" "Widget" 1} {renderChainStep "2" "Interaction Events" (length events)} {renderChainStep "3" "Annotations" (length annotations)} {renderChainStep "4" "Requirement Candidates" (length candidates)} {renderChainStep "5" "Requirements" (length requirements)} {renderChainStep "6" "Decision Records" (length decisions)} {renderChainStep "7" "Deployments" (length deployments)} {renderChainStep "8" "Outcome Signals" (length signals)}
{maybe mempty renderArchivePanel mArchive}

Recent Interaction Events

{renderEventsTable events}
|] where renderEventsTable :: [InteractionEvent] -> Html renderEventsTable [] = [hsx|

No events recorded.

|] renderEventsTable evs = [hsx|
{forEach evs renderEventRow}
Event Type Occurred At
|] renderChainStep :: Text -> Text -> Int -> Html renderChainStep stepNum label count = [hsx|
{stepNum}
{label} {show count}
|] renderEventRow :: InteractionEvent -> Html renderEventRow e = [hsx| {e.eventType} {show e.occurredAt} |] renderArchivePanel :: ArchiveRecord -> Html renderArchivePanel archive = [hsx|

Archive Record

Archived At
{show archive.archivedAt}
Archived By
{archive.archivedBy}
Reason
{archive.reason}
|] archivedBadge :: Html archivedBadge = [hsx|Archived|]