module Web.View.Hubs.Show where import Web.Types import Generated.Types import IHP.Prelude import IHP.ViewPrelude data ShowView = ShowView { hub :: !Hub , widgets :: ![Widget] , recentEvents :: ![InteractionEvent] , recentAnnotations :: ![Annotation] , mManifest :: !(Maybe HubCapabilityManifest) } instance View ShowView where html ShowView { .. } = [hsx|
Hubs / {hub.name}

{hub.name}

{kindBadge hub.hubKind}

{hub.slug} {hub.domain}

Widgets

{length widgets}

Recent Events

{length recentEvents}

Recent Annotations

{length recentAnnotations}

Widgets

{forEach widgets renderWidgetRow}
Name Type Status Version

Recent Interaction Events

{forEach recentEvents renderEventRow}
Event Actor Occurred

Recent Annotations

{forEach recentAnnotations renderAnnotationCard}

Capability Manifest

{renderManifestSection mManifest hub.id}
|] renderWidgetRow :: Widget -> Html renderWidgetRow w = [hsx| {w.name} {w.widgetType} {w.status} v{show w.version} |] renderEventRow :: InteractionEvent -> Html renderEventRow e = [hsx| {e.eventType} {e.actorType} {show e.occurredAt} |] renderAnnotationCard :: Annotation -> Html renderAnnotationCard a = [hsx|
{a.category} {a.actorType}

{a.body}

|] renderManifestSection :: Maybe HubCapabilityManifest -> Id Hub -> Html renderManifestSection Nothing hubId = [hsx|

No capability manifest registered for this hub.

Domain hubs should declare their vocabulary before creating hub-owned type registry entries.

Register Capabilities
|] renderManifestSection (Just m) _ = [hsx|
{manifestStatusBadge m.status} v{m.manifestVersion} {forEach (maybeText m.capabilityDescription) (\d -> [hsx|— {d}|])}
View manifest →
{forEach (maybeText m.contact) (\c -> [hsx|

Contact: {c}

|])}
|] manifestStatusBadge :: Text -> Html manifestStatusBadge "active" = [hsx|active|] manifestStatusBadge "draft" = [hsx|draft|] manifestStatusBadge "retired" = [hsx|retired|] manifestStatusBadge s = [hsx|{s}|] kindBadge :: Text -> Html kindBadge "framework" = [hsx|framework|] kindBadge "shared" = [hsx|shared|] kindBadge _ = [hsx|domain|] maybeText :: Maybe Text -> [Text] maybeText Nothing = [] maybeText (Just t) = [t]