From 6469c1aca9bb99464d592e33ba57ac687db2c6b4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 28 Feb 2014 20:37:03 -0400 Subject: [PATCH] webapp: Don't list the public repository group when editing a git repository; it only makes sense for special remotes. --- Assistant/WebApp/Configurators/Edit.hs | 17 ++++++++++++----- Types/StandardGroups.hs | 4 ++++ debian/changelog | 2 ++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Assistant/WebApp/Configurators/Edit.hs b/Assistant/WebApp/Configurators/Edit.hs index 279fe02a4c..f005e17792 100644 --- a/Assistant/WebApp/Configurators/Edit.hs +++ b/Assistant/WebApp/Configurators/Edit.hs @@ -30,6 +30,7 @@ import Logs.PreferredContent import Logs.Remote import Types.StandardGroups import qualified Git +import qualified Git.Types as Git import qualified Git.Command import qualified Git.Config import qualified Annex @@ -137,8 +138,8 @@ setRepoConfig uuid mremote oldc newc = do legalName = makeLegalName . T.unpack . repoName -editRepositoryAForm :: Bool -> RepoConfig -> MkAForm RepoConfig -editRepositoryAForm ishere def = RepoConfig +editRepositoryAForm :: Maybe Remote -> RepoConfig -> MkAForm RepoConfig +editRepositoryAForm mremote def = RepoConfig <$> areq (if ishere then readonlyTextField else textField) "Name" (Just $ repoName def) <*> aopt textField "Description" (Just $ repoDescription def) @@ -146,10 +147,16 @@ editRepositoryAForm ishere def = RepoConfig <*> associateddirectory <*> areq checkBoxField "Syncing enabled" (Just $ repoSyncable def) where + ishere = isNothing mremote + isspecial = fromMaybe False $ + (== Git.Unknown) . Git.location . Remote.repo <$> mremote groups = customgroups ++ standardgroups standardgroups :: [(Text, RepoGroup)] - standardgroups = map (\g -> (T.pack $ descStandardGroup g , RepoGroupStandard g)) - [minBound :: StandardGroup .. maxBound :: StandardGroup] + standardgroups = map (\g -> (T.pack $ descStandardGroup g , RepoGroupStandard g)) $ + filter sanegroup [minBound..maxBound] + sanegroup + | isspecial = const True + | otherwise = not . specialRemoteOnly customgroups :: [(Text, RepoGroup)] customgroups = case repoGroup def of RepoGroupCustom s -> [(T.pack s, RepoGroupCustom s)] @@ -187,7 +194,7 @@ editForm new (RepoUUID uuid) = page "Edit repository" (Just Configuration) $ do curr <- liftAnnex $ getRepoConfig uuid mremote liftAnnex $ checkAssociatedDirectory curr mremote ((result, form), enctype) <- liftH $ - runFormPostNoToken $ renderBootstrap $ editRepositoryAForm (isNothing mremote) curr + runFormPostNoToken $ renderBootstrap $ editRepositoryAForm mremote curr case result of FormSuccess input -> liftH $ do setRepoConfig uuid mremote curr input diff --git a/Types/StandardGroups.hs b/Types/StandardGroups.hs index d95f28ee1b..2f5cd4b304 100644 --- a/Types/StandardGroups.hs +++ b/Types/StandardGroups.hs @@ -72,6 +72,10 @@ associatedDirectory (Just c) PublicGroup = Just $ associatedDirectory Nothing PublicGroup = Just "public" associatedDirectory _ _ = Nothing +specialRemoteOnly :: StandardGroup -> Bool +specialRemoteOnly PublicGroup = True +specialRemoteOnly _ = False + {- See doc/preferred_content.mdwn for explanations of these expressions. -} preferredContent :: StandardGroup -> PreferredContentExpression preferredContent ClientGroup = lastResort $ diff --git a/debian/changelog b/debian/changelog index f051484b61..eeac261b88 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,8 @@ git-annex (5.20140228) UNRELEASED; urgency=medium git directory anymore. (Or are bare) * webapp: Refuse to start in a bare git repository. * assistant --autostart: Refuse to start in a bare git repository. + * webapp: Don't list the public repository group when editing a + git repository; it only makes sense for special remotes. -- Joey Hess Fri, 28 Feb 2014 14:52:15 -0400