basic repository edit form
Only shows description so far.
This commit is contained in:
parent
b6a3f03f82
commit
f06587ba23
2 changed files with 47 additions and 21 deletions
|
@ -13,31 +13,44 @@ import Assistant.Common
|
||||||
import Assistant.WebApp
|
import Assistant.WebApp
|
||||||
import Assistant.WebApp.Types
|
import Assistant.WebApp.Types
|
||||||
import Assistant.WebApp.SideBar
|
import Assistant.WebApp.SideBar
|
||||||
import Assistant.Sync
|
|
||||||
import Assistant.MakeRemote
|
|
||||||
import Utility.Yesod
|
import Utility.Yesod
|
||||||
import Init
|
import qualified Remote
|
||||||
import qualified Git
|
import Logs.UUID
|
||||||
import qualified Git.Construct
|
|
||||||
import qualified Git.Config
|
|
||||||
import qualified Annex
|
|
||||||
import Locations.UserConfig
|
|
||||||
import Utility.FreeDesktop
|
|
||||||
import Utility.Mounts
|
|
||||||
import Utility.DiskFree
|
|
||||||
import Utility.DataUnits
|
|
||||||
import Utility.Network
|
|
||||||
import Remote (prettyListUUIDs)
|
|
||||||
import Logs.Group
|
|
||||||
import Annex.UUID
|
|
||||||
|
|
||||||
import Yesod
|
import Yesod
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Data.Set as S
|
import qualified Data.Map as M
|
||||||
import Data.Char
|
|
||||||
import System.Posix.Directory
|
data RepoConfig = RepoConfig
|
||||||
import qualified Control.Exception as E
|
{ repoDescription :: Text
|
||||||
|
}
|
||||||
|
deriving (Show)
|
||||||
|
|
||||||
|
editRepositoryAForm :: RepoConfig -> AForm WebApp WebApp RepoConfig
|
||||||
|
editRepositoryAForm def = RepoConfig
|
||||||
|
<$> areq textField "Description" (Just $ repoDescription def)
|
||||||
|
|
||||||
|
getRepoConfig :: UUID -> Annex RepoConfig
|
||||||
|
getRepoConfig uuid = RepoConfig
|
||||||
|
<$> (T.pack . fromMaybe "" . M.lookup uuid <$> uuidMap)
|
||||||
|
|
||||||
getEditRepositoryR :: UUID -> Handler RepHtml
|
getEditRepositoryR :: UUID -> Handler RepHtml
|
||||||
getEditRepositoryR u = error "TODO"
|
getEditRepositoryR uuid = bootstrap (Just Config) $ do
|
||||||
|
sideBarDisplay
|
||||||
|
setTitle "Configure repository"
|
||||||
|
|
||||||
|
curr <- lift $ runAnnex undefined $ getRepoConfig uuid
|
||||||
|
((result, form), enctype) <- lift $
|
||||||
|
runFormGet $ renderBootstrap $ editRepositoryAForm curr
|
||||||
|
case result of
|
||||||
|
FormSuccess input -> do
|
||||||
|
error (show input)
|
||||||
|
_ -> showform form enctype
|
||||||
|
where
|
||||||
|
showform form enctype = do
|
||||||
|
let authtoken = webAppFormAuthToken
|
||||||
|
description <- lift $
|
||||||
|
runAnnex T.empty $ T.pack . concat <$>
|
||||||
|
Remote.prettyListUUIDs [uuid]
|
||||||
|
$(widgetFile "configurators/editrepository")
|
||||||
|
|
13
templates/configurators/editrepository.hamlet
Normal file
13
templates/configurators/editrepository.hamlet
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<div .span9 .hero-unit>
|
||||||
|
<h2>
|
||||||
|
Configuring #{description}
|
||||||
|
<p>
|
||||||
|
<form .form-horizontal enctype=#{enctype}>
|
||||||
|
<fieldset>
|
||||||
|
^{form}
|
||||||
|
^{authtoken}
|
||||||
|
<div .form-actions>
|
||||||
|
<button .btn .btn-primary type=submit>
|
||||||
|
Save Changes
|
||||||
|
<a .btn href="@{RepositoriesR}">
|
||||||
|
Cancel
|
Loading…
Reference in a new issue