Commit 4a7918bf authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[toestand] refactor of async tasks to toestand

parent a702dad5
...@@ -9,7 +9,6 @@ import Data.Array as A ...@@ -9,7 +9,6 @@ import Data.Array as A
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Map as Map import Data.Map as Map
import Data.Maybe (Maybe(..), maybe, fromMaybe) import Data.Maybe (Maybe(..), maybe, fromMaybe)
import Data.Tuple (fst)
import Effect (Effect) import Effect (Effect)
import Reactix as R import Reactix as R
import Toestand as T import Toestand as T
...@@ -24,7 +23,8 @@ localStorageKey :: String ...@@ -24,7 +23,8 @@ localStorageKey :: String
localStorageKey = "garg-async-tasks" localStorageKey = "garg-async-tasks"
type Storage = Map.Map GT.NodeID (Array GT.AsyncTaskWithType) type TaskList = Array GT.AsyncTaskWithType
type Storage = Map.Map GT.NodeID TaskList
empty :: Storage empty :: Storage
empty = Map.empty empty = Map.empty
...@@ -42,15 +42,16 @@ getAsyncTasks = R2.getls >>= WSS.getItem localStorageKey >>= handleMaybe ...@@ -42,15 +42,16 @@ getAsyncTasks = R2.getls >>= WSS.getItem localStorageKey >>= handleMaybe
parse s = GU.mapLeft (log2 "Error parsing serialised sessions:") (jsonParser s) parse s = GU.mapLeft (log2 "Error parsing serialised sessions:") (jsonParser s)
decode j = GU.mapLeft (log2 "Error decoding serialised sessions:") (decodeJson j) decode j = GU.mapLeft (log2 "Error decoding serialised sessions:") (decodeJson j)
getTasks :: Record ReductorProps -> GT.NodeID -> Array GT.AsyncTaskWithType getTasks :: GT.NodeID -> Storage -> TaskList
getTasks { storage } nodeId = fromMaybe [] $ Map.lookup nodeId storage getTasks nodeId storage = fromMaybe [] $ Map.lookup nodeId storage
getTasksMaybe :: Maybe Reductor -> GT.NodeID -> Array GT.AsyncTaskWithType setTasks :: GT.NodeID -> TaskList -> Storage -> Storage
getTasksMaybe mTasks nodeId = case mTasks of setTasks id tasks s = Map.insert id tasks s
Just tasks -> getTasks (fst tasks) nodeId
Nothing -> []
removeTaskFromList :: Array GT.AsyncTaskWithType -> GT.AsyncTaskWithType -> Array GT.AsyncTaskWithType focus :: GT.NodeID -> T.Box Storage -> R.Hooks (T.Box TaskList)
focus id tasks = T.useFocused (getTasks id) (setTasks id) tasks
removeTaskFromList :: TaskList -> GT.AsyncTaskWithType -> TaskList
removeTaskFromList ts (GT.AsyncTaskWithType { task: GT.AsyncTask { id: id' } }) = removeTaskFromList ts (GT.AsyncTaskWithType { task: GT.AsyncTask { id: id' } }) =
A.filter (\(GT.AsyncTaskWithType { task: GT.AsyncTask { id: id'' } }) -> id' /= id'') ts A.filter (\(GT.AsyncTaskWithType { task: GT.AsyncTask { id: id'' } }) -> id' /= id'') ts
...@@ -60,40 +61,15 @@ type ReductorProps = ( ...@@ -60,40 +61,15 @@ type ReductorProps = (
, storage :: Storage , storage :: Storage
) )
type Reductor = R2.Reductor (Record ReductorProps) Action insert :: GT.NodeID -> GT.AsyncTaskWithType -> T.Box Storage -> Effect Unit
type ReductorAction = Action -> Effect Unit insert id task storage = T.modify_ newStorage storage
where
newStorage s = Map.alter (maybe (Just [task]) (\ts -> Just $ A.cons task ts)) id s
finish :: GT.NodeID -> GT.AsyncTaskWithType -> T.Box Storage -> Effect Unit
finish id task storage = remove id task storage
useTasks :: T.Box T2.Reload -> T.Box T2.Reload -> R.Hooks Reductor remove :: GT.NodeID -> GT.AsyncTaskWithType -> T.Box Storage -> Effect Unit
useTasks reloadRoot reloadForest = R2.useReductor act initializer unit remove id task storage = T.modify_ newStorage storage
where where
act :: R2.Actor (Record ReductorProps) Action newStorage s = Map.alter (maybe Nothing $ (\ts -> Just $ removeTaskFromList ts task)) id s
act a s = action s a
initializer _ = do
storage <- getAsyncTasks
pure { reloadRoot, reloadForest, storage }
data Action =
Insert GT.NodeID GT.AsyncTaskWithType
| Finish GT.NodeID GT.AsyncTaskWithType
| Remove GT.NodeID GT.AsyncTaskWithType
action :: Record ReductorProps -> Action -> Effect (Record ReductorProps)
action p@{ reloadForest, storage } (Insert nodeId t) = do
-- _ <- T2.reload reloadForest
let newStorage = Map.alter (maybe (Just [t]) (\ts -> Just $ A.cons t ts)) nodeId storage
pure $ p { storage = newStorage }
action p (Finish nodeId t) = do
action p (Remove nodeId t)
action p@{ reloadRoot, reloadForest, storage } (Remove nodeId t@(GT.AsyncTaskWithType { typ })) = do
_ <- if GT.asyncTaskTriggersAppReload typ then
pure unit
-- T2.reload reloadRoot
else
pure unit
_ <- if GT.asyncTaskTriggersTreeReload typ then
pure unit
-- T2.reload reloadForest
else
pure unit
let newStorage = Map.alter (maybe Nothing $ (\ts -> Just $ removeTaskFromList ts t)) nodeId storage
pure $ p { storage = newStorage }
module Gargantext.Components.App (app) where module Gargantext.Components.App (app) where
import Data.Maybe (Maybe(..))
import Reactix as R
import Toestand as T
import Gargantext.Prelude import Gargantext.Prelude
import Data.Maybe (Maybe(..))
import Gargantext.AsyncTasks as GAT import Gargantext.AsyncTasks as GAT
import Gargantext.Components.App.Data (emptyApp) import Gargantext.Components.App.Data (emptyApp)
import Gargantext.Components.Router (router) import Gargantext.Components.Router (router)
...@@ -13,6 +10,8 @@ import Gargantext.Hooks (useHashRouter) ...@@ -13,6 +10,8 @@ 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 Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Reactix as R
import Toestand as T
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.App" here = R2.here "Gargantext.Components.App"
...@@ -28,11 +27,14 @@ appCpt = here.component "app" cpt where ...@@ -28,11 +27,14 @@ appCpt = here.component "app" cpt where
-- tasks <- T.useBox Nothing -- storage for asynchronous tasks reductor -- tasks <- T.useBox Nothing -- storage for asynchronous tasks reductor
R.useEffectOnce' $ do R.useEffectOnce' $ do
void $ Sessions.load boxes.sessions void $ Sessions.load boxes.sessions
tasks <- GAT.useTasks boxes.reloadRoot boxes.reloadForest -- tasks <- GAT.useTasks boxes.reloadRoot boxes.reloadForest
R.useEffectOnce' $ do
tasksStorage <- GAT.getAsyncTasks
T.write_ tasksStorage boxes.tasks
-- R.useEffectOnce' $ do -- R.useEffectOnce' $ do
-- T.write (Just tasksReductor) tasks -- T.write (Just tasksReductor) tasks
R.useEffectOnce' $ do R.useEffectOnce' $ do
R2.loadLocalStorageState R2.openNodesKey boxes.forestOpen R2.loadLocalStorageState R2.openNodesKey boxes.forestOpen
T.listen (R2.listenLocalStorageState R2.openNodesKey) boxes.forestOpen T.listen (R2.listenLocalStorageState R2.openNodesKey) boxes.forestOpen
useHashRouter Router.router boxes.route -- Install router to window useHashRouter Router.router boxes.route -- Install router to window
pure $ router { boxes, tasks } -- Render router component pure $ router { boxes } -- Render router component
...@@ -4,10 +4,11 @@ import Data.Set as Set ...@@ -4,10 +4,11 @@ import Data.Set as Set
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
import Toestand as T import Toestand as T
import Gargantext.AsyncTasks as GAT
import Gargantext.Ends (Backend) import Gargantext.Ends (Backend)
import Gargantext.Routes (AppRoute(Home))
import Gargantext.Sessions as Sessions import Gargantext.Sessions as Sessions
import Gargantext.Sessions (OpenNodes, Sessions) import Gargantext.Sessions (OpenNodes, Sessions)
import Gargantext.Routes (AppRoute(Home))
import Gargantext.Types (Handed(RightHanded)) import Gargantext.Types (Handed(RightHanded))
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
...@@ -21,6 +22,7 @@ type App = ...@@ -21,6 +22,7 @@ type App =
, sessions :: Sessions , sessions :: Sessions
, showCorpus :: Boolean , showCorpus :: Boolean
, showLogin :: Boolean , showLogin :: Boolean
, tasks :: GAT.Storage
} }
emptyApp :: App emptyApp :: App
...@@ -34,6 +36,7 @@ emptyApp = ...@@ -34,6 +36,7 @@ emptyApp =
, sessions: Sessions.empty , sessions: Sessions.empty
, showCorpus: false , showCorpus: false
, showLogin: false , showLogin: false
, tasks: GAT.empty
} }
type Boxes = type Boxes =
...@@ -46,5 +49,5 @@ type Boxes = ...@@ -46,5 +49,5 @@ type Boxes =
, sessions :: T.Box Sessions , sessions :: T.Box Sessions
, showCorpus :: T.Box Boolean , showCorpus :: T.Box Boolean
, showLogin :: T.Box Boolean , showLogin :: T.Box Boolean
, tasks :: T.Box GAT.Storage
} }
...@@ -37,8 +37,6 @@ type Common = ...@@ -37,8 +37,6 @@ type Common =
, handed :: T.Box Handed , handed :: T.Box Handed
, reloadRoot :: T.Box T2.Reload , reloadRoot :: T.Box T2.Reload
, route :: T.Box AppRoute , route :: T.Box AppRoute
-- , tasks :: T.Box (Maybe GAT.Reductor)
, tasks :: GAT.Reductor
) )
type Props = type Props =
...@@ -47,6 +45,7 @@ type Props = ...@@ -47,6 +45,7 @@ type Props =
, reloadForest :: T.Box T2.Reload , reloadForest :: T.Box T2.Reload
, sessions :: T.Box Sessions , sessions :: T.Box Sessions
, showLogin :: T.Box Boolean , showLogin :: T.Box Boolean
, tasks :: T.Box GAT.Storage
| Common | Common
) )
...@@ -86,8 +85,7 @@ forestCpt = here.component "forest" cpt where ...@@ -86,8 +85,7 @@ forestCpt = here.component "forest" cpt where
-- R.useEffect' $ do -- R.useEffect' $ do
-- R.setRef tasks $ Just tasks' -- R.setRef tasks $ Just tasks'
R2.useCache R2.useCache
( frontends /\ route' /\ sessions' /\ handed' /\ forestOpen' ( frontends /\ route' /\ sessions' /\ handed' /\ forestOpen' /\ reloadForest' )
/\ reloadForest' /\ (fst tasks).storage )
(cp handed' sessions') (cp handed' sessions')
where where
common = RX.pick props :: Record Common common = RX.pick props :: Record Common
......
...@@ -47,15 +47,14 @@ here = R2.here "Gargantext.Components.Forest.Tree" ...@@ -47,15 +47,14 @@ here = R2.here "Gargantext.Components.Forest.Tree"
-- Shared by every component here + performAction + nodeSpan -- Shared by every component here + performAction + nodeSpan
type Universal = type Universal =
( reloadRoot :: T.Box T2.Reload ( reloadRoot :: T.Box T2.Reload )
-- , tasks :: T.Box (Maybe GAT.Reductor) )
, tasks :: GAT.Reductor )
-- Shared by every component here + nodeSpan -- Shared by every component here + nodeSpan
type Global = type Global =
( frontends :: Frontends ( frontends :: Frontends
, handed :: Handed , handed :: Handed
, route :: T.Box AppRoute , route :: T.Box AppRoute
, tasks :: T.Box GAT.Storage
| Universal ) | Universal )
-- Shared by every component here -- Shared by every component here
...@@ -108,7 +107,10 @@ treeCpt = here.component "tree" cpt where ...@@ -108,7 +107,10 @@ treeCpt = here.component "tree" cpt where
[ H.div { className: divClass } -- TODO: naughty div should not be in a ul [ H.div { className: divClass } -- TODO: naughty div should not be in a ul
[ H.li { className: childrenClass children } [ H.li { className: childrenClass children }
[ nodeSpan (nsprops { folderOpen, name, id, nodeType, setPopoverRef, isLeaf }) [ nodeSpan (nsprops { folderOpen, name, id, nodeType, setPopoverRef, isLeaf })
(renderChildren open) ]]] (renderChildren open)
]
]
]
where where
isLeaf = A.null children isLeaf = A.null children
nodeId = mkNodeId session id nodeId = mkNodeId session id
...@@ -136,6 +138,7 @@ type PACommon = ...@@ -136,6 +138,7 @@ type PACommon =
( forestOpen :: T.Box OpenNodes ( forestOpen :: T.Box OpenNodes
, reloadTree :: T.Box T2.Reload , reloadTree :: T.Box T2.Reload
, session :: Session , session :: Session
, tasks :: T.Box GAT.Storage
, tree :: FTree , tree :: FTree
| Universal ) | Universal )
...@@ -181,13 +184,13 @@ performAction (DeleteNode nt) p@{ forestOpen ...@@ -181,13 +184,13 @@ performAction (DeleteNode nt) p@{ forestOpen
performAction RefreshTree p performAction RefreshTree p
performAction (DoSearch task) p@{ tasks performAction (DoSearch task) p@{ tasks
, tree: (NTree (LNode {id}) _) } = liftEffect $ do , tree: (NTree (LNode {id}) _) } = liftEffect $ do
snd tasks $ GAT.Insert id task GAT.insert id task tasks
log2 "[performAction] DoSearch task:" task log2 "[performAction] DoSearch task:" task
performAction (UpdateNode params) p@{ tasks performAction (UpdateNode params) p@{ tasks
, tree: (NTree (LNode {id}) _) } = do , tree: (NTree (LNode {id}) _) } = do
task <- updateRequest params p.session id task <- updateRequest params p.session id
liftEffect $ do liftEffect $ do
snd tasks $ GAT.Insert id task GAT.insert id task tasks
log2 "[performAction] UpdateNode task:" task log2 "[performAction] UpdateNode task:" task
performAction (RenameNode name) p@{ tree: (NTree (LNode {id}) _) } = do performAction (RenameNode name) p@{ tree: (NTree (LNode {id}) _) } = do
void $ rename p.session id $ RenameValue { text: name } void $ rename p.session id $ RenameValue { text: name }
...@@ -210,13 +213,13 @@ performAction (UploadFile nodeType fileType mName blob) p@{ tasks ...@@ -210,13 +213,13 @@ performAction (UploadFile nodeType fileType mName blob) p@{ tasks
, tree: (NTree (LNode { id }) _) } = do , tree: (NTree (LNode { id }) _) } = do
task <- uploadFile p.session nodeType id fileType {mName, blob} task <- uploadFile p.session nodeType id fileType {mName, blob}
liftEffect $ do liftEffect $ do
snd tasks $ GAT.Insert id task GAT.insert id task tasks
log2 "[performAction] UploadFile, uploaded, task:" task log2 "[performAction] UploadFile, uploaded, task:" task
performAction (UploadArbitraryFile mName blob) p@{ tasks performAction (UploadArbitraryFile mName blob) p@{ tasks
, tree: (NTree (LNode { id }) _) } = do , tree: (NTree (LNode { id }) _) } = do
task <- uploadArbitraryFile p.session id { blob, mName } task <- uploadArbitraryFile p.session id { blob, mName }
liftEffect $ do liftEffect $ do
snd tasks $ GAT.Insert id task GAT.insert id task tasks
log2 "[performAction] UploadArbitraryFile, uploaded, task:" task log2 "[performAction] UploadArbitraryFile, uploaded, task:" task
performAction DownloadNode _ = liftEffect $ log "[performAction] DownloadNode" performAction DownloadNode _ = liftEffect $ log "[performAction] DownloadNode"
performAction (MoveNode {params}) p@{ forestOpen performAction (MoveNode {params}) p@{ forestOpen
......
...@@ -54,7 +54,7 @@ type NodeMainSpanProps = ...@@ -54,7 +54,7 @@ type NodeMainSpanProps =
, reloadRoot :: T.Box T2.Reload , reloadRoot :: T.Box T2.Reload
, route :: T.Box Routes.AppRoute , route :: T.Box Routes.AppRoute
, setPopoverRef :: R.Ref (Maybe (Boolean -> Effect Unit)) , setPopoverRef :: R.Ref (Maybe (Boolean -> Effect Unit))
, tasks :: GAT.Reductor , tasks :: T.Box GAT.Storage
| CommonProps | CommonProps
) )
...@@ -97,6 +97,9 @@ nodeMainSpanCpt = here.component "nodeMainSpan" cpt ...@@ -97,6 +97,9 @@ nodeMainSpanCpt = here.component "nodeMainSpan" cpt
isDragOver' <- T.useLive T.unequal isDragOver isDragOver' <- T.useLive T.unequal isDragOver
popoverRef <- R.useRef null popoverRef <- R.useRef null
currentTasks <- GAT.focus id tasks
currentTasks' <- T.useLive T.unequal currentTasks
R.useEffect' $ do R.useEffect' $ do
R.setRef setPopoverRef $ Just $ Popover.setOpen popoverRef 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
...@@ -117,7 +120,7 @@ nodeMainSpanCpt = here.component "nodeMainSpan" cpt ...@@ -117,7 +120,7 @@ nodeMainSpanCpt = here.component "nodeMainSpan" cpt
, onFinish: onTaskFinish id t , onFinish: onTaskFinish id t
, session , session
} }
) $ GAT.getTasks (fst tasks) id ) currentTasks'
) )
, if nodeType == GT.NodeUser , if nodeType == GT.NodeUser
then GV.versionView {session} then GV.versionView {session}
...@@ -142,7 +145,8 @@ nodeMainSpanCpt = here.component "nodeMainSpan" cpt ...@@ -142,7 +145,8 @@ nodeMainSpanCpt = here.component "nodeMainSpan" cpt
] ]
where where
onTaskFinish id' t _ = do onTaskFinish id' t _ = do
snd tasks $ GAT.Finish id' t GAT.finish id' t tasks
-- snd tasks $ GAT.Finish id' t
-- mT <- T.read tasks -- mT <- T.read tasks
-- case mT of -- case mT of
-- Just t' -> snd t' $ GAT.Finish id' t -- Just t' -> snd t' $ GAT.Finish id' t
......
...@@ -53,7 +53,7 @@ type BaseProps = ...@@ -53,7 +53,7 @@ type BaseProps =
, route :: T.Box AppRoute , route :: T.Box AppRoute
, sessions :: T.Box Sessions , sessions :: T.Box Sessions
, showLogin :: T.Box Boolean , showLogin :: T.Box Boolean
, tasks :: GAT.Reductor , tasks :: T.Box GAT.Storage
) )
type LayoutLoaderProps = ( session :: R.Context Session | BaseProps ) type LayoutLoaderProps = ( session :: R.Context Session | BaseProps )
...@@ -277,7 +277,7 @@ type TreeProps = ( ...@@ -277,7 +277,7 @@ type TreeProps = (
, sessions :: T.Box Sessions , sessions :: T.Box Sessions
, show :: Boolean , show :: Boolean
, showLogin :: T.Box Boolean , showLogin :: T.Box Boolean
, tasks :: GAT.Reductor , tasks :: T.Box GAT.Storage
) )
type MSidebarProps = type MSidebarProps =
......
...@@ -263,7 +263,7 @@ type CommonProps = ( ...@@ -263,7 +263,7 @@ type CommonProps = (
, reloadRoot :: T.Box T2.Reload , reloadRoot :: T.Box T2.Reload
, sidePanelTriggers :: Record NT.SidePanelTriggers , sidePanelTriggers :: Record NT.SidePanelTriggers
, tabNgramType :: CTabNgramType , tabNgramType :: CTabNgramType
, tasks :: GAT.Reductor , tasks :: T.Box GAT.Storage
, withAutoUpdate :: Boolean , withAutoUpdate :: Boolean
) )
......
...@@ -1185,14 +1185,14 @@ chartsAfterSync :: forall props discard. ...@@ -1185,14 +1185,14 @@ chartsAfterSync :: forall props discard.
, tabType :: TabType , tabType :: TabType
| props | props
} }
-> GAT.Reductor -> T.Box GAT.Storage
-> discard -> discard
-> Aff Unit -> Aff Unit
chartsAfterSync path'@{ nodeId } tasks _ = do chartsAfterSync path'@{ nodeId } tasks _ = do
task <- postNgramsChartsAsync path' task <- postNgramsChartsAsync path'
liftEffect $ do liftEffect $ do
log2 "[chartsAfterSync] Synchronize task" task log2 "[chartsAfterSync] Synchronize task" task
snd tasks $ GAT.Insert nodeId task GAT.insert nodeId task tasks
postNgramsChartsAsync :: forall s. CoreParams s -> Aff AsyncTaskWithType postNgramsChartsAsync :: forall s. CoreParams s -> Aff AsyncTaskWithType
postNgramsChartsAsync { listIds, nodeId, session, tabType } = do postNgramsChartsAsync { listIds, nodeId, session, tabType } = do
......
...@@ -59,7 +59,7 @@ type TabsProps = ...@@ -59,7 +59,7 @@ type TabsProps =
, reloadRoot :: T.Box T2.Reload , reloadRoot :: T.Box T2.Reload
, session :: Session , session :: Session
, sidePanelTriggers :: Record LTypes.SidePanelTriggers , sidePanelTriggers :: Record LTypes.SidePanelTriggers
, tasks :: GAT.Reductor , tasks :: T.Box GAT.Storage
) )
tabs :: R2.Leaf TabsProps tabs :: R2.Leaf TabsProps
...@@ -136,5 +136,5 @@ type NTCommon = ...@@ -136,5 +136,5 @@ type NTCommon =
, reloadRoot :: T.Box T2.Reload , reloadRoot :: T.Box T2.Reload
, session :: Session , session :: Session
, sidePanelTriggers :: Record LTypes.SidePanelTriggers , sidePanelTriggers :: Record LTypes.SidePanelTriggers
, tasks :: GAT.Reductor , tasks :: T.Box GAT.Storage
) )
...@@ -155,7 +155,7 @@ type LayoutNoSessionProps = ...@@ -155,7 +155,7 @@ type LayoutNoSessionProps =
, nodeId :: Int , nodeId :: Int
, reloadForest :: T.Box T2.Reload , reloadForest :: T.Box T2.Reload
, reloadRoot :: T.Box T2.Reload , reloadRoot :: T.Box T2.Reload
, tasks :: GAT.Reductor , tasks :: T.Box GAT.Storage
) )
type LayoutProps = WithSession LayoutNoSessionProps type LayoutProps = WithSession LayoutNoSessionProps
......
...@@ -141,7 +141,7 @@ listElement = H.li { className: "list-group-item justify-content-between" } ...@@ -141,7 +141,7 @@ listElement = H.li { className: "list-group-item justify-content-between" }
type BasicProps = type BasicProps =
( frontends :: Frontends ( frontends :: Frontends
, nodeId :: Int , nodeId :: Int
, tasks :: GAT.Reductor , tasks :: T.Box GAT.Storage
) )
type ReloadProps = type ReloadProps =
......
...@@ -57,7 +57,7 @@ type TabsProps = ( ...@@ -57,7 +57,7 @@ type TabsProps = (
, reloadRoot :: T.Box T2.Reload , reloadRoot :: T.Box T2.Reload
, session :: Session , session :: Session
, sidePanelTriggers :: Record LTypes.SidePanelTriggers , sidePanelTriggers :: Record LTypes.SidePanelTriggers
, tasks :: GAT.Reductor , tasks :: T.Box GAT.Storage
) )
tabs :: Record TabsProps -> R.Element tabs :: Record TabsProps -> R.Element
...@@ -139,7 +139,7 @@ type NgramsViewTabsProps = ( ...@@ -139,7 +139,7 @@ type NgramsViewTabsProps = (
, reloadRoot :: T.Box T2.Reload , reloadRoot :: T.Box T2.Reload
, session :: Session , session :: Session
, sidePanelTriggers :: Record LTypes.SidePanelTriggers , sidePanelTriggers :: Record LTypes.SidePanelTriggers
, tasks :: GAT.Reductor , tasks :: T.Box GAT.Storage
) )
ngramsView :: R2.Component NgramsViewTabsProps ngramsView :: R2.Component NgramsViewTabsProps
......
...@@ -94,7 +94,7 @@ type CommonPropsNoSession = ...@@ -94,7 +94,7 @@ type CommonPropsNoSession =
, reloadForest :: T.Box T2.Reload , reloadForest :: T.Box T2.Reload
, reloadRoot :: T.Box T2.Reload , reloadRoot :: T.Box T2.Reload
, sessionUpdate :: Session -> Effect Unit , sessionUpdate :: Session -> Effect Unit
, tasks :: GAT.Reductor , tasks :: T.Box GAT.Storage
) )
type CommonProps = WithSession CommonPropsNoSession type CommonProps = WithSession CommonPropsNoSession
......
...@@ -41,7 +41,7 @@ type Props = ( ...@@ -41,7 +41,7 @@ type Props = (
, reloadRoot :: T.Box T2.Reload , reloadRoot :: T.Box T2.Reload
, session :: Session , session :: Session
, sidePanelTriggers :: Record SidePanelTriggers , sidePanelTriggers :: Record SidePanelTriggers
, tasks :: GAT.Reductor , tasks :: T.Box GAT.Storage
) )
type PropsWithKey = ( key :: String | Props ) type PropsWithKey = ( key :: String | Props )
......
...@@ -42,7 +42,7 @@ import Gargantext.Utils.Reactix as R2 ...@@ -42,7 +42,7 @@ import Gargantext.Utils.Reactix as R2
here :: R2.Here here :: R2.Here
here = R2.here "Gargantext.Components.Router" here = R2.here "Gargantext.Components.Router"
type Props = ( boxes :: Boxes, tasks :: GAT.Reductor ) type Props = ( boxes :: Boxes )
type SessionProps = ( session :: R.Context Session, sessionId :: SessionId | Props ) type SessionProps = ( session :: R.Context Session, sessionId :: SessionId | Props )
...@@ -54,7 +54,7 @@ router props = R.createElement routerCpt props [] ...@@ -54,7 +54,7 @@ router props = R.createElement routerCpt props []
routerCpt :: R.Component Props routerCpt :: R.Component Props
routerCpt = here.component "router" cpt where routerCpt = here.component "router" cpt where
cpt props@{ boxes, tasks } _ = do cpt props@{ boxes } _ = do
let session = R.createContext (unsafeCoerce {}) let session = R.createContext (unsafeCoerce {})
let sessionProps sId = Record.merge { session, sessionId: sId } props let sessionProps sId = Record.merge { session, sessionId: sId } props
let sessionNodeProps sId nId = Record.merge { nodeId: nId } $ sessionProps sId let sessionNodeProps sId nId = Record.merge { nodeId: nId } $ sessionProps sId
...@@ -101,7 +101,8 @@ forestedCpt = here.component "forested" cpt ...@@ -101,7 +101,8 @@ forestedCpt = here.component "forested" cpt
, reloadRoot , reloadRoot
, route , route
, sessions , sessions
, showLogin }, tasks } children = do , showLogin
, tasks } } children = do
pure $ forestLayout { backend pure $ forestLayout { backend
, forestOpen , forestOpen
, frontends: defaultFrontends , frontends: defaultFrontends
...@@ -114,7 +115,7 @@ forestedCpt = here.component "forested" cpt ...@@ -114,7 +115,7 @@ forestedCpt = here.component "forested" cpt
, tasks } children , tasks } children
authed :: Record SessionProps -> R.Element -> R.Element authed :: Record SessionProps -> R.Element -> R.Element
authed props@{ boxes: { sessions }, session, sessionId, tasks } content = authed props@{ boxes: { sessions }, session, sessionId } content =
sessionWrapper { fallback: home homeProps [] sessionWrapper { fallback: home homeProps []
, context: session , context: session
, sessionId , sessionId
...@@ -127,10 +128,10 @@ annuaire = R.createElement annuaireCpt ...@@ -127,10 +128,10 @@ annuaire = R.createElement annuaireCpt
annuaireCpt :: R.Component SessionNodeProps annuaireCpt :: R.Component SessionNodeProps
annuaireCpt = here.component "annuaire" cpt where annuaireCpt = here.component "annuaire" cpt where
cpt props@{ boxes, nodeId, session, sessionId, tasks } _ = do cpt props@{ boxes, nodeId, session, sessionId } _ = do
let sessionProps = RE.pick props :: Record SessionProps let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $ pure $ authed sessionProps $
forested { boxes, tasks } [ annuaireLayout { frontends, nodeId, session } ] forested { boxes } [ annuaireLayout { frontends, nodeId, session } ]
where frontends = defaultFrontends where frontends = defaultFrontends
corpus :: R2.Component SessionNodeProps corpus :: R2.Component SessionNodeProps
...@@ -138,10 +139,10 @@ corpus = R.createElement corpusCpt ...@@ -138,10 +139,10 @@ corpus = R.createElement corpusCpt
corpusCpt :: R.Component SessionNodeProps corpusCpt :: R.Component SessionNodeProps
corpusCpt = here.component "corpus" cpt where corpusCpt = here.component "corpus" cpt where
cpt props@{ boxes, nodeId, session, tasks } _ = do cpt props@{ boxes, nodeId, session } _ = do
let sessionProps = RE.pick props :: Record SessionProps let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $ pure $ authed sessionProps $
forested { boxes, tasks } [ corpusLayout { nodeId, session } ] forested { boxes } [ corpusLayout { nodeId, session } ]
type CorpusDocumentProps = type CorpusDocumentProps =
( corpusId :: CorpusId ( corpusId :: CorpusId
...@@ -155,10 +156,10 @@ corpusDocument = R.createElement corpusDocumentCpt ...@@ -155,10 +156,10 @@ corpusDocument = R.createElement corpusDocumentCpt
corpusDocumentCpt :: R.Component CorpusDocumentProps corpusDocumentCpt :: R.Component CorpusDocumentProps
corpusDocumentCpt = here.component "corpusDocument" cpt corpusDocumentCpt = here.component "corpusDocument" cpt
where where
cpt props@{ boxes, corpusId: corpusId', listId, nodeId, session, sessionId, tasks } _ = do cpt props@{ boxes, corpusId: corpusId', listId, nodeId, session, sessionId } _ = do
let sessionProps = RE.pick props :: Record SessionProps let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $ pure $ authed sessionProps $
forested { boxes, tasks } forested { boxes }
[ documentMainLayout { mCorpusId: corpusId, listId: listId, nodeId, session } [] ] [ documentMainLayout { mCorpusId: corpusId, listId: listId, nodeId, session } [] ]
where corpusId = Just corpusId' where corpusId = Just corpusId'
...@@ -168,10 +169,10 @@ dashboard = R.createElement dashboardCpt ...@@ -168,10 +169,10 @@ dashboard = R.createElement dashboardCpt
dashboardCpt :: R.Component SessionNodeProps dashboardCpt :: R.Component SessionNodeProps
dashboardCpt = here.component "dashboard" cpt dashboardCpt = here.component "dashboard" cpt
where where
cpt props@{ boxes, nodeId, session, tasks } _ = do cpt props@{ boxes, nodeId, session } _ = do
let sessionProps = RE.pick props :: Record SessionProps let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $ pure $ authed sessionProps $
forested { boxes, tasks } [ dashboardLayout { nodeId, session } [] ] forested { boxes } [ dashboardLayout { nodeId, session } [] ]
type DocumentProps = ( listId :: ListId | SessionNodeProps ) type DocumentProps = ( listId :: ListId | SessionNodeProps )
...@@ -180,10 +181,10 @@ document = R.createElement documentCpt ...@@ -180,10 +181,10 @@ document = R.createElement documentCpt
documentCpt :: R.Component DocumentProps documentCpt :: R.Component DocumentProps
documentCpt = here.component "document" cpt where documentCpt = here.component "document" cpt where
cpt props@{ listId, nodeId, session, sessionId, tasks, boxes } _ = do cpt props@{ listId, nodeId, session, sessionId, boxes } _ = do
let sessionProps = RE.pick props :: Record SessionProps let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $ pure $ authed sessionProps $
forested { boxes, tasks } forested { boxes }
[ documentMainLayout { listId, nodeId, mCorpusId, session } [] ] [ documentMainLayout { listId, nodeId, mCorpusId, session } [] ]
where mCorpusId = Nothing where mCorpusId = Nothing
...@@ -192,8 +193,8 @@ home = R.createElement homeCpt ...@@ -192,8 +193,8 @@ home = R.createElement homeCpt
homeCpt :: R.Component Props homeCpt :: R.Component Props
homeCpt = here.component "home" cpt where homeCpt = here.component "home" cpt where
cpt props@{ boxes: boxes@{ sessions, showLogin }, tasks } _ = do cpt props@{ boxes: boxes@{ sessions, showLogin } } _ = do
pure $ forested { boxes, tasks } [ homeLayout { lang: LL_EN, sessions, showLogin } ] pure $ forested { boxes } [ homeLayout { lang: LL_EN, sessions, showLogin } ]
lists :: R2.Component SessionNodeProps lists :: R2.Component SessionNodeProps
lists = R.createElement listsCpt lists = R.createElement listsCpt
...@@ -207,11 +208,11 @@ listsCpt = here.component "lists" cpt where ...@@ -207,11 +208,11 @@ listsCpt = here.component "lists" cpt where
, reloadRoot , reloadRoot
, route , route
, sessions , sessions
, showLogin } , showLogin
, tasks }
, nodeId , nodeId
, session , session
, sessionId , sessionId } _ = do
, tasks } _ = do
let sessionProps = RE.pick props :: Record SessionProps let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $ pure $ authed sessionProps $
Lists.listsWithForestSessionContext Lists.listsWithForestSessionContext
...@@ -246,10 +247,9 @@ graphExplorer = R.createElement graphExplorerCpt ...@@ -246,10 +247,9 @@ graphExplorer = R.createElement graphExplorerCpt
graphExplorerCpt :: R.Component SessionNodeProps graphExplorerCpt :: R.Component SessionNodeProps
graphExplorerCpt = here.component "graphExplorer" cpt where graphExplorerCpt = here.component "graphExplorer" cpt where
cpt props@{ boxes: { backend, handed, route, sessions, showLogin } cpt props@{ boxes: { backend, handed, route, sessions, showLogin, tasks }
, nodeId , nodeId
, session , session } _ = do
, tasks } _ = do
let sessionProps = RE.pick props :: Record SessionProps let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $ pure $ authed sessionProps $
simpleLayout { handed } simpleLayout { handed }
...@@ -269,10 +269,10 @@ routeFile = R.createElement routeFileCpt ...@@ -269,10 +269,10 @@ routeFile = R.createElement routeFileCpt
routeFileCpt :: R.Component SessionNodeProps routeFileCpt :: R.Component SessionNodeProps
routeFileCpt = here.component "routeFile" cpt where routeFileCpt = here.component "routeFile" cpt where
cpt props@{ nodeId, session, sessionId, boxes, tasks } _ = do cpt props@{ nodeId, session, sessionId, boxes } _ = do
let sessionProps = RE.pick props :: Record SessionProps let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $ pure $ authed sessionProps $
forested { boxes, tasks } [ fileLayout { nodeId, session } ] forested { boxes } [ fileLayout { nodeId, session } ]
type RouteFrameProps = ( type RouteFrameProps = (
nodeType :: NodeType nodeType :: NodeType
...@@ -284,20 +284,20 @@ routeFrame = R.createElement routeFrameCpt ...@@ -284,20 +284,20 @@ routeFrame = R.createElement routeFrameCpt
routeFrameCpt :: R.Component RouteFrameProps routeFrameCpt :: R.Component RouteFrameProps
routeFrameCpt = here.component "routeFrame" cpt where routeFrameCpt = here.component "routeFrame" cpt where
cpt props@{ nodeId, nodeType, session, sessionId, boxes, tasks } _ = do cpt props@{ nodeId, nodeType, session, sessionId, boxes } _ = do
let sessionProps = RE.pick props :: Record SessionProps let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $ pure $ authed sessionProps $
forested { boxes, tasks } [ frameLayout { nodeId, nodeType, session } ] forested { boxes } [ frameLayout { nodeId, nodeType, session } ]
team :: R2.Component SessionNodeProps team :: R2.Component SessionNodeProps
team = R.createElement teamCpt team = R.createElement teamCpt
teamCpt :: R.Component SessionNodeProps teamCpt :: R.Component SessionNodeProps
teamCpt = here.component "team" cpt where teamCpt = here.component "team" cpt where
cpt props@{ nodeId, session, sessionId, boxes, tasks } _ = do cpt props@{ nodeId, session, sessionId, boxes } _ = do
let sessionProps = RE.pick props :: Record SessionProps let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $ pure $ authed sessionProps $
forested { boxes, tasks } [ corpusLayout { nodeId, session } ] forested { boxes } [ corpusLayout { nodeId, session } ]
texts :: R2.Component SessionNodeProps texts :: R2.Component SessionNodeProps
texts = R.createElement textsCpt texts = R.createElement textsCpt
...@@ -312,11 +312,11 @@ textsCpt = here.component "texts" cpt ...@@ -312,11 +312,11 @@ textsCpt = here.component "texts" cpt
, reloadRoot , reloadRoot
, route , route
, sessions , sessions
, showLogin } , showLogin
, tasks }
, nodeId , nodeId
, session , session
, sessionId , sessionId } _ = do
, tasks } _ = do
let sessionProps = RE.pick props :: Record SessionProps let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $ pure $ authed sessionProps $
Texts.textsWithForestSessionContext Texts.textsWithForestSessionContext
...@@ -342,14 +342,13 @@ user = R.createElement userCpt ...@@ -342,14 +342,13 @@ user = R.createElement userCpt
userCpt :: R.Component SessionNodeProps userCpt :: R.Component SessionNodeProps
userCpt = here.component "user" cpt where userCpt = here.component "user" cpt where
cpt props@{ boxes: boxes@{ reloadForest, reloadRoot } cpt props@{ boxes: boxes@{ reloadForest, reloadRoot, tasks }
, nodeId , nodeId
, session , session
, sessionId , sessionId } _ = do
, tasks } _ = do
let sessionProps = RE.pick props :: Record SessionProps let sessionProps = RE.pick props :: Record SessionProps
pure $ authed sessionProps $ pure $ authed sessionProps $
forested { boxes, tasks } forested { boxes }
[ userLayoutSessionContext { frontends [ userLayoutSessionContext { frontends
, nodeId , nodeId
, reloadForest , reloadForest
...@@ -365,8 +364,8 @@ contact = R.createElement contactCpt ...@@ -365,8 +364,8 @@ contact = R.createElement contactCpt
contactCpt :: R.Component ContactProps contactCpt :: R.Component ContactProps
contactCpt = here.component "contact" cpt where contactCpt = here.component "contact" cpt where
cpt props@{ annuaireId, nodeId, session, sessionId, tasks cpt props@{ annuaireId, nodeId, session, sessionId
, boxes: { reloadForest, reloadRoot } } _ = do , boxes: { reloadForest, reloadRoot, tasks } } _ = do
let sessionProps = RE.pick props :: Record SessionProps let sessionProps = RE.pick props :: Record SessionProps
let forestedProps = RE.pick props :: Record Props let forestedProps = RE.pick props :: Record Props
pure $ authed sessionProps $ pure $ authed sessionProps $
......
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