[refactor] remove 'session' from various Props in favor of

'useSession' in context
parent a5d78f02
...@@ -34,6 +34,7 @@ import Gargantext.Config.REST (AffRESTError, logRESTError) ...@@ -34,6 +34,7 @@ import Gargantext.Config.REST (AffRESTError, logRESTError)
import Gargantext.Config.Utils (handleRESTError) import Gargantext.Config.Utils (handleRESTError)
import Gargantext.Hooks.LinkHandler (useLinkHandler) import Gargantext.Hooks.LinkHandler (useLinkHandler)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Session (useSession)
import Gargantext.Routes (AppRoute(Home), appPath, nodeTypeAppRoute) import Gargantext.Routes (AppRoute(Home), appPath, nodeTypeAppRoute)
import Gargantext.Sessions (Session(..), sessionId) import Gargantext.Sessions (Session(..), sessionId)
import Gargantext.Types (NodeType(..), SessionId) import Gargantext.Types (NodeType(..), SessionId)
...@@ -48,8 +49,8 @@ here :: R2.Here ...@@ -48,8 +49,8 @@ here :: R2.Here
here = R2.here "Gargantext.Components.FolderView" here = R2.here "Gargantext.Components.FolderView"
type Props = type Props =
( nodeId :: Int ( nodeId :: Int
, session :: Session , session :: Session
) )
data FolderStyle = FolderUp | FolderChild data FolderStyle = FolderUp | FolderChild
...@@ -67,7 +68,6 @@ folderViewCpt = here.component "folderViewCpt" cpt where ...@@ -67,7 +68,6 @@ folderViewCpt = here.component "folderViewCpt" cpt where
, render: \folders -> folderViewMain { folders , render: \folders -> folderViewMain { folders
, nodeId , nodeId
, reload , reload
, session
} [] } } [] }
where where
errorHandler = logRESTError here "[folderView]" errorHandler = logRESTError here "[folderView]"
...@@ -76,7 +76,6 @@ type FolderViewProps = ...@@ -76,7 +76,6 @@ type FolderViewProps =
( folders :: TreeFirstLevel ( folders :: TreeFirstLevel
, nodeId :: Int , nodeId :: Int
, reload :: T.Box T2.Reload , reload :: T.Box T2.Reload
, session :: Session
) )
folderViewMain :: R2.Component FolderViewProps folderViewMain :: R2.Component FolderViewProps
...@@ -103,7 +102,6 @@ folderViewMainCpt = here.component "folderViewMainCpt" cpt where ...@@ -103,7 +102,6 @@ folderViewMainCpt = here.component "folderViewMainCpt" cpt where
, linkNodeType: node.node_type , linkNodeType: node.node_type
, parentId: props.nodeId , parentId: props.nodeId
, reload: props.reload , reload: props.reload
, session: props.session
, style: FolderChild , style: FolderChild
, text: node.name , text: node.name
, disabled: false , disabled: false
...@@ -119,7 +117,6 @@ folderViewMainCpt = here.component "folderViewMainCpt" cpt where ...@@ -119,7 +117,6 @@ folderViewMainCpt = here.component "folderViewMainCpt" cpt where
, nodeType: root.node_type , nodeType: root.node_type
, parentId: parent.id , parentId: parent.id
, reload: props.reload , reload: props.reload
, session: props.session
, style: FolderUp , style: FolderUp
, text: "..." , text: "..."
, disabled: disabled parent , disabled: disabled parent
...@@ -139,7 +136,6 @@ type FolderProps = ...@@ -139,7 +136,6 @@ type FolderProps =
, nodeId :: Int , nodeId :: Int
, linkNodeType :: GT.NodeType , linkNodeType :: GT.NodeType
, linkId :: Int , linkId :: Int
, session :: Session
, parentId :: Int , parentId :: Int
, reload :: T.Box T2.Reload , reload :: T.Box T2.Reload
, disabled :: Boolean , disabled :: Boolean
...@@ -155,11 +151,11 @@ folderCpt = here.component "folderCpt" cpt where ...@@ -155,11 +151,11 @@ folderCpt = here.component "folderCpt" cpt where
, linkNodeType , linkNodeType
, parentId , parentId
, reload , reload
, session
, style , style
, text , text
, disabled , disabled
} _ = do } _ = do
session <- useSession
-- | States -- | States
-- | -- |
...@@ -229,7 +225,6 @@ folderCpt = here.component "folderCpt" cpt where ...@@ -229,7 +225,6 @@ folderCpt = here.component "folderCpt" cpt where
, id: props.nodeId , id: props.nodeId
, nodeType: props.nodeType , nodeType: props.nodeType
, name: props.text , name: props.text
, session: props.session
, closeCallback: \_ -> T.write_ false isBoxVisible , closeCallback: \_ -> T.write_ false isBoxVisible
} }
] ]
...@@ -262,28 +257,35 @@ backButtonCpt = here.component "backButton" cpt where ...@@ -262,28 +257,35 @@ backButtonCpt = here.component "backButton" cpt where
H.i { className: "fa fa-arrow-left", title: "Previous view"} [] H.i { className: "fa fa-arrow-left", title: "Previous view"} []
] ]
backButtonSmart :: R2.Component (nodeId :: Int, session :: Session) type BackButtonSmartProps =
backButtonSmart = R.createElement backButtonSmartCpt ( nodeId :: Int )
backButtonSmartCpt :: R.Component (nodeId :: Int, session :: Session) backButtonSmart :: R2.Component BackButtonSmartProps
backButtonSmart = R.createElement backButtonSmartCpt
backButtonSmartCpt :: R.Component BackButtonSmartProps
backButtonSmartCpt = here.component "backButtonSmart" cpt where backButtonSmartCpt = here.component "backButtonSmart" cpt where
cpt {nodeId, session} _ = do cpt {nodeId} _ = do
session <- useSession
reload <- T.useBox T2.newReload reload <- T.useBox T2.newReload
reload' <- T.useLive T.unequal reload reload' <- T.useLive T.unequal reload
useLoader { errorHandler useLoader { errorHandler
, loader: loadNode , loader: loadNode
, path: { nodeId, session, reload: reload' } , path: { nodeId, session, reload: reload' }
, render: \node -> backButtonSmartMain { node, session } [] , render: \node -> backButtonSmartMain { node } []
} }
where where
errorHandler = logRESTError here "[folderView]" errorHandler = logRESTError here "[folderView]"
backButtonSmartMain :: R2.Component (node :: Node, session :: Session) type BackButtonSmartMainProps =
backButtonSmartMain = R.createElement backButtonSmartMainCpt ( node :: Node )
backButtonSmartMainCpt :: R.Component (node :: Node, session :: Session) backButtonSmartMain :: R2.Component BackButtonSmartMainProps
backButtonSmartMain = R.createElement backButtonSmartMainCpt
backButtonSmartMainCpt :: R.Component BackButtonSmartMainProps
backButtonSmartMainCpt = here.component "backButtonSmartMain" cpt where backButtonSmartMainCpt = here.component "backButtonSmartMain" cpt where
cpt { node, session } _ = do cpt { node } _ = do
session <- useSession
handlers <- useLinkHandler handlers <- useLinkHandler
let rootId = treeId session let rootId = treeId session
......
...@@ -31,6 +31,7 @@ import Gargantext.Config.REST (AffRESTError, logRESTError) ...@@ -31,6 +31,7 @@ import Gargantext.Config.REST (AffRESTError, logRESTError)
import Gargantext.Config.Utils (handleRESTError) import Gargantext.Config.Utils (handleRESTError)
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoaderEffect) import Gargantext.Hooks.Loader (useLoaderEffect)
import Gargantext.Hooks.Session (useSession)
import Gargantext.Routes as GR import Gargantext.Routes as GR
import Gargantext.Sessions (Session, get, mkNodeId) import Gargantext.Sessions (Session, get, mkNodeId)
import Gargantext.Sessions.Types (useOpenNodesMemberBox, openNodesInsert, openNodesDelete) import Gargantext.Sessions.Types (useOpenNodesMemberBox, openNodesInsert, openNodesDelete)
...@@ -63,11 +64,11 @@ type LoaderProps = ...@@ -63,11 +64,11 @@ type LoaderProps =
type NodeProps = type NodeProps =
( reloadTree :: T2.ReloadS ( reloadTree :: T2.ReloadS
, session :: Session
| Common ) | Common )
type TreeProps = type TreeProps =
( root :: ID ( root :: ID
, session :: Session
, tree :: FTree , tree :: FTree
| NodeProps ) | NodeProps )
...@@ -81,15 +82,13 @@ type ChildrenTreeProps = ...@@ -81,15 +82,13 @@ type ChildrenTreeProps =
type PACommon = type PACommon =
( boxes :: Boxes ( boxes :: Boxes
, reloadTree :: T2.ReloadS , reloadTree :: T2.ReloadS
, session :: Session
, tree :: FTree , tree :: FTree
) )
-- The properties tree shares in common with nodeSpan -- The properties tree shares in common with nodeSpan
type NSCommon = type NSCommon =
( frontends :: Frontends ( frontends :: Frontends
, handed :: Handed , handed :: Handed )
, session :: Session )
-- The annoying 'render' here is busting a cycle in the low tech -- The annoying 'render' here is busting a cycle in the low tech
-- way. This function is only called by functions in this module, so -- way. This function is only called by functions in this module, so
...@@ -98,18 +97,19 @@ type ChildLoaderProps = ...@@ -98,18 +97,19 @@ type ChildLoaderProps =
( id :: ID ( id :: ID
, render :: R2.Leaf TreeProps , render :: R2.Leaf TreeProps
, root :: ID , root :: ID
, session :: Session
| NodeProps | NodeProps
) )
type PerformActionProps = type PerformActionProps =
( isBoxVisible :: T.Box Boolean ( isBoxVisible :: T.Box Boolean
, session :: Session
| PACommon | PACommon
) )
-- | Loads and renders the tree starting at the given root node id. -- | Loads and renders the tree starting at the given root node id.
treeLoader :: R2.Leaf ( key :: String | LoaderProps ) treeLoader :: R2.Leaf ( key :: String | LoaderProps )
treeLoader = R2.leaf treeLoaderCpt treeLoader = R2.leaf treeLoaderCpt
treeLoaderCpt :: R.Component ( key :: String | LoaderProps ) treeLoaderCpt :: R.Component ( key :: String | LoaderProps )
treeLoaderCpt = here.component "treeLoader" cpt where treeLoaderCpt = here.component "treeLoader" cpt where
-- treeLoaderCpt :: R.Memo LoaderProps -- treeLoaderCpt :: R.Memo LoaderProps
...@@ -163,6 +163,7 @@ treeCpt = here.component "tree" cpt where ...@@ -163,6 +163,7 @@ treeCpt = here.component "tree" cpt where
, root , root
, session , session
, tree: NTree (LNode { id, name, nodeType }) children } _ = do , tree: NTree (LNode { id, name, nodeType }) children } _ = do
let nodeId = mkNodeId session id
isBoxVisible <- T.useBox false isBoxVisible <- T.useBox false
folderOpen <- useOpenNodesMemberBox nodeId forestOpen folderOpen <- useOpenNodesMemberBox nodeId forestOpen
...@@ -184,7 +185,7 @@ treeCpt = here.component "tree" cpt where ...@@ -184,7 +185,7 @@ treeCpt = here.component "tree" cpt where
[ [
nodeSpan nodeSpan
{ boxes { boxes
, dispatch: dispatch' isBoxVisible , dispatch: dispatch' isBoxVisible session
, folderOpen , folderOpen
, frontends , frontends
, id , id
...@@ -193,8 +194,8 @@ treeCpt = here.component "tree" cpt where ...@@ -193,8 +194,8 @@ treeCpt = here.component "tree" cpt where
, nodeType , nodeType
, reload , reload
, root , root
, session
, isBoxVisible , isBoxVisible
, session
} }
<> <>
R2.when (folderOpen') R2.when (folderOpen')
...@@ -211,12 +212,11 @@ treeCpt = here.component "tree" cpt where ...@@ -211,12 +212,11 @@ treeCpt = here.component "tree" cpt where
] ]
where where
isLeaf = A.null children isLeaf = A.null children
nodeId = mkNodeId session id
children' = A.sortWith fTreeID pubChildren children' = A.sortWith fTreeID pubChildren
pubChildren = if isPublic nodeType then map (map pub) children else children pubChildren = if isPublic nodeType then map (map pub) children else children
dispatch' isBoxVisible a = performAction a (Record.merge common' extra) where dispatch' isBoxVisible session a = performAction a (Record.merge common' extra) where
common' = RecordE.pick p :: Record PACommon common' = RecordE.pick p :: Record PACommon
extra = { isBoxVisible } extra = { isBoxVisible, session }
pub (LNode n@{ nodeType: t }) = LNode (n { nodeType = publicize t }) pub (LNode n@{ nodeType: t }) = LNode (n { nodeType = publicize t })
...@@ -245,13 +245,14 @@ renderTreeChildrenCpt :: R.Component ChildrenTreeProps ...@@ -245,13 +245,14 @@ renderTreeChildrenCpt :: R.Component ChildrenTreeProps
renderTreeChildrenCpt = here.component "renderTreeChildren" cpt where renderTreeChildrenCpt = here.component "renderTreeChildren" cpt where
cpt p@{ childProps: { children' cpt p@{ childProps: { children'
, render } , render }
, root } _ = do , root
, session } _ = do
pure $ R.fragment (map renderChild children') pure $ R.fragment (map renderChild children')
where where
nodeProps = RecordE.pick p :: Record NodeProps nodeProps = RecordE.pick p :: Record NodeProps
renderChild (NTree (LNode {id: cId}) _) = childLoader props [] where renderChild (NTree (LNode {id: cId}) _) = childLoader props [] where
props = Record.merge nodeProps { id: cId, render, root } props = Record.merge nodeProps { id: cId, render, root, session }
childLoader :: R2.Component ChildLoaderProps childLoader :: R2.Component ChildLoaderProps
...@@ -261,7 +262,10 @@ childLoaderCpt = here.component "childLoader" cpt where ...@@ -261,7 +262,10 @@ childLoaderCpt = here.component "childLoader" cpt where
cpt p@{ boxes: { reloadRoot } cpt p@{ boxes: { reloadRoot }
, reloadTree , reloadTree
, render , render
, root } _ = do , root
, session } _ = do
let fetch _ = getNodeTreeFirstLevel session p.id
-- States -- States
reload <- T.useBox T2.newReload reload <- T.useBox T2.newReload
state /\ stateBox <- R2.useBox' Nothing state /\ stateBox <- R2.useBox' Nothing
...@@ -290,10 +294,9 @@ childLoaderCpt = here.component "childLoader" cpt where ...@@ -290,10 +294,9 @@ childLoaderCpt = here.component "childLoader" cpt where
where where
errorHandler = logRESTError here "[childLoader]" errorHandler = logRESTError here "[childLoader]"
fetch _ = getNodeTreeFirstLevel p.session p.id
paint reload tree' = render (Record.merge base extra) where paint reload tree' = render (Record.merge base extra) where
base = nodeProps { reload = reload } base = nodeProps { reload = reload }
extra = { root, tree: tree' } extra = { root, session, tree: tree' }
nodeProps = RecordE.pick p :: Record NodeProps nodeProps = RecordE.pick p :: Record NodeProps
closeBox { isBoxVisible } = closeBox { isBoxVisible } =
......
...@@ -30,6 +30,7 @@ import Gargantext.Config.REST (logRESTError) ...@@ -30,6 +30,7 @@ import Gargantext.Config.REST (logRESTError)
import Gargantext.Context.Progress (asyncContext, asyncProgress) import Gargantext.Context.Progress (asyncContext, asyncProgress)
import Gargantext.Ends (Frontends, url) import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoaderEffect) import Gargantext.Hooks.Loader (useLoaderEffect)
import Gargantext.Hooks.Session (useSession)
import Gargantext.Hooks.Version (Version, useVersion) import Gargantext.Hooks.Version (Version, useVersion)
import Gargantext.Routes as Routes import Gargantext.Routes as Routes
import Gargantext.Sessions (Session, sessionId) import Gargantext.Sessions (Session, sessionId)
...@@ -63,8 +64,8 @@ type NodeSpanProps = ...@@ -63,8 +64,8 @@ type NodeSpanProps =
, nodeType :: GT.NodeType , nodeType :: GT.NodeType
, reload :: T2.ReloadS , reload :: T2.ReloadS
, root :: ID , root :: ID
, session :: Session
, isBoxVisible :: T.Box Boolean , isBoxVisible :: T.Box Boolean
, session :: Session
) )
type IsLeaf = Boolean type IsLeaf = Boolean
...@@ -87,10 +88,10 @@ nodeSpanCpt = here.component "nodeSpan" cpt ...@@ -87,10 +88,10 @@ nodeSpanCpt = here.component "nodeSpan" cpt
, isLeaf , isLeaf
, nodeType , nodeType
, reload , reload
, session
, isBoxVisible , isBoxVisible
, session
} _ = do } _ = do
-- States -- States
route' <- T.useLive T.unequal route route' <- T.useLive T.unequal route
-- only 1 popup at a time is allowed to be opened -- only 1 popup at a time is allowed to be opened
...@@ -323,7 +324,6 @@ nodeSpanCpt = here.component "nodeSpan" cpt ...@@ -323,7 +324,6 @@ nodeSpanCpt = here.component "nodeSpan" cpt
, errors , errors
, nodeId: id , nodeId: id
, onFinish: onTaskFinish id task , onFinish: onTaskFinish id task
, session
} }
[ [
taskProgress taskProgress
...@@ -347,7 +347,6 @@ nodeSpanCpt = here.component "nodeSpan" cpt ...@@ -347,7 +347,6 @@ nodeSpanCpt = here.component "nodeSpan" cpt
, name , name
, nodeType , nodeType
, closeCallback: \_ -> T.write_ false isBoxVisible , closeCallback: \_ -> T.write_ false isBoxVisible
, session
} }
] ]
] ]
...@@ -555,7 +554,6 @@ type NodeActionsProps = ( nodeType :: GT.NodeType | NodeActionsCommon ) ...@@ -555,7 +554,6 @@ type NodeActionsProps = ( nodeType :: GT.NodeType | NodeActionsCommon )
nodeActions :: R2.Component NodeActionsProps nodeActions :: R2.Component NodeActionsProps
nodeActions = R.createElement nodeActionsCpt nodeActions = R.createElement nodeActionsCpt
nodeActionsCpt :: R.Component NodeActionsProps nodeActionsCpt :: R.Component NodeActionsProps
nodeActionsCpt = here.component "nodeActions" cpt where nodeActionsCpt = here.component "nodeActions" cpt where
cpt props _ = pure (child props.nodeType) cpt props _ = pure (child props.nodeType)
...@@ -572,7 +570,7 @@ graphNodeActions :: R2.Leaf NodeActionsCommon ...@@ -572,7 +570,7 @@ graphNodeActions :: R2.Leaf NodeActionsCommon
graphNodeActions = R2.leafComponent graphNodeActionsCpt graphNodeActions = R2.leafComponent graphNodeActionsCpt
graphNodeActionsCpt :: R.Component NodeActionsCommon graphNodeActionsCpt :: R.Component NodeActionsCommon
graphNodeActionsCpt = here.component "graphNodeActions" cpt where graphNodeActionsCpt = here.component "graphNodeActions" cpt where
cpt { id, session, refresh } _ = do cpt { id, refresh, session } _ = do
-- States -- States
state /\ stateBox <- R2.useBox' Nothing state /\ stateBox <- R2.useBox' Nothing
...@@ -588,7 +586,7 @@ graphNodeActionsCpt = here.component "graphNodeActions" cpt where ...@@ -588,7 +586,7 @@ graphNodeActionsCpt = here.component "graphNodeActions" cpt where
pure $ R2.fromMaybe state \gv -> pure $ R2.fromMaybe state \gv ->
nodeActionsGraph nodeActionsGraph
{ graphVersions: gv, session, id, refresh } { graphVersions: gv, id, refresh, session }
[] []
graphVersions session graphId = GraphAPI.graphVersions { graphId, session } graphVersions session graphId = GraphAPI.graphVersions { graphId, session }
...@@ -599,7 +597,7 @@ listNodeActions :: R2.Leaf NodeActionsCommon ...@@ -599,7 +597,7 @@ listNodeActions :: R2.Leaf NodeActionsCommon
listNodeActions = R2.leafComponent listNodeActionsCpt listNodeActions = R2.leafComponent listNodeActionsCpt
listNodeActionsCpt :: R.Component NodeActionsCommon listNodeActionsCpt :: R.Component NodeActionsCommon
listNodeActionsCpt = here.component "listNodeActions" cpt where listNodeActionsCpt = here.component "listNodeActions" cpt where
cpt { id, session, refresh } _ = do cpt { id, refresh, session } _ = do
-- States -- States
state /\ stateBox <- R2.useBox' Nothing state /\ stateBox <- R2.useBox' Nothing
...@@ -617,7 +615,6 @@ listNodeActionsCpt = here.component "listNodeActions" cpt where ...@@ -617,7 +615,6 @@ listNodeActionsCpt = here.component "listNodeActions" cpt where
nodeActionsNodeList nodeActionsNodeList
{ listId: id { listId: id
, nodeId: corpusId , nodeId: corpusId
, session
, refresh: refresh , refresh: refresh
, nodeType: GT.TabNgramType GT.CTabTerms , nodeType: GT.TabNgramType GT.CTabTerms
} }
......
...@@ -8,14 +8,12 @@ import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..)) ...@@ -8,14 +8,12 @@ import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..))
import Gargantext.Components.Forest.Tree.Node.Settings (NodeAction(..), glyphiconNodeAction) 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.FTree (ID)
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeOut, SubTreeParams(..)) import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeOut, SubTreeParams(..))
import Gargantext.Sessions (Session)
import Gargantext.Types as GT import Gargantext.Types as GT
type Props = type Props =
( dispatch :: Action -> Aff Unit ( dispatch :: Action -> Aff Unit
, id :: ID , id :: ID
, nodeType :: GT.NodeType , nodeType :: GT.NodeType
, session :: Session
) )
subTreeOut :: Action -> Maybe SubTreeOut subTreeOut :: Action -> Maybe SubTreeOut
......
...@@ -7,6 +7,7 @@ import Data.String.Common (toLower) ...@@ -7,6 +7,7 @@ import Data.String.Common (toLower)
import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(DownloadNode)) import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(DownloadNode))
import Gargantext.Components.Forest.Tree.Node.Tools (fragmentPT, panel, submitButtonHref) import Gargantext.Components.Forest.Tree.Node.Tools (fragmentPT, panel, submitButtonHref)
import Gargantext.Ends (url) import Gargantext.Ends (url)
import Gargantext.Hooks.Session (useSession)
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Routes as Routes import Gargantext.Routes as Routes
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
...@@ -23,8 +24,7 @@ here = R2.here "Gargantext.Components.Forest.Tree.Node.Action.Download" ...@@ -23,8 +24,7 @@ here = R2.here "Gargantext.Components.Forest.Tree.Node.Action.Download"
-- | Action : Download -- | Action : Download
type ActionDownload = type ActionDownload =
( id :: ID ( id :: ID
, nodeType :: GT.NodeType , nodeType :: GT.NodeType )
, session :: Session )
actionDownload :: R2.Component ActionDownload actionDownload :: R2.Component ActionDownload
actionDownload = R.createElement actionDownloadCpt actionDownload = R.createElement actionDownloadCpt
...@@ -40,22 +40,24 @@ actionDownloadCorpus :: R2.Component ActionDownload ...@@ -40,22 +40,24 @@ actionDownloadCorpus :: R2.Component ActionDownload
actionDownloadCorpus = R.createElement actionDownloadCorpusCpt actionDownloadCorpus = R.createElement actionDownloadCorpusCpt
actionDownloadCorpusCpt :: R.Component ActionDownload actionDownloadCorpusCpt :: R.Component ActionDownload
actionDownloadCorpusCpt = here.component "actionDownloadCorpus" cpt where actionDownloadCorpusCpt = here.component "actionDownloadCorpus" cpt where
cpt { id, session } _ = do cpt { id } _ = do
session <- useSession
pure $ panel [H.div {} [H.text info]] pure $ panel [H.div {} [H.text info]]
(submitButtonHref DownloadNode href) (submitButtonHref DownloadNode (href session))
where where
href = url session $ Routes.NodeAPI GT.Corpus (Just id) "export" href session = url session $ Routes.NodeAPI GT.Corpus (Just id) "export"
info = "Download as JSON" info = "Download as JSON"
actionDownloadGraph :: R2.Component ActionDownload actionDownloadGraph :: R2.Component ActionDownload
actionDownloadGraph = R.createElement actionDownloadGraphCpt actionDownloadGraph = R.createElement actionDownloadGraphCpt
actionDownloadGraphCpt :: R.Component ActionDownload actionDownloadGraphCpt :: R.Component ActionDownload
actionDownloadGraphCpt = here.component "actionDownloadGraph" cpt where actionDownloadGraphCpt = here.component "actionDownloadGraph" cpt where
cpt { id, session } _ = do cpt { id } _ = do
session <- useSession
pure $ panel [H.div {} [H.text info]] pure $ panel [H.div {} [H.text info]]
(submitButtonHref DownloadNode href) (submitButtonHref DownloadNode (href session))
where where
href = url session $ Routes.NodeAPI GT.Graph (Just id) "gexf" href session = url session $ Routes.NodeAPI GT.Graph (Just id) "gexf"
info = "Info about the Graph as GEXF format" info = "Info about the Graph as GEXF format"
data NodeListDownloadFormat = NL_CSV | NL_JSON data NodeListDownloadFormat = NL_CSV | NL_JSON
...@@ -75,7 +77,9 @@ actionDownloadNodeList :: R2.Component ActionDownload ...@@ -75,7 +77,9 @@ actionDownloadNodeList :: R2.Component ActionDownload
actionDownloadNodeList = R.createElement actionDownloadNodeListCpt actionDownloadNodeList = R.createElement actionDownloadNodeListCpt
actionDownloadNodeListCpt :: R.Component ActionDownload actionDownloadNodeListCpt :: R.Component ActionDownload
actionDownloadNodeListCpt = here.component "actionDownloadNodeList" cpt where actionDownloadNodeListCpt = here.component "actionDownloadNodeList" cpt where
cpt { id, session } _ = do cpt { id } _ = do
session <- useSession
downloadFormat <- T.useBox NL_JSON downloadFormat <- T.useBox NL_JSON
downloadFormat' <- T.useLive T.unequal downloadFormat downloadFormat' <- T.useLive T.unequal downloadFormat
...@@ -87,14 +91,14 @@ actionDownloadNodeListCpt = here.component "actionDownloadNodeList" cpt where ...@@ -87,14 +91,14 @@ actionDownloadNodeListCpt = here.component "actionDownloadNodeList" cpt where
, opt NL_JSON downloadFormat ] , opt NL_JSON downloadFormat ]
, H.div {} [ H.text $ info downloadFormat' ] , H.div {} [ H.text $ info downloadFormat' ]
] ]
(submitButtonHref DownloadNode $ href downloadFormat') (submitButtonHref DownloadNode $ href downloadFormat' session)
where where
opt t downloadFormat = H.option { value: show t } [ H.text $ show t ] opt t downloadFormat = H.option { value: show t } [ H.text $ show t ]
where where
onClick _ = T.write_ t downloadFormat onClick _ = T.write_ t downloadFormat
onChange downloadFormat e = T.write_ (readNodeListDownloadFormat $ R.unsafeEventValue e) downloadFormat onChange downloadFormat e = T.write_ (readNodeListDownloadFormat $ R.unsafeEventValue e) downloadFormat
href :: NodeListDownloadFormat -> String href :: NodeListDownloadFormat -> Session -> String
href t = url session $ Routes.NodeAPI GT.NodeList (Just id) (toLower $ show t) href t session = url session $ Routes.NodeAPI GT.NodeList (Just id) (toLower $ show t)
info :: NodeListDownloadFormat -> String info :: NodeListDownloadFormat -> String
info t = "Info about the Documents as " <> show t <> " format" info t = "Info about the Documents as " <> show t <> " format"
...@@ -118,7 +122,9 @@ actionDownloadNodeTexts :: R2.Component ActionDownload ...@@ -118,7 +122,9 @@ actionDownloadNodeTexts :: R2.Component ActionDownload
actionDownloadNodeTexts = R.createElement actionDownloadNodeTextsCpt actionDownloadNodeTexts = R.createElement actionDownloadNodeTextsCpt
actionDownloadNodeTextsCpt :: R.Component ActionDownload actionDownloadNodeTextsCpt :: R.Component ActionDownload
actionDownloadNodeTextsCpt = here.component "actionDownloadNodeTexts" cpt where actionDownloadNodeTextsCpt = here.component "actionDownloadNodeTexts" cpt where
cpt { id, session } _ = do cpt { id } _ = do
session <- useSession
downloadFormat <- T.useBox NT_JSON downloadFormat <- T.useBox NT_JSON
downloadFormat' <- T.useLive T.unequal downloadFormat downloadFormat' <- T.useLive T.unequal downloadFormat
...@@ -130,14 +136,14 @@ actionDownloadNodeTextsCpt = here.component "actionDownloadNodeTexts" cpt where ...@@ -130,14 +136,14 @@ actionDownloadNodeTextsCpt = here.component "actionDownloadNodeTexts" cpt where
, opt NT_JSON downloadFormat ] , opt NT_JSON downloadFormat ]
, H.div {} [ H.text $ info downloadFormat' ] , H.div {} [ H.text $ info downloadFormat' ]
] ]
(submitButtonHref DownloadNode $ href downloadFormat') (submitButtonHref DownloadNode $ href downloadFormat' session)
where where
opt t downloadFormat = H.option { value: show t } [ H.text $ show t ] opt t downloadFormat = H.option { value: show t } [ H.text $ show t ]
where where
onClick _ = T.write_ t downloadFormat onClick _ = T.write_ t downloadFormat
onChange downloadFormat e = T.write_ (readNodeTextsDownloadFormat $ R.unsafeEventValue e) downloadFormat onChange downloadFormat e = T.write_ (readNodeTextsDownloadFormat $ R.unsafeEventValue e) downloadFormat
href :: NodeTextsDownloadFormat -> String href :: NodeTextsDownloadFormat -> Session -> String
href t = url session $ Routes.NodeAPI GT.NodeTexts (Just id) ("export/" <> urlNodeTextsDownloadFormat t) href t session = url session $ Routes.NodeAPI GT.NodeTexts (Just id) ("export/" <> urlNodeTextsDownloadFormat t)
info :: NodeTextsDownloadFormat -> String info :: NodeTextsDownloadFormat -> String
info t = "Info about the Documents as " <> show t <> " format" info t = "Info about the Documents as " <> show t <> " format"
......
...@@ -37,7 +37,7 @@ linkNode = R.createElement linkNodeCpt ...@@ -37,7 +37,7 @@ linkNode = R.createElement linkNodeCpt
linkNodeCpt :: R.Component SubTreeParamsIn linkNodeCpt :: R.Component SubTreeParamsIn
linkNodeCpt = here.component "linkNode" cpt linkNodeCpt = here.component "linkNode" cpt
where where
cpt { boxes, dispatch, id, nodeType, session, subTreeParams } _ = do cpt { boxes, dispatch, id, nodeType, subTreeParams } _ = do
action <- T.useBox (LinkNode { nodeType: Nothing, params: Nothing}) action <- T.useBox (LinkNode { nodeType: Nothing, params: Nothing})
pure $ pure $
...@@ -47,7 +47,6 @@ linkNodeCpt = here.component "linkNode" cpt ...@@ -47,7 +47,6 @@ linkNodeCpt = here.component "linkNode" cpt
, dispatch , dispatch
, id , id
, nodeType , nodeType
, session
, subTreeParams , subTreeParams
} [] } []
...@@ -62,7 +61,7 @@ linkNode' = R.createElement linkNodeCpt' ...@@ -62,7 +61,7 @@ linkNode' = R.createElement linkNodeCpt'
linkNodeCpt' :: R.Component Props linkNodeCpt' :: R.Component Props
linkNodeCpt' = here.component "__clone__" cpt linkNodeCpt' = here.component "__clone__" cpt
where where
cpt { boxes, dispatch, id, nodeType, session, subTreeParams, action } _ = do cpt { boxes, dispatch, id, nodeType, subTreeParams, action } _ = do
action' <- T.useLive T.unequal action action' <- T.useLive T.unequal action
...@@ -82,7 +81,6 @@ linkNodeCpt' = here.component "__clone__" cpt ...@@ -82,7 +81,6 @@ linkNodeCpt' = here.component "__clone__" cpt
, dispatch , dispatch
, id , id
, nodeType , nodeType
, session
, subTreeParams , subTreeParams
} [] } []
] button ] button
......
...@@ -11,6 +11,7 @@ import Gargantext.Components.GraphQL.Endpoints (deleteTeamMembership, getTeam) ...@@ -11,6 +11,7 @@ import Gargantext.Components.GraphQL.Endpoints (deleteTeamMembership, getTeam)
import Gargantext.Components.GraphQL.Team (Team, TeamMember) import Gargantext.Components.GraphQL.Team (Team, TeamMember)
import Gargantext.Config.REST (AffRESTError, logRESTError) import Gargantext.Config.REST (AffRESTError, logRESTError)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Session (useSession)
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (ID, NodeType) import Gargantext.Types (ID, NodeType)
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
...@@ -24,21 +25,19 @@ here = R2.here "Gargantext.Components.Forest.Tree.Node.Action.ManageTeam" ...@@ -24,21 +25,19 @@ here = R2.here "Gargantext.Components.Forest.Tree.Node.Action.ManageTeam"
type ActionManageTeam = ( type ActionManageTeam = (
id :: ID id :: ID
, nodeType :: NodeType , nodeType :: NodeType
, session :: Session
) )
actionManageTeam :: R2.Component ActionManageTeam actionManageTeam :: R2.Component ActionManageTeam
actionManageTeam = R.createElement actionManageTeamCpt actionManageTeam = R.createElement actionManageTeamCpt
actionManageTeamCpt :: R.Component ActionManageTeam actionManageTeamCpt :: R.Component ActionManageTeam
actionManageTeamCpt = here.component "actionManageTeam" cpt where actionManageTeamCpt = here.component "actionManageTeam" cpt where
cpt {id, session} _ = do cpt {id} _ = do
session <- useSession
useLoader { errorHandler useLoader { errorHandler
, loader: loadTeam , loader: loadTeam
, path: { nodeId: id, session } , path: { nodeId: id, session }
, render: \team -> teamLayoutWrapper { team , render: \team -> teamLayoutWrapper { team
, nodeId: id , nodeId: id
, session
} [] } []
} }
where where
...@@ -46,28 +45,25 @@ actionManageTeamCpt = here.component "actionManageTeam" cpt where ...@@ -46,28 +45,25 @@ actionManageTeamCpt = here.component "actionManageTeam" cpt where
type TeamProps = type TeamProps =
( nodeId :: ID ( nodeId :: ID
, session :: Session
, team :: Team , team :: Team
) )
teamLayoutWrapper :: R2.Component TeamProps teamLayoutWrapper :: R2.Component TeamProps
teamLayoutWrapper = R.createElement teamLayoutWrapperCpt teamLayoutWrapper = R.createElement teamLayoutWrapperCpt
teamLayoutWrapperCpt :: R.Component TeamProps teamLayoutWrapperCpt :: R.Component TeamProps
teamLayoutWrapperCpt = here.component "teamLayoutWrapper" cpt where teamLayoutWrapperCpt = here.component "teamLayoutWrapper" cpt where
cpt {nodeId, session, team: {team_owner_username, team_members}} _ = do cpt {nodeId, team: {team_owner_username, team_members}} _ = do
teamS <- T.useBox team_members teamS <- T.useBox team_members
team' <- T.useLive T.unequal teamS team' <- T.useLive T.unequal teamS
error <- T.useBox "" error <- T.useBox ""
error' <- T.useLive T.unequal error error' <- T.useLive T.unequal error
pure $ teamLayoutRows {nodeId, session, team: teamS, team', error, error', team_owner_username} pure $ teamLayoutRows {nodeId, team: teamS, team', error, error', team_owner_username}
type TeamRowProps = type TeamRowProps =
( nodeId :: ID ( nodeId :: ID
, session :: Session
, team :: T.Box (Array TeamMember) , team :: T.Box (Array TeamMember)
, error :: T.Box String , error :: T.Box String
, team' :: Array TeamMember , team' :: Array TeamMember
, error' :: String , error' :: String
, team_owner_username :: String , team_owner_username :: String
...@@ -75,10 +71,23 @@ type TeamRowProps = ...@@ -75,10 +71,23 @@ type TeamRowProps =
teamLayoutRows :: R2.Leaf TeamRowProps teamLayoutRows :: R2.Leaf TeamRowProps
teamLayoutRows = R2.leafComponent teamLayoutRowsCpt teamLayoutRows = R2.leafComponent teamLayoutRowsCpt
teamLayoutRowsCpt :: R.Component TeamRowProps teamLayoutRowsCpt :: R.Component TeamRowProps
teamLayoutRowsCpt = here.component "teamLayoutRows" cpt where teamLayoutRowsCpt = here.component "teamLayoutRows" cpt where
cpt { team, nodeId, session, error, team', error', team_owner_username} _ = do cpt { team, nodeId, error, team', error', team_owner_username} _ = do
session <- useSession
let submit sharedFolderId _ = do
runAff_ callback $ saveDeleteTeam { session, nodeId, sharedFolderId }
makeTeam :: TeamMember -> R.Element
makeTeam { username, shared_folder_id } =
H.div {className: "from-group row"} [ H.div { className: "col-8" } [ H.text username ]
, H.a { className: "text-danger col-2 fa fa-times"
, title: "Remove user from team"
, type: "button"
, on: {click: submit shared_folder_id }
} []
]
case null team' of case null team' of
true -> pure $ H.div { style: {margin: "10px"}} true -> pure $ H.div { style: {margin: "10px"}}
...@@ -86,22 +95,11 @@ teamLayoutRowsCpt = here.component "teamLayoutRows" cpt where ...@@ -86,22 +95,11 @@ teamLayoutRowsCpt = here.component "teamLayoutRows" cpt where
false -> pure $ Tools.panel (makeLeader team_owner_username : (map makeTeam team')) (H.div {} [H.text error']) false -> pure $ Tools.panel (makeLeader team_owner_username : (map makeTeam team')) (H.div {} [H.text error'])
where where
makeTeam :: TeamMember -> R.Element
makeTeam { username, shared_folder_id } = H.div {className: "from-group row"} [ H.div { className: "col-8" } [ H.text username ] makeLeader username = H.div {className: "from-group row"} [ H.div { className: "col-8"} [ H.text username ]
, H.a { className: "text-danger col-2 fa fa-times"
, title: "Remove user from team"
, type: "button"
, on: {click: submit shared_folder_id }
} []
]
makeLeader username = H.div {className: "from-group row"} [ H.div { className: "col-8"} [ H.text username ]
, H.p { className: "col-2"} [ H.text "owner"] , H.p { className: "col-2"} [ H.text "owner"]
] ]
submit sharedFolderId _ = do
runAff_ callback $ saveDeleteTeam { session, nodeId, sharedFolderId }
callback res = callback res =
case res of case res of
Left _ -> do Left _ -> do
......
...@@ -28,7 +28,7 @@ mergeNode = R.createElement mergeNodeCpt ...@@ -28,7 +28,7 @@ mergeNode = R.createElement mergeNodeCpt
mergeNodeCpt :: R.Component SubTreeParamsIn mergeNodeCpt :: R.Component SubTreeParamsIn
mergeNodeCpt = here.component "mergeNode" cpt mergeNodeCpt = here.component "mergeNode" cpt
where where
cpt { boxes, dispatch, id, nodeType, session, subTreeParams } _ = do cpt { boxes, dispatch, id, nodeType, subTreeParams } _ = do
action <- T.useBox (MergeNode { params: Nothing }) action <- T.useBox (MergeNode { params: Nothing })
action' <- T.useLive T.unequal action action' <- T.useLive T.unequal action
...@@ -47,7 +47,6 @@ mergeNodeCpt = here.component "mergeNode" cpt ...@@ -47,7 +47,6 @@ mergeNodeCpt = here.component "mergeNode" cpt
, dispatch , dispatch
, id , id
, nodeType , nodeType
, session
, subTreeParams , subTreeParams
} [] } []
, H.ul { className:"merge mx-auto list-group"} , H.ul { className:"merge mx-auto list-group"}
......
...@@ -30,7 +30,7 @@ moveNode = R.createElement moveNodeCpt ...@@ -30,7 +30,7 @@ moveNode = R.createElement moveNodeCpt
moveNodeCpt :: R.Component SubTreeParamsIn moveNodeCpt :: R.Component SubTreeParamsIn
moveNodeCpt = here.component "moveNode" cpt moveNodeCpt = here.component "moveNode" cpt
where where
cpt { boxes, dispatch, id, nodeType, session, subTreeParams } _ = do cpt { boxes, dispatch, id, nodeType, subTreeParams } _ = do
action :: T.Box Action <- T.useBox (MoveNode {params: Nothing}) action :: T.Box Action <- T.useBox (MoveNode {params: Nothing})
pure $ pure $
...@@ -40,7 +40,6 @@ moveNodeCpt = here.component "moveNode" cpt ...@@ -40,7 +40,6 @@ moveNodeCpt = here.component "moveNode" cpt
, dispatch , dispatch
, id , id
, nodeType , nodeType
, session
, subTreeParams , subTreeParams
} [] } []
...@@ -54,7 +53,7 @@ moveNode' :: R2.Component Props ...@@ -54,7 +53,7 @@ moveNode' :: R2.Component Props
moveNode' = R.createElement moveNodeCpt' moveNode' = R.createElement moveNodeCpt'
moveNodeCpt' :: R.Component Props moveNodeCpt' :: R.Component Props
moveNodeCpt' = here.component "__clone__" cpt where moveNodeCpt' = here.component "__clone__" cpt where
cpt { boxes, dispatch, id, nodeType, session, subTreeParams, action } _ = do cpt { boxes, dispatch, id, nodeType, subTreeParams, action } _ = do
action' <- T.useLive T.unequal action action' <- T.useLive T.unequal action
...@@ -72,7 +71,6 @@ moveNodeCpt' = here.component "__clone__" cpt where ...@@ -72,7 +71,6 @@ moveNodeCpt' = here.component "__clone__" cpt where
, dispatch , dispatch
, id , id
, nodeType , nodeType
, session
, subTreeParams , subTreeParams
} [] } []
] button ] button
...@@ -10,7 +10,6 @@ import Gargantext.Components.Forest.Tree.Node.Action.Search.SearchBar (searchBar ...@@ -10,7 +10,6 @@ import Gargantext.Components.Forest.Tree.Node.Action.Search.SearchBar (searchBar
import Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField (defaultSearch) import Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField (defaultSearch)
import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..)) import Gargantext.Components.Forest.Tree.Node.Action.Types (Action(..))
import Gargantext.Components.Lang (allLangs) import Gargantext.Components.Lang (allLangs)
import Gargantext.Sessions (Session)
import Gargantext.Types (ID) import Gargantext.Types (ID)
import Gargantext.Types as GT import Gargantext.Types as GT
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
...@@ -25,8 +24,7 @@ here = R2.here "Gargantext.Components.Forest.Tree.Node.Action.Search" ...@@ -25,8 +24,7 @@ here = R2.here "Gargantext.Components.Forest.Tree.Node.Action.Search"
type Props = type Props =
( boxes :: Boxes ( boxes :: Boxes
, dispatch :: Action -> Aff Unit , dispatch :: Action -> Aff Unit
, id :: Maybe ID , id :: Maybe ID )
, session :: Session )
-- | Action : Search -- | Action : Search
actionSearch :: R2.Component Props actionSearch :: R2.Component Props
...@@ -34,7 +32,7 @@ actionSearch = R.createElement actionSearchCpt ...@@ -34,7 +32,7 @@ actionSearch = R.createElement actionSearchCpt
actionSearchCpt :: R.Component Props actionSearchCpt :: R.Component Props
actionSearchCpt = here.component "actionSearch" cpt actionSearchCpt = here.component "actionSearch" cpt
where where
cpt { boxes: { errors }, dispatch, id, session } _ = do cpt { boxes: { errors }, dispatch, id } _ = do
search <- T.useBox $ defaultSearch { node_id = id } search <- T.useBox $ defaultSearch { node_id = id }
pure $ R.fragment pure $ R.fragment
[ H.p { className: "action-search m-1" } [ H.p { className: "action-search m-1" }
...@@ -44,7 +42,6 @@ actionSearchCpt = here.component "actionSearch" cpt ...@@ -44,7 +42,6 @@ actionSearchCpt = here.component "actionSearch" cpt
, langs: allLangs , langs: allLangs
, onSearch: searchOn dispatch , onSearch: searchOn dispatch
, search , search
, session
} [] } []
] ]
where where
......
...@@ -7,6 +7,7 @@ import Effect (Effect) ...@@ -7,6 +7,7 @@ import Effect (Effect)
import Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField (searchField) import Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField (searchField)
import Gargantext.Components.Forest.Tree.Node.Action.Search.Types (Search, allDatabases) import Gargantext.Components.Forest.Tree.Node.Action.Search.Types (Search, allDatabases)
import Gargantext.Components.Lang (Lang) import Gargantext.Components.Lang (Lang)
import Gargantext.Hooks.Session (useSession)
import Gargantext.Prelude (Unit, pure, ($)) import Gargantext.Prelude (Unit, pure, ($))
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (FrontendError) import Gargantext.Types (FrontendError)
...@@ -23,7 +24,6 @@ type Props = ( errors :: T.Box (Array FrontendError) ...@@ -23,7 +24,6 @@ type Props = ( errors :: T.Box (Array FrontendError)
, langs :: Array Lang , langs :: Array Lang
, onSearch :: GT.AsyncTaskWithType -> Effect Unit , onSearch :: GT.AsyncTaskWithType -> Effect Unit
, search :: T.Box Search , search :: T.Box Search
, session :: Session
) )
searchBar :: R2.Component Props searchBar :: R2.Component Props
...@@ -31,7 +31,7 @@ searchBar = R.createElement searchBarCpt ...@@ -31,7 +31,7 @@ searchBar = R.createElement searchBarCpt
searchBarCpt :: R.Component Props searchBarCpt :: R.Component Props
searchBarCpt = here.component "searchBar" cpt searchBarCpt = here.component "searchBar" cpt
where where
cpt { errors, langs, onSearch, search, session } _ = do cpt { errors, langs, onSearch, search } _ = do
--onSearchChange session s --onSearchChange session s
pure $ H.div { className: "search-bar m-1" } pure $ H.div { className: "search-bar m-1" }
[ searchField { databases: allDatabases [ searchField { databases: allDatabases
...@@ -39,6 +39,5 @@ searchBarCpt = here.component "searchBar" cpt ...@@ -39,6 +39,5 @@ searchBarCpt = here.component "searchBar" cpt
, langs , langs
, onSearch , onSearch
, search , search
, session
} [] } []
] ]
...@@ -25,6 +25,7 @@ import Gargantext.Components.ListSelection.Types as ListSelection ...@@ -25,6 +25,7 @@ import Gargantext.Components.ListSelection.Types as ListSelection
import Gargantext.Config.REST (logRESTError) import Gargantext.Config.REST (logRESTError)
import Gargantext.Config.Utils (handleRESTError) import Gargantext.Config.Utils (handleRESTError)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Session (useSession)
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (FrontendError) import Gargantext.Types (FrontendError)
import Gargantext.Types as GT import Gargantext.Types as GT
...@@ -54,7 +55,6 @@ type Props = ...@@ -54,7 +55,6 @@ type Props =
-- State hook for a search, how we get data in and out -- State hook for a search, how we get data in and out
, onSearch :: GT.AsyncTaskWithType -> Effect Unit , onSearch :: GT.AsyncTaskWithType -> Effect Unit
, search :: T.Box Search , search :: T.Box Search
, session :: Session
) )
searchField :: R2.Component Props searchField :: R2.Component Props
...@@ -62,7 +62,7 @@ searchField = R.createElement searchFieldCpt ...@@ -62,7 +62,7 @@ searchField = R.createElement searchFieldCpt
searchFieldCpt :: R.Component Props searchFieldCpt :: R.Component Props
searchFieldCpt = here.component "searchField" cpt searchFieldCpt = here.component "searchField" cpt
where where
cpt { databases, errors, langs, onSearch, search, session } _ = do cpt { databases, errors, langs, onSearch, search } _ = do
selection <- T.useBox ListSelection.MyListsFirst selection <- T.useBox ListSelection.MyListsFirst
pure $ pure $
...@@ -72,9 +72,9 @@ searchFieldCpt = here.component "searchField" cpt ...@@ -72,9 +72,9 @@ searchFieldCpt = here.component "searchField" cpt
-- then -- then
-- H.div {}[] -- H.div {}[]
-- else -- else
, datafieldInput { databases, langs, search, session } [] , datafieldInput { databases, langs, search } []
, ListSelection.selection { selection, session } [] , ListSelection.selection { selection } []
, submitButton { errors, onSearch, search, selection, session } [] , submitButton { errors, onSearch, search, selection } []
] ]
--pure $ panel params button --pure $ panel params button
...@@ -118,14 +118,15 @@ componentYearsCpt = here.component "componentYears" cpt where ...@@ -118,14 +118,15 @@ componentYearsCpt = here.component "componentYears" cpt where
, on: { click: clickRemove idx search } } [] ] , on: { click: clickRemove idx search } } [] ]
type ComponentIMTProps = type ComponentIMTProps =
( session :: Session ( | ComponentProps )
| ComponentProps )
componentIMT :: R2.Component ComponentIMTProps componentIMT :: R2.Component ComponentIMTProps
componentIMT = R.createElement componentIMTCpt componentIMT = R.createElement componentIMTCpt
componentIMTCpt :: R.Component ComponentIMTProps componentIMTCpt :: R.Component ComponentIMTProps
componentIMTCpt = here.component "componentIMT" cpt where componentIMTCpt = here.component "componentIMT" cpt where
cpt { search, session } _ = do cpt { search } _ = do
session <- useSession
useLoader { errorHandler useLoader { errorHandler
, loader: \_ -> getIMTSchools session , loader: \_ -> getIMTSchools session
, path: unit , path: unit
...@@ -143,7 +144,7 @@ componentWithIMTOrgsCpt :: R.Component ComponentWithIMTOrgsProps ...@@ -143,7 +144,7 @@ componentWithIMTOrgsCpt :: R.Component ComponentWithIMTOrgsProps
componentWithIMTOrgsCpt = here.component "componentWithIMTOrgs" cpt where componentWithIMTOrgsCpt = here.component "componentWithIMTOrgs" cpt where
cpt { schools, search } _ = do cpt { schools, search } _ = do
search' <- T.useLive T.unequal search search' <- T.useLive T.unequal search
let allIMTOrgs = [All_IMT] <> (IMT_org <$> schools) let allIMTOrgs = [All_IMT] <> (IMT_org <$> schools)
liCpt org = liCpt org =
H.li {} H.li {}
...@@ -156,7 +157,7 @@ componentWithIMTOrgsCpt = here.component "componentWithIMTOrgs" cpt where ...@@ -156,7 +157,7 @@ componentWithIMTOrgsCpt = here.component "componentWithIMTOrgs" cpt where
All_IMT -> H.i {} [H.text $ " " <> show org] All_IMT -> H.i {} [H.text $ " " <> show org]
(IMT_org { school_shortName }) -> H.text $ " " <> school_shortName (IMT_org { school_shortName }) -> H.text $ " " <> school_shortName
] ]
pure $ R.fragment pure $ R.fragment
[ H.ul {} $ map liCpt $ allIMTOrgs [ H.ul {} $ map liCpt $ allIMTOrgs
--, filterInput fi --, filterInput fi
...@@ -428,44 +429,43 @@ filterInput (term /\ setTerm) = ...@@ -428,44 +429,43 @@ filterInput (term /\ setTerm) =
type DatafieldInputProps = type DatafieldInputProps =
( databases :: Array Database ( databases :: Array Database
, langs :: Array Lang , langs :: Array Lang
, search :: T.Box Search , search :: T.Box Search )
, session :: Session )
datafieldInput :: R2.Component DatafieldInputProps datafieldInput :: R2.Component DatafieldInputProps
datafieldInput = R.createElement datafieldInputCpt datafieldInput = R.createElement datafieldInputCpt
datafieldInputCpt :: R.Component DatafieldInputProps datafieldInputCpt :: R.Component DatafieldInputProps
datafieldInputCpt = here.component "datafieldInput" cpt where datafieldInputCpt = here.component "datafieldInput" cpt where
cpt { databases, langs, search, session} _ = do cpt { databases, langs, search} _ = do
search' <- T.useLive T.unequal search search' <- T.useLive T.unequal search
iframeRef <- R.useRef null iframeRef <- R.useRef null
pure $ H.div {} pure $ H.div {}
[ dataFieldNav { search } [] [ dataFieldNav { search } []
, if isExternal search'.datafield , if isExternal search'.datafield
then databaseInput { databases, search } [] then databaseInput { databases, search } []
else H.div {} [] else H.div {} []
, if isHAL search'.datafield , if isHAL search'.datafield
then orgInput { orgs: allOrgs, search } [] then orgInput { orgs: allOrgs, search } []
else H.div {} [] else H.div {} []
, if isIMT search'.datafield , if isIMT search'.datafield
then componentIMT { search, session } [] then componentIMT { search } []
else H.div {} [] else H.div {} []
, if isHAL search'.datafield , if isHAL search'.datafield
then componentYears { search } [] then componentYears { search } []
else H.div {} [] else H.div {} []
, if isCNRS search'.datafield , if isCNRS search'.datafield
then componentCNRS { search } [] then componentCNRS { search } []
else H.div {} [] else H.div {} []
, if needsLang search'.datafield , if needsLang search'.datafield
then langNav { langs, search } [] then langNav { langs, search } []
else H.div {} [] else H.div {} []
, H.div {} [ searchIframes { iframeRef, search } [] ] , H.div {} [ searchIframes { iframeRef, search } [] ]
] ]
...@@ -518,7 +518,6 @@ type SubmitButtonProps = ...@@ -518,7 +518,6 @@ type SubmitButtonProps =
, onSearch :: GT.AsyncTaskWithType -> Effect Unit , onSearch :: GT.AsyncTaskWithType -> Effect Unit
, search :: T.Box Search , search :: T.Box Search
, selection :: T.Box ListSelection.Selection , selection :: T.Box ListSelection.Selection
, session :: Session
) )
submitButton :: R2.Component SubmitButtonProps submitButton :: R2.Component SubmitButtonProps
...@@ -526,7 +525,9 @@ submitButton = R.createElement submitButtonComponent ...@@ -526,7 +525,9 @@ submitButton = R.createElement submitButtonComponent
submitButtonComponent :: R.Component SubmitButtonProps submitButtonComponent :: R.Component SubmitButtonProps
submitButtonComponent = here.component "submitButton" cpt submitButtonComponent = here.component "submitButton" cpt
where where
cpt { errors, onSearch, search, selection, session } _ = do cpt { errors, onSearch, search, selection } _ = do
session <- useSession
search' <- T.useLive T.unequal search search' <- T.useLive T.unequal search
selection' <- T.useLive T.unequal selection selection' <- T.useLive T.unequal selection
......
...@@ -20,7 +20,6 @@ import Gargantext.Utils.SimpleJSON as GUSJ ...@@ -20,7 +20,6 @@ import Gargantext.Utils.SimpleJSON as GUSJ
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Simple.JSON as JSON import Simple.JSON as JSON
import Simple.JSON.Generics as JSONG
import Toestand as T import Toestand as T
here :: R2.Here here :: R2.Here
...@@ -74,7 +73,7 @@ publishNode = R.createElement publishNodeCpt ...@@ -74,7 +73,7 @@ publishNode = R.createElement publishNodeCpt
publishNodeCpt :: R.Component SubTreeParamsIn publishNodeCpt :: R.Component SubTreeParamsIn
publishNodeCpt = here.component "publishNode" cpt publishNodeCpt = here.component "publishNode" cpt
where where
cpt { boxes, dispatch, id, nodeType, session, subTreeParams } _ = do cpt { boxes, dispatch, id, nodeType, subTreeParams } _ = do
action <- T.useBox (Action.SharePublic { params: Nothing }) action <- T.useBox (Action.SharePublic { params: Nothing })
action' <- T.useLive T.unequal action action' <- T.useLive T.unequal action
...@@ -90,7 +89,6 @@ publishNodeCpt = here.component "publishNode" cpt ...@@ -90,7 +89,6 @@ publishNodeCpt = here.component "publishNode" cpt
, dispatch , dispatch
, id , id
, nodeType , nodeType
, session
, subTreeParams , subTreeParams
} [] } []
] button ] button
...@@ -28,6 +28,7 @@ import Gargantext.Components.ListSelection as ListSelection ...@@ -28,6 +28,7 @@ import Gargantext.Components.ListSelection as ListSelection
import Gargantext.Components.ListSelection.Types (Selection(..)) import Gargantext.Components.ListSelection.Types (Selection(..))
import Gargantext.Components.ListSelection.Types as ListSelection import Gargantext.Components.ListSelection.Types as ListSelection
import Gargantext.Config.REST (AffRESTError, RESTError) import Gargantext.Config.REST (AffRESTError, RESTError)
import Gargantext.Hooks.Session (useSession)
import Gargantext.Routes as GR import Gargantext.Routes as GR
import Gargantext.Sessions (Session, postWwwUrlencoded, post) import Gargantext.Sessions (Session, postWwwUrlencoded, post)
import Gargantext.Types (ID, NodeType(..)) import Gargantext.Types (ID, NodeType(..))
...@@ -50,23 +51,22 @@ here = R2.here "Gargantext.Components.Forest.Tree.Node.Action.Upload" ...@@ -50,23 +51,22 @@ here = R2.here "Gargantext.Components.Forest.Tree.Node.Action.Upload"
type ActionUpload = type ActionUpload =
( dispatch :: Action -> Aff Unit ( dispatch :: Action -> Aff Unit
, id :: ID , id :: ID
, nodeType :: NodeType , nodeType :: NodeType )
, session :: Session )
actionUpload :: R2.Component ActionUpload actionUpload :: R2.Component ActionUpload
actionUpload = R.createElement actionUploadCpt actionUpload = R.createElement actionUploadCpt
actionUploadCpt :: R.Component ActionUpload actionUploadCpt :: R.Component ActionUpload
actionUploadCpt = here.component "actionUpload" cpt where actionUploadCpt = here.component "actionUpload" cpt where
cpt { nodeType: Corpus, dispatch, id, session } _ = cpt { nodeType: Corpus, dispatch, id } _ =
pure $ uploadFileView { dispatch, id, nodeType: GT.Corpus, session } pure $ uploadFileView { dispatch, id, nodeType: GT.Corpus }
cpt { nodeType: NodeList, dispatch, id, session } _ = cpt { nodeType: NodeList, dispatch, id } _ =
pure $ uploadTermListView { dispatch, id, nodeType: GT.NodeList, session } [] pure $ uploadTermListView { dispatch, id, nodeType: GT.NodeList } []
cpt props@{ nodeType: NodeFrameCalc } _ = pure $ uploadFrameCalcView props [] cpt props@{ nodeType: NodeFrameCalc } _ = pure $ uploadFrameCalcView props []
cpt props@{ nodeType: Annuaire, dispatch, id, session } _ = cpt props@{ nodeType: Annuaire, dispatch, id } _ =
pure $ uploadListView { dispatch, id, nodeType: GT.Annuaire, session } pure $ uploadListView { dispatch, id, nodeType: GT.Annuaire }
cpt props@{ nodeType: _ } _ = pure $ actionUploadOther props [] cpt props@{ nodeType: _ } _ = pure $ actionUploadOther props []
...@@ -105,7 +105,7 @@ uploadFileView = R2.leafComponent uploadFileViewCpt ...@@ -105,7 +105,7 @@ uploadFileView = R2.leafComponent uploadFileViewCpt
uploadFileViewCpt :: R.Component Props uploadFileViewCpt :: R.Component Props
uploadFileViewCpt = here.component "uploadFileView" cpt uploadFileViewCpt = here.component "uploadFileView" cpt
where where
cpt { dispatch, id, nodeType, session } _ = do cpt { dispatch, id, nodeType } _ = do
-- mFile :: R.State (Maybe UploadFile) <- R.useState' Nothing -- mFile :: R.State (Maybe UploadFile) <- R.useState' Nothing
mFile <- T.useBox (Nothing :: Maybe UploadFile) mFile <- T.useBox (Nothing :: Maybe UploadFile)
fileType <- T.useBox CSV fileType <- T.useBox CSV
...@@ -158,7 +158,7 @@ uploadFileViewCpt = here.component "uploadFileView" cpt ...@@ -158,7 +158,7 @@ uploadFileViewCpt = here.component "uploadFileView" cpt
] ]
, R2.row , R2.row
[ H.div { className: "col-6 flex-space-around" } [ H.div { className: "col-6 flex-space-around" }
[ ListSelection.selection { selection, session } [] ] [ ListSelection.selection { selection } [] ]
] ]
] ]
...@@ -200,7 +200,6 @@ type UploadButtonProps = ...@@ -200,7 +200,6 @@ type UploadButtonProps =
uploadButton :: R2.Component UploadButtonProps uploadButton :: R2.Component UploadButtonProps
uploadButton = R.createElement uploadButtonCpt uploadButton = R.createElement uploadButtonCpt
uploadButtonCpt :: R.Component UploadButtonProps uploadButtonCpt :: R.Component UploadButtonProps
uploadButtonCpt = here.component "uploadButton" cpt uploadButtonCpt = here.component "uploadButton" cpt
where where
...@@ -279,7 +278,7 @@ uploadListView :: R2.Leaf Props ...@@ -279,7 +278,7 @@ uploadListView :: R2.Leaf Props
uploadListView = R2.leafComponent uploadListViewCpt uploadListView = R2.leafComponent uploadListViewCpt
uploadListViewCpt :: R.Component Props uploadListViewCpt :: R.Component Props
uploadListViewCpt = here.component "uploadListView" cpt where uploadListViewCpt = here.component "uploadListView" cpt where
cpt { dispatch, session } _ = do cpt { dispatch } _ = do
-- States -- States
mFile mFile
<- T.useBox (Nothing :: Maybe UploadFile) <- T.useBox (Nothing :: Maybe UploadFile)
...@@ -396,7 +395,6 @@ uploadListViewCpt = here.component "uploadListView" cpt where ...@@ -396,7 +395,6 @@ uploadListViewCpt = here.component "uploadListView" cpt where
[ [
ListSelection.selection ListSelection.selection
{ selection { selection
, session
} [] } []
] ]
] ]
...@@ -713,7 +711,7 @@ uploadFrameCalcView = R.createElement uploadFrameCalcViewCpt ...@@ -713,7 +711,7 @@ uploadFrameCalcView = R.createElement uploadFrameCalcViewCpt
uploadFrameCalcViewCpt :: R.Component Props uploadFrameCalcViewCpt :: R.Component Props
uploadFrameCalcViewCpt = here.component "uploadFrameCalcView" cpt uploadFrameCalcViewCpt = here.component "uploadFrameCalcView" cpt
where where
cpt { dispatch, session } _ = do cpt { dispatch } _ = do
lang' /\ langBox lang' /\ langBox
<- R2.useBox' EN <- R2.useBox' EN
selection' /\ selectionBox selection' /\ selectionBox
...@@ -765,7 +763,6 @@ uploadFrameCalcViewCpt = here.component "uploadFrameCalcView" cpt ...@@ -765,7 +763,6 @@ uploadFrameCalcViewCpt = here.component "uploadFrameCalcView" cpt
[ [
ListSelection.selection ListSelection.selection
{ selection: selectionBox { selection: selectionBox
, session
} [] } []
] ]
] ]
......
...@@ -23,14 +23,13 @@ here = R2.here "Gargantext.Components.Forest.Tree.Node.Action.WriteNodesDocument ...@@ -23,14 +23,13 @@ here = R2.here "Gargantext.Components.Forest.Tree.Node.Action.WriteNodesDocument
type ActionWriteNodesDocuments = type ActionWriteNodesDocuments =
( boxes :: Boxes ( boxes :: Boxes
, dispatch :: Action -> Aff Unit , dispatch :: Action -> Aff Unit
, id :: GT.ID , id :: GT.ID )
, session :: Session )
actionWriteNodesDocuments :: R2.Component ActionWriteNodesDocuments actionWriteNodesDocuments :: R2.Component ActionWriteNodesDocuments
actionWriteNodesDocuments = R.createElement actionWriteNodesDocumentsCpt actionWriteNodesDocuments = R.createElement actionWriteNodesDocumentsCpt
actionWriteNodesDocumentsCpt :: R.Component ActionWriteNodesDocuments actionWriteNodesDocumentsCpt :: R.Component ActionWriteNodesDocuments
actionWriteNodesDocumentsCpt = here.component "actionWriteNodesDocuments" cpt where actionWriteNodesDocumentsCpt = here.component "actionWriteNodesDocuments" cpt where
cpt { boxes, dispatch, id, session } _ = do cpt { boxes, dispatch, id } _ = do
let bodies = let bodies =
[ R2.row [ R2.row
[ H.div { className: "col-12 flex-space-around" } [ H.div { className: "col-12 flex-space-around" }
......
...@@ -43,7 +43,6 @@ here = R2.here "Gargantext.Components.Forest.Tree.Node.Box" ...@@ -43,7 +43,6 @@ here = R2.here "Gargantext.Components.Forest.Tree.Node.Box"
type CommonProps = type CommonProps =
( dispatch :: Action -> Aff Unit ( dispatch :: Action -> Aff Unit
, session :: Session
) )
nodePopupView :: R2.Leaf NodePopupProps nodePopupView :: R2.Leaf NodePopupProps
...@@ -170,14 +169,13 @@ nodePopupViewCpt = here.component "nodePopupView" cpt where ...@@ -170,14 +169,13 @@ nodePopupViewCpt = here.component "nodePopupView" cpt where
mPanelAction :: Record NodePopupS -> Record NodePopupProps -> R.Element mPanelAction :: Record NodePopupS -> Record NodePopupProps -> R.Element
mPanelAction { action: Just action } mPanelAction { action: Just action }
{ boxes, dispatch, id, name, nodeType, session } = { boxes, dispatch, id, name, nodeType } =
panelAction { action panelAction { action
, boxes , boxes
, dispatch , dispatch
, id , id
, name , name
, nodeType , nodeType
, session
} }
mPanelAction { action: Nothing } _ = mPanelAction { action: Nothing } _ =
H.div H.div
...@@ -324,7 +322,6 @@ type PanelActionProps = ...@@ -324,7 +322,6 @@ type PanelActionProps =
, dispatch :: Action -> Aff Unit , dispatch :: Action -> Aff Unit
, name :: Name , name :: Name
, nodeType :: GT.NodeType , nodeType :: GT.NodeType
, session :: Session
) )
panelAction :: R2.Leaf PanelActionProps panelAction :: R2.Leaf PanelActionProps
...@@ -333,28 +330,28 @@ panelActionCpt :: R.Component PanelActionProps ...@@ -333,28 +330,28 @@ panelActionCpt :: R.Component PanelActionProps
panelActionCpt = here.component "panelAction" cpt panelActionCpt = here.component "panelAction" cpt
where where
cpt { action: Documentation nodeType} _ = pure $ actionDoc { nodeType } [] cpt { action: Documentation nodeType} _ = pure $ actionDoc { nodeType } []
cpt { action: Download, id, nodeType, session} _ = pure $ actionDownload { id, nodeType, session } [] cpt { action: Download, id, nodeType} _ = pure $ actionDownload { id, nodeType } []
cpt { action: Upload, dispatch, id, nodeType, session} _ = pure $ actionUpload { dispatch, id, nodeType, session } [] cpt { action: Upload, dispatch, id, nodeType} _ = pure $ actionUpload { dispatch, id, nodeType } []
cpt { action: Delete, nodeType, dispatch} _ = pure $ actionDelete { dispatch, nodeType } [] cpt { action: Delete, nodeType, dispatch} _ = pure $ actionDelete { dispatch, nodeType } []
cpt { action: ManageTeam, nodeType, id, session} _ = pure $ actionManageTeam { id, nodeType, session } [] cpt { action: ManageTeam, nodeType, id} _ = pure $ actionManageTeam { id, nodeType } []
cpt { action: Add xs, dispatch, id, name, nodeType} _ = cpt { action: Add xs, dispatch, id, name, nodeType} _ =
pure $ addNodeView {dispatch, id, name, nodeType, nodeTypes: xs} [] pure $ addNodeView {dispatch, id, name, nodeType, nodeTypes: xs} []
cpt { action: Refresh , dispatch, nodeType } _ = pure $ update { dispatch, nodeType } [] cpt { action: Refresh , dispatch, nodeType } _ = pure $ update { dispatch, nodeType } []
cpt { action: Config, nodeType } _ = cpt { action: Config, nodeType } _ =
pure $ fragmentPT $ "Config " <> show nodeType pure $ fragmentPT $ "Config " <> show nodeType
-- Functions using SubTree -- Functions using SubTree
cpt { action: Merge {subTreeParams}, boxes, dispatch, id, nodeType, session } _ = cpt { action: Merge {subTreeParams}, boxes, dispatch, id, nodeType } _ =
pure $ mergeNode { boxes, dispatch, id, nodeType, session, subTreeParams } [] pure $ mergeNode { boxes, dispatch, id, nodeType, subTreeParams } []
cpt { action: Move {subTreeParams}, boxes, dispatch, id, nodeType, session } _ = cpt { action: Move {subTreeParams}, boxes, dispatch, id, nodeType } _ =
pure $ moveNode { boxes, dispatch, id, nodeType, session, subTreeParams } [] pure $ moveNode { boxes, dispatch, id, nodeType, subTreeParams } []
cpt { action: Link {subTreeParams}, boxes, dispatch, id, nodeType, session } _ = cpt { action: Link {subTreeParams}, boxes, dispatch, id, nodeType } _ =
pure $ linkNode { boxes, dispatch, id, nodeType, session, subTreeParams } [] pure $ linkNode { boxes, dispatch, id, nodeType, subTreeParams } []
cpt { action : Share, dispatch, id } _ = pure $ Share.shareNode { dispatch, id } [] cpt { action : Share, dispatch, id } _ = pure $ Share.shareNode { dispatch, id } []
cpt { action : AddingContact, dispatch, id } _ = pure $ Contact.actionAddContact { dispatch, id } [] cpt { action : AddingContact, dispatch, id } _ = pure $ Contact.actionAddContact { dispatch, id } []
cpt { action : Publish {subTreeParams}, boxes, dispatch, id, nodeType, session } _ = cpt { action : Publish {subTreeParams}, boxes, dispatch, id, nodeType } _ =
pure $ Share.publishNode { boxes, dispatch, id, nodeType, session, subTreeParams } [] pure $ Share.publishNode { boxes, dispatch, id, nodeType, subTreeParams } []
cpt { action: SearchBox, boxes, dispatch, id, session } _ = cpt { action: SearchBox, boxes, dispatch, id } _ =
pure $ actionSearch { boxes, dispatch, id: Just id, session } [] pure $ actionSearch { boxes, dispatch, id: Just id } []
cpt { action: WriteNodesDocuments, boxes, dispatch, id, session } _ = cpt { action: WriteNodesDocuments, boxes, dispatch, id } _ =
pure $ actionWriteNodesDocuments { boxes, dispatch, id, session } [] pure $ actionWriteNodesDocuments { boxes, dispatch, id } []
cpt _ _ = pure $ H.div {} [] cpt _ _ = pure $ H.div {} []
...@@ -13,7 +13,6 @@ import Gargantext.Types as GT ...@@ -13,7 +13,6 @@ import Gargantext.Types as GT
type CommonProps = type CommonProps =
( dispatch :: Action -> Aff Unit ( dispatch :: Action -> Aff Unit
, session :: Session
) )
type NodePopupProps = type NodePopupProps =
......
...@@ -14,6 +14,7 @@ import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTr ...@@ -14,6 +14,7 @@ import Gargantext.Components.Forest.Tree.Node.Tools.FTree (FTree, LNode(..), NTr
import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeParams(..), SubTreeOut(..)) import Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types (SubTreeParams(..), SubTreeOut(..))
import Gargantext.Config.REST (AffRESTError, logRESTError) import Gargantext.Config.REST (AffRESTError, logRESTError)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Session (useSession)
import Gargantext.Routes as GR import Gargantext.Routes as GR
import Gargantext.Sessions (Session(..), get) import Gargantext.Sessions (Session(..), get)
import Gargantext.Types as GT import Gargantext.Types as GT
...@@ -49,9 +50,10 @@ subTreeViewCpt = here.component "subTreeView" cpt ...@@ -49,9 +50,10 @@ subTreeViewCpt = here.component "subTreeView" cpt
, dispatch , dispatch
, id , id
, nodeType , nodeType
, session
, subTreeParams , subTreeParams
} _ = do } _ = do
session <- useSession
let let
SubTreeParams {showtypes} = subTreeParams SubTreeParams {showtypes} = subTreeParams
-- (valAction /\ setAction) = action -- (valAction /\ setAction) = action
...@@ -66,7 +68,6 @@ subTreeViewCpt = here.component "subTreeView" cpt ...@@ -66,7 +68,6 @@ subTreeViewCpt = here.component "subTreeView" cpt
, dispatch , dispatch
, id , id
, nodeType , nodeType
, session
, subTreeParams , subTreeParams
, tree , tree
} [] } } [] }
......
...@@ -8,6 +8,7 @@ import Effect.Class (liftEffect) ...@@ -8,6 +8,7 @@ import Effect.Class (liftEffect)
import Gargantext.Components.Bootstrap as B import Gargantext.Components.Bootstrap as B
import Gargantext.Components.Bootstrap.Types (ComponentStatus(..), Elevation(..), Variant(..)) import Gargantext.Components.Bootstrap.Types (ComponentStatus(..), Elevation(..), Variant(..))
import Gargantext.Components.GraphExplorer.API as GraphAPI import Gargantext.Components.GraphExplorer.API as GraphAPI
import Gargantext.Hooks.Session (useSession)
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types as GT import Gargantext.Types as GT
import Gargantext.Utils ((?)) import Gargantext.Utils ((?))
...@@ -24,27 +25,27 @@ here = R2.here "Gargantext.Components.Forest.Tree.Node.Tools.Sync" ...@@ -24,27 +25,27 @@ here = R2.here "Gargantext.Components.Forest.Tree.Node.Tools.Sync"
type NodeActionsGraphProps = type NodeActionsGraphProps =
( id :: GT.ID ( id :: GT.ID
, graphVersions :: Record GraphAPI.GraphVersions , graphVersions :: Record GraphAPI.GraphVersions
, session :: Session
, refresh :: Unit -> Aff Unit , refresh :: Unit -> Aff Unit
, session :: Session
) )
nodeActionsGraph :: R2.Component NodeActionsGraphProps nodeActionsGraph :: R2.Component NodeActionsGraphProps
nodeActionsGraph = R.createElement nodeActionsGraphCpt nodeActionsGraph = R.createElement nodeActionsGraphCpt
nodeActionsGraphCpt :: R.Component NodeActionsGraphProps nodeActionsGraphCpt :: R.Component NodeActionsGraphProps
nodeActionsGraphCpt = here.component "nodeActionsGraph" cpt where nodeActionsGraphCpt = here.component "nodeActionsGraph" cpt where
cpt { id, graphVersions, session, refresh } _ = cpt { id, graphVersions, refresh, session } _ =
let sameVersions = (graphVersions.gv_graph == Just graphVersions.gv_repo) let sameVersions = (graphVersions.gv_graph == Just graphVersions.gv_repo)
in pure $ in pure $
R2.when (not sameVersions) $ R2.when (not sameVersions) $
graphUpdateButton { id, session, refresh } graphUpdateButton { id, refresh, session }
type GraphUpdateButtonProps = type GraphUpdateButtonProps =
( id :: GT.ID ( id :: GT.ID
, session :: Session
, refresh :: Unit -> Aff Unit , refresh :: Unit -> Aff Unit
, session :: Session
) )
graphUpdateButton :: Record GraphUpdateButtonProps -> R.Element graphUpdateButton :: Record GraphUpdateButtonProps -> R.Element
...@@ -52,7 +53,7 @@ graphUpdateButton p = R.createElement graphUpdateButtonCpt p [] ...@@ -52,7 +53,7 @@ graphUpdateButton p = R.createElement graphUpdateButtonCpt p []
graphUpdateButtonCpt :: R.Component GraphUpdateButtonProps graphUpdateButtonCpt :: R.Component GraphUpdateButtonProps
graphUpdateButtonCpt = here.component "graphUpdateButton" cpt graphUpdateButtonCpt = here.component "graphUpdateButton" cpt
where where
cpt { id, session, refresh } _ = do cpt { id, refresh, session } _ = do
enabled <- T.useBox true enabled <- T.useBox true
enabled' <- T.useLive T.unequal enabled enabled' <- T.useLive T.unequal enabled
...@@ -63,7 +64,7 @@ graphUpdateButtonCpt = here.component "graphUpdateButton" cpt ...@@ -63,7 +64,7 @@ graphUpdateButtonCpt = here.component "graphUpdateButton" cpt
, variant: Secondary , variant: Secondary
, elevation: Level1 , elevation: Level1
, status: enabled' ? Enabled $ Disabled , status: enabled' ? Enabled $ Disabled
, callback: const $ onClick enabled' enabled , callback: const $ onClick enabled' enabled session
, name: "refresh" , name: "refresh"
} }
...@@ -75,8 +76,8 @@ graphUpdateButtonCpt = here.component "graphUpdateButton" cpt ...@@ -75,8 +76,8 @@ graphUpdateButtonCpt = here.component "graphUpdateButton" cpt
-- , on: { click: onClick enabled' enabled } } [] -- , on: { click: onClick enabled' enabled } } []
-- ] -- ]
where where
onClick false _ = pure unit onClick false _ _ = pure unit
onClick true enabled = do onClick true enabled session = do
launchAff_ $ do launchAff_ $ do
liftEffect $ T.write_ false enabled liftEffect $ T.write_ false enabled
_g <- GraphAPI.updateGraphVersions { graphId: id, session } _g <- GraphAPI.updateGraphVersions { graphId: id, session }
...@@ -91,7 +92,6 @@ type NodeActionsNodeListProps = ...@@ -91,7 +92,6 @@ type NodeActionsNodeListProps =
listId :: GT.ListId listId :: GT.ListId
, nodeId :: GT.ID , nodeId :: GT.ID
, nodeType :: GT.TabSubType GT.CTabNgramType , nodeType :: GT.TabSubType GT.CTabNgramType
, session :: Session
, refresh :: Unit -> Aff Unit , refresh :: Unit -> Aff Unit
) )
...@@ -106,7 +106,6 @@ type NodeListUpdateButtonProps = ...@@ -106,7 +106,6 @@ type NodeListUpdateButtonProps =
( listId :: GT.ListId ( listId :: GT.ListId
, nodeId :: GT.ID , nodeId :: GT.ID
, nodeType :: GT.TabSubType GT.CTabNgramType , nodeType :: GT.TabSubType GT.CTabNgramType
, session :: Session
, refresh :: Unit -> Aff Unit , refresh :: Unit -> Aff Unit
) )
......
...@@ -15,6 +15,7 @@ import Gargantext.Components.Document.Types (LoadedData, DocPath) ...@@ -15,6 +15,7 @@ import Gargantext.Components.Document.Types (LoadedData, DocPath)
import Gargantext.Components.GraphExplorer.Types (GraphSideDoc(..)) import Gargantext.Components.GraphExplorer.Types (GraphSideDoc(..))
import Gargantext.Config.REST (logRESTError) import Gargantext.Config.REST (logRESTError)
import Gargantext.Hooks.Loader (useLoaderEffect) import Gargantext.Hooks.Loader (useLoaderEffect)
import Gargantext.Hooks.Session (useSession)
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (CTabNgramType(..), TabSubType(..), TabType(..)) import Gargantext.Types (CTabNgramType(..), TabSubType(..), TabType(..))
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
...@@ -27,19 +28,17 @@ here = R2.here "Gargantext.Components.GraphExplorer.Frame.DocFocus" ...@@ -27,19 +28,17 @@ here = R2.here "Gargantext.Components.GraphExplorer.Frame.DocFocus"
type Props = type Props =
( graphSideDoc :: GraphSideDoc ( graphSideDoc :: GraphSideDoc
, session :: Session
, closeCallback :: Unit -> Effect Unit , closeCallback :: Unit -> Effect Unit
) )
docFocus :: R2.Leaf ( key :: String | Props ) docFocus :: R2.Leaf ( key :: String | Props )
docFocus = R2.leaf docFocusCpt docFocus = R2.leaf docFocusCpt
docFocusCpt :: R.Component ( key :: String | Props ) docFocusCpt :: R.Component ( key :: String | Props )
docFocusCpt = here.component "main" cpt where docFocusCpt = here.component "main" cpt where
cpt { graphSideDoc: GraphSideDoc { docId, listId, corpusId } cpt { graphSideDoc: GraphSideDoc { docId, listId, corpusId }
, session
, closeCallback , closeCallback
} _ = do } _ = do
session <- useSession
-- | States -- | States
-- | -- |
state' /\ state <- R2.useBox' (Nothing :: Maybe LoadedData) state' /\ state <- R2.useBox' (Nothing :: Maybe LoadedData)
......
...@@ -28,7 +28,6 @@ import Gargantext.Components.GraphExplorer.Types as GET ...@@ -28,7 +28,6 @@ import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Components.GraphExplorer.Utils as GEU import Gargantext.Components.GraphExplorer.Utils as GEU
import Gargantext.Config (defaultFrontends) import Gargantext.Config (defaultFrontends)
import Gargantext.Data.Louvain as DLouvain import Gargantext.Data.Louvain as DLouvain
import Gargantext.Hooks.Session (useSession)
import Gargantext.Hooks.Sigmax.ForceAtlas2 as ForceAtlas import Gargantext.Hooks.Sigmax.ForceAtlas2 as ForceAtlas
import Gargantext.Hooks.Sigmax.Graphology as Graphology import Gargantext.Hooks.Sigmax.Graphology as Graphology
import Gargantext.Hooks.Sigmax.Louvain as Louvain import Gargantext.Hooks.Sigmax.Louvain as Louvain
...@@ -75,8 +74,6 @@ layoutCpt = here.component "layout" cpt where ...@@ -75,8 +74,6 @@ layoutCpt = here.component "layout" cpt where
, graphId , graphId
} <- GraphStore.use } <- GraphStore.use
session <- useSession
showSidebar' <- R2.useLive' showSidebar showSidebar' <- R2.useLive' showSidebar
showDoc' <- R2.useLive' showDoc showDoc' <- R2.useLive' showDoc
mMetaData' <- R2.useLive' mMetaData mMetaData' <- R2.useLive' mMetaData
...@@ -152,8 +149,7 @@ layoutCpt = here.component "layout" cpt where ...@@ -152,8 +149,7 @@ layoutCpt = here.component "layout" cpt where
{ className: "graph-layout__focus__inner" } { className: "graph-layout__focus__inner" }
[ [
docFocus docFocus
{ session { graphSideDoc
, graphSideDoc
, closeCallback: closeDoc , closeCallback: closeDoc
, key: show $ getter _.docId graphSideDoc , key: show $ getter _.docId graphSideDoc
} }
...@@ -182,7 +178,6 @@ layoutCpt = here.component "layout" cpt where ...@@ -182,7 +178,6 @@ layoutCpt = here.component "layout" cpt where
GES.sidebar GES.sidebar
{ frontends: defaultFrontends { frontends: defaultFrontends
, metaData , metaData
, session
} }
] ]
] ]
...@@ -200,7 +195,6 @@ layoutCpt = here.component "layout" cpt where ...@@ -200,7 +195,6 @@ layoutCpt = here.component "layout" cpt where
{ fa2Ref { fa2Ref
, noverlapRef , noverlapRef
, reloadForest: reloadForest , reloadForest: reloadForest
, session
, sigmaRef , sigmaRef
} }
] ]
......
...@@ -37,6 +37,7 @@ import Gargantext.Core.NgramsTable.Types as CNT ...@@ -37,6 +37,7 @@ import Gargantext.Core.NgramsTable.Types as CNT
import Gargantext.Data.Array (mapMaybe) import Gargantext.Data.Array (mapMaybe)
import Gargantext.Ends (Frontends) import Gargantext.Ends (Frontends)
import Gargantext.Hooks.FirstEffect (useFirstEffect') import Gargantext.Hooks.FirstEffect (useFirstEffect')
import Gargantext.Hooks.Session (useSession)
import Gargantext.Hooks.Sigmax.Types as SigmaxT import Gargantext.Hooks.Sigmax.Types as SigmaxT
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (CTabNgramType, FrontendError(..), NodeID, TabSubType(..), TabType(..), TermList(..), modeTabType) import Gargantext.Types (CTabNgramType, FrontendError(..), NodeID, TabSubType(..), TabType(..), TermList(..), modeTabType)
...@@ -54,7 +55,6 @@ here = R2.here "Gargantext.Components.GraphExplorer.Sidebar" ...@@ -54,7 +55,6 @@ here = R2.here "Gargantext.Components.GraphExplorer.Sidebar"
type Props = type Props =
( metaData :: GET.MetaData ( metaData :: GET.MetaData
, session :: Session
, frontends :: Frontends , frontends :: Frontends
) )
...@@ -626,7 +626,6 @@ updateTermButtonCpt = here.component "updateTermButton" cpt where ...@@ -626,7 +626,6 @@ updateTermButtonCpt = here.component "updateTermButton" cpt where
, metaData , metaData
, nodesMap , nodesMap
, rType , rType
, session
} children = do } children = do
-- States -- States
{ errors { errors
...@@ -641,6 +640,8 @@ updateTermButtonCpt = here.component "updateTermButton" cpt where ...@@ -641,6 +640,8 @@ updateTermButtonCpt = here.component "updateTermButton" cpt where
selectedNodeIds' <- R2.useLive' selectedNodeIds selectedNodeIds' <- R2.useLive' selectedNodeIds
graphId' <- R2.useLive' graphId graphId' <- R2.useLive' graphId
session <- useSession
-- Behaviors -- Behaviors
let let
callback _ = do callback _ = do
...@@ -650,7 +651,7 @@ updateTermButtonCpt = here.component "updateTermButton" cpt where ...@@ -650,7 +651,7 @@ updateTermButtonCpt = here.component "updateTermButton" cpt where
, graphId: graphId' , graphId: graphId'
, metaData: metaData , metaData: metaData
, nodes , nodes
, session: session , session
, termList: rType , termList: rType
, reloadForest , reloadForest
} }
......
...@@ -45,9 +45,8 @@ type Props = ...@@ -45,9 +45,8 @@ type Props =
docListWrapper :: R2.Leaf Props docListWrapper :: R2.Leaf Props
docListWrapper = R2.leaf docListWrapperCpt docListWrapper = R2.leaf docListWrapperCpt
docListWrapperCpt :: R.Component Props docListWrapperCpt :: R.Component Props
docListWrapperCpt = here.component "wrapper" cpt where docListWrapperCpt = here.component "docListWrapper" cpt where
cpt { metaData: GET.MetaData metaData cpt { metaData: GET.MetaData metaData
} _ = do } _ = do
-- | States -- | States
...@@ -123,9 +122,8 @@ type ListProps = ...@@ -123,9 +122,8 @@ type ListProps =
docList :: R2.Leaf ListProps docList :: R2.Leaf ListProps
docList = R2.leaf docListCpt docList = R2.leaf docListCpt
docListCpt :: R.Component ListProps docListCpt :: R.Component ListProps
docListCpt = here.component "main" cpt where docListCpt = here.component "docList" cpt where
-- | Helpers -- | Helpers
-- | -- |
errorHandler err = do errorHandler err = do
...@@ -268,7 +266,6 @@ type ItemProps = ...@@ -268,7 +266,6 @@ type ItemProps =
item :: R2.Leaf ItemProps item :: R2.Leaf ItemProps
item = R2.leaf itemCpt item = R2.leaf itemCpt
itemCpt :: R.Component ItemProps itemCpt :: R.Component ItemProps
itemCpt = here.component "item" cpt where itemCpt = here.component "item" cpt where
cpt { documentView: dv@(DocumentsView { id, title, source }) cpt { documentView: dv@(DocumentsView { id, title, source })
......
...@@ -29,12 +29,12 @@ import Gargantext.Components.Forest.Tree.Node.Action.Upload.Types (FileFormat(.. ...@@ -29,12 +29,12 @@ import Gargantext.Components.Forest.Tree.Node.Action.Upload.Types (FileFormat(..
import Gargantext.Components.GraphExplorer.API (cloneGraph) import Gargantext.Components.GraphExplorer.API (cloneGraph)
import Gargantext.Components.GraphExplorer.Types as GET import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Components.GraphExplorer.Utils as GEU import Gargantext.Components.GraphExplorer.Utils as GEU
import Gargantext.Hooks.Session (useSession)
import Gargantext.Hooks.Sigmax as Sigmax import Gargantext.Hooks.Sigmax as Sigmax
import Gargantext.Hooks.Sigmax.Camera as Camera import Gargantext.Hooks.Sigmax.Camera as Camera
import Gargantext.Hooks.Sigmax.Graphology as Graphology import Gargantext.Hooks.Sigmax.Graphology as Graphology
import Gargantext.Hooks.Sigmax.Sigma as Sigma import Gargantext.Hooks.Sigmax.Sigma as Sigma
import Gargantext.Hooks.Sigmax.Types as SigmaxTypes import Gargantext.Hooks.Sigmax.Types as SigmaxTypes
import Gargantext.Sessions (Session)
import Gargantext.Utils ((?)) import Gargantext.Utils ((?))
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
...@@ -76,7 +76,6 @@ type CameraButtonProps = ...@@ -76,7 +76,6 @@ type CameraButtonProps =
, hyperdataGraph :: GET.HyperdataGraph , hyperdataGraph :: GET.HyperdataGraph
, forceAtlasState :: T.Box SigmaxTypes.ForceAtlasState , forceAtlasState :: T.Box SigmaxTypes.ForceAtlasState
, reloadForest :: T2.ReloadS , reloadForest :: T2.ReloadS
, session :: Session
, sigmaRef :: R.Ref Sigmax.Sigma , sigmaRef :: R.Ref Sigmax.Sigma
) )
...@@ -96,8 +95,8 @@ cameraButtonCpt = here.component "cameraButton" cpt ...@@ -96,8 +95,8 @@ cameraButtonCpt = here.component "cameraButton" cpt
, forceAtlasState , forceAtlasState
, hyperdataGraph: GET.HyperdataGraph { graph: GET.GraphData graphData' } , hyperdataGraph: GET.HyperdataGraph { graph: GET.GraphData graphData' }
, reloadForest , reloadForest
, session
, sigmaRef } _ = do , sigmaRef } _ = do
session <- useSession
forceAtlasState' <- R2.useLive' forceAtlasState forceAtlasState' <- R2.useLive' forceAtlasState
pure $ B.button pure $ B.button
......
...@@ -15,6 +15,7 @@ import Gargantext.Components.GraphExplorer.Toolbar.Buttons (cameraButton, center ...@@ -15,6 +15,7 @@ import Gargantext.Components.GraphExplorer.Toolbar.Buttons (cameraButton, center
import Gargantext.Components.GraphExplorer.Toolbar.RangeControl (edgeConfluenceControl, nodeSizeControl) import Gargantext.Components.GraphExplorer.Toolbar.RangeControl (edgeConfluenceControl, nodeSizeControl)
import Gargantext.Components.GraphExplorer.Toolbar.SlideButton (labelSizeButton, labelRenderedSizeThresholdButton, mouseSelectorSizeSlider) import Gargantext.Components.GraphExplorer.Toolbar.SlideButton (labelSizeButton, labelRenderedSizeThresholdButton, mouseSelectorSizeSlider)
import Gargantext.Components.GraphExplorer.Types as GET import Gargantext.Components.GraphExplorer.Types as GET
import Gargantext.Hooks.Session (useSession)
import Gargantext.Hooks.Sigmax.ForceAtlas2 as ForceAtlas import Gargantext.Hooks.Sigmax.ForceAtlas2 as ForceAtlas
import Gargantext.Hooks.Sigmax.Noverlap as Noverlap import Gargantext.Hooks.Sigmax.Noverlap as Noverlap
import Gargantext.Hooks.Sigmax as Sigmax import Gargantext.Hooks.Sigmax as Sigmax
...@@ -35,7 +36,6 @@ type Controls = ...@@ -35,7 +36,6 @@ type Controls =
( fa2Ref :: R.Ref (Maybe ForceAtlas.FA2Layout) ( fa2Ref :: R.Ref (Maybe ForceAtlas.FA2Layout)
, noverlapRef :: R.Ref (Maybe Noverlap.NoverlapLayout) , noverlapRef :: R.Ref (Maybe Noverlap.NoverlapLayout)
, reloadForest :: T2.ReloadS , reloadForest :: T2.ReloadS
, session :: Session
, sigmaRef :: R.Ref Sigmax.Sigma , sigmaRef :: R.Ref Sigmax.Sigma
) )
...@@ -46,7 +46,6 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -46,7 +46,6 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
cpt { fa2Ref cpt { fa2Ref
, noverlapRef , noverlapRef
, reloadForest , reloadForest
, session
, sigmaRef , sigmaRef
} _ = do } _ = do
-- | States -- | States
...@@ -82,8 +81,6 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -82,8 +81,6 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
edgeConfluenceRange' <- R2.useLive' edgeConfluenceRange edgeConfluenceRange' <- R2.useLive' edgeConfluenceRange
nodeSizeRange' <- R2.useLive' nodeSizeRange nodeSizeRange' <- R2.useLive' nodeSizeRange
-- session <- useSession
-- ref to track automatic FA pausing -- ref to track automatic FA pausing
-- If user pauses FA before auto is triggered, clear the timeoutId -- If user pauses FA before auto is triggered, clear the timeoutId
mFAPauseRef <- R.useRef Nothing mFAPauseRef <- R.useRef Nothing
...@@ -182,7 +179,6 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -182,7 +179,6 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
, forceAtlasState , forceAtlasState
, hyperdataGraph: hyperdataGraph' , hyperdataGraph: hyperdataGraph'
, reloadForest , reloadForest
, session
, sigmaRef: sigmaRef , sigmaRef: sigmaRef
} }
] ]
......
...@@ -10,6 +10,7 @@ import Gargantext.Components.Forest.Tree.Node.Tools (formChoiceSafe) ...@@ -10,6 +10,7 @@ import Gargantext.Components.Forest.Tree.Node.Tools (formChoiceSafe)
import Gargantext.Components.ListSelection.Types (NodeSimple(..), Selection(..), selectedListIds) import Gargantext.Components.ListSelection.Types (NodeSimple(..), Selection(..), selectedListIds)
import Gargantext.Config.REST (RESTError(..), AffRESTError) import Gargantext.Config.REST (RESTError(..), AffRESTError)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Session (useSession)
import Gargantext.Routes (SessionRoute(..)) import Gargantext.Routes (SessionRoute(..))
import Gargantext.Sessions (Session(..), get) import Gargantext.Sessions (Session(..), get)
import Gargantext.Types (ID, NodeType(..), fldr) import Gargantext.Types (ID, NodeType(..), fldr)
...@@ -23,14 +24,13 @@ here = R2.here "Gargantext.Components.ListSelection" ...@@ -23,14 +24,13 @@ here = R2.here "Gargantext.Components.ListSelection"
type Props = type Props =
( selection :: T.Box Selection ( selection :: T.Box Selection
, session :: Session
) )
selection :: R2.Component Props selection :: R2.Component Props
selection = R.createElement selectionCpt selection = R.createElement selectionCpt
selectionCpt :: R.Component Props selectionCpt :: R.Component Props
selectionCpt = here.component "selection" cpt where selectionCpt = here.component "selection" cpt where
cpt { selection, session } _ = do cpt { selection } _ = do
selection' <- R2.useLive' selection selection' <- R2.useLive' selection
pure $ H.div { className: "list-selection" } pure $ H.div { className: "list-selection" }
[ [
...@@ -44,33 +44,33 @@ selectionCpt = here.component "selection" cpt where ...@@ -44,33 +44,33 @@ selectionCpt = here.component "selection" cpt where
] ]
} }
[] []
, selectedIds { selection, session } [] , selectedIds { selection } []
] ]
selectedIds :: R2.Component Props selectedIds :: R2.Component Props
selectedIds = R.createElement selectedIdsCpt selectedIds = R.createElement selectedIdsCpt
selectedIdsCpt :: R.Component Props selectedIdsCpt :: R.Component Props
selectedIdsCpt = here.component "selectedIds" cpt where selectedIdsCpt = here.component "selectedIds" cpt where
cpt { selection, session } _ = do cpt { selection } _ = do
selection' <- T.useLive T.unequal selection selection' <- T.useLive T.unequal selection
pure $ case selection' of pure $ case selection' of
SelectedLists ids -> H.div {} [ idsSelector { selection, session } [] ] SelectedLists ids -> H.div {} [ idsSelector { selection } [] ]
_ -> H.div {} [] _ -> H.div {} []
type IdsSelectorProps = type IdsSelectorProps =
( selection :: T.Box Selection ( selection :: T.Box Selection )
, session :: Session )
idsSelector :: R2.Component IdsSelectorProps idsSelector :: R2.Component IdsSelectorProps
idsSelector = R.createElement idsSelectorCpt idsSelector = R.createElement idsSelectorCpt
idsSelectorCpt :: R.Component IdsSelectorProps idsSelectorCpt :: R.Component IdsSelectorProps
idsSelectorCpt = here.component "idsSelector" cpt where idsSelectorCpt = here.component "idsSelector" cpt where
cpt { selection, session } _ = do cpt { selection } _ = do
session <- useSession
let Session { treeId: root } = session
pure $ H.div { className: "ids-selector" } pure $ H.div { className: "ids-selector" }
[ listTree { name: "", nodeType: NodeUser, root, selection, session } ] -- $ map checkbox [1, 2, 3, 4] [ listTree { name: "", nodeType: NodeUser, root, selection } ] -- $ map checkbox [1, 2, 3, 4]
where
Session { treeId: root } = session
listIdsRoute :: ID -> SessionRoute listIdsRoute :: ID -> SessionRoute
listIdsRoute = Children NodeList 0 1 Nothing <<< Just listIdsRoute = Children NodeList 0 1 Nothing <<< Just
...@@ -88,22 +88,20 @@ type ListTreeProps = ...@@ -88,22 +88,20 @@ type ListTreeProps =
, nodeType :: NodeType , nodeType :: NodeType
, root :: ID , root :: ID
, selection :: T.Box Selection , selection :: T.Box Selection
, session :: Session
) )
listTree :: R2.Leaf ListTreeProps listTree :: R2.Leaf ListTreeProps
listTree props = R.createElement listTreeCpt props [] listTree props = R.createElement listTreeCpt props []
listTreeCpt :: R.Component ListTreeProps listTreeCpt :: R.Component ListTreeProps
listTreeCpt = here.component "listTree" cpt where listTreeCpt = here.component "listTree" cpt where
cpt { name, nodeType, root, selection, session } _ = do cpt { name, nodeType, root, selection } _ = do
pure $ H.div { className: "tree" } pure $ H.div { className: "tree" }
[ H.div { className: "root" } [ H.div { className: "root" }
[ H.i { className: fldr nodeType true } [] [ H.i { className: fldr nodeType true } []
, H.text $ "[" <> show root <> "] " <> name ] , H.text $ "[" <> show root <> "] " <> name ]
, listTreeChildren { render: listTree , listTreeChildren { render: listTree
, root , root
, selection , selection } []
, session } []
] ]
type Render = Record ListTreeProps -> R.Element type Render = Record ListTreeProps -> R.Element
...@@ -111,14 +109,14 @@ type ListTreeChildrenProps = ...@@ -111,14 +109,14 @@ type ListTreeChildrenProps =
( render :: Render ( render :: Render
, root :: ID , root :: ID
, selection :: T.Box Selection , selection :: T.Box Selection
, session :: Session
) )
listTreeChildren :: R2.Component ListTreeChildrenProps listTreeChildren :: R2.Component ListTreeChildrenProps
listTreeChildren = R.createElement listTreeChildrenCpt listTreeChildren = R.createElement listTreeChildrenCpt
listTreeChildrenCpt :: R.Component ListTreeChildrenProps listTreeChildrenCpt :: R.Component ListTreeChildrenProps
listTreeChildrenCpt = here.component "listTreeChildren" cpt where listTreeChildrenCpt = here.component "listTreeChildren" cpt where
cpt { render, root, selection, session } _ = do cpt { render, root, selection } _ = do
session <- useSession
useLoader { errorHandler useLoader { errorHandler
, loader: loadTreeChildren , loader: loadTreeChildren
, path: { root, session } , path: { root, session }
...@@ -126,8 +124,7 @@ listTreeChildrenCpt = here.component "listTreeChildren" cpt where ...@@ -126,8 +124,7 @@ listTreeChildrenCpt = here.component "listTreeChildren" cpt where
listTreeChildrenLoaded { loaded listTreeChildrenLoaded { loaded
, render , render
, root , root
, selection , selection } [] }
, session } [] }
where where
errorHandler err = case err of errorHandler err = case err of
ReadJSONError err' -> here.warn2 "[listTreeChildren] ReadJSONError" $ show err' ReadJSONError err' -> here.warn2 "[listTreeChildren] ReadJSONError" $ show err'
...@@ -137,30 +134,29 @@ type ListTreeChildrenLoadedProps = ...@@ -137,30 +134,29 @@ type ListTreeChildrenLoadedProps =
( loaded :: Array NodeSimple ( loaded :: Array NodeSimple
, render :: Render , render :: Render
, root :: ID , root :: ID
, selection :: T.Box Selection , selection :: T.Box Selection )
, session :: Session )
listTreeChildrenLoaded :: R2.Component ListTreeChildrenLoadedProps listTreeChildrenLoaded :: R2.Component ListTreeChildrenLoadedProps
listTreeChildrenLoaded = R.createElement listTreeChildrenLoadedCpt listTreeChildrenLoaded = R.createElement listTreeChildrenLoadedCpt
listTreeChildrenLoadedCpt :: R.Component ListTreeChildrenLoadedProps listTreeChildrenLoadedCpt :: R.Component ListTreeChildrenLoadedProps
listTreeChildrenLoadedCpt = here.component "listTreeChildrenLoaded" cpt where listTreeChildrenLoadedCpt = here.component "listTreeChildrenLoaded" cpt where
cpt { loaded, render, root, selection, session } _ = do cpt { loaded, render, root, selection } _ = do
pure $ H.div { className: "children" } (element <$> loaded) pure $ H.div { className: "children" } (element <$> loaded)
where where
element (NodeSimple { id, name, nodeType: nodeType@Corpus }) = element (NodeSimple { id, name, nodeType: nodeType@Corpus }) =
render { root: id, name, nodeType, selection, session } render { root: id, name, nodeType, selection }
element (NodeSimple { id, name, nodeType: nodeType@Folder }) = element (NodeSimple { id, name, nodeType: nodeType@Folder }) =
render { root: id, name, nodeType, selection, session } render { root: id, name, nodeType, selection }
element (NodeSimple { id, name, nodeType: nodeType@FolderPrivate }) = element (NodeSimple { id, name, nodeType: nodeType@FolderPrivate }) =
render { root: id, name, nodeType, selection, session } render { root: id, name, nodeType, selection }
element (NodeSimple { id, name, nodeType: nodeType@FolderPublic }) = element (NodeSimple { id, name, nodeType: nodeType@FolderPublic }) =
render { root: id, name, nodeType, selection, session } render { root: id, name, nodeType, selection }
element (NodeSimple { id, name, nodeType: nodeType@FolderShared }) = element (NodeSimple { id, name, nodeType: nodeType@FolderShared }) =
render { root: id, name, nodeType, selection, session } render { root: id, name, nodeType, selection }
element (NodeSimple { id, name, nodeType: NodeList}) = element (NodeSimple { id, name, nodeType: NodeList}) =
renderListElement { id, name, selection } renderListElement { id, name, selection }
element (NodeSimple { id, name, nodeType: nodeType@Team }) = element (NodeSimple { id, name, nodeType: nodeType@Team }) =
render { root: id, name, nodeType, selection, session } render { root: id, name, nodeType, selection }
element _ = H.div {} [] element _ = H.div {} []
type RenderListElementProps = type RenderListElementProps =
......
...@@ -15,7 +15,7 @@ import Gargantext.Components.Document.Types (LoadedData, DocPath) ...@@ -15,7 +15,7 @@ import Gargantext.Components.Document.Types (LoadedData, DocPath)
import Gargantext.Components.PhyloExplorer.Types (FrameDoc(..)) import Gargantext.Components.PhyloExplorer.Types (FrameDoc(..))
import Gargantext.Config.REST (logRESTError) import Gargantext.Config.REST (logRESTError)
import Gargantext.Hooks.Loader (useLoaderEffect) import Gargantext.Hooks.Loader (useLoaderEffect)
import Gargantext.Sessions (Session) import Gargantext.Hooks.Session (useSession)
import Gargantext.Types (CTabNgramType(..), TabSubType(..), TabType(..)) import Gargantext.Types (CTabNgramType(..), TabSubType(..), TabType(..))
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Reactix as R import Reactix as R
...@@ -27,7 +27,6 @@ here = R2.here "Gargantext.Components.PhyloExplorer.Frame.DocFocus" ...@@ -27,7 +27,6 @@ here = R2.here "Gargantext.Components.PhyloExplorer.Frame.DocFocus"
type Props = type Props =
( frameDoc :: FrameDoc ( frameDoc :: FrameDoc
, session :: Session
, closeCallback :: Unit -> Effect Unit , closeCallback :: Unit -> Effect Unit
) )
...@@ -37,9 +36,9 @@ docFocus = R2.leaf docFocusCpt ...@@ -37,9 +36,9 @@ docFocus = R2.leaf docFocusCpt
docFocusCpt :: R.Component ( key :: String | Props ) docFocusCpt :: R.Component ( key :: String | Props )
docFocusCpt = here.component "main" cpt where docFocusCpt = here.component "main" cpt where
cpt { frameDoc: FrameDoc { docId, listId, corpusId } cpt { frameDoc: FrameDoc { docId, listId, corpusId }
, session
, closeCallback , closeCallback
} _ = do } _ = do
session <- useSession
-- | States -- | States
-- | -- |
state' /\ state <- R2.useBox' (Nothing :: Maybe LoadedData) state' /\ state <- R2.useBox' (Nothing :: Maybe LoadedData)
......
...@@ -22,7 +22,6 @@ import Gargantext.Components.PhyloExplorer.ToolBar (toolBar) ...@@ -22,7 +22,6 @@ import Gargantext.Components.PhyloExplorer.ToolBar (toolBar)
import Gargantext.Components.PhyloExplorer.TopBar (topBar) import Gargantext.Components.PhyloExplorer.TopBar (topBar)
import Gargantext.Components.PhyloExplorer.Types (DisplayView, ExtractedCount, FrameDoc, PhyloData(..), TabView(..), Term, sortSources) import Gargantext.Components.PhyloExplorer.Types (DisplayView, ExtractedCount, FrameDoc, PhyloData(..), TabView(..), Term, sortSources)
import Gargantext.Hooks.FirstEffect (useFirstEffect') import Gargantext.Hooks.FirstEffect (useFirstEffect')
import Gargantext.Hooks.Session (useSession)
import Gargantext.Hooks.UpdateEffect (useUpdateEffect1', useUpdateEffect3') import Gargantext.Hooks.UpdateEffect (useUpdateEffect1', useUpdateEffect3')
import Gargantext.Types (SidePanelState(..)) import Gargantext.Types (SidePanelState(..))
import Gargantext.Utils (getter, (?)) import Gargantext.Utils (getter, (?))
...@@ -79,8 +78,6 @@ layoutCpt = here.component "layout" cpt where ...@@ -79,8 +78,6 @@ layoutCpt = here.component "layout" cpt where
selectedSource' <- R2.useLive' selectedSource selectedSource' <- R2.useLive' selectedSource
frameDoc' <- R2.useLive' frameDoc frameDoc' <- R2.useLive' frameDoc
session <- useSession
-- | Hooks -- | Hooks
-- | -- |
let topBarPortalKey = "portal-topbar::" <> show phyloId' let topBarPortalKey = "portal-topbar::" <> show phyloId'
...@@ -272,8 +269,7 @@ layoutCpt = here.component "layout" cpt where ...@@ -272,8 +269,7 @@ layoutCpt = here.component "layout" cpt where
{ className: "phylo__focus__inner" } { className: "phylo__focus__inner" }
[ [
docFocus docFocus
{ session { frameDoc: frameDoc_
, frameDoc: frameDoc_
, closeCallback: closeDocCallback , closeCallback: closeDocCallback
, key: show $ getter _.docId frameDoc_ , key: show $ getter _.docId frameDoc_
} }
......
...@@ -215,7 +215,6 @@ mainPageCpt = here.component "mainPage" cpt where ...@@ -215,7 +215,6 @@ mainPageCpt = here.component "mainPage" cpt where
forest :: R2.Leaf Props forest :: R2.Leaf Props
forest = R2.leaf forestCpt forest = R2.leaf forestCpt
forestCpt :: R.Memo Props forestCpt :: R.Memo Props
forestCpt = R.memo' $ here.component "forest" cpt where forestCpt = R.memo' $ here.component "forest" cpt where
cpt { boxes } _ = do cpt { boxes } _ = do
......
...@@ -15,11 +15,12 @@ import Effect.Timer (IntervalId, clearInterval, setInterval) ...@@ -15,11 +15,12 @@ import Effect.Timer (IntervalId, clearInterval, setInterval)
import Gargantext.Components.Forest.Tree.Node.Tools.ProgressBar (QueryProgressData, queryProgress) import Gargantext.Components.Forest.Tree.Node.Tools.ProgressBar (QueryProgressData, queryProgress)
import Gargantext.Config.Utils (handleErrorInAsyncProgress, handleRESTError) import Gargantext.Config.Utils (handleErrorInAsyncProgress, handleRESTError)
import Gargantext.Hooks.FirstEffect (useFirstEffect') import Gargantext.Hooks.FirstEffect (useFirstEffect')
import Gargantext.Sessions (Session) import Gargantext.Hooks.Session (useSession)
import Gargantext.Types (AsyncProgress, FrontendError) import Gargantext.Types (AsyncProgress, FrontendError)
import Gargantext.Types as GT import Gargantext.Types as GT
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Reactix as R import Reactix as R
import Record as Record
import Record.Extra as RX import Record.Extra as RX
import Toestand as T import Toestand as T
...@@ -28,7 +29,6 @@ type AsyncProps = ...@@ -28,7 +29,6 @@ type AsyncProps =
, errors :: T.Box (Array FrontendError) , errors :: T.Box (Array FrontendError)
, nodeId :: GT.ID , nodeId :: GT.ID
, onFinish :: Unit -> Effect Unit , onFinish :: Unit -> Effect Unit
, session :: Session
) )
asyncProgress :: R2.Component AsyncProps asyncProgress :: R2.Component AsyncProps
...@@ -39,6 +39,7 @@ component = R.hooksComponent "asyncProgressContext" cpt where ...@@ -39,6 +39,7 @@ component = R.hooksComponent "asyncProgressContext" cpt where
cpt props@{ errors cpt props@{ errors
, onFinish , onFinish
} children = do } children = do
session <- useSession
-- States -- States
progress /\ progressBox <- R2.useBox' 0.0 progress /\ progressBox <- R2.useBox' 0.0
intervalIdRef <- R.useRef (Nothing :: Maybe IntervalId) intervalIdRef <- R.useRef (Nothing :: Maybe IntervalId)
...@@ -47,7 +48,8 @@ component = R.hooksComponent "asyncProgressContext" cpt where ...@@ -47,7 +48,8 @@ component = R.hooksComponent "asyncProgressContext" cpt where
let let
exec :: Unit -> Effect Unit exec :: Unit -> Effect Unit
exec _ = launchAff_ do exec _ = launchAff_ do
let rdata = (RX.pick props :: Record QueryProgressData) let rdata = (Record.merge (RX.pick props :: { asyncTask :: GT.AsyncTaskWithType
, nodeId :: GT.ID }) { session })
eAsyncProgress <- queryProgress rdata eAsyncProgress <- queryProgress rdata
handleRESTError errors eAsyncProgress onProgress handleRESTError errors eAsyncProgress onProgress
......
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