summaryrefslogtreecommitdiff
path: root/Assistant/Alert.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-10-29 16:48:06 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-10-29 16:50:38 -0400
commitfcfe4f532f4a87cccd1e61423e1f43c0e8e83c6a (patch)
treebeda9d60b0390c416538ed9da494f43c30c8720e /Assistant/Alert.hs
parent16d6ab71124876f7cffb79778cf8de1b23b5c1ba (diff)
webapp: remind user when using repositories that lack consistency checks
When starting up the assistant, it'll remind about the current repository, if it doesn't have checks. And when a removable drive is plugged in, it will remind if a repository on it lacks checks. Since that might be annoying, the reminders can be turned off. This commit was sponsored by Nedialko Andreev.
Diffstat (limited to 'Assistant/Alert.hs')
-rw-r--r--Assistant/Alert.hs44
1 files changed, 36 insertions, 8 deletions
diff --git a/Assistant/Alert.hs b/Assistant/Alert.hs
index ff378a7b0..b10a724ed 100644
--- a/Assistant/Alert.hs
+++ b/Assistant/Alert.hs
@@ -15,7 +15,6 @@ import Assistant.Alert.Utility
import qualified Remote
import Utility.Tense
import Logs.Transfer
-import Git.Remote (RemoteName)
import Data.String
import qualified Data.Text as T
@@ -168,25 +167,54 @@ sanityCheckFixAlert msg = Alert
alerthead = "The daily sanity check found and fixed a problem:"
alertfoot = "If these problems persist, consider filing a bug report."
-fsckAlert :: AlertButton -> Maybe RemoteName -> Alert
-fsckAlert button n = baseActivityAlert
- { alertData = case n of
+fsckingAlert :: AlertButton -> Maybe Remote -> Alert
+fsckingAlert button mr = baseActivityAlert
+ { alertData = case mr of
Nothing -> [ UnTensed $ T.pack $ "Consistency check in progress" ]
- Just remotename -> [ UnTensed $ T.pack $ "Consistency check of " ++ remotename ++ " in progress"]
+ Just r -> [ UnTensed $ T.pack $ "Consistency check of " ++ Remote.name r ++ " in progress"]
, alertButton = Just button
}
-showFscking :: UrlRenderer -> Maybe RemoteName -> IO (Either E.SomeException a) -> Assistant a
-showFscking urlrenderer remotename a = do
+showFscking :: UrlRenderer -> Maybe Remote -> IO (Either E.SomeException a) -> Assistant a
+showFscking urlrenderer mr a = do
#ifdef WITH_WEBAPP
button <- mkAlertButton False (T.pack "Configure") urlrenderer ConfigFsckR
- r <- alertDuring (fsckAlert button remotename) $
+ r <- alertDuring (fsckingAlert button mr) $
liftIO a
#else
r <- liftIO a
#endif
either (liftIO . E.throwIO) return r
+notFsckedNudge :: UrlRenderer -> Maybe Remote -> Assistant ()
+#ifdef WITH_WEBAPP
+notFsckedNudge urlrenderer mr = do
+ button <- mkAlertButton True (T.pack "Configure") urlrenderer ConfigFsckR
+ void $ addAlert (notFsckedAlert mr button)
+#else
+notFsckedNudge _ = noop
+#endif
+
+notFsckedAlert :: Maybe Remote -> AlertButton -> Alert
+notFsckedAlert mr button = Alert
+ { alertHeader = Just $ fromString $ concat
+ [ "You should enable consistency checking to protect your data"
+ , maybe "" (\r -> " in " ++ Remote.name r) mr
+ , "."
+ ]
+ , alertIcon = Just InfoIcon
+ , alertPriority = High
+ , alertButton = Just button
+ , alertClosable = True
+ , alertClass = Message
+ , alertMessageRender = renderData
+ , alertCounter = 0
+ , alertBlockDisplay = True
+ , alertName = Just NotFsckedAlert
+ , alertCombiner = Just $ dataCombiner $ \_old new -> new
+ , alertData = []
+ }
+
brokenRepositoryAlert :: AlertButton -> Alert
brokenRepositoryAlert = errorAlert "Serious problems have been detected with your repository. This needs your immediate attention!"