viewPullRequestWithApproval :: ProjectInfo -> PullRequestId -> PullRequest -> Html
viewPullRequestWithApproval info prId pullRequest = do
  viewPullRequest info prId pullRequest
  case Project.approvedBy pullRequest of
    Just username ->
      span ! class_ "review" $ do
        void "Approved by "
        -- TODO: Link to approval comment, not just username.
        let url = Text.append "https://github.com/" username
        a ! href (toValue url) $ toHtml username
    Nothing ->
      fail $
        "Tried to render approval link for pull request " ++ (show prId) ++
        " which was not approved. This is a programming error."

-- Render all pull requests in the list with the given view function.
-- TODO: Use a safer abstraction, than a list of IDs for which it is not clear
-- from the types that lookup will not fail.
viewPullRequestWithApproval :: ProjectInfo -> PullRequestId -> PullRequest -> Html
viewPullRequestWithApproval info prId pullRequest = do
  viewPullRequest info prId pullRequest
  case Project.approvedBy pullRequest of
    Just username ->
      span ! class_ "review" $ do
        void "Approved by "
        -- TODO: Link to approval comment, not just username.
        let url = Text.append "https://github.com/" username
        a ! href (toValue url) $ toHtml username
    Nothing ->
      fail $
        "Tried to render approval link for pull request " ++ (show prId) ++
        " which was not approved. This is a programming error."

-- Render all pull requests in the list with the given view function.
-- TODO: Use a safer abstraction, than a list of IDs for which it is not clear
-- from the types that lookup will not fail.
viewPullRequestWithApproval info prId pullRequest = do
  viewPullRequest info prId pullRequest
  case Project.approvedBy pullRequest of
    Just username ->
      span ! class_ "review" $ do
        void "Approved by "
        -- TODO: Link to approval comment, not just username.
        let url = Text.append "https://github.com/" username
        a ! href (toValue url) $ toHtml username
    Nothing ->
      fail $
        "Tried to render approval link for pull request " ++ (show prId) ++
        " which was not approved. This is a programming error."

-- Render all pull requests in the list with the given view function.
-- TODO: Use a safer abstraction, than a list of IDs for which it is not clear
-- from the types that lookup will not fail.