$newline never

$# SPDX-FileCopyrightText: 2022 Gregor Kleen <gregor.kleen@ifi.lmu.de>,Sarah Vaupel <sarah.vaupel@ifi.lmu.de>
$#
$# SPDX-License-Identifier: AGPL-3.0-or-later

$maybe WorkflowCurrentState{..} <- workflowState
  <section>
    $maybe archived <- wcsArchived
      $if now < archived
        ^{notification NotificationBroad =<< messageWidget Warning (archivationScheduled archived)}

    <h2>
      _{MsgWorkflowWorkflowWorkflowStateHeading}

    <div .workflow-state>
      <dl .deflist>
        <dt .deflist__dt>
          _{MsgWorkflowWorkflowWorkflowStateStateLabel}
        <dd .deflist__dd>
          $maybe (stLbl, stFin) <- wcsState
            #{stLbl}
            $maybe icn <- stFin
              &nbsp;#{icon icn}
          $nothing
            <span .workflow-state--state-special>
              _{MsgWorkflowWorkflowWorkflowStateStateHidden}
        $maybe archived <- wcsArchived
          $if now >= archived
            <dt .deflist__dt>
              _{MsgWorkflowWorkflowWorkflowStateArchivedLabel} #
              ^{messageTooltip =<< messageI Info MsgWorkflowWorkflowWorkflowArchivationInfo}
            <dd .deflist__dd>
              ^{formatTimeW SelFormatDateTime archived}

    $forall msg <- wcsMessages
      ^{notification NotificationBroad msg}
  
    $if not (onull wcsPayload)
      <div .workflow-payload>
        <div .workflow-payload--label>
          _{MsgWorkflowWorkflowWorkflowPayloadHeading}
        <dl .deflist>
          $forall (payloadLbl, (newPayload, mFileRoute)) <- wcsPayload
            <dt .deflist__dt>
              #{payloadLbl}
            <dd .deflist__dd>
              $if is _Nothing mFileRoute && null newPayload
                —
              $else
                <ul .list--iconless>
                  $maybe fileRoute <- mFileRoute
                    <li>
                      <a href=#{fileRoute}>
                        _{MsgWorkflowPayloadFiles}
                  $forall pItem <- newPayload
                    <li>
                      ^{payloadToWidget pItem}
  
$maybe edgeView <- mEdgeView
  <section>
    <h2>
      _{MsgWorkflowWorkflowWorkflowEdgeFormHeading}
    ^{edgeView}
  
<section>
  <h2>
    _{MsgWorkflowWorkflowWorkflowHistoryHeading}

  <div .workflow-history-labels .explanation>
    <div .workflow-history-labels__others>
      _{MsgWorkflowWorkflowWorkflowHistoryLabelOthers}
    <div .workflow-history-labels__own>
      _{MsgWorkflowWorkflowWorkflowHistoryLabelOwn}

  <ul .workflow-history>
    $forall histItem <- workflowHistory
      ^{historyToWidget histItem}
