Commit da90f04c authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FEAT PUBLIC] fix API

parent f58dad0d
...@@ -46,6 +46,7 @@ import Gargantext.Core.Types (NodeTableResult) ...@@ -46,6 +46,7 @@ import Gargantext.Core.Types (NodeTableResult)
import Gargantext.Core.Types.Individu (User(..)) import Gargantext.Core.Types.Individu (User(..))
import Gargantext.Core.Types.Main (Tree, NodeTree) import Gargantext.Core.Types.Main (Tree, NodeTree)
import Gargantext.Database.Action.Flow.Pairing (pairing) import Gargantext.Database.Action.Flow.Pairing (pairing)
import Gargantext.Database.Action.Share (unPublish)
import Gargantext.Database.Admin.Types.Node import Gargantext.Database.Admin.Types.Node
import Gargantext.Database.Prelude -- (Cmd, CmdM) import Gargantext.Database.Prelude -- (Cmd, CmdM)
import Gargantext.Database.Query.Facet (FacetDoc, OrderBy(..)) import Gargantext.Database.Query.Facet (FacetDoc, OrderBy(..))
...@@ -144,6 +145,7 @@ type NodeAPI a = Get '[JSON] (Node a) ...@@ -144,6 +145,7 @@ type NodeAPI a = Get '[JSON] (Node a)
:<|> "phylo" :> PhyloAPI :<|> "phylo" :> PhyloAPI
-- :<|> "add" :> NodeAddAPI -- :<|> "add" :> NodeAddAPI
:<|> "move" :> MoveAPI :<|> "move" :> MoveAPI
:<|> "unpublish" :> Post '[JSON] Int
-- TODO-ACCESS: check userId CanRenameNode nodeId -- TODO-ACCESS: check userId CanRenameNode nodeId
-- TODO-EVENTS: NodeRenamed RenameNode or re-use some more general NodeEdited... -- TODO-EVENTS: NodeRenamed RenameNode or re-use some more general NodeEdited...
...@@ -219,6 +221,8 @@ nodeAPI p uId id' = withAccess (Proxy :: Proxy (NodeAPI a)) Proxy uId (PathNode ...@@ -219,6 +221,8 @@ nodeAPI p uId id' = withAccess (Proxy :: Proxy (NodeAPI a)) Proxy uId (PathNode
:<|> moveNode (RootId $ NodeId uId) id' :<|> moveNode (RootId $ NodeId uId) id'
-- :<|> nodeAddAPI id' -- :<|> nodeAddAPI id'
-- :<|> postUpload id' -- :<|> postUpload id'
:<|> unPublish (RootId $ NodeId uId) id'
------------------------------------------------------------------------ ------------------------------------------------------------------------
data RenameNode = RenameNode { r_name :: Text } data RenameNode = RenameNode { r_name :: Text }
......
...@@ -36,8 +36,10 @@ data ShareNode = ShareTeam { username :: Text } ...@@ -36,8 +36,10 @@ data ShareNode = ShareTeam { username :: Text }
deriving (Generic) deriving (Generic)
------------------------------------------------------------------------ ------------------------------------------------------------------------
-- TODO unPrefix "pn_" FromJSON, ToJSON, ToSchema, adapt frontend. -- TODO unPrefix "pn_" FromJSON, ToJSON, ToSchema, adapt frontend.
instance FromJSON ShareNode instance FromJSON ShareNode where
instance ToJSON ShareNode parseJSON = genericParseJSON (defaultOptions { sumEncoding = ObjectWithSingleField })
instance ToJSON ShareNode where
toJSON = genericToJSON (defaultOptions { sumEncoding = ObjectWithSingleField })
instance ToSchema ShareNode instance ToSchema ShareNode
instance Arbitrary ShareNode where instance Arbitrary ShareNode where
arbitrary = elements [ ShareTeam "user1" arbitrary = elements [ ShareTeam "user1"
...@@ -59,3 +61,7 @@ type API = Summary " Share Node with username" ...@@ -59,3 +61,7 @@ type API = Summary " Share Node with username"
:> ReqBody '[JSON] ShareNode :> ReqBody '[JSON] ShareNode
:> Post '[JSON] Int :> Post '[JSON] Int
...@@ -65,6 +65,7 @@ getFolderId u nt = do ...@@ -65,6 +65,7 @@ getFolderId u nt = do
Nothing -> panic "No folder shared found" Nothing -> panic "No folder shared found"
Just f -> pure (_node_id f) Just f -> pure (_node_id f)
------------------------------------------------------------------------
type TeamId = NodeId type TeamId = NodeId
delFolderTeam :: User -> TeamId -> Cmd err Int delFolderTeam :: User -> TeamId -> Cmd err Int
...@@ -77,4 +78,3 @@ unPublish u nId = do ...@@ -77,4 +78,3 @@ unPublish u nId = do
folderId <- getFolderId u NodeFolderPublic folderId <- getFolderId u NodeFolderPublic
deleteNodeNode folderId nId deleteNodeNode folderId nId
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