Commit 90b4eda6 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch 'dev' into testing

parents cb7c2849 57a17676
Pipeline #6166 failed with stages
in 2 minutes and 25 seconds
{ {
"name": "Gargantext", "name": "Gargantext",
"version": "0.0.7.1.5.2", "version": "0.0.7.1.5.3",
"scripts": { "scripts": {
"build": "spago build", "build": "spago build",
"bundle": "spago bundle --module Main --outfile dist/bundle.js", "bundle": "spago bundle --module Main --outfile dist/bundle.js",
......
...@@ -140,6 +140,12 @@ component = R.memo' $ R.hooksComponent componentName cpt where ...@@ -140,6 +140,12 @@ component = R.memo' $ R.hooksComponent componentName cpt where
then showModal window selector modalEvents then showModal window selector modalEvents
else hideModal window selector else hideModal window selector
-- | When box is true, show the modal immediately
R.useEffectOnce' $ do
if isVisible
then showModal window selector modalEvents
else hideModal window selector
-- | Behaviors -- | Behaviors
-- | -- |
let let
......
...@@ -88,6 +88,7 @@ componentCpt = here.component "breadcrumb" cpt where ...@@ -88,6 +88,7 @@ componentCpt = here.component "breadcrumb" cpt where
breadcrumbView { format: "default" breadcrumbView { format: "default"
, route: route' , route: route'
, session: session'' , session: session''
, openTreeNodes: true
} }
] ]
-- , -- ,
...@@ -141,9 +142,10 @@ componentCpt = here.component "breadcrumb" cpt where ...@@ -141,9 +142,10 @@ componentCpt = here.component "breadcrumb" cpt where
] ]
type BreadcrumbViewProps = type BreadcrumbViewProps =
( format :: String ( format :: String
, route :: AppRoute , route :: AppRoute
, session :: Session , session :: Session
, openTreeNodes :: Boolean
) )
...@@ -151,7 +153,7 @@ breadcrumbView :: R2.Leaf BreadcrumbViewProps ...@@ -151,7 +153,7 @@ breadcrumbView :: R2.Leaf BreadcrumbViewProps
breadcrumbView = R2.leaf breadcrumbViewCpt breadcrumbView = R2.leaf breadcrumbViewCpt
breadcrumbViewCpt :: R.Component BreadcrumbViewProps breadcrumbViewCpt :: R.Component BreadcrumbViewProps
breadcrumbViewCpt = R2.hereComponent here "breadcrumbViewCpt" hCpt where breadcrumbViewCpt = R2.hereComponent here "breadcrumbViewCpt" hCpt where
hCpt hp { format, route, session } _ = do hCpt hp { format, route, session, openTreeNodes } _ = do
useLoader { errorHandler: Nothing useLoader { errorHandler: Nothing
, herePrefix: hp , herePrefix: hp
...@@ -163,6 +165,7 @@ breadcrumbViewCpt = R2.hereComponent here "breadcrumbViewCpt" hCpt where ...@@ -163,6 +165,7 @@ breadcrumbViewCpt = R2.hereComponent here "breadcrumbViewCpt" hCpt where
, items , items
, session , session
-- , reload: reload -- , reload: reload
, openTreeNodes
} [] } []
} }
...@@ -171,16 +174,17 @@ type BreadcrumbViewMainProps = ...@@ -171,16 +174,17 @@ type BreadcrumbViewMainProps =
, items :: BreadcrumbInfo , items :: BreadcrumbInfo
, session :: Session , session :: Session
-- , reload :: T.Box T2.Reload -- , reload :: T.Box T2.Reload
, openTreeNodes :: Boolean
) )
breadcrumbViewMain :: R2.Component BreadcrumbViewMainProps breadcrumbViewMain :: R2.Component BreadcrumbViewMainProps
breadcrumbViewMain = R.createElement breadcrumbViewMainCpt breadcrumbViewMain = R.createElement breadcrumbViewMainCpt
breadcrumbViewMainCpt :: R.Component BreadcrumbViewMainProps breadcrumbViewMainCpt :: R.Component BreadcrumbViewMainProps
breadcrumbViewMainCpt = here.component "breadcrumbViewMainCpt" cpt where breadcrumbViewMainCpt = here.component "breadcrumbViewMainCpt" cpt where
cpt { items: { parents }, session, format } _ = do cpt { items: { parents }, session, format, openTreeNodes } _ = do
-- session' <- T.useLive T.unequal session -- session' <- T.useLive T.unequal session
let items = makeBreadcrumbElements parents session format let items = makeBreadcrumbElements parents session format openTreeNodes
-- case session of -- case session of
-- Nothing -> pure $ H.div {} [] -- Nothing -> pure $ H.div {} []
...@@ -190,8 +194,8 @@ breadcrumbViewMainCpt = here.component "breadcrumbViewMainCpt" cpt where ...@@ -190,8 +194,8 @@ breadcrumbViewMainCpt = here.component "breadcrumbViewMainCpt" cpt where
R.fragment items R.fragment items
makeBreadcrumbElements :: Array TreeNode -> Session -> String -> Array R.Element makeBreadcrumbElements :: Array TreeNode -> Session -> String -> Boolean -> Array R.Element
makeBreadcrumbElements items' session format = makeBreadcrumbElementsMap <$> items' where makeBreadcrumbElements items' session format openTreeNodes = makeBreadcrumbElementsMap <$> items' where
makeBreadcrumbElementsMap :: TreeNode -> R.Element makeBreadcrumbElementsMap :: TreeNode -> R.Element
makeBreadcrumbElementsMap node = breadcrumbItem { linkId: node.id makeBreadcrumbElementsMap node = breadcrumbItem { linkId: node.id
, linkNodeType: node.node_type , linkNodeType: node.node_type
...@@ -201,6 +205,7 @@ breadcrumbViewMainCpt = here.component "breadcrumbViewMainCpt" cpt where ...@@ -201,6 +205,7 @@ breadcrumbViewMainCpt = here.component "breadcrumbViewMainCpt" cpt where
-- , reload: props.reload -- , reload: props.reload
-- , style: FolderUp -- , style: FolderUp
, format: format , format: format
, openTreeNodes: openTreeNodes
} }
type BreadcrumbItemProps = type BreadcrumbItemProps =
...@@ -212,6 +217,7 @@ type BreadcrumbItemProps = ...@@ -212,6 +217,7 @@ type BreadcrumbItemProps =
-- , style :: FolderStyle -- , style :: FolderStyle
, text :: String , text :: String
, format :: String , format :: String
, openTreeNodes :: Boolean
) )
breadcrumbItem :: R2.Leaf BreadcrumbItemProps breadcrumbItem :: R2.Leaf BreadcrumbItemProps
...@@ -226,15 +232,21 @@ breadcrumbItemCpt = here.component "breadcrumbItemCpt" cpt where ...@@ -226,15 +232,21 @@ breadcrumbItemCpt = here.component "breadcrumbItemCpt" cpt where
-- , reload -- , reload
-- , style -- , style
, format , format
, openTreeNodes
} _ = do } _ = do
boxes@{ forestOpen } <- Store.use boxes@{ forestOpen } <- Store.use
boxes@{ route } <- Store.use
let sid = sessionId session let sid = sessionId session
let rootId = treeId session let rootId = treeId session
let currentNodeIdFromUrl = mkNodeId session linkId let currentNodeIdFromUrl = mkNodeId session linkId
-- R.unsafeHooksEffect $ T.modify_ (openNodesInsert (currentNodeIdFromUrl)) forestOpen if openTreeNodes then
R.unsafeHooksEffect $ T.modify_ (openNodesInsert (currentNodeIdFromUrl)) forestOpen
else
pure unit
pure $ pure $
......
...@@ -90,9 +90,13 @@ type NSCommon = ...@@ -90,9 +90,13 @@ type NSCommon =
, handed :: Handed , handed :: Handed
, session :: Session ) , session :: Session )
-- The annoying 'render' here is busting a cycle in the low tech -- | The annoying 'render' here is busting a cycle in the low tech
-- way. This function is only called by functions in this module, so -- way. This function is only called by functions in this module, so
-- we just have to careful in what we pass. -- we just have to careful in what we pass.
-- Without the 'render' function though, we get a 'tree' cpt that
-- depends on a 'renderTreeChildren' component, which itself depends
-- on 'tree'. This results in PS 'CycleInDeclaration' compilation
-- error.
type ChildLoaderProps = type ChildLoaderProps =
( id :: ID ( id :: ID
, render :: R2.Leaf TreeProps , render :: R2.Leaf TreeProps
...@@ -109,7 +113,6 @@ type PerformActionProps = ...@@ -109,7 +113,6 @@ type PerformActionProps =
-- | Loads and renders the tree starting at the given root node id. -- | Loads and renders the tree starting at the given root node id.
treeLoader :: R2.Leaf ( key :: String | LoaderProps ) treeLoader :: R2.Leaf ( key :: String | LoaderProps )
treeLoader = R2.leaf treeLoaderCpt treeLoader = R2.leaf treeLoaderCpt
treeLoaderCpt :: R.Component ( key :: String | LoaderProps ) treeLoaderCpt :: R.Component ( key :: String | LoaderProps )
treeLoaderCpt = R2.hereComponent here "treeLoader" hCpt where treeLoaderCpt = R2.hereComponent here "treeLoader" hCpt where
-- treeLoaderCpt :: R.Memo LoaderProps -- treeLoaderCpt :: R.Memo LoaderProps
...@@ -155,7 +158,6 @@ getNodeTreeFirstLevel session nodeId = get session $ GR.TreeFirstLevel (Just nod ...@@ -155,7 +158,6 @@ getNodeTreeFirstLevel session nodeId = get session $ GR.TreeFirstLevel (Just nod
tree :: R2.Leaf TreeProps tree :: R2.Leaf TreeProps
tree props = R.createElement treeCpt props [] tree props = R.createElement treeCpt props []
treeCpt :: R.Component TreeProps treeCpt :: R.Component TreeProps
treeCpt = here.component "tree" cpt where treeCpt = here.component "tree" cpt where
cpt p@{ frontends cpt p@{ frontends
...@@ -255,8 +257,42 @@ renderTreeChildrenCpt = here.component "renderTreeChildren" cpt where ...@@ -255,8 +257,42 @@ renderTreeChildrenCpt = here.component "renderTreeChildren" cpt where
where where
nodeProps = RecordE.pick p :: Record NodeProps nodeProps = RecordE.pick p :: Record NodeProps
renderChild (NTree (LNode {id: cId}) _) = childLoader props [] where -- | | If a child doesn't have children, avoid normal
props = Record.merge nodeProps { id: cId, render, root } -- | 'childLoader' which queries API for first-level data (there
-- | is nothing new here) and render the child immediately.
renderChild tree'@(NTree (LNode {id: cId}) []) = childDummyLoader renderProps []
where
renderProps = Record.merge nodeProps { id: cId, render, root, tree: tree' } :: Record ChildDummyLoaderProps
renderChild (NTree (LNode {id: cId}) _children) = childLoader renderProps []
where
renderProps = Record.merge nodeProps { id: cId, render, root } :: Record ChildLoaderProps
type ChildDummyLoaderProps =
( tree :: FTree
| ChildLoaderProps
)
-- | A "dummy" loader: this is because for nodes without children, we
-- | don't want to make the API call.
childDummyLoader :: R2.Component ChildDummyLoaderProps
childDummyLoader = R.createElement childDummyLoaderCpt
childDummyLoaderCpt :: R.Component ChildDummyLoaderProps
childDummyLoaderCpt = R2.hereComponent here "childDummyLoader" hCpt where
hCpt hp p@{ reloadTree
, render
, root
, tree: tree' } _ = do
{ reloadRoot } <- Store.use
reload <- T.useBox T2.newReload
pure $ paint reload tree'
where
paint reload tree' = render (Record.merge base extra) where
base = nodeProps { reload = reload }
extra = { root, tree: tree' }
nodeProps = RecordE.pick p :: Record NodeProps
childLoader :: R2.Component ChildLoaderProps childLoader :: R2.Component ChildLoaderProps
......
...@@ -31,6 +31,7 @@ import Gargantext.Components.Nodes.Corpus.Types (CorpusData) ...@@ -31,6 +31,7 @@ import Gargantext.Components.Nodes.Corpus.Types (CorpusData)
import Gargantext.Context.Progress (asyncContext, asyncProgress) import Gargantext.Context.Progress (asyncContext, asyncProgress)
import Gargantext.Ends (Frontends, url) import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoader) import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.UpdateEffect (useUpdateEffect1')
import Gargantext.Hooks.Version (Version, useVersion) import Gargantext.Hooks.Version (Version, useVersion)
import Gargantext.Routes as Routes import Gargantext.Routes as Routes
import Gargantext.Sessions (Session, sessionId) import Gargantext.Sessions (Session, sessionId)
...@@ -100,6 +101,19 @@ nodeSpanCpt = here.component "nodeSpan" cpt ...@@ -100,6 +101,19 @@ nodeSpanCpt = here.component "nodeSpan" cpt
folderOpen' <- R2.useLive' folderOpen folderOpen' <- R2.useLive' folderOpen
isBoxVisible' <- R2.useLive' isBoxVisible
isBoxVisiblePersist <- T.useBox isBoxVisible'
isBoxVisiblePersist' <- R2.useLive' isBoxVisiblePersist
-- | Modal not visible initially, but visible after first user
-- | click. This is to avoid modal loading initially
-- | (optimization for large trees), but persist it after user
-- | opens it.
useUpdateEffect1' isBoxVisible'
if isBoxVisible'
then T.write_ true isBoxVisiblePersist
else pure unit
-- tasks' <- T.read tasks -- tasks' <- T.read tasks
-- Computed -- Computed
...@@ -221,17 +235,17 @@ nodeSpanCpt = here.component "nodeSpan" cpt ...@@ -221,17 +235,17 @@ nodeSpanCpt = here.component "nodeSpan" cpt
-- // Abstract informations // -- // Abstract informations //
nodeTooltip -- nodeTooltip
{ id -- { id
, nodeType -- , nodeType
, name -- , name
} -- }
[ -- [
case mVersion of -- case mVersion of
Nothing -> mempty -- Nothing -> mempty
Just v -> versionComparator v -- Just v -> versionComparator v
] -- ]
, -- ,
R.createPortal R.createPortal
[ [
fileTypeView fileTypeView
...@@ -340,24 +354,25 @@ nodeSpanCpt = here.component "nodeSpan" cpt ...@@ -340,24 +354,25 @@ nodeSpanCpt = here.component "nodeSpan" cpt
-- // Modals // -- // Modals //
B.baseModal R2.when isBoxVisiblePersist' (
{ isVisibleBox: isBoxVisible B.baseModal
, noBody: true { isVisibleBox: isBoxVisible
, noHeader: true , noBody: true
, modalClassName: "forest-tree-node-modal" , noHeader: true
} , modalClassName: "forest-tree-node-modal"
[
nodePopupView
{ boxes
, closeCallback: \_ -> T.write_ false isBoxVisible
, dispatch
, id
, name
, nodeType
, session
} }
] [
] nodePopupView
{ boxes
, closeCallback: \_ -> T.write_ false isBoxVisible
, dispatch
, id
, name
, nodeType
, session
}
]
)
, ,
-- // Mainleaf indicator of selected node // -- // Mainleaf indicator of selected node //
-- --
...@@ -372,6 +387,7 @@ nodeSpanCpt = here.component "nodeSpan" cpt ...@@ -372,6 +387,7 @@ nodeSpanCpt = here.component "nodeSpan" cpt
{ className: "mainleaf-selection-indicator" } { className: "mainleaf-selection-indicator" }
[] []
] ]
]
--------------------------------------------------------- ---------------------------------------------------------
......
...@@ -359,7 +359,7 @@ renderBackendCpt = here.component "renderBackend" cpt where ...@@ -359,7 +359,7 @@ renderBackendCpt = here.component "renderBackend" cpt where
{} {}
[ [
B.icon B.icon
{ name: "database" { name: "server"
} }
] ]
, ,
......
...@@ -197,6 +197,7 @@ treeSearchRenderCpt = here.component "treeSearchRenderCpt" cpt where ...@@ -197,6 +197,7 @@ treeSearchRenderCpt = here.component "treeSearchRenderCpt" cpt where
, breadcrumbView { format: "text" , breadcrumbView { format: "text"
, route: getRouteFromSearchResult sd session , route: getRouteFromSearchResult sd session
, session , session
, openTreeNodes: false
} }
] ]
] ]
...@@ -220,6 +221,7 @@ treeSearchRenderCpt = here.component "treeSearchRenderCpt" cpt where ...@@ -220,6 +221,7 @@ treeSearchRenderCpt = here.component "treeSearchRenderCpt" cpt where
, breadcrumbView { format: "text" , breadcrumbView { format: "text"
, route: getRouteFromSearchResult sd session , route: getRouteFromSearchResult sd session
, session: session , session: session
, openTreeNodes: false
} }
] ]
] ]
......
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