Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
6d0d0db7
Commit
6d0d0db7
authored
Mar 09, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[toestand] more refactoring fixes
parent
48f83762
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
98 additions
and
68 deletions
+98
-68
App.purs
src/Gargantext/Components/App.purs
+5
-2
GraphExplorer.purs
src/Gargantext/Components/GraphExplorer.purs
+22
-16
Router.purs
src/Gargantext/Components/Router.purs
+71
-50
No files found.
src/Gargantext/Components/App.purs
View file @
6d0d0db7
module Gargantext.Components.App (app) where
import Data.Maybe (Maybe(..))
import Prelude
import Reactix as R
import Toestand as T
import Gargantext.Components.App.Data (emptyApp)
import Gargantext.Components.Router (router)
import Gargantext.Hooks (useHashRouter)
import Gargantext.Router as Router
import Gargantext.Sessions as Sessions
import Reactix as R
import Toestand as T
import Gargantext.Utils.Reactix as R2
here :: R2.Here
here = R2.here "Gargantext.Components.App"
...
...
src/Gargantext/Components/GraphExplorer.purs
View file @
6d0d0db7
...
...
@@ -45,33 +45,36 @@ import Gargantext.Utils.Toestand as T2
here :: R2.Here
here = R2.here "Gargantext.Components.GraphExplorer"
type BaseProps =
(
backend :: T.Cursor (Maybe Backend)
type BaseProps =
(
backend :: T.Cursor (Maybe Backend)
, frontends :: Frontends
, graphId :: GET.GraphId
, handed :: T.Cursor Types.Handed
, route :: T.Cursor AppRoute
, sessions :: T.Cursor Sessions
, showLogin :: T.Cursor Boolean
, tasks :: T.Cursor (Maybe GAT.Reductor) )
, tasks :: T.Cursor (Maybe GAT.Reductor)
)
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 =
( graph :: SigmaxT.SGraph
, graphVersion :: GUR.ReloadS
type Props = (
graph :: SigmaxT.SGraph
, hyperdataGraph :: GET.HyperdataGraph
, mMetaData :: Maybe GET.MetaData
, session :: Session
| LayoutProps
)
--------------------------------------------------------------
explorerLayoutLoader :: R2.Component LayoutLoaderProps
explorerLayoutLoader
props = R.createElement explorerLayoutLoaderCpt props []
explorerLayoutLoader
= R.createElement explorerLayoutLoaderCpt
explorerLayoutLoaderCpt :: R.Component LayoutLoaderProps
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
let base = RX.pick props :: Record BaseProps
let props' = Record.merge base { graphVersion, session }
pure $ explorerLayout props'
pure $ explorerLayout props'
[]
explorerLayout :: R2.Component LayoutProps
explorerLayout
props = R.createElement explorerLayoutCpt props []
explorerLayout
= R.createElement explorerLayoutCpt
explorerLayoutCpt :: R.Component LayoutProps
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
where
handler loaded =
explorer (Record.merge props { graph, graphVersion, hyperdataGraph: loaded, mMetaData })
handler loaded =
explorer (Record.merge props { graph, hyperdataGraph: loaded, mMetaData }) []
--
explorer (Record.merge props { graph, graphVersion, hyperdataGraph: loaded, mMetaData })
where
GET.HyperdataGraph { graph: hyperdataGraph } = loaded
Tuple mMetaData graph = convert hyperdataGraph
--------------------------------------------------------------
explorer :: R
ecord Props -> R.Element
explorer
props = R.createElement explorerCpt props []
explorer :: R
2.Component Props
explorer
= R.createElement explorerCpt
explorerCpt :: R.Component Props
explorerCpt = here.component "explorer" cpt
...
...
src/Gargantext/Components/Router.purs
View file @
6d0d0db7
...
...
@@ -14,7 +14,7 @@ import Gargantext.AsyncTasks as GAT
import Gargantext.Components.App.Data (Cursors)
import Gargantext.Components.Footer (footer)
import Gargantext.Components.Forest (forestLayout)
import Gargantext.Components.GraphExplorer (explorerLayout)
import Gargantext.Components.GraphExplorer (explorerLayout
Loader
)
import Gargantext.Components.Lang (LandingLang(LL_EN))
import Gargantext.Components.Login (login)
import Gargantext.Components.Nodes.Annuaire (annuaireLayout)
...
...
@@ -64,36 +64,35 @@ router props = R.createElement routerCpt props []
routerCpt :: R.Component Props
routerCpt = here.component "root" cpt where
cpt props@{ cursors, tasks
, ws
} _ = do
cpt props@{ cursors, tasks } _ = 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
let props' = Record.merge props { route' }
if showLogin then login' cursors
route' <- T.useLive T.unequal cursors.route
pure $ if showLogin then login' cursors
else case route' of
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 (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 (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
(Record.merge { listId: l } $ sessionNodeProps 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 (sessionNodeProps s n)
[]
GR.Login -> login' cursors
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 (sessionNodeProps s n)
GR.Texts s n -> texts (sessionNodeProps s n)
GR.UserPage s n -> user (sessionNodeProps s n)
GR.PGraphExplorer s g -> graphExplorer (sessionNodeProps s g)
[]
GR.RouteFile s n -> routeFile (sessionNodeProps s n)
[]
GR.RouteFrameCalc s n -> routeFrame
(Record.merge { nodeType: NodeFrameCalc } $ sessionNodeProps s n) []
GR.RouteFrameCode s n -> routeFrame
(Record.merge { nodeType: NodeFrameNotebook } $ sessionNodeProps s n) []
GR.RouteFrameWrite s n -> routeFrame
(Record.merge { nodeType: NodeFrameWrite } $ sessionNodeProps s n) []
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
...
...
@@ -124,10 +123,10 @@ annuaire = R.createElement annuaireCpt
annuaireCpt :: R.Component SessionNodeProps
annuaireCpt = here.component "annuaire" cpt where
cpt props@{ nodeId, session, sessionId, tasks } _ = do
cpt props@{
cursors,
nodeId, session, sessionId, tasks } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $
forested
props
[ annuaireLayout { frontends, nodeId, session } ]
forested
{ cursors, tasks }
[ annuaireLayout { frontends, nodeId, session } ]
where frontends = defaultFrontends
corpus :: R2.Component SessionNodeProps
...
...
@@ -142,7 +141,7 @@ corpusCpt = here.component "corpus" cpt where
type CorpusDocumentProps =
( corpusId :: CorpusId
, listI
D
:: ListId
, listI
d
:: ListId
| SessionNodeProps
)
...
...
@@ -152,11 +151,11 @@ corpusDocument = R.createElement corpusDocumentCpt
corpusDocumentCpt :: R.Component CorpusDocumentProps
corpusDocumentCpt = here.component "corpusDocument" cpt
where
cpt props@{ cursors, corpusId: corpusId', listI
D
, nodeId, session, sessionId, tasks } _ = do
cpt props@{ cursors, corpusId: corpusId', listI
d
, nodeId, session, sessionId, tasks } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $
forested { cursors, tasks }
[ documentMainLayout { mCorpusId: corpusId, listId: listI
D
, nodeId, session } [] ]
[ documentMainLayout { mCorpusId: corpusId, listId: listI
d
, nodeId, session } [] ]
where corpusId = Just corpusId'
dashboard :: R2.Component SessionNodeProps
...
...
@@ -209,6 +208,7 @@ listsCpt = here.component "lists" cpt where
, sessionId
, tasks } _ = do
let sessionProps = RE.pick props :: Record SessionProps
session' <- R.useContext session
pure $ authed sessionProps $
Lists.listsWithForest
{ forestProps: { backend
...
...
@@ -220,14 +220,21 @@ listsCpt = here.component "lists" cpt where
, sessions
, showLogin
, tasks }
, listsProps: { nodeId, reloadRoot, reloadForest, session, tasks }
, listsProps: { nodeId
, reloadRoot
, reloadForest
, session: session'
, sessionUpdate: \_ -> pure unit
, tasks }
} []
where frontends = defaultFrontends
login' :: Cursors -> R.Element
login' { backend, sessions, showLogin: visible } =
login { backend, sessions, visible
, backends: fromFoldable defaultBackends }
login { backend
, backends: fromFoldable defaultBackends
, sessions
, visible }
graphExplorer :: R2.Component SessionNodeProps
graphExplorer = R.createElement graphExplorerCpt
...
...
@@ -235,19 +242,21 @@ 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
, nodeId
, session
, tasks } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $
simpleLayout { handed }
[ explorerLayout { backend
, graphId: nodeId
[ explorerLayoutLoader { backend
, frontends
, graphId: nodeId
, handed
, route
, session
, sessions
, showLogin
, tasks }
]
, tasks } []
]
where frontends = defaultFrontends
routeFile :: R2.Component SessionNodeProps
...
...
@@ -301,6 +310,7 @@ textsCpt = here.component "texts" cpt
, sessionId
, tasks } _ = do
let sessionProps = RE.pick props :: Record SessionProps
session' <- R.useContext session
pure $ authed sessionProps $
Texts.textsWithForest
{ forestProps: { backend
...
...
@@ -312,7 +322,9 @@ textsCpt = here.component "texts" cpt
, sessions
, showLogin
, tasks }
, textsProps: { frontends, nodeId, session } }
, textsProps: { frontends
, nodeId
, session: session' } }
[] where frontends = defaultFrontends
user :: R2.Component SessionNodeProps
...
...
@@ -320,12 +332,21 @@ user = R.createElement userCpt
userCpt :: R.Component SessionNodeProps
userCpt = here.component "user" cpt where
cpt props@{ cursors: cursors@{ reloadRoot }
, nodeId, session, sessionId, tasks } _ = do
cpt props@{ cursors: cursors@{ reloadForest, reloadRoot }
, nodeId
, session
, sessionId
, tasks } _ = do
let sessionProps = RE.pick props :: Record SessionProps
session' <- R.useContext session
pure $ authed sessionProps $
forested { cursors, tasks }
[ userLayout { frontends, nodeId, reloadRoot, session, tasks } ]
[ userLayout { frontends
, nodeId
, reloadForest
, reloadRoot
, session: session'
, tasks } ]
where frontends = defaultFrontends
type ContactProps = ( annuaireId :: NodeID | SessionNodeProps )
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment