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
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
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
gargantext
purescript-gargantext
Commits
e984d3dc
Commit
e984d3dc
authored
Apr 26, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[router] refactoring of sessions (no more context)
parent
b27a7f6e
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
196 additions
and
242 deletions
+196
-242
Data.purs
src/Gargantext/Components/App/Data.purs
+4
-1
DocsTable.purs
src/Gargantext/Components/DocsTable.purs
+7
-6
Forest.purs
src/Gargantext/Components/Forest.purs
+0
-1
GraphExplorer.purs
src/Gargantext/Components/GraphExplorer.purs
+0
-13
Annuaire.purs
src/Gargantext/Components/Nodes/Annuaire.purs
+7
-8
User.purs
src/Gargantext/Components/Nodes/Annuaire/User.purs
+0
-12
Contact.purs
src/Gargantext/Components/Nodes/Annuaire/User/Contact.purs
+3
-4
Corpus.purs
src/Gargantext/Components/Nodes/Corpus.purs
+13
-15
Dashboard.purs
src/Gargantext/Components/Nodes/Corpus/Dashboard.purs
+6
-6
Document.purs
src/Gargantext/Components/Nodes/Corpus/Document.purs
+5
-4
File.purs
src/Gargantext/Components/Nodes/File.purs
+7
-7
Frame.purs
src/Gargantext/Components/Nodes/Frame.purs
+6
-7
Lists.purs
src/Gargantext/Components/Nodes/Lists.purs
+0
-10
Texts.purs
src/Gargantext/Components/Nodes/Texts.purs
+1
-18
Router.purs
src/Gargantext/Components/Router.purs
+135
-128
SessionLoader.purs
src/Gargantext/Components/SessionLoader.purs
+2
-2
No files found.
src/Gargantext/Components/App/Data.purs
View file @
e984d3dc
...
...
@@ -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
, Session
s)
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
...
...
src/Gargantext/Components/DocsTable.purs
View file @
e984d3dc
...
...
@@ -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
...
...
src/Gargantext/Components/Forest.purs
View file @
e984d3dc
...
...
@@ -52,7 +52,6 @@ type Props =
type TreeExtra = (
forestOpen :: T.Box OpenNodes
, session :: Session
)
forest :: R2.Component Props
...
...
src/Gargantext/Components/GraphExplorer.purs
View file @
e984d3dc
...
...
@@ -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
...
...
src/Gargantext/Components/Nodes/Annuaire.purs
View file @
e984d3dc
...
...
@@ -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
...
...
src/Gargantext/Components/Nodes/Annuaire/User.purs
View file @
e984d3dc
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
...
...
src/Gargantext/Components/Nodes/Annuaire/User/Contact.purs
View file @
e984d3dc
...
...
@@ -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
...
...
src/Gargantext/Components/Nodes/Corpus.purs
View file @
e984d3dc
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
...
...
src/Gargantext/Components/Nodes/Corpus/Dashboard.purs
View file @
e984d3dc
...
...
@@ -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
...
...
src/Gargantext/Components/Nodes/Corpus/Document.purs
View file @
e984d3dc
...
...
@@ -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
...
...
src/Gargantext/Components/Nodes/File.purs
View file @
e984d3dc
...
...
@@ -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
...
...
src/Gargantext/Components/Nodes/Frame.purs
View file @
e984d3dc
...
...
@@ -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 []
...
...
src/Gargantext/Components/Nodes/Lists.purs
View file @
e984d3dc
...
...
@@ -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 =
...
...
src/Gargantext/Components/Nodes/Texts.purs
View file @
e984d3dc
...
...
@@ -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 } []
src/Gargantext/Components/Router.purs
View file @
e984d3dc
This diff is collapsed.
Click to expand it.
src/Gargantext/Components/SessionLoader.purs
View file @
e984d3dc
...
...
@@ -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
)
...
...
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