Commit 361bc8ca authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[ngrams] more asyncTasks refactoring

parent 48f62a98
......@@ -55,6 +55,7 @@ type ReductorProps = (
type Reductor = R2.Reductor (Record ReductorProps) Action
type ReductorAction = Action -> Effect Unit
type OnFinish = Effect Unit
useTasks :: R.State Int -> R.Hooks Reductor
useTasks reload = R2.useReductor act initializer unit
......@@ -67,6 +68,7 @@ useTasks reload = R2.useReductor act initializer unit
data Action =
Insert NodeId GT.AsyncTaskWithType
| Finish NodeId GT.AsyncTaskWithType OnFinish
| Remove NodeId GT.AsyncTaskWithType
action :: Record ReductorProps -> Action -> Effect (Record ReductorProps)
......@@ -74,6 +76,10 @@ action { reload, storage } (Insert nodeId t) = do
_ <- snd reload $ (_ + 1)
let newStorage = Map.alter (maybe (Just [t]) (\ts -> Just $ A.cons t ts)) nodeId storage
pure { reload, storage: newStorage }
action p@{ reload, storage } (Finish nodeId t onFinish) = do
ret <- action p (Remove nodeId t)
onFinish
pure ret
action { reload, storage } (Remove nodeId t) = do
_ <- snd reload $ (_ + 1)
let newStorage = Map.alter (maybe Nothing $ (\ts -> Just $ removeTaskFromList ts t)) nodeId storage
......
......@@ -57,7 +57,7 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
showLogin <- R.useState' false
backend <- R.useState' Nothing
treeReload <- R.useState' 0
reload <- R.useState' 0
showCorpus <- R.useState' false
......@@ -69,7 +69,7 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
, child
, frontends
, handed
, reload: treeReload
, reload
, route: fst route
, sessions: fst sessions
, showLogin: snd showLogin
......@@ -93,6 +93,7 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
Annuaire sid nodeId -> withSession sid $ \session -> forested $ annuaireLayout { frontends, nodeId, session }
ContactPage sid aId nodeId -> withSession sid $ \session -> forested $ annuaireUserLayout {
annuaireId: aId
, appReload: reload
, asyncTasksRef
, frontends
, nodeId
......@@ -110,7 +111,8 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
FolderShared sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
Home -> forested $ homeLayout { backend, lang:LL_EN, publicBackend, sessions, visible: showLogin }
Lists sid nodeId -> withSession sid $ \session -> forested $ listsLayout {
asyncTasksRef
appReload: reload
, asyncTasksRef
, nodeId
, session
, sessionUpdate
......@@ -129,7 +131,6 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
, session
, sessions: (fst sessions)
, showLogin
--, treeReload
}
RouteFile sid nodeId -> withSession sid $ \session -> forested $ fileLayout { nodeId, session }
RouteFrameCalc sid nodeId -> withSession sid $ \session -> forested $ frameLayout { nodeId, session, nodeType: GT.NodeFrameCalc }
......@@ -138,7 +139,8 @@ appCpt = R.hooksComponentWithModule thisModule "app" cpt where
Team sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { nodeId, session }
Texts sid nodeId -> withSession sid $ \session -> forested $ textsLayout { frontends, nodeId, session, sessionUpdate }
UserPage sid nodeId -> withSession sid $ \session -> forested $ userLayout {
asyncTasksRef
appReload: reload
, asyncTasksRef
, frontends
, nodeId
, session
......
......@@ -39,8 +39,8 @@ forestCpt :: R.Component Props
forestCpt = R.hooksComponentWithModule thisModule "forest" cpt where
cpt { asyncTasksRef, frontends, handed, reload: extReload, route, sessions, showLogin, backend} _ = do
-- NOTE: this is a hack to reload the tree view on demand
asyncTasks <- GAT.useTasks extReload
reload <- R.useState' (0 :: Reload)
asyncTasks <- GAT.useTasks reload
openNodes <- R2.useLocalStorageState R2.openNodesKey (Set.empty :: OpenNodes)
R.useEffect' $ do
......
......@@ -176,10 +176,6 @@ toHtmlCpt = R.hooksComponentWithModule thisModule "nodeView" cpt
, openNodes
, reload: reload@(_ /\ setReload)
, session
-- , tasks: tasks@{ onTaskAdd
-- , onTaskFinish
-- , tasks: tasks'
-- }
, tree: tree@(NTree (LNode { id
, name
, nodeType
......@@ -199,7 +195,8 @@ toHtmlCpt = R.hooksComponentWithModule thisModule "nodeView" cpt
let withId (NTree (LNode {id: id'}) _) = id'
pure $ H.li { className: if A.null ary then "no-children" else "with-children" } $
[ nodeMainSpan { asyncTasks
[ nodeMainSpan { appReload: reload
, asyncTasks
, dispatch: pAction
, folderOpen
, frontends
......@@ -288,7 +285,6 @@ performAction (DoSearch task) { asyncTasks: (_ /\ dispatch)
-------
performAction (UpdateNode params) { asyncTasks: (_ /\ dispatch)
, session
-- , tasks: {onTaskAdd}
, tree: (NTree (LNode {id}) _)
} =
do
......
......@@ -3,6 +3,7 @@ module Gargantext.Components.Forest.Tree.Node where
import Data.Array (reverse)
import Data.Maybe (Maybe(..))
import Data.Nullable (null)
import Data.Tuple (snd)
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff, launchAff)
import Effect.Class (liftEffect)
......@@ -40,8 +41,9 @@ thisModule = "Gargantext.Components.Forest.Tree.Node"
-- Main Node
type NodeMainSpanProps =
( asyncTasks :: GAT.Reductor
type NodeMainSpanProps = (
appReload :: R.State Int
, asyncTasks :: GAT.Reductor
, folderOpen :: R.State Boolean
, frontends :: Frontends
, id :: ID
......@@ -61,7 +63,8 @@ nodeMainSpan p = R.createElement nodeMainSpanCpt p []
nodeMainSpanCpt :: R.Component NodeMainSpanProps
nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt
where
cpt props@{ asyncTasks: (asyncTasks /\ dispatchAsyncTasks)
cpt props@{ appReload
, asyncTasks: (asyncTasks /\ dispatchAsyncTasks)
, dispatch
, folderOpen
, frontends
......@@ -104,7 +107,7 @@ nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt
, H.div {} (map (\t -> asyncProgressBar { asyncTask: t
, barType: Pie
, nodeId: id
, onFinish: const $ dispatchAsyncTasks $ GAT.Remove id t
, onFinish: onTaskFinish id t
, session
}
) $ GAT.getTasks asyncTasks id
......@@ -134,6 +137,9 @@ nodeMainSpanCpt = R.hooksComponentWithModule thisModule "nodeMainSpan" cpt
]
where
onTaskFinish id t _ = do
dispatchAsyncTasks $ GAT.Finish id t (snd appReload $ (_ + 1))
SettingsBox {show: showBox} = settingsBox nodeType
onPopoverClose popoverRef _ = Popover.setOpen popoverRef false
......
......@@ -24,6 +24,7 @@ import Gargantext.Utils (toggleSet)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.ReactTooltip as ReactTooltip
thisModule :: String
thisModule = "Gargantext.Components.Forest.Tree.Node.Tools"
------------------------------------------------------------------------
......@@ -246,16 +247,18 @@ checkboxes :: forall a
-> R.State (Set a)
-> R.Element
checkboxes xs (val /\ set) =
H.fieldset {} $ map (\a -> H.div {} [ H.input { type: "checkbox"
, checked: Set.member a val
, on: { click: \_ -> set
$ const
$ toggleSet a val
}
}
, H.div {} [H.text $ show a]
]
) xs
H.fieldset {} $ map (
\a -> H.div {} [
H.input { type: "checkbox"
, checked: Set.member a val
, on: { click: \_ -> set
$ const
$ toggleSet a val
}
}
, H.div {} [H.text $ show a]
]
) xs
prettyNodeType :: GT.NodeType -> String
......
module Gargantext.Components.Forest.Tree.Node.Tools.Task
where
import Data.Array as A
import Data.Map as Map
import Data.Maybe (Maybe(..), maybe)
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Reactix as R
import Gargantext.AsyncTasks as GAT
import Gargantext.Prelude (Unit, discard, identity, ($), (+))
import Gargantext.Types (Reload)
import Gargantext.Types as GT
type Tasks =
( onTaskAdd :: GT.AsyncTaskWithType -> Effect Unit
, onTaskFinish :: GT.AsyncTaskWithType -> Effect Unit
, tasks :: Array GT.AsyncTaskWithType
)
tasksStruct :: Int
-> GAT.Reductor
-> R.State Reload
-> Record Tasks
tasksStruct id ({ storage } /\ dispatch) (_ /\ setReload) =
{ onTaskAdd, onTaskFinish, tasks }
where
tasks = maybe [] identity $ Map.lookup id storage
onTaskAdd t = dispatch $ GAT.Insert id t
onTaskFinish t = dispatch $ GAT.Remove id t
......@@ -10,6 +10,7 @@ import Reactix as R
import Gargantext.Components.LoadingSpinner (loadingSpinner)
import Gargantext.Utils.Reactix as R2
thisModule :: String
thisModule = "Gargantext.Components.Loader"
type Props path loaded =
......
......@@ -31,6 +31,8 @@ import Reactix.DOM.HTML as H
import Record as Record
import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Prelude
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.AutoUpdate (autoUpdateElt)
import Gargantext.Hooks.Loader (useLoader)
......@@ -39,7 +41,6 @@ import Gargantext.Components.NgramsTable.Core
import Gargantext.Components.NgramsTable.Loader (useLoaderWithCacheAPI)
import Gargantext.Components.Nodes.Lists.Types as NT
import Gargantext.Components.Table as T
import Gargantext.Prelude (class Show, Unit, bind, const, discard, identity, map, mempty, not, pure, show, unit, (#), ($), (&&), (/=), (<$>), (<<<), (<>), (=<<), (==), (||), read, otherwise)
import Gargantext.Routes (SessionRoute(..)) as R
import Gargantext.Sessions (Session, get)
import Gargantext.Types (CTabNgramType, OrderBy(..), SearchQuery, TabType, TermList(..), TermSize, termLists, termSizes)
......@@ -279,7 +280,8 @@ tableContainerCpt { dispatch
-- NEXT
type Props = (
afterSync :: Unit -> Aff Unit
appReload :: R.State Int
, afterSync :: Unit -> Aff Unit
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, path :: R.State PageParams
, state :: R.State State
......@@ -295,6 +297,7 @@ loadedNgramsTableCpt :: R.Component Props
loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable" cpt
where
cpt { afterSync
, appReload
, asyncTasksRef
, path: path@(path'@{ listIds, nodeId, params, searchQuery, scoreType, termListFilter, termSizeFilter } /\ setPath)
, state: (state@{ ngramsChildren
......@@ -306,10 +309,12 @@ loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable"
, versioned: Versioned { data: initTable }
, withAutoUpdate } _ = do
let syncResetBtns = [syncResetButtons { afterSync: chartsAfterSync
, ngramsLocalPatch
, performAction: performAction <<< CoreAction
}]
let syncResetBtns = [
syncResetButtons { afterSync: chartsAfterSync
, ngramsLocalPatch
, performAction: performAction <<< CoreAction
}
]
pure $ R.fragment $
autoUpdate <> syncResetBtns <> [
......@@ -343,7 +348,9 @@ loadedNgramsTableCpt = R.hooksComponentWithModule thisModule "loadedNgramsTable"
log2 "[performAction] Synchronize task" task
case R.readRef asyncTasksRef of
Nothing -> log "[performAction] asyncTasksRef is Nothing"
Just asyncTasks -> snd asyncTasks $ GAT.Insert nodeId task
Just asyncTasks -> do
snd asyncTasks $ GAT.Insert nodeId task
snd appReload $ (_ + 1)
autoUpdate :: Array R.Element
autoUpdate = if withAutoUpdate then
......@@ -497,6 +504,7 @@ selectNgramsOnFirstPage rows = Set.fromFoldable $ (view $ _NgramsElement <<< _ng
type MainNgramsTableProps = (
afterSync :: Unit -> Aff Unit
, appReload :: R.State Int
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, cacheState :: R.State NT.CacheState
, defaultListId :: Int
......@@ -515,6 +523,7 @@ mainNgramsTableCpt :: R.Component MainNgramsTableProps
mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
where
cpt props@{ afterSync
, appReload
, asyncTasksRef
, cacheState
, defaultListId
......@@ -525,6 +534,7 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
, withAutoUpdate } _ = do
let path = initialPageParams session nodeId [defaultListId] tabType
let render versioned = mainNgramsTablePaint { afterSync
, appReload
, asyncTasksRef
, path
, tabNgramType
......@@ -589,6 +599,7 @@ mainNgramsTableCpt = R.hooksComponentWithModule thisModule "mainNgramsTable" cpt
type MainNgramsTablePaintProps = (
afterSync :: Unit -> Aff Unit
, appReload :: R.State Int
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, path :: PageParams
, tabNgramType :: CTabNgramType
......@@ -602,12 +613,13 @@ mainNgramsTablePaint p = R.createElement mainNgramsTablePaintCpt p []
mainNgramsTablePaintCpt :: R.Component MainNgramsTablePaintProps
mainNgramsTablePaintCpt = R.hooksComponentWithModule thisModule "mainNgramsTablePaint" cpt
where
cpt props@{ afterSync, asyncTasksRef, path, tabNgramType, versioned, withAutoUpdate } _ = do
cpt props@{ afterSync, appReload, asyncTasksRef, path, tabNgramType, versioned, withAutoUpdate } _ = do
pathS <- R.useState' path
state <- R.useState' $ initialState versioned
pure $ loadedNgramsTable {
afterSync
, appReload
, asyncTasksRef
, path: pathS
, state
......
......@@ -932,15 +932,10 @@ syncPatches props ({ ngramsLocalPatch: ngramsLocalPatch@{ ngramsPatches }
, ngramsVersion
} /\ setState) callback = do
when (isEmptyNgramsTablePatch ngramsStagePatch) $ do
-- setState $ \s ->
-- s { ngramsLocalPatch = fromNgramsPatches mempty
-- , ngramsStagePatch = ngramsLocalPatch
-- }
let pt = Versioned { data: ngramsPatches, version: ngramsVersion }
launchAff_ $ do
Versioned { data: newPatch, version: newVersion } <- putNgramsPatches props pt
callback unit
-- task <- postNgramsChartsAsync props
liftEffect $ do
log2 "[syncPatches] setting state, newVersion" newVersion
setState $ \s ->
......@@ -1090,20 +1085,24 @@ syncResetButtonsCpt = R.hooksComponentWithModule thisModule "syncResetButtons" c
let
hasChanges = ngramsLocalPatch /= mempty
hasChangesClass = if hasChanges then "" else " disabled"
newAfterSync x = do
afterSync x
liftEffect $ setSynchronizing $ const false
resetClick _ = do
performAction ResetPatches
synchronizeClick _ = delay unit $ \_ -> do
setSynchronizing $ const true
performAction $ Synchronize { afterSync: newAfterSync }
newAfterSync x = do
afterSync x
liftEffect $ setSynchronizing $ const false
pure $ H.div {} [
H.button { className: "btn btn-danger " <> if hasChanges then "" else " disabled"
, on: { click: \_ -> performAction ResetPatches }
H.button { className: "btn btn-danger " <> hasChangesClass
, on: { click: resetClick }
} [ H.text "Reset" ]
, H.button { className: "btn btn-primary " <> (if s || (not hasChanges) then "disabled" else "")
, H.button { className: "btn btn-primary " <> hasChangesClass
, on: { click: synchronizeClick }
} [ H.text "Sync" ]
]
......@@ -145,7 +145,8 @@ infoRender (Tuple title content) =
, H.span {} [H.text content] ]
type LayoutProps = (
asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
appReload :: R.State Int
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, frontends :: Frontends
, nodeId :: Int
, session :: Session
......@@ -162,10 +163,17 @@ userLayout props = R.createElement userLayoutCpt props []
userLayoutCpt :: R.Component LayoutProps
userLayoutCpt = R.hooksComponentWithModule thisModule "userLayout" cpt
where
cpt { asyncTasksRef, frontends, nodeId, session } _ = do
cpt { appReload, asyncTasksRef, frontends, nodeId, session } _ = do
let sid = sessionId session
pure $ userLayoutWithKey { asyncTasksRef, frontends, key: show sid <> "-" <> show nodeId, nodeId, session }
pure $ userLayoutWithKey {
appReload
, asyncTasksRef
, frontends
, key: show sid <> "-" <> show nodeId
, nodeId
, session
}
userLayoutWithKey :: Record KeyLayoutProps -> R.Element
userLayoutWithKey props = R.createElement userLayoutWithKeyCpt props []
......@@ -173,7 +181,7 @@ userLayoutWithKey props = R.createElement userLayoutWithKeyCpt props []
userLayoutWithKeyCpt :: R.Component KeyLayoutProps
userLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "userLayoutWithKey" cpt
where
cpt { asyncTasksRef, frontends, nodeId, session } _ = do
cpt { appReload, asyncTasksRef, frontends, nodeId, session } _ = do
reload <- R.useState' 0
cacheState <- R.useState' NT.CacheOn
......@@ -182,7 +190,15 @@ userLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "userLayoutWithKey"
\contactData@{contactNode: Contact {name, hyperdata}} ->
H.ul { className: "col-md-12 list-group" } [
display (fromMaybe "no name" name) (contactInfos hyperdata (onUpdateHyperdata reload))
, Tabs.tabs { asyncTasksRef, cacheState, contactData, frontends, nodeId, session }
, Tabs.tabs {
appReload
, asyncTasksRef
, cacheState
, contactData
, frontends
, nodeId
, session
}
]
where
onUpdateHyperdata :: R.State Int -> HyperdataUser -> Effect Unit
......@@ -224,14 +240,23 @@ annuaireUserLayout props = R.createElement annuaireUserLayoutCpt props []
annuaireUserLayoutCpt :: R.Component AnnuaireLayoutProps
annuaireUserLayoutCpt = R.hooksComponentWithModule thisModule "annuaireUserLayout" cpt
where
cpt { annuaireId, asyncTasksRef, frontends, nodeId, session } _ = do
cpt { annuaireId, appReload, asyncTasksRef, frontends, nodeId, session } _ = do
cacheState <- R.useState' NT.CacheOn
useLoader nodeId (getAnnuaireContact session annuaireId) $
\contactData@{contactNode: Contact {name, hyperdata}} ->
H.ul { className: "col-md-12 list-group" }
[ display (fromMaybe "no name" name) (contactInfos hyperdata onUpdateHyperdata)
, Tabs.tabs { asyncTasksRef, cacheState, contactData, frontends, nodeId, session } ]
H.ul { className: "col-md-12 list-group" } [
display (fromMaybe "no name" name) (contactInfos hyperdata onUpdateHyperdata)
, Tabs.tabs {
appReload
, asyncTasksRef
, cacheState
, contactData
, frontends
, nodeId
, session
}
]
where
onUpdateHyperdata :: HyperdataUser -> Effect Unit
......
......@@ -44,7 +44,8 @@ modeTabType' Books = CTabAuthors
modeTabType' Communication = CTabAuthors
type TabsProps = (
asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
appReload :: R.State Int
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, cacheState :: R.State NTypes.CacheState
, contactData :: ContactData
, frontends :: Frontends
......@@ -58,7 +59,7 @@ tabs props = R.createElement tabsCpt props []
tabsCpt :: R.Component TabsProps
tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
where
cpt { asyncTasksRef, cacheState, contactData: {defaultListId}, frontends, nodeId, session} _ = do
cpt { appReload, asyncTasksRef, cacheState, contactData: {defaultListId}, frontends, nodeId, session} _ = do
active <- R.useState' 0
pure $
Tab.tabs { selected: fst active, tabs: tabs' }
......@@ -71,9 +72,9 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
, "Trash" /\ docs -- TODO pass-in trash mode
]
where
patentsView = { asyncTasksRef, cacheState, defaultListId, mode: Patents, nodeId, session }
booksView = { asyncTasksRef, cacheState, defaultListId, mode: Books, nodeId, session }
commView = { asyncTasksRef, cacheState, defaultListId, mode: Communication, nodeId, session }
patentsView = { appReload, asyncTasksRef, cacheState, defaultListId, mode: Patents, nodeId, session }
booksView = { appReload, asyncTasksRef, cacheState, defaultListId, mode: Books, nodeId, session }
commView = { appReload, asyncTasksRef, cacheState, defaultListId, mode: Communication, nodeId, session }
chart = mempty
totalRecords = 4736 -- TODO
docs = DT.docViewLayout
......@@ -91,7 +92,8 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
type NgramsViewTabsProps = (
asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
appReload :: R.State Int
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, cacheState :: R.State NTypes.CacheState
, defaultListId :: Int
, mode :: Mode
......@@ -100,9 +102,10 @@ type NgramsViewTabsProps = (
)
ngramsView :: Record NgramsViewTabsProps -> R.Element
ngramsView { asyncTasksRef, cacheState, defaultListId, mode, nodeId, session } =
ngramsView { appReload, asyncTasksRef, cacheState, defaultListId, mode, nodeId, session } =
NT.mainNgramsTable {
afterSync: \_ -> pure unit
appReload
, afterSync: \_ -> pure unit
, asyncTasksRef
, cacheState
, defaultListId
......
......@@ -26,7 +26,8 @@ thisModule = "Gargantext.Components.Nodes.Lists"
------------------------------------------------------------------------
type Props = (
asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
appReload :: R.State Int
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, nodeId :: Int
, session :: Session
, sessionUpdate :: Session -> Effect Unit
......@@ -54,7 +55,7 @@ listsLayoutWithKey props = R.createElement listsLayoutWithKeyCpt props []
listsLayoutWithKeyCpt :: R.Component KeyProps
listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKey" cpt
where
cpt { asyncTasksRef, nodeId, session, sessionUpdate } _ = do
cpt { appReload, asyncTasksRef, nodeId, session, sessionUpdate } _ = do
let path = { nodeId, session }
cacheState <- R.useState' $ getCacheState NT.CacheOn session nodeId
......@@ -75,7 +76,8 @@ listsLayoutWithKeyCpt = R.hooksComponentWithModule thisModule "listsLayoutWithKe
, title: "Corpus " <> name
, user: authors }
, Tabs.tabs {
asyncTasksRef
appReload
, asyncTasksRef
, cacheState
, corpusData
, corpusId
......
......@@ -5,6 +5,7 @@ import Data.Tuple.Nested ((/\))
import Effect.Class (liftEffect)
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
import Gargantext.Prelude
......@@ -26,7 +27,8 @@ thisModule :: String
thisModule = "Gargantext.Components.Nodes.Lists.Tabs"
type Props = (
asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
appReload :: R.State Int
, asyncTasksRef :: R.Ref (Maybe GAT.Reductor)
, cacheState :: R.State NTypes.CacheState
, corpusData :: CorpusData
, corpusId :: Int
......@@ -44,7 +46,7 @@ tabs props = R.createElement tabsCpt props []
tabsCpt :: R.Component PropsWithKey
tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
where
cpt { asyncTasksRef, cacheState, corpusData: corpusData@{ defaultListId }, corpusId, session } _ = do
cpt { appReload, asyncTasksRef, cacheState, corpusData, corpusId, session } _ = do
(selected /\ setSelected) <- R.useState' 0
pure $ Tab.tabs { selected, tabs: tabs' }
......@@ -53,7 +55,7 @@ tabsCpt = R.hooksComponentWithModule thisModule "tabs" cpt
, "Institutes" /\ view Institutes
, "Sources" /\ view Sources
, "Terms" /\ view Terms ]
view mode = ngramsView { asyncTasksRef, cacheState, corpusData, corpusId, mode, session }
view mode = ngramsView { appReload, asyncTasksRef, cacheState, corpusData, corpusId, mode, session }
type NgramsViewProps = ( mode :: Mode | Props )
......@@ -63,7 +65,8 @@ ngramsView props = R.createElement ngramsViewCpt props []
ngramsViewCpt :: R.Component NgramsViewProps
ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
where
cpt { asyncTasksRef
cpt { appReload
, asyncTasksRef
, cacheState
, corpusData: { defaultListId }
, corpusId
......@@ -76,6 +79,7 @@ ngramsViewCpt = R.hooksComponentWithModule thisModule "ngramsView" cpt
pure $ R.fragment
( charts tabNgramType chartType chartsReload
<> [ NT.mainNgramsTable { afterSync: afterSync chartsReload
, appReload
, asyncTasksRef
, cacheState
, defaultListId
......
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