Commit e984d3dc authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[router] refactoring of sessions (no more context)

parent b27a7f6e
......@@ -11,7 +11,7 @@ import Gargantext.Components.Nodes.Texts.Types as TextsT
import Gargantext.Ends (Backend)
import Gargantext.Routes (AppRoute(Home))
import Gargantext.Sessions as Sessions
import Gargantext.Sessions (OpenNodes, Sessions)
import Gargantext.Sessions (OpenNodes, Session, Sessions)
import Gargantext.Types (Handed(RightHanded), SidePanelState(..))
import Gargantext.Utils.Toestand as T2
......@@ -24,6 +24,7 @@ type App =
, reloadMainPage :: T2.Reload
, reloadRoot :: T2.Reload
, route :: AppRoute
, session :: Maybe Session
, sessions :: Sessions
, showCorpus :: Boolean
, showLogin :: Boolean
......@@ -45,6 +46,7 @@ emptyApp =
, reloadMainPage : T2.newReload
, reloadRoot : T2.newReload
, route : Home
, session : Nothing
, sessions : Sessions.empty
, showCorpus : false
, showLogin : false
......@@ -65,6 +67,7 @@ type Boxes =
, reloadMainPage :: T2.ReloadS
, reloadRoot :: T2.ReloadS
, route :: T.Box AppRoute
, session :: T.Box (Maybe Session)
, sessions :: T.Box Sessions
, showCorpus :: T.Box Boolean
, showLogin :: T.Box Boolean
......
......@@ -379,18 +379,19 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where
, totalRecords }
, localCategories
, params } _ = do
reload <- T.useBox T2.newReload
localCategories' <- T.useLive T.unequal localCategories
sidePanel' <- T.useLive T.unequal sidePanel
let mCurrentDocId = maybe Nothing (_.mCurrentDocId) sidePanel'
mCurrentDocId <- T.useFocused
(maybe Nothing _.mCurrentDocId)
(\val -> maybe Nothing (\sp -> Just $ sp { mCurrentDocId = val })) sidePanel
mCurrentDocId' <- T.useLive T.unequal mCurrentDocId
pure $ TT.table
{ colNames
, container: TT.defaultContainer { title: "Documents" }
, params
, rows: rows reload localCategories' mCurrentDocId
, rows: rows reload localCategories' mCurrentDocId'
, syncResetButton : [ H.div {} [] ]
, totalRecords
, wrapColElts
......@@ -407,7 +408,7 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where
| otherwise = Routes.Document sid listId
colNames = TT.ColumnName <$> [ "Show", "Tag", "Date", "Title", "Source", "Score" ]
wrapColElts = const identity
rows reload localCategories' mCurrentDocId = row <$> A.toUnfoldable documents
rows reload localCategories' mCurrentDocId' = row <$> A.toUnfoldable documents
where
row dv@(DocumentsView r@{ _id, category }) =
{ row:
......@@ -444,7 +445,7 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where
-- checked = Star_1 == cat
tClassName = trashClassName cat selected
className = gi cat
selected = mCurrentDocId == Just r._id
selected = mCurrentDocId' == Just r._id
type DocChooser = (
listId :: ListId
......
......@@ -52,7 +52,6 @@ type Props =
type TreeExtra = (
forestOpen :: T.Box OpenNodes
, session :: Session
)
forest :: R2.Component Props
......
......@@ -55,8 +55,6 @@ type BaseProps =
, tasks :: T.Box GAT.Storage
)
type LayoutLoaderProps = ( session :: R.Context Session | BaseProps )
type LayoutProps =
( session :: Session
| BaseProps )
......@@ -75,17 +73,6 @@ type Props =
)
--------------------------------------------------------------
explorerLayoutLoader :: R2.Component LayoutLoaderProps
explorerLayoutLoader = R.createElement explorerLayoutLoaderCpt
explorerLayoutLoaderCpt :: R.Component LayoutLoaderProps
explorerLayoutLoaderCpt = here.component "explorerLayoutLoader" cpt where
cpt props _ = do
session <- R.useContext props.session -- TODO: ugh, props fiddling
let base = RX.pick props :: Record BaseProps
let props' = Record.merge base { session }
pure $ explorerLayout props' []
explorerLayout :: R2.Component LayoutProps
explorerLayout = R.createElement explorerLayoutCpt
......
......@@ -49,7 +49,7 @@ newtype IndividuView =
type LayoutProps =
( frontends :: Frontends
, nodeId :: Int
, session :: R.Context Session
, session :: Session
)
annuaireLayout :: R2.Leaf LayoutProps
......@@ -57,15 +57,14 @@ annuaireLayout props = R.createElement annuaireLayoutCpt props []
annuaireLayoutCpt :: R.Component LayoutProps
annuaireLayoutCpt = here.component "annuaireLayout" cpt where
cpt { frontends, nodeId, session } _ = cp <$> R.useContext session where
cp s = annuaireLayoutWithKey { frontends, key, nodeId, session: s } where
key = show (sessionId s) <> "-" <> show nodeId
cpt { frontends, nodeId, session } _ = do
pure $ annuaireLayoutWithKey { frontends, key, nodeId, session }
where
key = show (sessionId session) <> "-" <> show nodeId
type KeyLayoutProps =
( frontends :: Frontends
, nodeId :: Int
, session :: Session
, key :: String
( key :: String
| LayoutProps
)
annuaireLayoutWithKey :: R2.Leaf KeyLayoutProps
......
module Gargantext.Components.Nodes.Annuaire.User
( module Gargantext.Components.Nodes.Annuaire.User.Contacts.Types
, userLayout
, userLayoutSessionContext
)
where
......@@ -170,17 +169,6 @@ type KeyLayoutProps = (
| LayoutProps
)
userLayoutSessionContext :: R2.Component LayoutSessionContextProps
userLayoutSessionContext = R.createElement userLayoutSessionContextCpt
userLayoutSessionContextCpt :: R.Component LayoutSessionContextProps
userLayoutSessionContextCpt = here.component "userLayoutSessionContext" cpt
where
cpt props@{ session } _ = do
session' <- R.useContext session
pure $ userLayout (Record.merge { session: session' } $ (REX.pick props :: Record LayoutNoSessionProps)) []
userLayout :: R2.Component LayoutProps
userLayout = R.createElement userLayoutCpt
......
......@@ -160,7 +160,7 @@ type KeyLayoutProps = ( key :: String, session :: Session | ReloadProps )
saveContactHyperdata :: Session -> Int -> HyperdataContact -> Aff Int
saveContactHyperdata session id = put session (Routes.NodeAPI Node (Just id) "")
type AnnuaireLayoutProps = ( annuaireId :: Int, session :: R.Context Session | ReloadProps )
type AnnuaireLayoutProps = ( annuaireId :: Int, session :: Session | ReloadProps )
type AnnuaireKeyLayoutProps = ( annuaireId :: Int | KeyLayoutProps )
......@@ -178,8 +178,7 @@ contactLayoutCpt = here.component "contactLayout" cpt where
, sidePanel
, sidePanelState
, tasks } _ = do
s <- R.useContext session
let key = show (sessionId s) <> "-" <> show nodeId
let key = show (sessionId session) <> "-" <> show nodeId
pure $
contactLayoutWithKey
{ annuaireId
......@@ -188,7 +187,7 @@ contactLayoutCpt = here.component "contactLayout" cpt where
, nodeId
, reloadForest
, reloadRoot
, session: s
, session
, sidePanel
, sidePanelState
, tasks
......
module Gargantext.Components.Nodes.Corpus where
import Gargantext.Prelude (class Eq, class Show, Unit, bind, discard, pure, show, unit, ($), (+), (-), (<), (<$>), (<<<), (<>), (==), (>))
import DOM.Simple.Console (log2)
import Data.Argonaut (class DecodeJson, decodeJson, encodeJson)
import Data.Argonaut.Parser (jsonParser)
import Data.Array as A
......@@ -11,46 +11,44 @@ import Data.Generic.Rep.Show (genericShow)
import Data.List as List
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Tuple (Tuple(..))
import DOM.Simple.Console (log2)
import Effect (Effect)
import Effect.Aff (Aff, launchAff_, throwError)
import Effect.Class (liftEffect)
import Effect.Exception (error)
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
import Gargantext.Components.FolderView as FV
import Gargantext.Components.CodeEditor as CE
import Gargantext.Components.FolderView as FV
import Gargantext.Components.Forest.Tree.Node.Action.Search.Types (doc)
import Gargantext.Components.InputWithEnter (inputWithEnter)
import Gargantext.Components.Node (NodePoly(..), HyperdataList)
import Gargantext.Components.Nodes.Types
( FTField, FTFieldWithIndex, FTFieldsWithIndex, Field(..), FieldType(..), Hash, Index
, defaultField, defaultHaskell', defaultJSON', defaultMarkdown', defaultPython' )
import Gargantext.Components.Nodes.Corpus.Types (CorpusData, Hyperdata(..))
import Gargantext.Components.Nodes.Types (FTField, FTFieldWithIndex, FTFieldsWithIndex, Field(..), FieldType(..), Hash, Index, defaultField, defaultHaskell', defaultJSON', defaultMarkdown', defaultPython')
import Gargantext.Data.Array as GDA
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (class Eq, class Show, Unit, bind, discard, pure, show, unit, ($), (+), (-), (<), (<$>), (<<<), (<>), (==), (>))
import Gargantext.Routes (SessionRoute(Children, NodeAPI))
import Gargantext.Sessions (Session, get, put, sessionId)
import Gargantext.Types (AffTableResult, NodeType(..))
import Gargantext.Utils.Crypto as Crypto
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
import Reactix as R
import Reactix.DOM.HTML as H
import Toestand as T
here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Corpus"
type Props = ( nodeId :: Int, session :: R.Context Session )
type Props = ( nodeId :: Int, session :: Session )
corpusLayout :: R2.Leaf Props
corpusLayout props = R.createElement corpusLayoutCpt props []
corpusLayoutCpt :: R.Component Props
corpusLayoutCpt = here.component "corpusLayout" cpt where
cpt { nodeId, session } _ = cp <$> R.useContext session where
cp s = corpusLayoutMain { key, nodeId, session: s } where
key = show (sessionId s) <> "-" <> show nodeId
cpt { nodeId, session } _ = do
pure $ corpusLayoutMain { key, nodeId, session }
where
key = show (sessionId session) <> "-" <> show nodeId
type KeyProps =
( nodeId :: Int
......
......@@ -28,21 +28,21 @@ import Gargantext.Utils.Toestand as T2
here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Corpus.Dashboard"
type Props = ( nodeId :: NodeID, session :: R.Context Session )
type Props = ( nodeId :: NodeID, session :: Session )
dashboardLayout :: R2.Component Props
dashboardLayout = R.createElement dashboardLayoutCpt
dashboardLayoutCpt :: R.Component Props
dashboardLayoutCpt = here.component "dashboardLayout" cpt where
cpt { nodeId, session } content = cp <$> R.useContext session where
cp s = dashboardLayoutWithKey { key, nodeId, session: s } content where
key = show (sessionId s) <> "-" <> show nodeId
cpt { nodeId, session } content = do
pure $ dashboardLayoutWithKey { key, nodeId, session } content
where
key = show (sessionId session) <> "-" <> show nodeId
type KeyProps =
( key :: String
, nodeId :: NodeID
, session :: Session
| Props
)
dashboardLayoutWithKey :: R2.Component KeyProps
......
......@@ -118,7 +118,7 @@ type LayoutProps =
( listId :: ListId
, mCorpusId :: Maybe NodeID
, nodeId :: NodeID
, session :: R.Context Session
, session :: Session
)
documentMainLayout :: R2.Component LayoutProps
......@@ -133,9 +133,10 @@ documentLayout = R.createElement documentLayoutCpt
documentLayoutCpt :: R.Component LayoutProps
documentLayoutCpt = here.component "documentLayout" cpt where
cpt { listId, mCorpusId, nodeId, session } children = cp <$> R.useContext session where
cp s = documentLayoutWithKey { key, listId, mCorpusId, nodeId, session: s } children where
key = show (sessionId s) <> "-" <> show nodeId
cpt { listId, mCorpusId, nodeId, session } children = do
pure $ documentLayoutWithKey { key, listId, mCorpusId, nodeId, session } children
where
key = show (sessionId session) <> "-" <> show nodeId
type KeyLayoutProps =
( key :: String
......
......@@ -55,25 +55,25 @@ instance decodeFile :: DecodeJson File where
hyperdata <- (obj .: "hyperdata") >>= decodeJson
pure $ File { id, date, hyperdata, name }
type FileLayoutProps = ( nodeId :: NodeID, session :: R.Context Session )
type FileLayoutProps = ( nodeId :: NodeID, session :: Session )
fileLayout :: R2.Leaf FileLayoutProps
fileLayout props = R.createElement fileLayoutCpt props []
fileLayoutCpt :: R.Component FileLayoutProps
fileLayoutCpt = here.component "fileLayout" cpt where
cpt { nodeId, session } _ = R.useContext session >>= cp where
cp s = useLoader nodeId (loadFile s) onLoad where
onLoad loaded = fileLayoutLoaded { loaded, nodeId, session: s } where
key = show (sessionId s) <> "-" <> show nodeId
cpt { nodeId, session } _ = do
useLoader nodeId (loadFile session) onLoad
where
onLoad loaded = fileLayoutLoaded { loaded, nodeId, session }
key = show (sessionId session) <> "-" <> show nodeId
loadFile :: Session -> NodeID -> Aff File
loadFile session nodeId = get session $ NodeAPI Node (Just nodeId) ""
type FileLayoutLoadedProps =
( loaded :: File
, nodeId :: Int
, session :: Session
| FileLayoutProps
)
fileLayoutLoaded :: Record FileLayoutLoadedProps -> R.Element
......
......@@ -46,15 +46,13 @@ instance encodeJsonHyperdata :: Argonaut.EncodeJson Hyperdata where
type Props =
( nodeId :: Int
, session :: R.Context Session
, nodeType :: NodeType
, session :: Session
)
type KeyProps =
( key :: String
, nodeId :: Int
, session :: Session
, nodeType :: NodeType
| Props
)
frameLayout :: R2.Leaf Props
......@@ -62,9 +60,10 @@ frameLayout props = R.createElement frameLayoutCpt props []
frameLayoutCpt :: R.Component Props
frameLayoutCpt = here.component "frameLayout" cpt where
cpt { nodeId, nodeType, session } _ = cp <$> R.useContext session where
cp s = frameLayoutWithKey { key, nodeId, nodeType, session: s } where
key = show (sessionId s) <> "-" <> show nodeId
cpt { nodeId, nodeType, session } _ = do
pure $ frameLayoutWithKey { key, nodeId, nodeType, session }
where
key = show (sessionId session) <> "-" <> show nodeId
frameLayoutWithKey :: R2.Leaf KeyProps
frameLayoutWithKey props = R.createElement frameLayoutWithKeyCpt props []
......
......@@ -24,16 +24,6 @@ import Toestand as T
here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Lists"
listsWithSessionContext :: R2.Component CommonPropsSessionContext
listsWithSessionContext = R.createElement listsWithSessionContextCpt
listsWithSessionContextCpt :: R.Component CommonPropsSessionContext
listsWithSessionContextCpt = here.component "listsWithSessionContext" cpt where
cpt props@{ session, sidePanel, sidePanelState } _ = do
session' <- R.useContext session
pure $ listsLayout (Record.merge { session: session', sidePanel, sidePanelState } props) []
--------------------------------------------------------
type CommonPropsNoSession =
......
......@@ -33,20 +33,6 @@ here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Texts"
--------------------------------------------------------
textsWithSessionContext :: R2.Component CommonPropsSessionContext
textsWithSessionContext = R.createElement textsWithSessionContextCpt
textsWithSessionContextCpt :: R.Component CommonPropsSessionContext
textsWithSessionContextCpt = here.component "textsWithSessionContext" cpt
where
cpt props@{ session, sidePanel, sidePanelState } _ = do
session' <- R.useContext session
pure $ R.fragment
[
textsLayout (Record.merge { session: session', sidePanel, sidePanelState } props) []
-- , H.div { className: "side-panel" } [ sidePanelC { session: session', sidePanel } [] ]
]
type CommonPropsNoSession = (
......@@ -57,7 +43,6 @@ type CommonPropsNoSession = (
)
type Props = WithSession CommonPropsNoSession
type CommonPropsSessionContext = WithSessionContext CommonPropsNoSession
textsLayout :: R2.Component Props
......@@ -427,9 +412,7 @@ sidePanelDocViewCpt = here.component "sidePanelDocView" cpt
pure $ H.div {} []
cpt { mSidePanel: Just { corpusId, listId, nodeId }
, session } _ = do
let session' = R.createContext session
pure $ D.documentLayout { listId
, mCorpusId: Just corpusId
, nodeId
, session: session' } []
, session } []
......@@ -10,7 +10,6 @@ import Reactix.DOM.HTML as H
import Record as Record
import Record.Extra as RE
import Toestand as T
import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.Footer (footer)
......@@ -21,7 +20,7 @@ import Gargantext.Components.GraphExplorer.Sidebar.Types as GEST
import Gargantext.Components.Lang (LandingLang(LL_EN))
import Gargantext.Components.Login (login)
import Gargantext.Components.Nodes.Annuaire (annuaireLayout)
import Gargantext.Components.Nodes.Annuaire.User (userLayoutSessionContext)
import Gargantext.Components.Nodes.Annuaire.User (userLayout)
import Gargantext.Components.Nodes.Annuaire.User.Contact (contactLayout)
import Gargantext.Components.Nodes.Corpus (corpusLayout)
import Gargantext.Components.Nodes.Corpus.Dashboard (dashboardLayout)
......@@ -31,13 +30,13 @@ import Gargantext.Components.Nodes.Frame (frameLayout)
import Gargantext.Components.Nodes.Home (homeLayout)
import Gargantext.Components.Nodes.Lists as Lists
import Gargantext.Components.Nodes.Texts as Texts
import Gargantext.Components.SessionLoader (sessionWrapper)
import Gargantext.Components.TopBar as TopBar
import Gargantext.Config (defaultFrontends, defaultBackends)
import Gargantext.Ends (Backend)
import Gargantext.Routes (AppRoute)
import Gargantext.Routes as GR
import Gargantext.Sessions (Session, WithSessionContext)
import Gargantext.Sessions as Sessions
import Gargantext.Sessions (Session, WithSession)
import Gargantext.Types (CorpusId, ListId, NodeID, NodeType(..), SessionId, SidePanelState(..))
import Gargantext.Utils.Reactix as R2
......@@ -46,10 +45,10 @@ here = R2.here "Gargantext.Components.Router"
type Props = ( boxes :: Boxes )
type SessionProps = ( session :: R.Context Session, sessionId :: SessionId | Props )
type SessionProps = ( sessionId :: SessionId | Props )
type SessionNodeProps = ( nodeId :: NodeID | SessionProps )
type Props' = ( route' :: AppRoute, backend :: Backend | Props )
type Props' = ( backend :: Backend, route' :: AppRoute | Props )
router :: R2.Leaf Props
router props = R.createElement routerCpt props []
......@@ -57,23 +56,20 @@ router props = R.createElement routerCpt props []
routerCpt :: R.Component Props
routerCpt = here.component "router" cpt where
cpt props@{ boxes } _ = do
let session = R.createContext (unsafeCoerce {})
pure $ R.fragment
[ loginModal { boxes } []
, topBar { boxes } []
, forest { boxes, session } []
, sidePanel { boxes, session } []
, forest { boxes } []
, sidePanel { boxes } []
]
renderRoute :: R2.Component (WithSessionContext Props)
renderRoute :: R2.Component Props
renderRoute = R.createElement renderRouteCpt
renderRouteCpt :: R.Component (WithSessionContext Props)
renderRouteCpt :: R.Component Props
renderRouteCpt = here.component "renderRoute" cpt where
cpt props@{ boxes, session } _ = do
let sessionProps sId = Record.merge { session, sessionId: sId } props
let sessionNodeProps sId nId = Record.merge { nodeId: nId } $ sessionProps sId
cpt props@{ boxes } _ = do
let sessionNodeProps sId nId = Record.merge { nodeId: nId, sessionId: sId } props
route' <- T.useLive T.unequal boxes.route
......@@ -114,12 +110,24 @@ loginModalCpt = here.component "loginModal" cpt
pure $ if showLogin' then login' boxes else H.div {} []
authed :: Record SessionProps -> R.Element -> R.Element
authed props@{ boxes: { sessions }, session, sessionId } content =
sessionWrapper { fallback: home homeProps []
, context: session
, sessionId
, sessions } [ content, footer {} [] ]
type AuthedProps =
( content :: Session -> R.Element
| SessionProps )
authed :: R2.Component AuthedProps
authed = R.createElement authedCpt
authedCpt :: R.Component AuthedProps
authedCpt = here.component "authed" cpt where
cpt props@{ boxes: { session, sessions }
, content
, sessionId } _ = do
sessions' <- T.useLive T.unequal sessions
let session' = Sessions.lookup sessionId sessions'
case session' of
Nothing -> pure $ home homeProps []
Just s -> pure $ R.fragment [ content s, footer {} [] ]
where
homeProps = RE.pick props :: Record Props
......@@ -139,25 +147,23 @@ topBarCpt = here.component "topBar" cpt where
pure $ TopBar.topBar { handed } children
forest :: R2.Component (WithSessionContext Props)
forest :: R2.Component Props
forest = R.createElement forestCpt
forestCpt :: R.Component (WithSessionContext Props)
forestCpt :: R.Component Props
forestCpt = here.component "forest" cpt where
cpt props@{ boxes: { backend
, forestOpen
, handed
, reloadForest
, reloadMainPage
, reloadRoot
, route
, sessions
, showLogin
, showTree
, tasks }
, session } _ = do
session' <- R.useContext session
cpt props@{ boxes: boxes@{ backend
, forestOpen
, handed
, reloadForest
, reloadMainPage
, reloadRoot
, route
, sessions
, showLogin
, showTree
, tasks }
} _ = do
pure $ Forest.forestLayoutMain { backend
, forestOpen
, frontends: defaultFrontends
......@@ -169,30 +175,34 @@ forestCpt = here.component "forest" cpt where
, sessions
, showLogin
, showTree
, tasks } [ renderRoute (Record.merge { session } props) [] ]
, tasks } [ renderRoute { boxes } [] ]
sidePanel :: R2.Component (WithSessionContext Props)
sidePanel :: R2.Component Props
sidePanel = R.createElement sidePanelCpt
sidePanelCpt :: R.Component (WithSessionContext Props)
sidePanelCpt :: R.Component Props
sidePanelCpt = here.component "sidePanel" cpt where
cpt props@{ boxes: boxes@{ graphVersion
, reloadForest
, session
, sidePanelGraph
, sidePanelState
, sidePanelLists
, sidePanelTexts }
, session } _ = do
, sidePanelTexts } } _ = do
sidePanelState' <- T.useLive T.unequal sidePanelState
session' <- T.useLive T.unequal session
case sidePanelState' of
Opened -> pure $ openedSidePanel props []
_ -> pure $ H.div {} []
case session' of
Nothing -> pure $ H.div {} []
Just s ->
case sidePanelState' of
Opened -> pure $ openedSidePanel (Record.merge { session: s } props) []
_ -> pure $ H.div {} []
openedSidePanel :: R2.Component (WithSessionContext Props)
openedSidePanel :: R2.Component (WithSession Props)
openedSidePanel = R.createElement openedSidePanelCpt
openedSidePanelCpt :: R.Component (WithSessionContext Props)
openedSidePanelCpt :: R.Component (WithSession Props)
openedSidePanelCpt = here.component "openedSidePanel" cpt where
cpt props@{ boxes: boxes@{ graphVersion
, reloadForest
......@@ -200,9 +210,8 @@ openedSidePanelCpt = here.component "openedSidePanel" cpt where
, sidePanelState
, sidePanelLists
, sidePanelTexts }
, session } _ = do
, session} _ = do
route' <- T.useLive T.unequal boxes.route
session' <- R.useContext session
{ mGraph, mMetaData, removedNodeIds, selectedNodeIds, sideTab } <- GEST.focusedSidePanel sidePanelGraph
mGraph' <- T.useLive T.unequal mGraph
......@@ -214,7 +223,7 @@ openedSidePanelCpt = here.component "openedSidePanel" cpt where
case route' of
GR.Lists s n -> do
pure $ wrapper
[ Lists.sidePanel { session: session'
[ Lists.sidePanel { session
, sidePanel: sidePanelLists
, sidePanelState } [] ]
GR.PGraphExplorer s g -> do
......@@ -235,12 +244,12 @@ openedSidePanelCpt = here.component "openedSidePanel" cpt where
, reloadForest
, removedNodeIds
, selectedNodeIds
, session: session'
, session
, sideTab
} [] ]
GR.Texts s n -> do
pure $ wrapper
[ Texts.sidePanel { session: session'
[ Texts.sidePanel { session
, sidePanel: sidePanelTexts
, sidePanelState } [] ]
_ -> pure $ wrapper []
......@@ -250,20 +259,22 @@ annuaire = R.createElement annuaireCpt
annuaireCpt :: R.Component SessionNodeProps
annuaireCpt = here.component "annuaire" cpt where
cpt props@{ boxes, nodeId, session, sessionId } _ = do
cpt props@{ boxes, nodeId, sessionId } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $ annuaireLayout { frontends: defaultFrontends
, nodeId
, session }
pure $ authed (Record.merge { content: \session ->
annuaireLayout { frontends: defaultFrontends
, nodeId
, session } } sessionProps) []
corpus :: R2.Component SessionNodeProps
corpus = R.createElement corpusCpt
corpusCpt :: R.Component SessionNodeProps
corpusCpt = here.component "corpus" cpt where
cpt props@{ boxes, nodeId, session } _ = do
cpt props@{ boxes, nodeId } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $ corpusLayout { nodeId, session }
pure $ authed (Record.merge { content: \session ->
corpusLayout { nodeId, session } } sessionProps) []
type CorpusDocumentProps =
( corpusId :: CorpusId
......@@ -277,10 +288,10 @@ corpusDocument = R.createElement corpusDocumentCpt
corpusDocumentCpt :: R.Component CorpusDocumentProps
corpusDocumentCpt = here.component "corpusDocument" cpt
where
cpt props@{ boxes, corpusId: corpusId', listId, nodeId, session, sessionId } _ = do
cpt props@{ boxes, corpusId: corpusId', listId, nodeId, sessionId } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $
documentMainLayout { mCorpusId: corpusId, listId: listId, nodeId, session } []
pure $ authed (Record.merge { content: \session ->
documentMainLayout { mCorpusId: corpusId, listId: listId, nodeId, session } [] } sessionProps )[]
where corpusId = Just corpusId'
dashboard :: R2.Component SessionNodeProps
......@@ -289,9 +300,10 @@ dashboard = R.createElement dashboardCpt
dashboardCpt :: R.Component SessionNodeProps
dashboardCpt = here.component "dashboard" cpt
where
cpt props@{ boxes, nodeId, session } _ = do
cpt props@{ boxes, nodeId } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $ dashboardLayout { nodeId, session } []
pure $ authed (Record.merge { content: \session ->
dashboardLayout { nodeId, session } [] } sessionProps) []
type DocumentProps = ( listId :: ListId | SessionNodeProps )
......@@ -300,10 +312,10 @@ document = R.createElement documentCpt
documentCpt :: R.Component DocumentProps
documentCpt = here.component "document" cpt where
cpt props@{ boxes, listId, nodeId, session, sessionId } _ = do
cpt props@{ boxes, listId, nodeId, sessionId } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $
documentMainLayout { listId, nodeId, mCorpusId, session } []
pure $ authed (Record.merge { content: \session ->
documentMainLayout { listId, nodeId, mCorpusId, session } [] } sessionProps) []
where mCorpusId = Nothing
graphExplorer :: R2.Component SessionNodeProps
......@@ -319,21 +331,20 @@ graphExplorerCpt = here.component "graphExplorer" cpt where
, sidePanelGraph
, sidePanelState
, tasks }
, nodeId
, session } _ = do
, nodeId } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $
-- simpleLayout { handed }
GraphExplorer.explorerLayoutLoader { backend
, boxes
, frontends: defaultFrontends
, graphId: nodeId
, handed
, route
, session
, sessions
, showLogin
, tasks } []
pure $ authed (Record.merge { content: \session ->
-- simpleLayout { handed }
GraphExplorer.explorerLayout { backend
, boxes
, frontends: defaultFrontends
, graphId: nodeId
, handed
, route
, session
, sessions
, showLogin
, tasks } [] } sessionProps) []
home :: R2.Component Props
home = R.createElement homeCpt
......@@ -361,19 +372,18 @@ listsCpt = here.component "lists" cpt where
, sidePanelLists
, tasks }
, nodeId
, session
, sessionId } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $
Lists.listsWithSessionContext { nodeId
, reloadForest
, reloadMainPage
, reloadRoot
, session
, sessionUpdate: \_ -> pure unit
, sidePanel: sidePanelLists
, sidePanelState
, tasks } []
pure $ authed (Record.merge { content: \session ->
Lists.listsLayout { nodeId
, reloadForest
, reloadMainPage
, reloadRoot
, session
, sessionUpdate: \_ -> pure unit
, sidePanel: sidePanelLists
, sidePanelState
, tasks } [] } sessionProps) []
login' :: Boxes -> R.Element
login' { backend, sessions, showLogin: visible } =
......@@ -387,10 +397,10 @@ routeFile = R.createElement routeFileCpt
routeFileCpt :: R.Component SessionNodeProps
routeFileCpt = here.component "routeFile" cpt where
cpt props@{ boxes, nodeId, session, sessionId } _ = do
cpt props@{ boxes, nodeId, sessionId } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $
fileLayout { nodeId, session }
pure $ authed (Record.merge { content: \session ->
fileLayout { nodeId, session } } sessionProps) []
type RouteFrameProps = (
nodeType :: NodeType
......@@ -402,20 +412,20 @@ routeFrame = R.createElement routeFrameCpt
routeFrameCpt :: R.Component RouteFrameProps
routeFrameCpt = here.component "routeFrame" cpt where
cpt props@{ boxes, nodeId, nodeType, session, sessionId } _ = do
cpt props@{ boxes, nodeId, nodeType, sessionId } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $
frameLayout { nodeId, nodeType, session }
pure $ authed (Record.merge { content: \session ->
frameLayout { nodeId, nodeType, session } } sessionProps) []
team :: R2.Component SessionNodeProps
team = R.createElement teamCpt
teamCpt :: R.Component SessionNodeProps
teamCpt = here.component "team" cpt where
cpt props@{ boxes, nodeId, session, sessionId } _ = do
cpt props@{ boxes, nodeId, sessionId } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $
corpusLayout { nodeId, session }
pure $ authed (Record.merge { content: \session ->
corpusLayout { nodeId, session } } sessionProps) []
texts :: R2.Component SessionNodeProps
texts = R.createElement textsCpt
......@@ -435,15 +445,14 @@ textsCpt = here.component "texts" cpt
, sidePanelTexts
, tasks }
, nodeId
, session
, sessionId } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $
Texts.textsWithSessionContext { frontends: defaultFrontends
, nodeId
, session
, sidePanel: sidePanelTexts
, sidePanelState } []
pure $ authed (Record.merge { content: \session ->
Texts.textsLayout { frontends: defaultFrontends
, nodeId
, session
, sidePanel: sidePanelTexts
, sidePanelState } [] } sessionProps) []
user :: R2.Component SessionNodeProps
user = R.createElement userCpt
......@@ -456,18 +465,17 @@ userCpt = here.component "user" cpt where
, sidePanelTexts
, tasks }
, nodeId
, session
, sessionId } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $
userLayoutSessionContext { frontends: defaultFrontends
, nodeId
, reloadForest
, reloadRoot
, session
, sidePanel: sidePanelTexts
, sidePanelState
, tasks } []
pure $ authed (Record.merge { content: \session ->
userLayout { frontends: defaultFrontends
, nodeId
, reloadForest
, reloadRoot
, session
, sidePanel: sidePanelTexts
, sidePanelState
, tasks } [] } sessionProps) []
type ContactProps = ( annuaireId :: NodeID | SessionNodeProps )
......@@ -483,17 +491,16 @@ contactCpt = here.component "contact" cpt where
, sidePanelState
, tasks }
, nodeId
, session
, sessionId } _ = do
let sessionProps = RE.pick props :: Record SessionProps
let forestedProps = RE.pick props :: Record Props
pure $ authed sessionProps $
contactLayout { annuaireId
, frontends: defaultFrontends
, nodeId
, reloadForest
, reloadRoot
, session
, sidePanel: sidePanelTexts
, sidePanelState
, tasks } []
pure $ authed (Record.merge { content: \session ->
contactLayout { annuaireId
, frontends: defaultFrontends
, nodeId
, reloadForest
, reloadRoot
, session
, sidePanel: sidePanelTexts
, sidePanelState
, tasks } [] } sessionProps) []
......@@ -20,8 +20,8 @@ here = R2.here "Gargantext.Components.SessionWrapper"
type Props =
(
fallback :: R.Element
, context :: R.Context Session
context :: R.Context Session
, fallback :: R.Element
, sessionId :: SessionId
, sessions :: T.Box Sessions
)
......
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