Commit 99a19646 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] generics types ShareNode

parent 9e9f2004
......@@ -23,7 +23,7 @@ import Gargantext.Components.Forest.Tree.Node.Action.Move (moveNodeReq)
import Gargantext.Components.Forest.Tree.Node.Action.Merge (mergeNodeReq)
import Gargantext.Components.Forest.Tree.Node.Action.Link (linkNodeReq)
import Gargantext.Components.Forest.Tree.Node.Action.Rename (RenameValue(..), rename)
import Gargantext.Components.Forest.Tree.Node.Action.Share (ShareValue(..), share)
import Gargantext.Components.Forest.Tree.Node.Action.Share as Share
import Gargantext.Components.Forest.Tree.Node.Action.Update (updateRequest)
import Gargantext.Components.Forest.Tree.Node.Action.Upload (uploadFile)
import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTree(..))
......@@ -274,12 +274,12 @@ performAction (RenameNode name) p@{ reload: (_ /\ setReload)
performAction RefreshTree p
-------
performAction (ShareNode username) p@{ reload: (_ /\ setReload)
performAction (ShareTeam username) p@{ reload: (_ /\ setReload)
, session
, tree: (NTree (LNode {id}) _)
} =
do
void $ share session id $ ShareValue {text:username}
void $ Share.share session id $ Share.ShareTeam {username}
-------
performAction (AddNode name nodeType) p@{ openNodes: (_ /\ setOpenNodes)
......
......@@ -23,7 +23,7 @@ data Action = AddNode String GT.NodeType
| DeleteNode
| RenameNode String
| UpdateNode UpdateNodeParams
| ShareNode String
| ShareTeam String
| DoSearch GT.AsyncTaskWithType
| UploadFile GT.NodeType FileType (Maybe String) UploadFileContents
| DownloadNode
......@@ -54,7 +54,7 @@ instance showShow :: Show Action where
show DeleteNode = "DeleteNode"
show (RenameNode _ )= "RenameNode"
show (UpdateNode _ )= "UpdateNode"
show (ShareNode _ )= "ShareNode"
show (ShareTeam _ )= "ShareTeam"
show (DoSearch _ )= "SearchQuery"
show (UploadFile _ _ _ _)= "UploadFile"
show RefreshTree = "RefreshTree"
......@@ -70,7 +70,7 @@ icon (AddNode _ _) = glyphiconNodeAction (Add [])
icon DeleteNode = glyphiconNodeAction Delete
icon (RenameNode _) = glyphiconNodeAction Config
icon (UpdateNode _) = glyphiconNodeAction Refresh
icon (ShareNode _) = glyphiconNodeAction Share
icon (ShareTeam _) = glyphiconNodeAction Share
icon (DoSearch _) = glyphiconNodeAction SearchBox
icon (UploadFile _ _ _ _) = glyphiconNodeAction Upload
icon RefreshTree = glyphiconNodeAction Refresh
......@@ -88,7 +88,7 @@ text (AddNode _ _ )= "Add !"
text DeleteNode = "Delete !"
text (RenameNode _ )= "Rename !"
text (UpdateNode _ )= "Update !"
text (ShareNode _ )= "Share !"
text (ShareTeam _ )= "Share !"
text (DoSearch _ )= "Launch search !"
text (UploadFile _ _ _ _)= "Upload File !"
text RefreshTree = "Refresh Tree !"
......
......@@ -5,20 +5,29 @@ import Data.Maybe (Maybe(..))
import Effect.Aff (Aff)
import Prelude (($))
import Reactix as R
import Gargantext.Components.Forest.Tree.Node.Action
import Gargantext.Components.Forest.Tree.Node.Action (Action)
import Gargantext.Components.Forest.Tree.Node.Action as Action
import Gargantext.Types as GT
import Gargantext.Types (ID)
import Gargantext.Routes as GR
import Gargantext.Sessions (Session, post)
import Gargantext.Components.Forest.Tree.Node.Tools as Tools
import Data.Argonaut as Argonaut
import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Gargantext.Utils.Argonaut (genericSumDecodeJson, genericSumEncodeJson, genericEnumDecodeJson, genericEnumEncodeJson)
import Data.Maybe (Maybe(..))
import Gargantext.Prelude (class Eq, class Read, class Show)
------------------------------------------------------------------------
share :: Session -> ID -> ShareValue -> Aff (Array ID)
share :: Session -> ID -> ShareNode -> Aff ID
share session nodeId =
post session $ GR.NodeAPI GT.Node (Just nodeId) "share"
shareAction :: String -> Action
shareAction username = ShareNode username
shareAction username = Action.ShareTeam username
------------------------------------------------------------------------
newtype ShareValue = ShareValue
......@@ -33,3 +42,20 @@ instance encodeJsonShareValue :: EncodeJson ShareValue where
textInputBox :: Record Tools.TextInputBoxProps -> R.Element
textInputBox = Tools.textInputBox
------------------------------------------------------------------------
data ShareNode = ShareTeam { username :: String }
| SharePublic { rights :: String }
derive instance eqShareNode :: Eq ShareNode
derive instance genericShareNode :: Generic ShareNode _
instance showShareNode :: Show ShareNode where
show = genericShow
instance decodeJsonShareNode :: Argonaut.DecodeJson ShareNode where
decodeJson = genericSumDecodeJson
instance encodeJsonShareNode :: Argonaut.EncodeJson ShareNode where
encodeJson = genericSumEncodeJson
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