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

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