module Web.View.CrossHubPropagations.Index where
import Web.Types
import Generated.Types
import IHP.Prelude
import IHP.ViewPrelude
data IndexView = IndexView
{ propagations :: ![CrossHubPropagation]
, hubs :: ![Hub]
}
instance View IndexView where
html IndexView { .. } = [hsx|
{if null propagations
then [hsx|No propagation events detected yet.
|]
else [hsx|
| Pattern |
Summary |
Source Hub |
Status |
Detected |
|
{forEach propagations renderRow}
|]}
|]
where
hubName hid = maybe "–" (.name) (find (\h -> h.id == hid) hubs)
renderRow :: CrossHubPropagation -> Html
renderRow p = [hsx|
|
{p.patternType}
|
{p.summary} |
{maybe "–" hubName p.sourceHubId}
|
" text-xs px-2 py-0.5 rounded font-medium"}>
{p.status}
|
{show p.detectedAt} |
{if p.status == "open"
then [hsx|
Acknowledge
|]
else mempty}
{if p.status /= "resolved"
then [hsx|
Resolve
|]
else mempty}
|
|]
statusBadge :: Text -> Text
statusBadge s = case s of
"open" -> "bg-yellow-100 text-yellow-800"
"acknowledged" -> "bg-blue-100 text-blue-800"
"resolved" -> "bg-green-100 text-green-800"
_ -> "bg-gray-100 text-gray-600"