Commit 167b8698 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] Invitation if completed corpus exists

parent f0b921c1
...@@ -27,7 +27,7 @@ import Gargantext.Database.Action.User ...@@ -27,7 +27,7 @@ import Gargantext.Database.Action.User
import Gargantext.Database.Action.User.New import Gargantext.Database.Action.User.New
import Gargantext.Database.Admin.Types.Node import Gargantext.Database.Admin.Types.Node
import Gargantext.Database.Prelude import Gargantext.Database.Prelude
import Gargantext.Database.Query.Tree (findNodesId) import Gargantext.Database.Query.Tree (findNodesWithType)
import Gargantext.Database.Query.Table.Node.Error (HasNodeError(..)) import Gargantext.Database.Query.Table.Node.Error (HasNodeError(..))
import Gargantext.Prelude import Gargantext.Prelude
import Servant import Servant
...@@ -75,7 +75,12 @@ api userInviting nId (ShareTeamParams user') = do ...@@ -75,7 +75,12 @@ api userInviting nId (ShareTeamParams user') = do
printDebug "[G.A.N.Share.api]" ("demo users are not allowed to invite" :: Text) printDebug "[G.A.N.Share.api]" ("demo users are not allowed to invite" :: Text)
pure () pure ()
False -> do False -> do
children <- findNodesId nId [NodeCorpus] -- TODO better analysis of the composition of what is shared
children <- findNodesWithType nId [NodeList] [ NodeFolderShared
, NodeTeam
, NodeFolder
, NodeCorpus
]
_ <- case List.null children of _ <- case List.null children of
True -> do True -> do
printDebug "[G.A.N.Share.api]" ("Invitation is enabled if you share a corpus at least" :: Text) printDebug "[G.A.N.Share.api]" ("Invitation is enabled if you share a corpus at least" :: Text)
......
...@@ -31,6 +31,8 @@ findListsId u mode = do ...@@ -31,6 +31,8 @@ findListsId u mode = do
<$> findNodes' rootId mode <$> findNodes' rootId mode
pure ns pure ns
-- | TODO not clear enough: -- | TODO not clear enough:
-- | Shared is for Shared with me but I am not the owner of it -- | Shared is for Shared with me but I am not the owner of it
-- | Private is for all Lists I have created -- | Private is for all Lists I have created
......
...@@ -30,6 +30,7 @@ module Gargantext.Database.Query.Tree ...@@ -30,6 +30,7 @@ module Gargantext.Database.Query.Tree
, dt_typeId , dt_typeId
, findShared , findShared
, findNodes , findNodes
, findNodesWithType
, NodeMode(..) , NodeMode(..)
) )
where where
...@@ -38,7 +39,8 @@ import Control.Lens (view, toListOf, at, each, _Just, to, set, makeLenses) ...@@ -38,7 +39,8 @@ import Control.Lens (view, toListOf, at, each, _Just, to, set, makeLenses)
import Control.Monad.Except (MonadError()) import Control.Monad.Except (MonadError())
import Data.List (tail, concat, nub) import Data.List (tail, concat, nub)
import Data.Map (Map, fromListWith, lookup) import Data.Map (Map, fromListWith, lookup)
import qualified Data.Set as Set import qualified Data.Set as Set
import qualified Data.List as List
import Data.Text (Text) import Data.Text (Text)
import Database.PostgreSQL.Simple import Database.PostgreSQL.Simple
import Database.PostgreSQL.Simple.SqlQQ import Database.PostgreSQL.Simple.SqlQQ
...@@ -171,6 +173,14 @@ findNodesId :: RootId -> [NodeType] -> Cmd err [NodeId] ...@@ -171,6 +173,14 @@ findNodesId :: RootId -> [NodeType] -> Cmd err [NodeId]
findNodesId r nt = tail findNodesId r nt = tail
<$> map _dt_nodeId <$> map _dt_nodeId
<$> dbTree r nt <$> dbTree r nt
findNodesWithType :: RootId -> [NodeType] -> [NodeType] -> Cmd err [DbTreeNode]
findNodesWithType root target through =
filter isInTarget <$> dbTree root through
where
isInTarget n = List.elem (fromNodeTypeId $ view dt_typeId n)
$ List.nub $ target <> through
------------------------------------------------------------------------ ------------------------------------------------------------------------
------------------------------------------------------------------------ ------------------------------------------------------------------------
toTree :: ( MonadError e m toTree :: ( MonadError e m
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment