module Web.View.WidgetAdapterSpecs.Show where import Web.Types import Generated.Types import IHP.Prelude import IHP.ViewPrelude import Application.Helper.View (adapterStatusBadge) data ShowView = ShowView { spec :: !WidgetAdapterSpec , mEnvelope :: !(Maybe EnvelopeEmissionContract) , mReporting :: !(Maybe InteractionReportingContract) , widgets :: ![Widget] } instance View ShowView where html ShowView { .. } = [hsx|
← Adapter Specs
{spec.framework}

{spec.name}

" text-xs px-2 py-0.5 rounded font-medium"}> {spec.status} {maturityBadge spec.maturity}
Edit status / notes
Spec Version
{spec.version}
Registered Widgets
{length widgets}
Envelope Contract
{renderEnvelopeLink mEnvelope}
Reporting Contract
{renderReportingLink mReporting}
{forEach (specNotes spec) (\n -> [hsx|
Notes: {n}
|])} {if null widgets then [hsx|

No widgets assigned to this adapter spec.

|] else [hsx|

Assigned Widgets

{forEach widgets renderWidgetRow}
Name Type Status
|]} |] renderEnvelopeLink :: Maybe EnvelopeEmissionContract -> Html renderEnvelopeLink Nothing = [hsx||] renderEnvelopeLink (Just c) = [hsx| v{c.contractVersion} |] renderReportingLink :: Maybe InteractionReportingContract -> Html renderReportingLink Nothing = [hsx||] renderReportingLink (Just c) = [hsx| v{c.contractVersion} |] renderWidgetRow :: Widget -> Html renderWidgetRow w = [hsx| {w.name} {w.widgetType} {w.status} |] specNotes :: WidgetAdapterSpec -> [Text] specNotes s = case s.notes of Just n -> [n] Nothing -> [] maturityBadge :: Text -> Html maturityBadge "stable" = [hsx|Stable|] maturityBadge "beta" = [hsx|Beta|] maturityBadge "experimental" = [hsx|Experimental|] maturityBadge "deprecated" = [hsx|Deprecated|] maturityBadge m = [hsx|{m}|]