Commit c10a6d14 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[boxes] refactoring of boxes

parent 4da3ef16
Pipeline #1716 canceled with stage
......@@ -15,7 +15,7 @@ import Gargantext.Routes (AppRoute(Home))
import Gargantext.Sessions (Session, Sessions)
import Gargantext.Sessions as Sessions
import Gargantext.Sessions.Types (OpenNodes(..))
import Gargantext.Types (FrontendError(..), Handed(RightHanded), SidePanelState(..))
import Gargantext.Types (FrontendError, Handed(RightHanded), SidePanelState(..))
import Gargantext.Utils.Toestand as T2
type App =
......
-- TODO: this module should be replaced by FacetsTable
module Gargantext.Components.DocsTable where
import Gargantext.Prelude
import DOM.Simple.Console (log2)
import DOM.Simple.Event as DE
import Data.Array as A
......@@ -21,6 +23,7 @@ import Data.Tuple (Tuple(..))
import Effect (Effect)
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.Category (rating)
import Gargantext.Components.Category.Types (Star(..))
import Gargantext.Components.DocsTable.Types (DocumentsView(..), Hyperdata(..), LocalUserScore, Query, Response(..), Year, sampleData)
......@@ -31,7 +34,6 @@ import Gargantext.Components.Table.Types as TT
import Gargantext.Config.REST (RESTError)
import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoader, useLoaderWithCacheAPI, HashedResponse(..))
import Gargantext.Prelude
import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Routes as Routes
import Gargantext.Sessions (Session, sessionId, get, delete)
......@@ -60,15 +62,14 @@ type Path a =
)
type CommonProps =
( cacheState :: T.Box NT.CacheState
, errors :: T.Box (Array FrontendError)
( boxes :: Boxes
, cacheState :: T.Box NT.CacheState
, frontends :: Frontends
, listId :: Int
, mCorpusId :: Maybe Int
, nodeId :: Int
, session :: Session
, sidePanel :: T.Box (Maybe (Record TextsT.SidePanel))
, sidePanelState :: T.Box SidePanelState
, tabType :: TabType
-- ^ tabType is not ideal here since it is too much entangled with tabs and
-- ngramtable. Let's see how this evolves. )
......@@ -77,16 +78,14 @@ type CommonProps =
)
type LayoutProps =
(
chart :: R.Element
( chart :: R.Element
, showSearch :: Boolean
| CommonProps
-- , path :: Record (Path a)
)
type PageLayoutProps =
(
key :: String -- NOTE Necessary to clear the component when cache state changes
( key :: String -- NOTE Necessary to clear the component when cache state changes
, params :: TT.Params
, query :: Query
| CommonProps
......@@ -115,9 +114,9 @@ docView :: R2.Component Props
docView = R.createElement docViewCpt
docViewCpt :: R.Component Props
docViewCpt = here.component "docView" cpt where
cpt { layout: { cacheState
cpt { layout: { boxes
, cacheState
, chart
, errors
, frontends
, listId
, mCorpusId
......@@ -125,7 +124,6 @@ docViewCpt = here.component "docView" cpt where
, session
, showSearch
, sidePanel
, sidePanelState
, tabType
, totalRecords
, yearFilter
......@@ -141,8 +139,8 @@ docViewCpt = here.component "docView" cpt where
[ chart
, if showSearch then searchBar { query } [] else H.div {} []
, H.div {className: "col-md-12"}
[ pageLayout { cacheState
, errors
[ pageLayout { boxes
, cacheState
, frontends
, key: "docView-" <> (show cacheState')
, listId
......@@ -152,7 +150,6 @@ docViewCpt = here.component "docView" cpt where
, query: query'
, session
, sidePanel
, sidePanelState
, tabType
, totalRecords
, yearFilter
......@@ -262,9 +259,8 @@ pageLayout :: R2.Component PageLayoutProps
pageLayout = R.createElement pageLayoutCpt
pageLayoutCpt :: R.Component PageLayoutProps
pageLayoutCpt = here.component "pageLayout" cpt where
cpt props@{ cacheState
, errors
, frontends
cpt props@{ boxes
, cacheState
, listId
, mCorpusId
, nodeId
......@@ -298,16 +294,16 @@ pageLayoutCpt = here.component "pageLayout" cpt where
case cacheState' of
NT.CacheOn -> do
let paint (Tuple count docs) = page { documents: docs
, errors
let paint (Tuple count docs) = page { boxes
, documents: docs
, layout: props { totalRecords = count }
, params } []
mkRequest :: PageParams -> GUC.Request
mkRequest p = GUC.makeGetRequest session $ tableRoute p
useLoaderWithCacheAPI {
cacheEndpoint: getPageHash session
, errors
useLoaderWithCacheAPI
{ boxes
, cacheEndpoint: getPageHash session
, handleResponse
, mkRequest
, path
......@@ -335,9 +331,9 @@ pageLayoutCpt = here.component "pageLayout" cpt where
, loader
, render }
type PageProps = (
documents :: Array DocumentsView
, errors :: T.Box (Array FrontendError)
type PageProps =
( boxes :: Boxes
, documents :: Array DocumentsView
, layout :: Record PageLayoutProps
, params :: TT.Params
)
......@@ -383,8 +379,8 @@ pagePaintCpt = here.component "pagePaintCpt" cpt
filteredRows params' = TT.filterRows { params: params' } $ (orderWith params') $ A.toUnfoldable documents
type PagePaintRawProps = (
documents :: Array DocumentsView
type PagePaintRawProps =
( documents :: Array DocumentsView
, layout :: Record PageLayoutProps
, localCategories :: T.Box LocalUserScore
, params :: T.Box TT.Params
......@@ -392,21 +388,19 @@ type PagePaintRawProps = (
pagePaintRaw :: R2.Component PagePaintRawProps
pagePaintRaw = R.createElement pagePaintRawCpt
pagePaintRawCpt :: R.Component PagePaintRawProps
pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where
cpt { documents
, layout: { frontends
, layout: { boxes
, frontends
, listId
, mCorpusId
, nodeId
, session
, sidePanel
, sidePanelState
, totalRecords }
, localCategories
, params } _ = do
reload <- T.useBox T2.newReload
mCurrentDocId <- T.useFocused
(maybe Nothing _.mCurrentDocId)
(\val -> maybe Nothing (\sp -> Just $ sp { mCurrentDocId = val })) sidePanel
......@@ -416,17 +410,15 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where
pure $ TT.table
{ colNames
, container: TT.defaultContainer { title: "Documents" }
, container: TT.defaultContainer
, params
, rows: rows reload localCategories' mCurrentDocId'
, rows: rows localCategories' mCurrentDocId'
, syncResetButton : [ H.div {} [] ]
, totalRecords
, wrapColElts
}
where
sid = sessionId session
gi Star_1 = "fa fa-star"
gi _ = "fa fa-star-empty"
trashClassName Star_0 _ = "trash"
trashClassName _ true = "active"
trashClassName _ false = ""
......@@ -435,18 +427,17 @@ 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 localCategories' mCurrentDocId' = row <$> A.toUnfoldable documents
where
row dv@(DocumentsView r@{ _id, category }) =
{ row:
TT.makeRow [ -- H.div {} [ H.a { className, style, on: {click: click Favorite} } [] ]
H.div { className: "" }
[ docChooser { listId
[ docChooser { boxes
, listId
, mCorpusId
, nodeId: r._id
, sidePanel
, sidePanelState
, tableReload: reload } []
, sidePanel } []
]
--, H.div { className: "column-tag flex" } [ caroussel { category: cat, nodeId, row: dv, session, setLocalCategories } [] ]
, H.div { className: "column-tag flex" }
......@@ -471,32 +462,28 @@ pagePaintRawCpt = here.component "pagePaintRawCpt" cpt where
-- checked = Star_1 == cat
selected = mCurrentDocId' == Just r._id
tClassName = trashClassName cat selected
className = gi cat
type DocChooser = (
listId :: ListId
boxes :: Boxes
, listId :: ListId
, mCorpusId :: Maybe NodeID
, nodeId :: NodeID
, sidePanel :: T.Box (Maybe (Record TextsT.SidePanel))
, sidePanelState :: T.Box SidePanelState
, tableReload :: T2.ReloadS
)
docChooser :: R2.Component DocChooser
docChooser = R.createElement docChooserCpt
docChooserCpt :: R.Component DocChooser
docChooserCpt = here.component "docChooser" cpt
where
cpt { mCorpusId: Nothing } _ = do
pure $ H.div {} []
cpt { listId
cpt { boxes: { sidePanelState }
, listId
, mCorpusId: Just corpusId
, nodeId
, sidePanel
, sidePanelState
, tableReload } _ = do
, sidePanel } _ = do
mCurrentDocId <- T.useFocused
(maybe Nothing _.mCurrentDocId)
(\val -> maybe Nothing (\sp -> Just $ sp { mCurrentDocId = val })) sidePanel
......
module Gargantext.Components.FolderView where
import Control.Monad.Error.Class (throwError)
import Data.Array as A
import Data.Either (Either(..))
import Data.Either (Either)
import Data.Maybe (Maybe(..), fromMaybe)
import Data.Nullable (null)
import Data.Traversable (traverse_)
import Effect (Effect)
import Effect.Aff (Aff, error)
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action.Add (AddNodeValue(..), addNode)
import Gargantext.Components.Forest.Tree.Node.Action.Contact as Contact
......@@ -30,7 +30,7 @@ import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Prelude (Ordering, Unit, bind, compare, discard, pure, unit, void, ($), (<$>), (<>))
import Gargantext.Routes (AppRoute(Home), SessionRoute(..), appPath, nodeTypeAppRoute)
import Gargantext.Sessions (Session, get, sessionId)
import Gargantext.Types (FrontendError, NodeType(..))
import Gargantext.Types (NodeType(..))
import Gargantext.Types as GT
import Gargantext.Utils.Popover as Popover
import Gargantext.Utils.Reactix as R2
......@@ -47,12 +47,10 @@ here :: R2.Here
here = R2.here "Gargantext.Components.FolderView"
type Props =
( backFolder :: Boolean
, errors :: T.Box (Array FrontendError)
, nodeId :: Int
, reloadForest :: T.Box T2.Reload
, session :: Session
, tasks :: T.Box GAT.Storage
( backFolder :: Boolean
, boxes :: Boxes
, nodeId :: Int
, session :: Session
)
data FolderStyle = FolderUp | FolderChild
......@@ -61,7 +59,7 @@ folderView :: R2.Leaf Props
folderView props = R.createElement folderViewCpt props []
folderViewCpt :: R.Component Props
folderViewCpt = here.component "folderViewCpt" cpt where
cpt { errors, nodeId, session, backFolder, tasks, reloadForest } _ = do
cpt { backFolder, boxes, nodeId, session } _ = do
setPopoverRef <- R.useRef Nothing
reload <- T.useBox T2.newReload
reload' <- T.useLive T.unequal reload
......@@ -69,27 +67,23 @@ folderViewCpt = here.component "folderViewCpt" cpt where
, loader: loadFolders
, path: { nodeId, session, reload: reload'}
, render: \folders -> folderViewMain { backFolder
, errors
, boxes
, folders
, nodeId
, session
, tasks
, reload
, setPopoverRef
, reloadForest} }
, setPopoverRef } }
where
errorHandler err = here.log2 "[folderView] RESTError" err
type FolderViewProps =
( backFolder :: Boolean
, errors :: T.Box (Array FrontendError)
, boxes :: Boxes
, folders :: FTree
, nodeId :: Int
, reload :: T.Box T2.Reload
, reloadForest :: T.Box T2.Reload
, session :: Session
, setPopoverRef :: R.Ref (Maybe (Boolean -> Effect Unit))
, tasks :: T.Box GAT.Storage
)
folderViewMain :: Record FolderViewProps -> R.Element
......@@ -97,30 +91,26 @@ folderViewMain props = R.createElement folderViewMainCpt props []
folderViewMainCpt :: R.Component FolderViewProps
folderViewMainCpt = here.component "folderViewMainCpt" cpt where
cpt { backFolder
, errors
, boxes
, folders: NTree (LNode {parent_id: parentId, nodeType}) (folders)
, nodeId
, reload
, reloadForest
, session
, setPopoverRef
, tasks } _ = do
, setPopoverRef } _ = do
let foldersS = A.sortBy sortFolders folders
let backHome = isBackHome nodeType
let parent = makeParentFolder parentId session backFolder backHome
let children = makeFolderElements foldersS { errors, session, setPopoverRef, nodeId, tasks, reload, reloadForest }
let children = makeFolderElements foldersS { boxes, nodeId, reload, session, setPopoverRef }
pure $ H.div {className: "fv folders"} $ parent <> children
makeFolderElements foldersS props = makeFolderElementsMap <$> foldersS where
makeFolderElementsMap :: NTree LNode -> R.Element
makeFolderElementsMap (NTree (LNode node) _) = folder { errors: props.errors
makeFolderElementsMap (NTree (LNode node) _) = folder { boxes: props.boxes
, nodeId: node.id
, nodeType: node.nodeType
, parentId: props.nodeId
, tasks: props.tasks
, reload: props.reload
, reloadForest: props.reloadForest
, session: props.session
, setPopoverRef: props.setPopoverRef
, style: FolderChild
......@@ -180,12 +170,10 @@ folderSimpleCpt = here.component "folderSimpleCpt" cpt where
getFolderPath nodeType sid nodeId = appPath $ fromMaybe Home $ nodeTypeAppRoute nodeType sid nodeId
type FolderProps =
( errors :: T.Box (Array FrontendError)
( boxes :: Boxes
, parentId :: Int
, reload :: T.Box T2.Reload
, reloadForest :: T.Box T2.Reload
, setPopoverRef :: R.Ref (Maybe (Boolean -> Effect Unit))
, tasks :: T.Box GAT.Storage
| FolderSimpleProps
)
......@@ -193,9 +181,17 @@ folder :: R2.Component FolderProps
folder = R.createElement folderCpt
folderCpt :: R.Component FolderProps
folderCpt = here.component "folderCpt" cpt where
cpt props@{ errors, style, text, nodeId, session, nodeType, setPopoverRef, parentId, tasks, reload, reloadForest } _ = do
cpt props@{ boxes
, nodeId
, nodeType
, parentId
, reload
, session
, setPopoverRef
, style
, text } _ = do
let sid = sessionId session
let dispatch a = performAction a { errors, nodeId, parentId, tasks, reload, reloadForest, session, setPopoverRef }
let dispatch a = performAction a { boxes, nodeId, parentId, reload, session, setPopoverRef }
popoverRef <- R.useRef null
R.useEffect' $ do
......@@ -211,7 +207,7 @@ folderCpt = here.component "folderCpt" cpt where
, ref: popoverRef
} [
popOverIcon
, mNodePopupView (Record.merge props {dispatch}) (onPopoverClose popoverRef)
, mNodePopupView (Record.merge props { dispatch }) (onPopoverClose popoverRef)
]]
, H.button {on: {click: link ("/#/" <> getFolderPath nodeType sid nodeId) }, className: "btn btn-primary fv btn" } [
H.i {className: icon style nodeType} []
......@@ -234,14 +230,13 @@ folderCpt = here.component "folderCpt" cpt where
<> "Click here to execute one of them." } []
]
mNodePopupView props opc = nodePopupView { dispatch: props.dispatch
, errors: props.errors
mNodePopupView props opc = nodePopupView { boxes: props.boxes
, dispatch: props.dispatch
, id: props.nodeId
, onPopoverClose: opc
, nodeType: props.nodeType
, name: props.text
, session: props.session
, handed: GT.RightHanded
}
backButton :: R.Element
......@@ -273,14 +268,12 @@ loadFolders :: Record LoadProps -> Aff (Either RESTError FTree)
loadFolders {nodeId, session} = get session $ TreeFirstLevel (Just nodeId) ""
type PerformActionProps =
( errors :: T.Box (Array FrontendError)
( boxes :: Boxes
, nodeId :: Int
, parentId :: Int
, reload :: T.Box T2.Reload
, reloadForest :: T.Box T2.Reload
, setPopoverRef :: R.Ref (Maybe (Boolean -> Effect Unit))
, session :: Session
, tasks :: T.Box GAT.Storage
)
performAction :: Action -> Record PerformActionProps -> Aff Unit
......@@ -306,77 +299,77 @@ performAction = performAction' where
closePopover { setPopoverRef } =
liftEffect $ traverse_ (\set -> set false) (R.readRef setPopoverRef)
refreshFolders p = do
liftEffect $ T2.reload p.reload
liftEffect $ T2.reload p.reloadForest
refreshFolders p@{ boxes: { reloadForest }, reload } = do
liftEffect $ T2.reload reload
liftEffect $ T2.reload reloadForest
closePopover p
deleteNode' nt p@{ nodeId: id, parentId: parent_id } = do
deleteNode' nt p@{ nodeId: id, parentId: parent_id, session } = do
case nt of
NodePublic FolderPublic -> void $ deleteNode p.session nt id
NodePublic _ -> void $ unpublishNode p.session (Just parent_id) id
_ -> void $ deleteNode p.session nt id
NodePublic FolderPublic -> void $ deleteNode session nt id
NodePublic _ -> void $ unpublishNode session (Just parent_id) id
_ -> void $ deleteNode session nt id
refreshFolders p
doSearch task { tasks, nodeId: id } = liftEffect $ do
doSearch task { boxes: { tasks }, nodeId: id } = liftEffect $ do
GAT.insert id task tasks
here.log2 "[performAction] DoSearch task:" task
updateNode params p@{ errors, tasks, nodeId: id } = do
eTask <- updateRequest params p.session id
updateNode params { boxes: { errors, tasks }, nodeId: id, session } = do
eTask <- updateRequest params session id
handleRESTError errors eTask $ \task -> liftEffect $ do
GAT.insert id task tasks
here.log2 "[performAction] UpdateNode task:" task
shareTeam username p@{ errors, nodeId: id} = do
eTask <- Share.shareReq p.session id $ Share.ShareTeamParams {username}
shareTeam username { boxes: { errors }, nodeId: id, session } = do
eTask <- Share.shareReq session id $ Share.ShareTeamParams { username }
handleRESTError errors eTask $ \_task -> pure unit
sharePublic params p@{ errors } = traverse_ f params where
sharePublic params p@{ boxes: { errors }, session } = traverse_ f params where
f (SubTreeOut { in: inId, out }) = do
eTask <- Share.shareReq p.session inId $ Share.SharePublicParams { node_id: out }
eTask <- Share.shareReq session inId $ Share.SharePublicParams { node_id: out }
handleRESTError errors eTask $ \_task -> pure unit
refreshFolders p
addContact params p@{ nodeId: id } =
void $ Contact.contactReq p.session id params
addContact params { nodeId: id, session } =
void $ Contact.contactReq session id params
uploadFile' nodeType fileType mName contents p@{ errors, tasks, nodeId: id } = do
eTask <- uploadFile { contents, fileType, id, nodeType, mName, session: p.session }
uploadFile' nodeType fileType mName contents { boxes: { errors, tasks }, nodeId: id, session } = do
eTask <- uploadFile { contents, fileType, id, nodeType, mName, session }
handleRESTError errors eTask $ \task -> liftEffect $ do
GAT.insert id task tasks
here.log2 "[performAction] UploadFile, uploaded, task:" task
uploadArbitraryFile' mName blob p@{ errors, tasks, nodeId: id } = do
eTask <- uploadArbitraryFile p.session id { blob, mName }
uploadArbitraryFile' mName blob { boxes: { errors, tasks }, nodeId: id, session } = do
eTask <- uploadArbitraryFile session id { blob, mName }
handleRESTError errors eTask $ \task -> liftEffect $ do
GAT.insert id task tasks
here.log2 "[performAction] UploadArbitraryFile, uploaded, task:" task
moveNode params p@{ errors } = traverse_ f params where
moveNode params p@{ boxes: { errors }, session } = traverse_ f params where
f (SubTreeOut { in: in', out }) = do
eTask <- moveNodeReq p.session in' out
eTask <- moveNodeReq session in' out
handleRESTError errors eTask $ \_task -> pure unit
refreshFolders p
mergeNode params p@{ errors } = traverse_ f params where
mergeNode params p@{ boxes: { errors }, session } = traverse_ f params where
f (SubTreeOut { in: in', out }) = do
eTask <- mergeNodeReq p.session in' out
eTask <- mergeNodeReq session in' out
handleRESTError errors eTask $ \_task -> pure unit
refreshFolders p
linkNode nodeType params p@{ errors } = traverse_ f params where
linkNode nodeType params p@{ boxes: { errors }, session } = traverse_ f params where
f (SubTreeOut { in: in', out }) = do
eTask <- linkNodeReq p.session nodeType in' out
eTask <- linkNodeReq session nodeType in' out
handleRESTError errors eTask $ \_task -> pure unit
refreshFolders p
renameNode name p@{ errors, nodeId: id } = do
eTask <- rename p.session id $ RenameValue { text: name }
renameNode name p@{ boxes: { errors }, nodeId: id, session } = do
eTask <- rename session id $ RenameValue { text: name }
handleRESTError errors eTask $ \_task -> pure unit
refreshFolders p
addNode' name nodeType p@{ errors, nodeId: id } = do
eTask <- addNode p.session id $ AddNodeValue {name, nodeType}
addNode' name nodeType p@{ boxes: { errors }, nodeId: id, session } = do
eTask <- addNode session id $ AddNodeValue {name, nodeType}
handleRESTError errors eTask $ \_task -> pure unit
refreshFolders p
module Gargantext.Components.Forest
( forest
, forestLayout
, Common
, Props
) where
......@@ -9,62 +8,33 @@ import Gargantext.Prelude
import Data.Array as A
import Data.Maybe (Maybe(..))
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.Forest.Tree (treeLoader)
import Gargantext.Ends (Frontends, Backend)
import Gargantext.Routes (AppRoute)
import Gargantext.Sessions (Session(..), Sessions, OpenNodes, unSessions)
import Gargantext.Types (FrontendError, Handed, switchHanded)
import Gargantext.Ends (Frontends)
import Gargantext.Sessions (Session(..), unSessions)
import Gargantext.Types (switchHanded)
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
import Reactix as R
import Reactix.DOM.HTML as H
import Record.Extra as RX
import Toestand as T
here :: R2.Here
here = R2.here "Gargantext.Components.Forest"
-- Shared by components here with Tree
type Common =
( frontends :: Frontends
, handed :: T.Box Handed
, reloadMainPage :: T2.ReloadS
, reloadRoot :: T2.ReloadS
, route :: T.Box AppRoute
)
type Props =
( backend :: T.Box (Maybe Backend)
, errors :: T.Box (Array FrontendError)
, forestOpen :: T.Box OpenNodes
, reloadForest :: T2.ReloadS
, sessions :: T.Box Sessions
, showLogin :: T.Box Boolean
, tasks :: T.Box GAT.Storage
| Common
)
type TreeExtra = (
forestOpen :: T.Box OpenNodes
( boxes :: Boxes
, frontends :: Frontends
)
forest :: R2.Component Props
forest = R.createElement forestCpt
forestCpt :: R.Component Props
forestCpt = here.component "forest" cpt where
cpt props@{ backend
, errors
, forestOpen
, frontends
, handed
, reloadForest
, reloadMainPage
, reloadRoot
, route
, sessions
, showLogin
, tasks } _ = do
cpt { boxes: boxes@{ handed
, reloadForest
, sessions }
, frontends } _ = do
-- TODO Fix this. I think tasks shouldn't be a Box but only a Reductor
-- tasks' <- GAT.useTasks reloadRoot reloadForest
-- R.useEffect' $ do
......@@ -78,33 +48,24 @@ forestCpt = here.component "forest" cpt where
-- TODO If `reloadForest` is set, `reload` state should be updated
-- TODO fix tasks ref
pure $ H.div { className: "forest-layout-content" }
(A.cons (plus { backend, handed, showLogin }) (trees handed' sessions'))
(A.cons (plus { boxes }) (trees handed' sessions'))
where
common = RX.pick props :: Record Common
trees handed' sessions' = (tree handed') <$> unSessions sessions'
tree handed' s@(Session {treeId}) =
treeLoader { errors
, forestOpen
tree handed' s@(Session { treeId }) =
treeLoader { boxes
, frontends
, handed: handed'
, reload: reloadForest
, reloadMainPage
, reloadRoot
, root: treeId
, route
, session: s
, tasks } []
, session: s } []
type Plus =
( backend :: T.Box (Maybe Backend)
, handed :: T.Box Handed
, showLogin :: T.Box Boolean )
type Plus = ( boxes :: Boxes )
plus :: R2.Leaf Plus
plus p = R.createElement plusCpt p []
plusCpt :: R.Component Plus
plusCpt = here.component "plus" cpt where
cpt { backend, handed, showLogin } _ = do
cpt { boxes: { backend, handed, showLogin } } _ = do
handed' <- T.useLive T.unequal handed
pure $ H.div {}
......
......@@ -10,6 +10,7 @@ import Effect (Effect)
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.Forest.Tree.Node (nodeSpan)
import Gargantext.Components.Forest.Tree.Node.Action (Action(..))
import Gargantext.Components.Forest.Tree.Node.Action.Add (AddNodeValue(..), addNode)
......@@ -28,11 +29,10 @@ import Gargantext.Config.REST (RESTError)
import Gargantext.Config.Utils (handleRESTError)
import Gargantext.Ends (Frontends)
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Routes (AppRoute)
import Gargantext.Routes as GR
import Gargantext.Sessions (OpenNodes, Session, get, mkNodeId)
import Gargantext.Sessions (Session, get, mkNodeId)
import Gargantext.Sessions.Types (useOpenNodesMemberBox, openNodesInsert, openNodesDelete)
import Gargantext.Types (FrontendError, Handed, ID, isPublic, publicize, switchHanded)
import Gargantext.Types (Handed, ID, isPublic, publicize, switchHanded)
import Gargantext.Types as GT
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
......@@ -45,28 +45,59 @@ import Toestand as T
here :: R2.Here
here = R2.here "Gargantext.Components.Forest.Tree"
-- Shared by every component here + performAction + nodeSpan
type Universal =
( reloadMainPage :: T2.ReloadS
, reloadRoot :: T2.ReloadS )
-- Shared by every component here
type Common =
( boxes :: Boxes
, frontends :: Frontends
, handed :: Handed
, reload :: T2.ReloadS
)
type LoaderProps =
( root :: ID
, session :: Session
| Common )
type NodeProps =
( reloadTree :: T2.ReloadS
, session :: Session
| Common )
type TreeProps =
( tree :: FTree
| NodeProps )
type ChildrenTreeProps =
( childProps :: { children' :: Array FTree
, folderOpen :: T.Box Boolean
, render :: R2.Leaf TreeProps }
| TreeProps )
--- The properties tree shares in common with performAction
type PACommon =
( boxes :: Boxes
, reloadTree :: T2.ReloadS
, session :: Session
, tree :: FTree
)
-- Shared by every component here + nodeSpan
type Global =
-- The properties tree shares in common with nodeSpan
type NSCommon =
( frontends :: Frontends