aboutsummaryrefslogtreecommitdiffstats
path: root/app/History/IssueEvent.hs
blob: 93bd133ab61cbbb1c6e232466269a147b333e0d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
module History.IssueEvent (IssueEvent (..)) where

import History.CommitHash (CommitHash)
import Issue (Issue)
import Issue.Render qualified as I
import Patch (Patch)
import Render ((<<<))
import Render qualified as P

data IssueEvent
  = IssueCreated
      { hash :: CommitHash,
        issue :: Issue,
        patch :: Patch
      }
  | IssueChanged
      { hash :: CommitHash,
        oldIssue :: Issue,
        issue :: Issue,
        patch :: Patch
      }
  | IssueDeleted
      { hash :: CommitHash,
        issue :: Issue,
        patch :: Patch
      }
  deriving (Show)

instance P.Render IssueEvent where
  render = P.render . P.Detailed

instance P.Render (P.Detailed IssueEvent) where
  render (P.Detailed issueEvent) =
    P.Summarized issueEvent
      <<< P.hardline @P.AnsiStyle
      <<< issueEvent.patch

instance P.Render (P.Summarized IssueEvent) where
  render (P.Summarized issueEvent) =
    case issueEvent of
      IssueCreated {hash, issue} ->
        P.Summarized hash
          <<< P.styled [P.color P.Green] "created"
          <<< I.IssueTitle issue
      IssueChanged {hash, issue} ->
        P.Summarized hash
          <<< P.styled [P.color P.Green] "changed"
          <<< I.IssueTitle issue
      IssueDeleted {hash, issue} ->
        P.Summarized hash
          <<< P.styled [P.color P.Green] "deleted"
          <<< I.IssueTitle issue