Commit 95d4771f authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[tree] properly refresh tree after dispatch

parent e558ac4c
...@@ -6,7 +6,7 @@ import Data.Maybe (Maybe(..), fromMaybe) ...@@ -6,7 +6,7 @@ import Data.Maybe (Maybe(..), fromMaybe)
import Data.Set as Set import Data.Set as Set
import Data.Tuple (fst, snd) import Data.Tuple (fst, snd)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log) import DOM.Simple.Console (log, log2)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
...@@ -71,13 +71,14 @@ forestCpt = R.hooksComponentWithModule thisModule "forest" cpt where ...@@ -71,13 +71,14 @@ forestCpt = R.hooksComponentWithModule thisModule "forest" cpt where
/\ (fst asyncTasks).storage /\ (fst asyncTasks).storage
/\ handed /\ handed
) )
(cpt' openNodes asyncTasks reload showLogin backend) (cpt' openNodes asyncTasks appReload reload showLogin backend)
cpt' openNodes asyncTasks reload showLogin backend (frontends /\ route /\ sessions /\ _ /\ _ /\ _ /\ _ /\ handed) = do cpt' openNodes asyncTasks appReload reload showLogin backend (frontends /\ route /\ sessions /\ _ /\ _ /\ _ /\ _ /\ handed) = do
pure $ R2.row $ [plus handed showLogin backend] <> trees pure $ R2.row $ [plus handed showLogin backend] <> trees
where where
trees = tree <$> unSessions sessions trees = tree <$> unSessions sessions
tree s@(Session {treeId}) = tree s@(Session {treeId}) =
treeView { asyncTasks treeView { appReload
, asyncTasks
, frontends , frontends
, handed , handed
, mCurrentRoute: Just route , mCurrentRoute: Just route
......
...@@ -6,6 +6,7 @@ import Data.Maybe (Maybe(..)) ...@@ -6,6 +6,7 @@ import Data.Maybe (Maybe(..))
import Data.Set as Set import Data.Set as Set
import Data.Tuple (Tuple(..), fst, snd) import Data.Tuple (Tuple(..), fst, snd)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect.Aff (Aff) import Effect.Aff (Aff)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Reactix as R import Reactix as R
...@@ -44,11 +45,12 @@ thisModule = "Gargantext.Components.Forest.Tree" ...@@ -44,11 +45,12 @@ thisModule = "Gargantext.Components.Forest.Tree"
------------------------------------------------------------------------ ------------------------------------------------------------------------
type CommonProps = ( type CommonProps = (
frontends :: Frontends appReload :: GT.ReloadS
, frontends :: Frontends
, handed :: GT.Handed , handed :: GT.Handed
, mCurrentRoute :: Maybe AppRoute , mCurrentRoute :: Maybe AppRoute
, openNodes :: R.State OpenNodes , openNodes :: R.State OpenNodes
, reload :: R.State Reload , reload :: GT.ReloadS
, session :: Session , session :: Session
) )
...@@ -65,7 +67,8 @@ treeView = R.createElement elCpt ...@@ -65,7 +67,8 @@ treeView = R.createElement elCpt
elCpt :: R.Component Props elCpt :: R.Component Props
elCpt = R.hooksComponentWithModule thisModule "treeView" cpt elCpt = R.hooksComponentWithModule thisModule "treeView" cpt
cpt { asyncTasks cpt { appReload
, asyncTasks
, frontends , frontends
, handed , handed
, mCurrentRoute , mCurrentRoute
...@@ -74,7 +77,8 @@ treeView = R.createElement elCpt ...@@ -74,7 +77,8 @@ treeView = R.createElement elCpt
, root , root
, session , session
} _children = do } _children = do
pure $ treeLoadView { asyncTasks pure $ treeLoadView { appReload
, asyncTasks
, frontends , frontends
, handed , handed
, mCurrentRoute , mCurrentRoute
...@@ -90,7 +94,8 @@ treeLoadView = R.createElement elCpt ...@@ -90,7 +94,8 @@ treeLoadView = R.createElement elCpt
elCpt :: R.Component Props elCpt :: R.Component Props
elCpt = R.hooksComponentWithModule thisModule "treeLoadView" cpt elCpt = R.hooksComponentWithModule thisModule "treeLoadView" cpt
cpt { asyncTasks cpt { appReload
, asyncTasks
, frontends , frontends
, handed , handed
, mCurrentRoute , mCurrentRoute
...@@ -110,7 +115,8 @@ treeLoadView = R.createElement elCpt ...@@ -110,7 +115,8 @@ treeLoadView = R.createElement elCpt
-- -- , tasks: tasksStruct root asyncTasks reload -- -- , tasks: tasksStruct root asyncTasks reload
-- , tree: loaded -- , tree: loaded
-- } [] -- } []
let paint loaded = loadedTreeViewFirstLevel { asyncTasks let paint loaded = loadedTreeViewFirstLevel { appReload
, asyncTasks
, frontends , frontends
, handed , handed
, mCurrentRoute , mCurrentRoute
...@@ -135,36 +141,38 @@ type TreeViewProps = ( ...@@ -135,36 +141,38 @@ type TreeViewProps = (
| CommonProps | CommonProps
) )
loadedTreeView :: R2.Component TreeViewProps -- loadedTreeView :: R2.Component TreeViewProps
loadedTreeView = R.createElement elCpt -- loadedTreeView = R.createElement elCpt
where -- where
elCpt :: R.Component TreeViewProps -- elCpt :: R.Component TreeViewProps
elCpt = R.hooksComponentWithModule thisModule "loadedTreeView" cpt -- elCpt = R.hooksComponentWithModule thisModule "loadedTreeView" cpt
cpt { asyncTasks -- cpt { appReload
, frontends -- , asyncTasks
, handed -- , frontends
, mCurrentRoute -- , handed
, openNodes -- , mCurrentRoute
, reload -- , openNodes
, session -- , reload
-- , tasks -- , session
, tree -- -- , tasks
} _ = do -- , tree
pure $ H.ul { className: "tree" } [ -- } _ = do
H.div { className: if handed == GT.RightHanded then "righthanded" else "lefthanded" } [ -- pure $ H.ul { className: "tree" } [
toHtml { asyncTasks -- H.div { className: if handed == GT.RightHanded then "righthanded" else "lefthanded" } [
, frontends -- toHtml { appReload
, handed -- , asyncTasks
, mCurrentRoute -- , frontends
, openNodes -- , handed
, reload -- , mCurrentRoute
, session -- , openNodes
-- , tasks -- , reload
, tree -- , session
} [] -- -- , tasks
] -- , tree
] -- } []
-- ]
-- ]
loadedTreeViewFirstLevel :: R2.Component TreeViewProps loadedTreeViewFirstLevel :: R2.Component TreeViewProps
loadedTreeViewFirstLevel = R.createElement elCpt loadedTreeViewFirstLevel = R.createElement elCpt
...@@ -172,7 +180,8 @@ loadedTreeViewFirstLevel = R.createElement elCpt ...@@ -172,7 +180,8 @@ loadedTreeViewFirstLevel = R.createElement elCpt
elCpt :: R.Component TreeViewProps elCpt :: R.Component TreeViewProps
elCpt = R.hooksComponentWithModule thisModule "loadedTreeViewFirstLevel" cpt elCpt = R.hooksComponentWithModule thisModule "loadedTreeViewFirstLevel" cpt
cpt { asyncTasks cpt { appReload
, asyncTasks
, frontends , frontends
, handed , handed
, mCurrentRoute , mCurrentRoute
...@@ -184,12 +193,14 @@ loadedTreeViewFirstLevel = R.createElement elCpt ...@@ -184,12 +193,14 @@ loadedTreeViewFirstLevel = R.createElement elCpt
} _ = do } _ = do
pure $ H.ul { className: "tree" } [ pure $ H.ul { className: "tree" } [
H.div { className: if handed == GT.RightHanded then "righthanded" else "lefthanded" } [ H.div { className: if handed == GT.RightHanded then "righthanded" else "lefthanded" } [
toHtmlFirstLevel { asyncTasks toHtmlFirstLevel { appReload
, asyncTasks
, frontends , frontends
, handed , handed
, mCurrentRoute , mCurrentRoute
, openNodes , openNodes
, reload , reload
, reloadTree: reload
, session , session
-- , tasks -- , tasks
, tree , tree
...@@ -202,73 +213,83 @@ loadedTreeViewFirstLevel = R.createElement elCpt ...@@ -202,73 +213,83 @@ loadedTreeViewFirstLevel = R.createElement elCpt
type ToHtmlProps = ( type ToHtmlProps = (
asyncTasks :: GAT.Reductor asyncTasks :: GAT.Reductor
, reloadTree :: GT.ReloadS
-- , tasks :: Record Tasks -- , tasks :: Record Tasks
, tree :: FTree , tree :: FTree
| CommonProps | CommonProps
) )
toHtml :: R2.Component ToHtmlProps -- toHtml :: R2.Component ToHtmlProps
toHtml = R.createElement elCpt -- toHtml = R.createElement elCpt
where -- where
elCpt :: R.Component ToHtmlProps -- elCpt :: R.Component ToHtmlProps
elCpt = R.hooksComponentWithModule thisModule "toHtml" cpt -- elCpt = R.hooksComponentWithModule thisModule "toHtml" cpt
cpt p@{ asyncTasks -- cpt p@{ appReload
, frontends -- , asyncTasks
, handed -- , frontends
, mCurrentRoute -- , handed
, openNodes -- , mCurrentRoute
, reload: reload@(_ /\ setReload) -- , openNodes
, session -- , reload: reload@(_ /\ setReload)
, tree: tree@(NTree (LNode { id -- , session
, name -- , tree: tree@(NTree (LNode { id
, nodeType -- , name
} -- , nodeType
) ary -- }
) -- ) ary
} _ = do -- )
let commonProps = RecordE.pick p :: Record CommonProps -- } _ = do
let pAction a = performAction a (RecordE.pick p :: Record PerformActionProps) -- setPopoverRef <- R.useRef Nothing
let nodeId = mkNodeId session id -- let commonProps = RecordE.pick p :: Record CommonProps
let folderIsOpen = Set.member nodeId (fst openNodes) -- let pAction a = performAction a (RecordE.pick (Record.merge { appReload, setPopoverRef } p) :: Record PerformActionProps)
let setFn = if folderIsOpen then Set.delete else Set.insert
let toggleFolderIsOpen _ = (snd openNodes) (setFn nodeId) -- let nodeId = mkNodeId session id
let folderOpen = Tuple folderIsOpen toggleFolderIsOpen -- let folderIsOpen = Set.member nodeId (fst openNodes)
-- let setFn = if folderIsOpen then Set.delete else Set.insert
let withId (NTree (LNode {id: id'}) _) = id' -- let toggleFolderIsOpen _ = (snd openNodes) (setFn nodeId)
-- let folderOpen = Tuple folderIsOpen toggleFolderIsOpen
let publicizedChildren = if isPublic nodeType
then map (\t -> map (\(LNode n@{ nodeType: nt } ) -- let withId (NTree (LNode {id: id'}) _) = id'
-> (LNode (n { nodeType = publicize nt }))
) t) ary -- let publicizedChildren = if isPublic nodeType
else ary -- then map (\t -> map (\(LNode n@{ nodeType: nt } )
-- -> (LNode (n { nodeType = publicize nt }))
pure $ H.li { className: if A.null ary then "no-children" else "with-children" } -- ) t) ary
[ nodeSpan { appReload: reload -- else ary
, asyncTasks
, dispatch: pAction -- pure $ H.li { className: if A.null ary then "no-children" else "with-children" }
, folderOpen -- [ nodeSpan { appReload
, frontends -- , asyncTasks
, handed -- , dispatch: pAction
, id -- , folderOpen
, isLeaf: A.null ary -- , frontends
, mCurrentRoute -- , handed
, name -- , id
, nodeType -- , isLeaf: A.null ary
, session -- , mCurrentRoute
-- , tasks -- , name
} -- , nodeType
( -- , session
childNodes ( Record.merge commonProps -- , setPopoverRef
{ asyncTasks -- -- , tasks
, children: publicizedChildren -- }
, folderOpen -- (
, handed -- childNodes ( Record.merge commonProps
} -- { asyncTasks
) -- , children: publicizedChildren
) -- , folderOpen
] -- , handed
-- }
-- )
-- )
-- ]
-- type ToHtmlFirstLevelProps = (
-- appReload :: GT.ReloadS
-- | ToHtmlProps
-- )
toHtmlFirstLevel :: R2.Component ToHtmlProps toHtmlFirstLevel :: R2.Component ToHtmlProps
toHtmlFirstLevel = R.createElement elCpt toHtmlFirstLevel = R.createElement elCpt
...@@ -276,12 +297,14 @@ toHtmlFirstLevel = R.createElement elCpt ...@@ -276,12 +297,14 @@ toHtmlFirstLevel = R.createElement elCpt
elCpt :: R.Component ToHtmlProps elCpt :: R.Component ToHtmlProps
elCpt = R.hooksComponentWithModule thisModule "toHtmlFirstLevel" cpt elCpt = R.hooksComponentWithModule thisModule "toHtmlFirstLevel" cpt
cpt p@{ asyncTasks cpt p@{ appReload
, asyncTasks
, frontends , frontends
, handed , handed
, mCurrentRoute , mCurrentRoute
, openNodes , openNodes
, reload: reload@(_ /\ setReload) , reload: reload@(_ /\ setReload)
, reloadTree
, session , session
, tree: tree@(NTree (LNode { id , tree: tree@(NTree (LNode { id
, name , name
...@@ -290,7 +313,9 @@ toHtmlFirstLevel = R.createElement elCpt ...@@ -290,7 +313,9 @@ toHtmlFirstLevel = R.createElement elCpt
) ary ) ary
) )
} _ = do } _ = do
let pAction a = performAction a (RecordE.pick p :: Record PerformActionProps) setPopoverRef <- R.useRef Nothing
let pAction a = performAction a (RecordE.pick (Record.merge p { setPopoverRef }) :: Record PerformActionProps)
let nodeId = mkNodeId session id let nodeId = mkNodeId session id
let folderIsOpen = Set.member nodeId (fst openNodes) let folderIsOpen = Set.member nodeId (fst openNodes)
...@@ -301,20 +326,21 @@ toHtmlFirstLevel = R.createElement elCpt ...@@ -301,20 +326,21 @@ toHtmlFirstLevel = R.createElement elCpt
let withId (NTree (LNode {id: id'}) _) = id' let withId (NTree (LNode {id: id'}) _) = id'
pure $ H.li { className: if A.null ary then "no-children" else "with-children" } $ pure $ H.li { className: if A.null ary then "no-children" else "with-children" } $
[ nodeSpan { appReload: reload [ nodeSpan { appReload
, asyncTasks , asyncTasks
, dispatch: pAction , dispatch: pAction
, folderOpen , folderOpen
, frontends , frontends
, handed , handed
, id , id
, isLeaf: A.null ary , isLeaf: A.null ary
, mCurrentRoute , mCurrentRoute
, name , name
, nodeType , nodeType
, session , session
-- , tasks , setPopoverRef
} -- , tasks
}
$ renderChildren folderOpen publicizedChildren $ renderChildren folderOpen publicizedChildren
] ]
where where
...@@ -335,6 +361,7 @@ toHtmlFirstLevel = R.createElement elCpt ...@@ -335,6 +361,7 @@ toHtmlFirstLevel = R.createElement elCpt
, folderOpen , folderOpen
, handed , handed
, id: cId , id: cId
, reloadTree
} }
) [] ) []
) $ sorted publicizedChildren ) $ sorted publicizedChildren
...@@ -355,35 +382,36 @@ toHtmlFirstLevel = R.createElement elCpt ...@@ -355,35 +382,36 @@ toHtmlFirstLevel = R.createElement elCpt
sorted = A.sortWith (\(NTree (LNode {id}) _) -> id) sorted = A.sortWith (\(NTree (LNode {id}) _) -> id)
type ChildNodesProps = -- type ChildNodesProps =
( asyncTasks :: GAT.Reductor -- ( asyncTasks :: GAT.Reductor
, children :: Array FTree -- , children :: Array FTree
, folderOpen :: R.State Boolean -- , folderOpen :: R.State Boolean
| CommonProps -- | CommonProps
) -- )
childNodes :: Record ChildNodesProps -> Array R.Element -- childNodes :: Record ChildNodesProps -> Array R.Element
childNodes { children: [] } = [] -- childNodes { children: [] } = []
childNodes { folderOpen: (false /\ _) } = [] -- childNodes { folderOpen: (false /\ _) } = []
childNodes props@{ asyncTasks, children, reload, handed } = -- childNodes props@{ asyncTasks, children, reload, handed } =
map (\ctree@(NTree (LNode {id}) _) -> H.ul {} [ -- map (\ctree@(NTree (LNode {id}) _) -> H.ul {} [
toHtml (Record.merge commonProps { asyncTasks -- toHtml (Record.merge commonProps { asyncTasks
, handed -- , handed
-- , tasks: tasksStruct id asyncTasks reload -- -- , tasks: tasksStruct id asyncTasks reload
, tree: ctree -- , tree: ctree
} -- }
) [] -- ) []
] -- ]
) $ sorted children -- ) $ sorted children
where -- where
commonProps = RecordE.pick props :: Record CommonProps -- commonProps = RecordE.pick props :: Record CommonProps
sorted :: Array FTree -> Array FTree -- sorted :: Array FTree -> Array FTree
sorted = A.sortWith (\(NTree (LNode {id}) _) -> id) -- sorted = A.sortWith (\(NTree (LNode {id}) _) -> id)
type ChildNodeFirstLevelProps = ( type ChildNodeFirstLevelProps = (
asyncTasks :: GAT.Reductor asyncTasks :: GAT.Reductor
, folderOpen :: R.State Boolean , folderOpen :: R.State Boolean
, id :: ID , id :: ID
, reloadTree :: GT.ReloadS
| CommonProps | CommonProps
) )
...@@ -393,27 +421,40 @@ childNodeFirstLevel = R.createElement elCpt ...@@ -393,27 +421,40 @@ childNodeFirstLevel = R.createElement elCpt
elCpt :: R.Component ChildNodeFirstLevelProps elCpt :: R.Component ChildNodeFirstLevelProps
elCpt = R.hooksComponentWithModule thisModule "childNodeFirstLevel" cpt elCpt = R.hooksComponentWithModule thisModule "childNodeFirstLevel" cpt
cpt props@{ asyncTasks, folderOpen, id, frontends, handed, mCurrentRoute, openNodes, reload, session } _ = do cpt props@{ appReload
, asyncTasks
, folderOpen
, id
, frontends
, handed
, mCurrentRoute
, openNodes
, reload
, reloadTree
, session } _ = do
cptReload <- R.useState' 0 cptReload <- R.useState' 0
let fetch _ = getNodeTreeFirstLevel session id let fetch _ = getNodeTreeFirstLevel session id
let paint loaded = childNodeFirstLevelPaint { asyncTasks let paint loaded = childNodeFirstLevelPaint { appReload
, asyncTasks
, folderOpen , folderOpen
, frontends , frontends
, handed , handed
, mCurrentRoute , mCurrentRoute
, openNodes , openNodes
, reload: cptReload , reload: cptReload
, reloadTree
, session , session
, tree: loaded } [] , tree: loaded } []
useLoader { counter: fst cptReload, root: id } fetch paint useLoader { counter: fst cptReload, root: id, treeCounter: fst reloadTree } fetch paint
type ChildNodeFirstLevelPaintProps = ( type ChildNodeFirstLevelPaintProps = (
asyncTasks :: GAT.Reductor asyncTasks :: GAT.Reductor
, folderOpen :: R.State Boolean , folderOpen :: R.State Boolean
, tree :: FTree , reloadTree :: GT.ReloadS
, tree :: FTree
| CommonProps | CommonProps
) )
...@@ -425,10 +466,15 @@ childNodeFirstLevelPaint = R.createElement elCpt ...@@ -425,10 +466,15 @@ childNodeFirstLevelPaint = R.createElement elCpt
-- TODO folderOpen is unused -- TODO folderOpen is unused
cpt props@{ asyncTasks, handed, reload, tree: ctree@(NTree (LNode { id }) _) } _ = do cpt props@{ asyncTasks
, handed
, reload
, reloadTree
, tree: ctree@(NTree (LNode { id }) _) } _ = do
pure $ H.ul {} [ pure $ H.ul {} [
toHtmlFirstLevel (Record.merge commonProps { asyncTasks toHtmlFirstLevel (Record.merge commonProps { asyncTasks
, handed , handed
, reloadTree
, tree: ctree } , tree: ctree }
) [] ) []
] ]
...@@ -437,13 +483,16 @@ childNodeFirstLevelPaint = R.createElement elCpt ...@@ -437,13 +483,16 @@ childNodeFirstLevelPaint = R.createElement elCpt
commonProps = RecordE.pick props :: Record CommonProps commonProps = RecordE.pick props :: Record CommonProps
type PerformActionProps = type PerformActionProps = (
( asyncTasks :: GAT.Reductor appReload :: GT.ReloadS
, openNodes :: R.State OpenNodes , asyncTasks :: GAT.Reductor
, reload :: R.State Reload , openNodes :: R.State OpenNodes
, session :: Session , reload :: GT.ReloadS
, reloadTree :: GT.ReloadS
, session :: Session
, setPopoverRef :: R.Ref (Maybe (Boolean -> Effect Unit))
-- , tasks :: Record Tasks -- , tasks :: Record Tasks
, tree :: FTree , tree :: FTree
) )
------- -------
...@@ -451,7 +500,6 @@ performAction :: Action ...@@ -451,7 +500,6 @@ performAction :: Action
-> Record PerformActionProps -> Record PerformActionProps
-> Aff Unit -> Aff Unit
performAction (DeleteNode nt) p@{ openNodes: (_ /\ setOpenNodes) performAction (DeleteNode nt) p@{ openNodes: (_ /\ setOpenNodes)
, reload: (_ /\ setReload)
, session , session
, tree: (NTree (LNode {id, parent_id}) _) , tree: (NTree (LNode {id, parent_id}) _)
} = } =
...@@ -485,8 +533,7 @@ performAction (UpdateNode params) { asyncTasks: (_ /\ dispatch) ...@@ -485,8 +533,7 @@ performAction (UpdateNode params) { asyncTasks: (_ /\ dispatch)
------- -------
performAction (RenameNode name) p@{ reload: (_ /\ setReload) performAction (RenameNode name) p@{ session
, session
, tree: (NTree (LNode {id}) _) , tree: (NTree (LNode {id}) _)
} = } =
do do
...@@ -494,8 +541,7 @@ performAction (RenameNode name) p@{ reload: (_ /\ setReload) ...@@ -494,8 +541,7 @@ performAction (RenameNode name) p@{ reload: (_ /\ setReload)
performAction RefreshTree p performAction RefreshTree p
------- -------
performAction (ShareTeam username) p@{ reload: (_ /\ setReload) performAction (ShareTeam username) p@{ session
, session
, tree: (NTree (LNode {id}) _) , tree: (NTree (LNode {id}) _)
} = } =
do do
...@@ -513,8 +559,7 @@ performAction (SharePublic {params}) p@{ session ...@@ -513,8 +559,7 @@ performAction (SharePublic {params}) p@{ session
performAction RefreshTree p performAction RefreshTree p
performAction (AddContact params) p@{ reload: (_ /\ setReload) performAction (AddContact params) p@{ session
, session
, tree: (NTree (LNode {id}) _) , tree: (NTree (LNode {id}) _)
} = } =
void $ Contact.contactReq session id params void $ Contact.contactReq session id params
...@@ -523,7 +568,6 @@ performAction (AddContact params) p@{ reload: (_ /\ setReload) ...@@ -523,7 +568,6 @@ performAction (AddContact params) p@{ reload: (_ /\ setReload)
------- -------
performAction (AddNode name nodeType) p@{ openNodes: (_ /\ setOpenNodes) performAction (AddNode name nodeType) p@{ openNodes: (_ /\ setOpenNodes)
, reload: (_ /\ setReload)
, session , session
, tree: (NTree (LNode {id}) _) , tree: (NTree (LNode {id}) _)
} = } =
...@@ -577,8 +621,13 @@ performAction (LinkNode {nodeType, params}) p@{session} = do ...@@ -577,8 +621,13 @@ performAction (LinkNode {nodeType, params}) p@{session} = do
performAction RefreshTree p performAction RefreshTree p
------- -------
performAction RefreshTree { reload: (_ /\ setReload) } = do performAction RefreshTree { reloadTree: (_ /\ setReload)
liftEffect $ setReload (_ + 1) , setPopoverRef } = do
liftEffect $ do
setReload (_ + 1)
case R.readRef setPopoverRef of
Nothing -> pure unit
Just setPopover -> setPopover false
------- -------
performAction NoAction _ = do performAction NoAction _ = do
liftEffect $ log "[performAction] NoAction" liftEffect $ log "[performAction] NoAction"
......
...@@ -5,6 +5,7 @@ import Data.Maybe (Maybe(..)) ...@@ -5,6 +5,7 @@ import Data.Maybe (Maybe(..))
import Data.Nullable (null) import Data.Nullable (null)
import Data.Tuple (snd) import Data.Tuple (snd)
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect.Aff (Aff, launchAff) import Effect.Aff (Aff, launchAff)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import React.SyntheticEvent as E import React.SyntheticEvent as E
...@@ -39,7 +40,6 @@ import Gargantext.Utils.Reactix as R2 ...@@ -39,7 +40,6 @@ import Gargantext.Utils.Reactix as R2
thisModule :: String thisModule :: String
thisModule = "Gargantext.Components.Forest.Tree.Node" thisModule = "Gargantext.Components.Forest.Tree.Node"
-- Main Node -- Main Node
type NodeMainSpanProps = ( type NodeMainSpanProps = (
appReload :: GT.ReloadS appReload :: GT.ReloadS
...@@ -51,6 +51,7 @@ type NodeMainSpanProps = ( ...@@ -51,6 +51,7 @@ type NodeMainSpanProps = (
, mCurrentRoute :: Maybe Routes.AppRoute , mCurrentRoute :: Maybe Routes.AppRoute
, name :: Name , name :: Name
, nodeType :: GT.NodeType , nodeType :: GT.NodeType
, setPopoverRef :: R.Ref (Maybe (Boolean -> Effect Unit))
| CommonProps | CommonProps
) )
...@@ -83,6 +84,7 @@ nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt ...@@ -83,6 +84,7 @@ nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt
, name , name
, nodeType , nodeType
, session , session
, setPopoverRef
} _ = do } _ = do
-- only 1 popup at a time is allowed to be opened -- only 1 popup at a time is allowed to be opened
droppedFile <- R.useState' (Nothing :: Maybe DroppedFile) droppedFile <- R.useState' (Nothing :: Maybe DroppedFile)
...@@ -90,6 +92,9 @@ nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt ...@@ -90,6 +92,9 @@ nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt
popoverRef <- R.useRef null popoverRef <- R.useRef null
R.useEffect' $ do
R.setRef setPopoverRef $ Just $ Popover.setOpen popoverRef
let ordering = let ordering =
case handed of case handed of
GT.LeftHanded -> reverse GT.LeftHanded -> reverse
......
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