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
import Gargantext.Database.Action.User.New
import Gargantext.Database.Admin.Types.Node
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.Prelude
import Servant
......@@ -75,7 +75,12 @@ api userInviting nId (ShareTeamParams user') = do
printDebug "[G.A.N.Share.api]" ("demo users are not allowed to invite" :: Text)
pure ()
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
True -> do
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
<$> findNodes' rootId mode
pure ns
-- | TODO not clear enough:
-- | Shared is for Shared with me but I am not the owner of it
-- | Private is for all Lists I have created
......
......@@ -30,6 +30,7 @@ module Gargantext.Database.Query.Tree
, dt_typeId
, findShared
, findNodes
, findNodesWithType
, NodeMode(..)
)
where
......@@ -38,7 +39,8 @@ import Control.Lens (view, toListOf, at, each, _Just, to, set, makeLenses)
import Control.Monad.Except (MonadError())
import Data.List (tail, concat, nub)
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 Database.PostgreSQL.Simple
import Database.PostgreSQL.Simple.SqlQQ
......@@ -171,6 +173,14 @@ findNodesId :: RootId -> [NodeType] -> Cmd err [NodeId]
findNodesId r nt = tail
<$> map _dt_nodeId
<$> 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
......
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