Action.purs 3.6 KB
Newer Older
1
module Gargantext.Components.Forest.Tree.Node.Action where
2

3 4
import Gargantext.Prelude

5
import Data.Maybe (Maybe(..))
6
import Effect.Aff (Aff)
7
import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..))
8 9 10
import Gargantext.Components.Forest.Tree.Node.Settings (NodeAction(..), glyphiconNodeAction)
import Gargantext.Components.Forest.Tree.Node.Tools.FTree (ID)
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeOut, SubTreeParams(..))
11
import Gargantext.Sessions (Session)
12
import Gargantext.Types as GT
13 14 15

type Props =
  ( dispatch :: Action -> Aff Unit
16
  , id       :: ID
17 18
  , nodeType :: GT.NodeType
  , session  :: Session
Alexandre Delanoë's avatar
Alexandre Delanoë committed
19
  )
20

21

22
subTreeOut :: Action -> Maybe SubTreeOut
23 24 25 26
subTreeOut (MoveNode    {params}) = params
subTreeOut (MergeNode   {params}) = params
subTreeOut (LinkNode    {params}) = params
subTreeOut (SharePublic {params}) = params
27 28 29
subTreeOut _                    = Nothing

setTreeOut ::  Action -> Maybe SubTreeOut -> Action
Alexandre Delanoë's avatar
Alexandre Delanoë committed
30
setTreeOut (MoveNode  {params:_}) p = MoveNode  {params: p}
Alexandre Delanoë's avatar
Alexandre Delanoë committed
31
setTreeOut (MergeNode {params:_}) p = MergeNode {params: p}
32
setTreeOut (LinkNode  {nodeType, params:_}) p = LinkNode  {nodeType, params: p}
33
setTreeOut (SharePublic {params:_}) p = SharePublic  {params: p}
34 35
setTreeOut a   _             = a

36
-----------------------------------------------------------------------
37
icon :: Action -> String
38 39 40 41 42 43 44 45
icon (AddNode    _ _)             = glyphiconNodeAction (Add [])
icon (DeleteNode _)               = glyphiconNodeAction Delete
icon (RenameNode _)               = glyphiconNodeAction Config
icon (UpdateNode _)               = glyphiconNodeAction Refresh
icon (ShareTeam   _)              = glyphiconNodeAction Share
icon (AddContact  _)              = glyphiconNodeAction Share
icon (SharePublic _ )             = glyphiconNodeAction (Publish { subTreeParams : SubTreeParams {showtypes:[], valitypes:[] }})
icon (DoSearch   _)               = glyphiconNodeAction SearchBox
46 47
icon (UploadFile _ _ _ _ _)       = glyphiconNodeAction Upload
icon (UploadArbitraryFile _ _ _ ) = glyphiconNodeAction Upload
48
icon  RefreshTree                 = glyphiconNodeAction Refresh
49
icon  ClosePopover                = glyphiconNodeAction CloseNodePopover
50 51 52 53
icon  DownloadNode                = glyphiconNodeAction Download
icon (MoveNode _ )                = glyphiconNodeAction (Move  { subTreeParams : SubTreeParams {showtypes:[], valitypes:[] }})
icon (MergeNode _ )               = glyphiconNodeAction (Merge { subTreeParams : SubTreeParams {showtypes:[], valitypes:[] }})
icon (LinkNode _  )               = glyphiconNodeAction (Link  { subTreeParams : SubTreeParams {showtypes:[], valitypes:[] }})
54

55
icon NoAction                     = "hand-o-right"
56

57 58
-- icon _             = "hand-o-right"

59
text :: Action -> String
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
text (AddNode     _ _    )        = "Add !"
text (DeleteNode _       )        = "Delete !"
text (RenameNode  _      )        = "Rename !"
text (UpdateNode  _      )        = "Update !"
text (ShareTeam   _      )        = "Share with team !"
text (AddContact  _      )        = "Add contact !"
text (SharePublic _      )        = "Publish !"
text (DoSearch    _      )        = "Launch search !"
text (UploadFile  _ _ _ _ _)      = "Upload File !"
text (UploadArbitraryFile _  _ _) = "Upload arbitrary file !"
text  RefreshTree                 = "Refresh Tree !"
text  ClosePopover                = "Close Popover !"
text DownloadNode                 = "Download !"
text (MoveNode  _ )               = "Move !"
text (MergeNode _ )               = "Merge !"
text (LinkNode  _ )               = "Link !"
text NoAction                     = "No Action"
77
-----------------------------------------------------------------------
78