Commit db7e16cc authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[toestand] more refactoring work

parent 7ee27ee6
......@@ -4,6 +4,7 @@ import Data.Set as Set
import Data.Maybe (Maybe(..))
import Toestand as T
import Gargantext.Ends (Backend(..))
import Gargantext.Sessions as Sessions
import Gargantext.Sessions (OpenNodes, Sessions)
import Gargantext.Routes (AppRoute(Home))
......@@ -34,10 +35,11 @@ emptyApp =
}
type Cursors =
{ handed :: T.Cursor Handed
{ backend :: T.Cursor (Maybe Backend)
, handed :: T.Cursor Handed
, forestOpen :: T.Cursor OpenNodes
, reloadRoot :: T.Cursor Int
, reloadForest :: T.Cursor Int
, reloadRoot :: T.Cursor T2.Reload
, reloadForest :: T.Cursor T2.Reload
, route :: T.Cursor AppRoute
, sessions :: T.Cursor Sessions
, showCorpus :: T.Cursor Boolean
......
......@@ -13,12 +13,12 @@ here :: R2.Here
here = R2.here "Gargantext.Components.Footer"
---------------------------------------------------------------------------
type FooterProps s = ( session :: s )
type FooterProps = ( )
footer :: forall cell c. T.Read cell c => Record (FooterProps cell) -> R.Element
footer props = R.createElement footerCpt props []
footer :: R2.Component FooterProps
footer = R.createElement footerCpt
footerCpt :: forall cell c. T.Read cell c => R.Component (FooterProps cell)
footerCpt :: R.Component FooterProps
footerCpt = here.component "footer" cpt where
cpt { session } _ =
cpt { } _ = do
pure $ H.div { className: "container" } [ H.hr {}, H.footer {} [] ]
......@@ -37,12 +37,12 @@ type Common =
( frontends :: Frontends
, handed :: T.Cursor Handed
, reloadRoot :: T.Cursor T2.Reload
, route :: AppRoute
, route :: T.Cursor AppRoute
, tasks :: T.Cursor (Maybe GAT.Reductor)
)
type LayoutProps =
( backend :: T.Cursor Backend
( backend :: T.Cursor (Maybe Backend)
, reloadForest :: T.Cursor T2.Reload
, sessions :: T.Cursor Sessions
, showLogin :: T.Cursor Boolean
......@@ -73,13 +73,13 @@ forestCpt = here.component "forest" cpt where
, sessions
, showLogin
, tasks } _ = do
-- NOTE: this is a hack to reload the forest on demand
tasks' <- GAT.useTasks reloadRoot reloadForest
R.useEffect' $ do
T2.write_ (Just tasks') tasks
handed' <- T.useLive T.unequal handed
reloadForest' <- T.useLive T.unequal reloadForest
reloadRoot' <- T.useLive T.unequal reloadRoot
route' <- T.useLive T.unequal route
forestOpen' <- T.useLive T.unequal forestOpen
sessions' <- T.useLive T.unequal sessions
-- TODO If `reloadForest` is set, `reload` state should be updated
......@@ -88,14 +88,14 @@ forestCpt = here.component "forest" cpt where
-- R.setRef tasks $ Just tasks'
-- GUR.initializeI reloadForest reload
R2.useCache
( frontends /\ route /\ sessions' /\ handed' /\ forestOpen'
( frontends /\ route' /\ sessions' /\ handed' /\ forestOpen'
/\ reloadForest' /\ reloadRoot' /\ (fst tasks').storage )
(cp handed' sessions' tasks')
where
common = RX.pick props :: Record Common
cp handed' sessions' tasks' _ =
pure $ H.div { className: "forest" }
(A.cons (plus handed' showLogin backend) (trees handed' sessions' tasks'))
(A.cons (plus handed' showLogin) (trees handed' sessions' tasks'))
trees handed' sessions' tasks' = (tree handed' tasks') <$> unSessions sessions'
tree handed' tasks' s@(Session {treeId}) =
treeLoader { forestOpen
......@@ -108,8 +108,8 @@ forestCpt = here.component "forest" cpt where
, session: s
, tasks } []
plus :: Handed -> T.Cursor Boolean -> T.Cursor Backend -> R.Element
plus handed showLogin backend = H.div { className: "row" }
plus :: Handed -> T.Cursor Boolean -> R.Element
plus handed showLogin = H.div { className: "row" }
[ H.button { className: buttonClass
, on: { click }
, title }
......@@ -131,18 +131,19 @@ plus handed showLogin backend = H.div { className: "row" }
forestLayout :: R2.Component LayoutProps
forestLayout props = R.createElement forestLayoutCpt props
forestLayout = R.createElement forestLayoutCpt
forestLayoutCpt :: R.Component LayoutProps
forestLayoutCpt = here.component "forestLayout" cpt where
cpt props@{ handed } children =
pure $ R.fragment
[ topBar { handed } [], forestLayoutMain props children ]
[ topBar { handed } []
, forestLayoutMain props children ]
-- Renders its first child component in the top bar and the rest in
-- the main view.
forestLayoutWithTopBar :: R2.Component LayoutProps
forestLayoutWithTopBar props = R.createElement forestLayoutWithTopBarCpt props
forestLayoutWithTopBar = R.createElement forestLayoutWithTopBarCpt
forestLayoutWithTopBarCpt :: R.Component LayoutProps
forestLayoutWithTopBarCpt = here.component "forestLayoutWithTopBar" cpt where
......@@ -154,14 +155,14 @@ forestLayoutWithTopBarCpt = here.component "forestLayoutWithTopBar" cpt where
, forestLayoutMain props mainChildren ]
forestLayoutMain :: R2.Component LayoutProps
forestLayoutMain props = R.createElement forestLayoutMainCpt props
forestLayoutMain = R.createElement forestLayoutMainCpt
forestLayoutMainCpt :: R.Component LayoutProps
forestLayoutMainCpt = here.component "forestLayoutMain" cpt where
cpt props children = pure $ forestLayoutRaw props [ mainPage {} children ]
forestLayoutRaw :: R2.Component LayoutProps
forestLayoutRaw props = R.createElement forestLayoutRawCpt props
forestLayoutRaw = R.createElement forestLayoutRawCpt
forestLayoutRawCpt :: R.Component LayoutProps
forestLayoutRawCpt = here.component "forestLayoutRaw" cpt where
......
......@@ -55,12 +55,15 @@ type Universal =
type Global =
( frontends :: Frontends
, handed :: Handed
, route :: AppRoute
, route :: T.Cursor AppRoute
| Universal )
-- Shared by every component here
type Common =
( forestOpen :: T.Cursor OpenNodes, reload :: T.Cursor T2.Reload | Global )
type Common = (
forestOpen :: T.Cursor OpenNodes
, reload :: T.Cursor T2.Reload
| Global
)
type LoaderProps = ( session :: Session, root :: ID | Common )
......
......@@ -54,7 +54,7 @@ type NodeMainSpanProps =
, name :: Name
, nodeType :: GT.NodeType
, reloadRoot :: T.Cursor T2.Reload
, route :: Routes.AppRoute
, route :: T.Cursor Routes.AppRoute
, setPopoverRef :: R.Ref (Maybe (Boolean -> Effect Unit))
, tasks :: T.Cursor (Maybe GAT.Reductor)
| CommonProps
......@@ -91,13 +91,14 @@ nodeMainSpanCpt = here.component "nodeMainSpan" cpt
, setPopoverRef
, tasks
} _ = do
route' <- T.useLive T.unequal route
-- only 1 popup at a time is allowed to be opened
droppedFile <- R.useState' (Nothing :: Maybe DroppedFile)
isDragOver <- R.useState' false
popoverRef <- R.useRef null
R.useEffect' $ do
R.setRef setPopoverRef $ Just $ Popover.setOpen popoverRef
let isSelected = Just route == Routes.nodeTypeAppRoute nodeType (sessionId session) id
let isSelected = Just route' == Routes.nodeTypeAppRoute nodeType (sessionId session) id
tasks' <- T.read tasks
......
......@@ -45,11 +45,11 @@ here :: R2.Here
here = R2.here "Gargantext.Components.GraphExplorer"
type LayoutProps = (
backend :: T.Cursor Backend
backend :: T.Cursor (Maybe Backend)
, frontends :: Frontends
, graphId :: GET.GraphId
, handed :: T.Cursor Types.Handed
, route :: AppRoute
, route :: T.Cursor AppRoute
, session :: Session
, sessions :: T.Cursor Sessions
, showLogin :: T.Cursor Boolean
......@@ -95,9 +95,7 @@ explorer props = R.createElement explorerCpt props []
explorerCpt :: R.Component Props
explorerCpt = here.component "explorer" cpt
where
cpt props@{ tasks
, backend
, route
cpt props@{ backend
, frontends
, graph
, graphId
......@@ -105,9 +103,11 @@ explorerCpt = here.component "explorer" cpt
, handed
, hyperdataGraph
, mMetaData
, route
, session
, sessions
, showLogin
, tasks
} _ = do
handed' <- T.useLive T.unequal handed
......@@ -120,6 +120,7 @@ explorerCpt = here.component "explorer" cpt
dataRef <- R.useRef graph
graphRef <- R.useRef null
graphVersionRef <- R.useRef (GUR.value graphVersion)
-- reloadForest <- T2.useCursed $ T2.Ready 0
reloadForest <- T2.useCursed 0
-- reloadForest <- GUR.newIInitialized reloadForest
controls <- Controls.useGraphControls { forceAtlasS
......@@ -250,13 +251,13 @@ explorerCpt = here.component "explorer" cpt
Sidebar.sidebar (Record.merge props { metaData })
type TreeProps = (
backend :: T.Cursor Backend
, forestOpen :: T.Cursor OpenNodes
backend :: T.Cursor (Maybe Backend)
, forestOpen :: T.Cursor OpenNodes
, frontends :: Frontends
, handed :: T.Cursor Types.Handed
, reload :: T.Cursor T2.Reload
, reloadForest :: T.Cursor T2.Reload
, route :: AppRoute
, route :: T.Cursor AppRoute
, sessions :: T.Cursor Sessions
, show :: Boolean
, showLogin :: T.Cursor Boolean
......
......@@ -31,9 +31,9 @@ here = R2.here "Gargantext.Components.Login"
-- and ask for login (modal) or account creation after 15 mn when user
-- if not logged user can not save his work
type Props =
( backends :: Array Backend
, backend :: T.Cursor (Maybe Backend)
type Props = (
backend :: T.Cursor (Maybe Backend)
, backends :: Array Backend
, sessions :: T.Cursor Sessions
, visible :: T.Cursor Boolean
)
......@@ -43,11 +43,11 @@ login props = R.createElement loginCpt props []
loginCpt :: R.Component Props
loginCpt = here.component "login" cpt where
cpt props@{ visible, sessions } _ = do
b <- T.useLive T.unequal props.backend
cpt props@{ backend, sessions, visible } _ = do
b <- T.useLive T.unequal backend
pure $ modal { visible } (inner b) where
inner Nothing = chooser props
inner (Just b) = form { sessions, visible, backend: b }
inner (Just b) = form { backend: b, sessions, visible }
chooser :: R2.Leaf Props
chooser props = R.createElement chooserCpt props []
......
......@@ -258,7 +258,7 @@ tableContainerCpt { dispatch
type CommonProps = (
afterSync :: Unit -> Aff Unit
, reloadForest :: T.Cursor (T2.InitReload T.Cursor)
, reloadForest :: T.Cursor T2.Reload
, reloadRoot :: T.Cursor T2.Reload
, sidePanelTriggers :: Record NT.SidePanelTriggers
, tabNgramType :: CTabNgramType
......
......@@ -140,6 +140,7 @@ import Gargantext.Sessions (Session, get, post, put)
import Gargantext.Types (AsyncTaskType(..), AsyncTaskWithType(..), CTabNgramType(..), ListId, OrderBy(..), ScoreType(..), TabSubType(..), TabType(..), TermList(..), TermSize(..))
import Gargantext.Utils.KarpRabin (indicesOfAny)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reload as GUR
import Gargantext.Utils.Toestand as T2
here :: R2.Here
......@@ -1179,7 +1180,7 @@ chartsAfterSync :: forall props discard.
}
-> T.Cursor (Maybe GAT.Reductor)
-> Int
-> T.Cursor (T2.InitReload T.Cursor)
-> T.Cursor T2.Reload
-> discard
-> Aff Unit
chartsAfterSync path' tasks nodeId reloadForest _ = do
......@@ -1189,7 +1190,9 @@ chartsAfterSync path' tasks nodeId reloadForest _ = do
mT <- T.read tasks
case mT of
Nothing -> log "[chartsAfterSync] tasks is Nothing"
Just tasks' -> snd tasks' (GAT.Insert nodeId task) *> T2.reload reloadForest
Just tasks' -> do
snd tasks' (GAT.Insert nodeId task) -- *> T2.reload reloadForest
GUR.bumpCursor reloadForest
postNgramsChartsAsync :: forall s. CoreParams s -> Aff AsyncTaskWithType
postNgramsChartsAsync { listIds, nodeId, session, tabType } = do
......
......@@ -55,7 +55,7 @@ type TabsProps =
, contactData :: ContactData
, frontends :: Frontends
, nodeId :: Int
, reloadForest :: T.Cursor (T2.InitReload T.Cursor)
, reloadForest :: T.Cursor T2.Reload
, reloadRoot :: T.Cursor T2.Reload
, session :: Session
, sidePanelTriggers :: Record LTypes.SidePanelTriggers
......@@ -130,7 +130,7 @@ type NTCommon =
( cacheState :: R.State LTypes.CacheState
, defaultListId :: Int
, nodeId :: Int
, reloadForest :: T.Cursor (T2.InitReload T.Cursor)
, reloadForest :: T.Cursor T2.Reload
, reloadRoot :: T.Cursor T2.Reload
, session :: Session
, sidePanelTriggers :: Record LTypes.SidePanelTriggers
......
......@@ -154,7 +154,7 @@ listElement = H.li { className: "list-group-item justify-content-between" }
type LayoutProps =
( frontends :: Frontends
, nodeId :: Int
, reloadForest :: T.Cursor (T2.InitReload T.Cursor)
, reloadForest :: T.Cursor T2.Reload
, reloadRoot :: T.Cursor T2.Reload
, session :: Session
, tasks :: T.Cursor (Maybe GAT.Reductor)
......
......@@ -4,7 +4,7 @@ module Gargantext.Components.Nodes.Annuaire.User.Contact
) where
import Gargantext.Prelude
( Unit, bind, const, discard, pure, show, ($), (<$>), (*>), (<<<), (<>) )
( Unit, bind, const, discard, pure, show, void, ($), (<$>), (*>), (<<<), (<>) )
import Data.Lens as L
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Tuple.Nested ((/\))
......@@ -26,6 +26,7 @@ import Gargantext.Routes as Routes
import Gargantext.Sessions (Session, get, put, sessionId)
import Gargantext.Types (NodeType(..))
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reload as GUR
import Gargantext.Utils.Toestand as T2
here :: R2.Here
......@@ -134,12 +135,12 @@ type BasicProps =
)
type ReloadProps =
( reloadForest :: T.Cursor (T2.InitReload T.Cursor)
( reloadForest :: T.Cursor T2.Reload
, reloadRoot :: T.Cursor T2.Reload
| BasicProps
)
type LayoutProps = ( session :: T.Cursor (Maybe Session) | ReloadProps )
type LayoutProps = ( session :: Session | ReloadProps )
type KeyLayoutProps = ( key :: String, session :: Session | ReloadProps )
......@@ -150,12 +151,12 @@ type AnnuaireLayoutProps = ( annuaireId :: Int, session :: Session | ReloadProps
type AnnuaireKeyLayoutProps = ( annuaireId :: Int | KeyLayoutProps )
contactLayout :: R2.Leaf AnnuaireLayoutProps
contactLayout props = R.createElement contactLayoutCpt props []
contactLayout :: R2.Component AnnuaireLayoutProps
contactLayout = R.createElement contactLayoutCpt
contactLayoutCpt :: R.Component AnnuaireLayoutProps
contactLayoutCpt = here.component "contactLayout" cpt where
cpt { annuaireId, reloadRoot, tasks, frontends, nodeId, session, reloadForest } _ =
cpt { annuaireId, frontends, nodeId, reloadForest, reloadRoot, session, tasks } _ = do
pure $
contactLayoutWithKey
{ annuaireId, tasks, frontends, key, nodeId
......@@ -167,8 +168,13 @@ contactLayoutWithKey props = R.createElement contactLayoutWithKeyCpt props []
contactLayoutWithKeyCpt :: R.Component AnnuaireKeyLayoutProps
contactLayoutWithKeyCpt = here.component "contactLayoutWithKey" cpt where
cpt { annuaireId, reloadRoot, tasks, frontends
, nodeId, session, reloadForest } _ = do
cpt { annuaireId
, frontends
, reloadForest
, reloadRoot
, nodeId
, session
, tasks } _ = do
reload <- T.useCell T2.newReload
_ <- T.useLive T.unequal reload
cacheState <- R.useState' LT.CacheOn
......
......@@ -53,7 +53,7 @@ type TabsProps = (
, contactData :: ContactData'
, frontends :: Frontends
, nodeId :: Int
, reloadForest :: T.Cursor (T2.InitReload T.Cursor)
, reloadForest :: T.Cursor T2.Reload
, reloadRoot :: T.Cursor T2.Reload
, session :: Session
, sidePanelTriggers :: Record LTypes.SidePanelTriggers
......@@ -135,7 +135,7 @@ type NgramsViewTabsProps = (
, defaultListId :: Int
, mode :: Mode
, nodeId :: Int
, reloadForest :: T.Cursor (T2.InitReload T.Cursor)
, reloadForest :: T.Cursor T2.Reload
, reloadRoot :: T.Cursor T2.Reload
, session :: Session
, sidePanelTriggers :: Record LTypes.SidePanelTriggers
......
......@@ -76,7 +76,7 @@ topBarCpt = here.component "topBar" cpt
type CommonProps = (
nodeId :: Int
, reloadForest :: T.Cursor (T2.InitReload T.Cursor)
, reloadForest :: T.Cursor T2.Reload
, reloadRoot :: T.Cursor T2.Reload
, session :: Session
, sessionUpdate :: Session -> Effect Unit
......
......@@ -37,7 +37,7 @@ type Props = (
cacheState :: R.State CacheState
, corpusData :: CorpusData
, corpusId :: Int
, reloadForest :: T.Cursor (T2.InitReload T.Cursor)
, reloadForest :: T.Cursor T2.Reload
, reloadRoot :: T.Cursor T2.Reload
, session :: Session
, sidePanelTriggers :: Record SidePanelTriggers
......
......@@ -2,7 +2,10 @@ module Gargantext.Components.Router (router) where
import Data.Array (fromFoldable)
import Data.Maybe (Maybe(..), maybe')
import Prim.Row (class Cons, class Lacks)
import Reactix as R
import Record as Record
import Record.Extra as RE
import Toestand as T
import Unsafe.Coerce (unsafeCoerce)
......@@ -31,6 +34,7 @@ import Gargantext.Components.SimpleLayout (simpleLayout)
import Gargantext.Config (defaultFrontends, defaultBackends, publicBackend)
import Gargantext.Routes (AppRoute(..))
import Gargantext.Routes as GR
import Gargantext.Sessions (Session)
import Gargantext.Types (CorpusId, ListId, NodeID, NodeType(..), SessionId(..))
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
......@@ -43,151 +47,313 @@ type Props = (
, tasks :: T.Cursor (Maybe GAT.Reductor)
)
type SessionProps = (
session :: Session
, sessionId :: SessionId
| Props
)
type SessionNodeProps = (
nodeId :: NodeID
| SessionProps
)
router :: R2.Leaf Props
router props = R.createElement routerCpt props []
routerCpt :: R.Component Props
routerCpt = here.component "root" cpt where
cpt props@{ cursors, ws, tasks } _ = do
cpt props@{ cursors, tasks, ws } _ = do
let session = R.createContext (unsafeCoerce {})
let sessionProps sId = Record.merge { session, sessionId: sId } props
let sessionNodeProps sId nId = Record.merge { nodeId: nId } $ sessionProps sId
showLogin <- T.useLive T.unequal cursors.showLogin
route <- T.useLive (T.changed notEq) cursors.route
if showLogin then login' cursors
else case route of
GR.Annuaire s n -> annuaire props s n
GR.Corpus s n -> corpus props s n
GR.CorpusDocument s c l n -> corpusDocument props s c l n
GR.Dashboard s n -> dashboard props s n
GR.Annuaire s n -> annuaire (sessionNodeProps s n) []
GR.ContactPage s a n -> contact (Record.merge { annuaireId: a } $ sessionNodeProps s n)
GR.Corpus s n -> corpus (sessionNodeProps s n)
GR.CorpusDocument s c l n -> corpusDocument (Record.merge { corpusId: c, listId: l } $ sessionNodeProps s n)
GR.Dashboard s n -> dashboard (sessionNodeProps s n)
GR.Document s l n -> document props s l n
GR.Folder s n -> corpus props s n
GR.FolderPrivate s n -> corpus props s n
GR.FolderPublic s n -> corpus props s n
GR.FolderShared s n -> corpus props s n
GR.Folder s n -> corpus (sessionNodeProps s n)
GR.FolderPrivate s n -> corpus (sessionNodeProps s n)
GR.FolderPublic s n -> corpus (sessionNodeProps s n)
GR.FolderShared s n -> corpus (sessionNodeProps s n)
GR.Home -> home props
GR.Lists s n -> lists props s n
GR.Lists s n -> lists (sessionNodeProps s n)
GR.Login -> login' cursors
GR.PGraphExplorer s g -> graphExplorer props s g
GR.RouteFile s n -> routeFile props s n
GR.PGraphExplorer s g -> graphExplorer (sessionNodeProps s g)
GR.RouteFile s n -> routeFile (sessionNodeProps s n)
GR.RouteFrameCalc s n -> routeFrame props s n NodeFrameCalc
GR.RouteFrameCode s n -> routeFrame props s n NodeFrameNotebook
GR.RouteFrameWrite s n -> routeFrame props s n NodeFrameWrite
GR.Team s n -> team props s n
GR.Texts s n -> texts props s n
GR.UserPage s n -> user props s n
GR.ContactPage s a n -> contact props s a n
forested :: Record Props -> Array R.Element -> R.Element
forested { tasks, cursors: { route, handed, sessions, backend, reloadForest, reloadRoot, showLogin } } =
forestLayout
{ tasks, frontends, route, handed, sessions
, backend, reloadForest, reloadRoot, showLogin
} where frontends = defaultFrontends
authed :: Record Props -> SessionId -> R.Element -> R.Element
authed props@{ cursors: { session, sessions } , tasks } sessionId content =
sessionWrapper { sessionId, session, sessions, fallback: home props }
[ content, footer { session } ]
annuaire :: Record Props -> SessionId -> NodeID -> R.Element
annuaire props@{ tasks, cursors: { session } } sessionId nodeId =
authed props sessionId $
forested props [ annuaireLayout { nodeId, frontends, session } ]
where frontends = defaultFrontends
corpus :: Record Props -> SessionId -> NodeID -> R.Element
corpus props@{ tasks, cursors: session } sessionId nodeId =
authed props sessionId $
forested props
[ corpusLayout { nodeId, session } ]
corpusDocument :: Record Props -> SessionId -> CorpusId -> ListId -> NodeID -> R.Element
corpusDocument props@{ tasks, cursors: session } sessionId corpusId' listId nodeId =
authed props sessionId $
forested props
[ documentMainLayout { listId, nodeId, corpusId, sessionId, session } [] ]
where corpusId = Just corpusId'
dashboard :: Record Props -> SessionId -> NodeID -> R.Element
dashboard props@{ tasks, cursors: { session } } sessionId nodeId =
authed props sessionId $
forested props [ dashboardLayout { nodeId, session } [] ]
document :: Record Props -> SessionId -> ListId -> NodeID -> R.Element
document props@{ tasks, cursors: { session } } sessionId listId nodeId =
authed props sessionId $
forested props
[ documentMainLayout { listId, nodeId, corpusId, session } [] ]
where corpusId = Nothing
home :: Record Props -> R.Element
home props@{ cursors: { backend, showLogin, sessions } } =
forested props [ homeLayout { sessions, backend, showLogin, lang: LL_EN } ]
lists :: Record Props -> SessionId -> NodeID -> R.Element
lists props@{ cursors: { backend, route, handed, sessions
, reloadForest, reloadRoot, session, showLogin }
, tasks } sessionId nodeId =
authed props sessionId $
Lists.listsWithForest
{ forestProps: { backend
, frontends
, handed
, reloadForest
, reloadRoot
, route
, sessions
, showLogin
, tasks }
, listsProps: { tasks, reloadRoot, reloadForest, nodeId, session }
} []
where frontends = defaultFrontends
GR.Team s n -> team (sessionNodeProps s n)
GR.Texts s n -> texts (sessionNodeProps s n)
GR.UserPage s n -> user (sessionNodeProps s n)
forested :: R2.Component Props
forested = R.createElement forestedCpt
forestedCpt :: R.Component Props
forestedCpt = here.component "forested" cpt
where
cpt { cursors: { backend, handed, reloadForest, reloadRoot, route, sessions, showLogin }, tasks } children = do
pure $ forestLayout { backend
, frontends: defaultFrontends
, handed
, reloadForest
, reloadRoot
, route
, sessions
, showLogin
, tasks } children
authed :: Record SessionProps -> R.Element -> R.Element
authed props@{ cursors: { sessions }, session, sessionId, tasks } content =
sessionWrapper { fallback: home homeProps [], provider: session, sessionId, sessions }
[ content, footer { } [] ]
where
homeProps = RE.pick props :: Record Props
annuaire :: R2.Component SessionNodeProps
annuaire = R.createElement annuaireCpt
annuaireCpt :: R.Component SessionNodeProps
annuaireCpt = here.component "annuaire" cpt
where
cpt props@{ nodeId, session, sessionId, tasks } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $
forested props [ annuaireLayout { frontends, nodeId, session } ]
where frontends = defaultFrontends
corpus :: R2.Component SessionNodeProps
corpus = R.createElement corpusCpt
corpusCpt :: R.Component SessionNodeProps
corpusCpt = here.component "corpus" cpt
where
cpt props@{ cursors: session, nodeId, session, tasks } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $
forested props
[ corpusLayout { nodeId, session } ]
type CorpusDocumentProps = (
corpusId :: CorpusId
, listID :: ListId
| SessionNodeProps
)
corpusDocument :: R2.Component CorpusDocumentProps
corpusDocument = R.createElement corpusDocumentCpt
corpusDocumentCpt :: R.Component CorpusDocumentProps
corpusDocumentCpt = here.component "corpusDocument" cpt
where
cpt props@{ corpusId: corpusId', listId, nodeId, session, sessionId, tasks } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $
forested props
[ documentMainLayout { corpusId', listId, nodeId, session, sessionId } [] ]
where corpusId = Just corpusId'
dashboard :: R2.Component SessionNodeProps
dashboard = R.createElement dashboardCpt
dashboardCpt :: R.Component SessionNodeProps
dashboardCpt = here.component "dashboard" cpt
where
cpt props@{ cursors: session, nodeId, session, tasks } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $
forested props [ dashboardLayout { nodeId, session } [] ]
type DocumentProps = (
listId :: ListId
| SessionNodeProps
)
document :: R2.Component DocumentProps
document = R.createElement documentCpt
documentCpt :: R.Component DocumentProps
documentCpt = here.component "document" cpt
where
cpt props@{ listId, nodeId, session, sessionId, tasks } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $
forested props
[ documentMainLayout { listId, nodeId, corpusId, session } [] ]
where corpusId = Nothing
home :: R2.Component Props
home = R.createElement homeCpt
homeCpt :: R.Component Props
homeCpt = here.component "home" cpt
where
cpt props@{ cursors: { sessions, showLogin } } _ = do
pure $ forested props [ homeLayout { lang: LL_EN, sessions, showLogin } ]
lists :: R2.Component SessionNodeProps
lists = R.createElement listsCpt
listsCpt :: R.Component SessionNodeProps
listsCpt = here.component "lists" cpt
where
cpt props@{ cursors: { backend
, handed
, reloadForest
, reloadRoot
, route
, sessions
, showLogin }
, nodeId
, session
, sessionId
, tasks } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $
Lists.listsWithForest
{ forestProps: { backend
, frontends
, handed
, reloadForest
, reloadRoot
, route
, sessions
, showLogin
, tasks }
, listsProps: { nodeId, reloadRoot, reloadForest, session, tasks }
} []
where frontends = defaultFrontends
login' :: Cursors -> R.Element
login' { backend, sessions, showLogin: visible } =
login { backend, sessions, visible
, backends: fromFoldable defaultBackends }
graphExplorer :: Record Props -> SessionId -> Int -> R.Element
graphExplorer props@{ views: { backend, route, handed, session, sessions, showLogin }
, tasks } sessionId graphId =
authed props sessionId $
simpleLayout { handed }
[ explorerLayout { tasks, graphId, backend, route, frontends
, handed, session, sessions, showLogin } ]
where frontends = defaultFrontends
routeFile :: Record Props -> SessionId -> NodeID -> R.Element
routeFile props@{ cursors: { session } } sessionId nodeId =
authed props sessionId $ forested props [ fileLayout { nodeId, session } ]
routeFrame :: Record Props -> SessionId -> NodeID -> NodeType -> R.Element
routeFrame props@{ cursors: { session } } sessionId nodeId nodeType =
authed props sessionId $ forested props [ frameLayout { nodeId, nodeType, session } ]
team :: Record Props -> SessionId -> NodeID -> R.Element
team props@{ tasks, cursors: { session } } sessionId nodeId =
authed props sessionId $ forested props [ corpusLayout { nodeId, session } ]
texts :: Record Props -> SessionId -> NodeID -> R.Element
texts props@{ cursors: { backend, reloadForest, reloadRoot, showLogin, route, handed, session, sessions }
, tasks } sessionId nodeId =
authed props sessionId $
Texts.textsWithForest
{ forestProps: { frontends, tasks, route, handed, sessions
, backend, reloadForest, reloadRoot, showLogin }
, textsProps: { frontends, nodeId, session } }
[] where frontends = defaultFrontends
user :: Record Props -> SessionId -> NodeID -> R.Element
user props@{ cursors: { reloadRoot, session }, tasks } sessionId nodeId =
authed props sessionId $
forested props
[ userLayout { tasks, nodeId, session, reloadRoot, frontends } ]
where frontends = defaultFrontends
contact :: Record Props -> SessionId -> NodeID -> R.Element
contact props@{ tasks, cursors: { reloadRoot } } sessionId annuaireId nodeId =
authed props sessionId $
forested props
[ contactLayout { annuaireId, tasks, nodeId, reloadRoot, frontends } ]
where frontends = defaultFrontends
graphExplorer :: R2.Component SessionNodeProps
graphExplorer = R.createElement graphExplorerCpt
graphExplorerCpt :: R.Component SessionNodeProps
graphExplorerCpt = here.component "graphExplorer" cpt
where
cpt props@{ cursors: { backend
, handed
, route
, sessions
, showLogin }
, nodeId
, session
, tasks } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $
simpleLayout { handed }
[ explorerLayout { backend
, graphId: nodeId
, frontends
, handed
, route
, session
, sessions
, showLogin
, tasks } ]
where frontends = defaultFrontends
routeFile :: R2.Component SessionNodeProps
routeFile = R.createElement routeFileCpt
routeFileCpt :: R.Component SessionNodeProps
routeFileCpt = here.component "routeFile" cpt
where
cpt props@{ nodeId, session, sessionId } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $ forested props [ fileLayout { nodeId, session } ]
type RouteFrameProps = (
nodeType :: NodeType
| SessionNodeProps
)
routeFrame :: R2.Component RouteFrameProps
routeFrame = R.createElement routeFrameCpt
routeFrameCpt :: R.Component RouteFrameProps
routeFrameCpt = here.component "routeFrame" cpt
where
cpt props@{ nodeId, nodeType, session, sessionId } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $ forested props [ frameLayout { nodeId, nodeType, session } ]
team :: R2.Component SessionNodeProps
team = R.createElement teamCpt
teamCpt :: R.Component SessionNodeProps
teamCpt = here.component "team" cpt
where
cpt props@{ nodeId, session, sessionId } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $ forested props [ corpusLayout { nodeId, session } ]
texts :: R2.Component SessionNodeProps
texts = R.createElement textsCpt
textsCpt :: R.Component SessionNodeProps
textsCpt = here.component "texts" cpt
where
cpt props@{ cursors: { backend
, handed
, reloadForest
, reloadRoot
, route
, sessions
, showLogin }
, nodeId
, session
, sessionId
, tasks } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $
Texts.textsWithForest
{ forestProps: { backend
, frontends
, handed
, route
, reloadForest
, reloadRoot
, sessions
, showLogin
, tasks }
, textsProps: { frontends, nodeId, session } }
[] where frontends = defaultFrontends
user :: R2.Component SessionNodeProps
user = R.createElement userCpt
userCpt :: R.Component SessionNodeProps
userCpt = here.component "user" cpt
where
cpt props@{ cursors: { reloadRoot }
, nodeId
, session
, sessionId
, tasks } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $
forested props
[ userLayout { frontends, nodeId, reloadRoot, session, tasks } ]
where frontends = defaultFrontends
type ContactProps = (
annuaireId :: NodeID
| SessionNodeProps
)
contact :: R2.Component ContactProps
contact = R.createElement contactCpt
contactCpt :: R.Component ContactProps
contactCpt = here.component "contact" cpt
where
cpt props@{ annuaireId
, cursors: { reloadForest, reloadRoot }
, nodeId
, session
, sessionId
, tasks } _ = do
let sessionProps = RE.pick props :: Record SessionProps
let forestedProps = RE.pick props :: Record Props
pure $ authed sessionProps $
forested forestedProps
[ contactLayout { annuaireId, frontends, nodeId, reloadForest, reloadRoot, session, tasks } [] ]
where frontends = defaultFrontends
-- | A component that loads the session specified in the route and provides it to its child.
-- |
-- | If the session cannot be loaded, displays the homepage.
module Gargantext.Components.SessionLoader where
module Gargantext.Components.SessionLoader
where
import Prelude (($), (<$>))
import Data.Maybe (Maybe(..))
......@@ -16,17 +17,19 @@ here :: R2.Here
here = R2.here "Gargantext.Components.SessionWrapper"
type Props sessions =
( sessionId :: SessionId
, sessions :: sessions
(
fallback :: R.Element
, provider :: R.Provider Session
, fallback :: R.Element )
, sessionId :: SessionId
, sessions :: sessions
)
sessionWrapper :: forall s. T.Read s Sessions => R2.Component (Props s)
sessionWrapper = R.createElement sessionWrapperCpt
sessionWrapperCpt :: forall s. T.Read s Sessions => R.Component (Props s)
sessionWrapperCpt = here.component "sessionWrapper" cpt where
cpt { sessionId, sessions, provider, fallback } content =
cpt { fallback, provider, sessionId, sessions } content =
cp <$> T.useLive T.unequal sessions where
cp sessions' = c $ Sessions.lookup sessionId sessions' where
c (Just session) = (R.provide provider session content)
......
......@@ -23,6 +23,9 @@ bump (_ /\ setReload) = setReload (_ + 1)
bumpCursor :: T.Cursor Reload -> Effect Unit
bumpCursor c = T2.modify_ (_ + 1) c
bumpCell :: T.Cell Reload -> Effect Unit
bumpCell c = T2.modify_ (_ + 1) c
value :: ReloadS -> Reload
value (val /\ _) = val
......
......@@ -5,7 +5,7 @@ module Gargantext.Utils.Toestand
, write_, modify_
) where
import Prelude (class Ord, Unit, bind, identity, pure, unit, void, ($), (+), (>>=))
import Prelude (class Eq, class Ord, Unit, bind, identity, pure, unit, void, ($), (+), (>>=))
import Data.Set as Set
import Data.Set (Set)
import Effect (Effect)
......
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