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 (Just $ ShowWidgetAction { widgetId = widget.id })} {renderChainStep "2" "Interaction Events" (length events) Nothing} {renderChainStep "3" "Annotations" (length annotations) Nothing} {renderChainStep "4" "Requirement Candidates" (length candidates) Nothing} {renderChainStep "5" "Requirements" (length requirements) Nothing} {renderChainStep "6" "Decision Records" (length decisions) Nothing} {renderChainStep "7" "Deployments" (length deployments) Nothing} {renderChainStep "8" "Outcome Signals" (length signals) Nothing}
{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 -> Maybe a -> Html renderChainStep stepNum label count mLink = [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|]