Commit 6d0d0db7 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[toestand] more refactoring fixes

parent 48f83762
module Gargantext.Components.App (app) where module Gargantext.Components.App (app) where
import Data.Maybe (Maybe(..))
import Prelude import Prelude
import Reactix as R
import Toestand as T
import Gargantext.Components.App.Data (emptyApp) import Gargantext.Components.App.Data (emptyApp)
import Gargantext.Components.Router (router) import Gargantext.Components.Router (router)
import Gargantext.Hooks (useHashRouter) import Gargantext.Hooks (useHashRouter)
import Gargantext.Router as Router import Gargantext.Router as Router
import Gargantext.Sessions as Sessions import Gargantext.Sessions as Sessions
import Reactix as R import Gargantext.Utils.Reactix as R2
import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.App" here = R2.here "Gargantext.Components.App"
......
...@@ -45,33 +45,36 @@ import Gargantext.Utils.Toestand as T2 ...@@ -45,33 +45,36 @@ import Gargantext.Utils.Toestand as T2
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.GraphExplorer" here = R2.here "Gargantext.Components.GraphExplorer"
type BaseProps = type BaseProps = (
( backend :: T.Cursor (Maybe Backend) backend :: T.Cursor (Maybe Backend)
, frontends :: Frontends , frontends :: Frontends
, graphId :: GET.GraphId , graphId :: GET.GraphId
, handed :: T.Cursor Types.Handed , handed :: T.Cursor Types.Handed
, route :: T.Cursor AppRoute , route :: T.Cursor AppRoute
, sessions :: T.Cursor Sessions , sessions :: T.Cursor Sessions
, showLogin :: T.Cursor Boolean , showLogin :: T.Cursor Boolean
, tasks :: T.Cursor (Maybe GAT.Reductor) ) , tasks :: T.Cursor (Maybe GAT.Reductor)
)
type LayoutLoaderProps = ( session :: R.Context Session | BaseProps ) type LayoutLoaderProps = ( session :: R.Context Session | BaseProps )
type LayoutProps = ( session :: Session, graphVersion :: GUR.ReloadS | BaseProps ) type LayoutProps = (
graphVersion :: GUR.ReloadS
, session :: Session
| BaseProps
)
type Props = type Props = (
( graph :: SigmaxT.SGraph graph :: SigmaxT.SGraph
, graphVersion :: GUR.ReloadS
, hyperdataGraph :: GET.HyperdataGraph , hyperdataGraph :: GET.HyperdataGraph
, mMetaData :: Maybe GET.MetaData , mMetaData :: Maybe GET.MetaData
, session :: Session
| LayoutProps | LayoutProps
) )
-------------------------------------------------------------- --------------------------------------------------------------
explorerLayoutLoader :: R2.Component LayoutLoaderProps explorerLayoutLoader :: R2.Component LayoutLoaderProps
explorerLayoutLoader props = R.createElement explorerLayoutLoaderCpt props [] explorerLayoutLoader = R.createElement explorerLayoutLoaderCpt
explorerLayoutLoaderCpt :: R.Component LayoutLoaderProps explorerLayoutLoaderCpt :: R.Component LayoutLoaderProps
explorerLayoutLoaderCpt = here.component "explorerLayoutLoader" cpt where explorerLayoutLoaderCpt = here.component "explorerLayoutLoader" cpt where
...@@ -80,25 +83,28 @@ explorerLayoutLoaderCpt = here.component "explorerLayoutLoader" cpt where ...@@ -80,25 +83,28 @@ explorerLayoutLoaderCpt = here.component "explorerLayoutLoader" cpt where
session <- R.useContext props.session -- todo: ugh, props fiddling session <- R.useContext props.session -- todo: ugh, props fiddling
let base = RX.pick props :: Record BaseProps let base = RX.pick props :: Record BaseProps
let props' = Record.merge base { graphVersion, session } let props' = Record.merge base { graphVersion, session }
pure $ explorerLayout props' pure $ explorerLayout props' []
explorerLayout :: R2.Component LayoutProps explorerLayout :: R2.Component LayoutProps
explorerLayout props = R.createElement explorerLayoutCpt props [] explorerLayout = R.createElement explorerLayoutCpt
explorerLayoutCpt :: R.Component LayoutProps explorerLayoutCpt :: R.Component LayoutProps
explorerLayoutCpt = here.component "explorerLayout" cpt where explorerLayoutCpt = here.component "explorerLayout" cpt where
cpt props@{ graphId, session, graphVersion } _ = do cpt props@{ backend
, graphId
, graphVersion
, session } _ = do
useLoader graphId (getNodes session graphVersion) handler useLoader graphId (getNodes session graphVersion) handler
where where
handler loaded = handler loaded = explorer (Record.merge props { graph, hyperdataGraph: loaded, mMetaData }) []
explorer (Record.merge props { graph, graphVersion, hyperdataGraph: loaded, mMetaData }) -- explorer (Record.merge props { graph, graphVersion, hyperdataGraph: loaded, mMetaData })
where where
GET.HyperdataGraph { graph: hyperdataGraph } = loaded GET.HyperdataGraph { graph: hyperdataGraph } = loaded
Tuple mMetaData graph = convert hyperdataGraph Tuple mMetaData graph = convert hyperdataGraph
-------------------------------------------------------------- --------------------------------------------------------------
explorer :: Record Props -> R.Element explorer :: R2.Component Props
explorer props = R.createElement explorerCpt props [] explorer = R.createElement explorerCpt
explorerCpt :: R.Component Props explorerCpt :: R.Component Props
explorerCpt = here.component "explorer" cpt explorerCpt = here.component "explorer" cpt
......
This diff is collapsed.
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