summaryrefslogtreecommitdiff
path: root/Assistant/Alert.hs
blob: f4220eea9ae49b42327f919824c98cc30fa60729 (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
{- git-annex assistant alerts
 -
 - Copyright 2012 Joey Hess <joey@kitenet.net>
 -
 - Licensed under the GNU GPL version 3 or higher.
 -}

{-# LANGUAGE RankNTypes #-}

module Assistant.Alert where

import Yesod

type Widget = forall sub master. GWidget sub master ()

{- Different classes of alerts are displayed differently. -}
data AlertClass = Activity | Warning | Error | Success | Message
	deriving (Eq)

{- An alert can be a simple message, or an arbitrary Yesod Widget -}
data AlertMessage = StringAlert String | WidgetAlert Widget

data Alert = Alert
	{ alertClass :: AlertClass
	, alertHeader :: Maybe String
	, alertMessage :: AlertMessage
	, alertBlockDisplay :: Bool
	}

activityAlert :: Maybe String -> String -> Alert
activityAlert header message = Alert
	{ alertClass = Activity
	, alertHeader = header
	, alertMessage = StringAlert message
	, alertBlockDisplay = False
	}