module Web.View.HubRoutingRules.Index where import Web.Types import Generated.Types import IHP.Prelude import IHP.ViewPrelude data IndexView = IndexView { rules :: ![HubRoutingRule] , hubs :: ![Hub] } instance View IndexView where html IndexView { .. } = [hsx|

Hub Routing Rules

New Rule
{if null rules then [hsx|

No routing rules configured yet.

|] else [hsx|
{forEach rules renderRow}
Source → Target Match Category Match Widget Type Priority Status
|]} |] where hubName hid = maybe (show hid) (.name) (find (\h -> h.id == hid) hubs) renderRow :: HubRoutingRule -> Html renderRow r = [hsx| {hubName r.sourceHubId} → {hubName r.targetHubId} {maybe "any" id r.matchCategory} {maybe "any" id r.matchWidgetType} {show r.priority} " text-xs px-2 py-0.5 rounded font-medium"}> {r.status} View {if r.status == "inactive" then [hsx|Activate|] else [hsx|Deactivate|]} |] statusBadge :: Text -> Text statusBadge s = case s of "active" -> "bg-green-100 text-green-700" "inactive" -> "bg-gray-100 text-gray-500" _ -> "bg-gray-100 text-gray-600"