From 531f1d1446afef8005591cb85d2f1296cfc4d3dd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 27 Oct 2012 12:25:29 -0400 Subject: [PATCH] add XMPP nudge alert, displayed after making a cloud repository --- Assistant/Alert.hs | 16 ++++++++++++++++ Assistant/WebApp/Configurators/Edit.hs | 4 ++++ Assistant/WebApp/Configurators/S3.hs | 2 +- Assistant/WebApp/Configurators/Ssh.hs | 2 +- Assistant/WebApp/Configurators/XMPP.hs | 13 +++++++++++++ Assistant/WebApp/routes | 1 + doc/assistant/xmppnudge.png | Bin 0 -> 6156 bytes 7 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 doc/assistant/xmppnudge.png diff --git a/Assistant/Alert.hs b/Assistant/Alert.hs index d873d21c7f..102863ea3d 100644 --- a/Assistant/Alert.hs +++ b/Assistant/Alert.hs @@ -34,6 +34,7 @@ data AlertName | SanityCheckFixAlert | WarningAlert String | PairAlert String + | XMPPNeededAlert deriving (Eq) {- The first alert is the new alert, the second is an old alert. @@ -322,6 +323,21 @@ pairRequestAcknowledgedAlert repo button = baseActivityAlert , alertButton = button } +xmppNeededAlert :: AlertButton -> Alert +xmppNeededAlert button = Alert + { alertHeader = Just "Keep your repositories in sync across the cloud, or share with friends." + , alertIcon = Just TheCloud + , alertPriority = High + , alertButton = Just button + , alertClosable = True + , alertClass = Message + , alertMessageRender = tenseWords + , alertBlockDisplay = True + , alertName = Just $ XMPPNeededAlert + , alertCombiner = Just $ dataCombiner $ \_old new -> new + , alertData = [] + } + fileAlert :: TenseChunk -> FilePath -> Alert fileAlert msg file = (activityAlert Nothing [f]) { alertName = Just $ FileAlert msg diff --git a/Assistant/WebApp/Configurators/Edit.hs b/Assistant/WebApp/Configurators/Edit.hs index bb48737623..64d89c911e 100644 --- a/Assistant/WebApp/Configurators/Edit.hs +++ b/Assistant/WebApp/Configurators/Edit.hs @@ -16,6 +16,7 @@ import Assistant.WebApp.SideBar import Assistant.WebApp.Utility import Assistant.DaemonStatus import Assistant.MakeRemote (uniqueRemoteName) +import Assistant.WebApp.Configurators.XMPP (xmppNeeded) import Utility.Yesod import qualified Remote import qualified Remote.List as Remote @@ -100,6 +101,9 @@ getEditRepositoryR = editForm False getEditNewRepositoryR :: UUID -> Handler RepHtml getEditNewRepositoryR = editForm True +getEditNewCloudRepositoryR :: UUID -> Handler RepHtml +getEditNewCloudRepositoryR uuid = xmppNeeded >> editForm True uuid + editForm :: Bool -> UUID -> Handler RepHtml editForm new uuid = bootstrap (Just Config) $ do sideBarDisplay diff --git a/Assistant/WebApp/Configurators/S3.hs b/Assistant/WebApp/Configurators/S3.hs index cd019be0b8..e4401d445f 100644 --- a/Assistant/WebApp/Configurators/S3.hs +++ b/Assistant/WebApp/Configurators/S3.hs @@ -125,4 +125,4 @@ makeS3Remote (S3Creds ak sk) name setup config = do return remotename setup r liftIO $ syncNewRemote st (daemonStatus webapp) (scanRemotes webapp) r - redirect $ EditNewRepositoryR $ Remote.uuid r + redirect $ EditNewCloudRepositoryR $ Remote.uuid r diff --git a/Assistant/WebApp/Configurators/Ssh.hs b/Assistant/WebApp/Configurators/Ssh.hs index 9c97a017f5..9da291b0c6 100644 --- a/Assistant/WebApp/Configurators/Ssh.hs +++ b/Assistant/WebApp/Configurators/Ssh.hs @@ -290,7 +290,7 @@ makeSshRepo forcersync setup sshdata = do (scanRemotes webapp) forcersync sshdata setup r - redirect $ EditNewRepositoryR $ Remote.uuid r + redirect $ EditNewCloudRepositoryR $ Remote.uuid r getAddRsyncNetR :: Handler RepHtml getAddRsyncNetR = do diff --git a/Assistant/WebApp/Configurators/XMPP.hs b/Assistant/WebApp/Configurators/XMPP.hs index 830bea8aeb..80472c1d75 100644 --- a/Assistant/WebApp/Configurators/XMPP.hs +++ b/Assistant/WebApp/Configurators/XMPP.hs @@ -13,6 +13,8 @@ module Assistant.WebApp.Configurators.XMPP where import Assistant.WebApp import Assistant.WebApp.Types import Assistant.WebApp.SideBar +import Assistant.Alert +import Assistant.DaemonStatus import Utility.Yesod #ifdef WITH_XMPP import Assistant.Common @@ -29,6 +31,17 @@ import Data.Text (Text) import qualified Data.Text as T #endif +{- Displays an alert suggesting to configure XMPP, with a button. -} +xmppNeeded :: Handler () +xmppNeeded = whenM (isNothing <$> runAnnex Nothing getXMPPCreds) $ do + dstatus <- daemonStatus <$> getYesod + urlrender <- getUrlRender + void $ liftIO $ addAlert dstatus $ xmppNeededAlert $ AlertButton + { buttonLabel = "Configure a Jabber account" + , buttonUrl = urlrender XMPPR + , buttonAction = Just $ removeAlert dstatus + } + getXMPPR :: Handler RepHtml #ifdef WITH_XMPP getXMPPR = xmppPage $ do diff --git a/Assistant/WebApp/routes b/Assistant/WebApp/routes index b9885f9e5c..2e848f44ef 100644 --- a/Assistant/WebApp/routes +++ b/Assistant/WebApp/routes @@ -13,6 +13,7 @@ /config/repository/switchto/#FilePath SwitchToRepositoryR GET /config/repository/edit/#UUID EditRepositoryR GET /config/repository/edit/new/#UUID EditNewRepositoryR GET +/config/repository/edit/new/cloud/#UUID EditNewCloudRepositoryR GET /config/repository/sync/disable/#UUID DisableSyncR GET /config/repository/sync/enable/#UUID EnableSyncR GET diff --git a/doc/assistant/xmppnudge.png b/doc/assistant/xmppnudge.png new file mode 100644 index 0000000000000000000000000000000000000000..b3a0658cbfc1d62839c20952b588ac469cab716f GIT binary patch literal 6156 zcmZ8l1yCEzwhr!E+-ZSQyg-rSk|M=g+}#OKQi?-x3PoC+;1n(HP^2^zf;G4XcS@iT zTp$0v_szU_XJ>b3cXrPC&d%)F^L-z6v{Xn483+LY0EwEa^4o{`@S%s|V?KHSYTJ|KKd|@7gBpSnPcXQY8{1YstO$+9Z2HKA8 z4W*^vz2TlY+l8v{jVMS;6jYpAc!kgOPLDk69TRfKVa97%l;}BquI%RnbTI z99aa|lp_&15oSUyGph&nQYy}A5;5eVy#qxJwzf3=@NgA$85Bjwtex`aBh?WjJ7q!W z8AY@@4WkMW&)C_FzWFIo*K18g5xa)_OJO-L>}=)F7DZMnkRp-dF@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