Commit c039b417 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch '296-dev-tree-refresh-from-folders' of...

Merge branch '296-dev-tree-refresh-from-folders' of ssh://gitlab.iscpif.fr:20022/gargantext/purescript-gargantext into dev-merge
parents 63180be3 d2a24e7f
Pipeline #1538 failed with stage
......@@ -48,6 +48,7 @@ type Props =
, session :: Session
, backFolder :: Boolean
, tasks :: T.Box GAT.Storage
, reloadForest :: T.Box T2.Reload
)
data FolderStyle = FolderUp | FolderChild
......@@ -57,12 +58,12 @@ folderView props = R.createElement folderViewCpt props []
folderViewCpt :: R.Component Props
folderViewCpt = here.component "folderViewCpt" cpt where
cpt {nodeId, session, backFolder, tasks} _ = do
cpt {nodeId, session, backFolder, tasks, reloadForest} _ = do
setPopoverRef <- R.useRef Nothing
reload <- T.useBox T2.newReload
reload' <- T.useLive T.unequal reload
useLoader { nodeId, session, reload: reload'} loadFolders $
\folders -> folderViewMain {folders, nodeId, session, backFolder, tasks, reload, setPopoverRef}
\folders -> folderViewMain {folders, nodeId, session, backFolder, tasks, reload, setPopoverRef, reloadForest}
type FolderViewProps =
(
......@@ -72,6 +73,7 @@ type FolderViewProps =
, backFolder :: Boolean
, tasks :: T.Box GAT.Storage
, reload :: T.Box T2.Reload
, reloadForest :: T.Box T2.Reload
, setPopoverRef :: R.Ref (Maybe (Boolean -> Effect Unit))
)
......@@ -80,11 +82,11 @@ folderViewMain props = R.createElement folderViewMainCpt props []
folderViewMainCpt :: R.Component FolderViewProps
folderViewMainCpt = here.component "folderViewMainCpt" cpt where
cpt {nodeId, session, backFolder, tasks, setPopoverRef, reload, folders: tree@(NTree (LNode {parent_id: parentId, nodeType}) (folders))} _ = do
cpt {nodeId, session, backFolder, tasks, setPopoverRef, reload, reloadForest, folders: tree@(NTree (LNode {parent_id: parentId, nodeType}) (folders))} _ = do
let foldersS = A.sortBy sortFolders folders
let backHome = isBackHome nodeType
let parent = makeParentFolder parentId session backFolder backHome
let children = makeFolderElements foldersS {session, setPopoverRef, nodeId, tasks, reload}
let children = makeFolderElements foldersS {session, setPopoverRef, nodeId, tasks, reload, reloadForest}
pure $ H.div {className: "fv folders"} $ parent <> children
......@@ -98,7 +100,8 @@ folderViewMainCpt = here.component "folderViewMainCpt" cpt where
, setPopoverRef: props.setPopoverRef
, parentId: props.nodeId
, tasks: props.tasks
, reload: props.reload} []
, reload: props.reload
, reloadForest: props.reloadForest} []
makeParentFolder :: Maybe Int -> Session -> Boolean -> Boolean -> Array R.Element
makeParentFolder (Just parentId) session _ _ =
......@@ -159,6 +162,7 @@ type FolderProps =
, parentId :: Int
, tasks :: T.Box GAT.Storage
, reload :: T.Box T2.Reload
, reloadForest :: T.Box T2.Reload
| FolderSimpleProps
)
......@@ -167,9 +171,9 @@ folder = R.createElement folderCpt
folderCpt :: R.Component FolderProps
folderCpt = here.component "folderCpt" cpt where
cpt props@{style, text, nodeId, session, nodeType, setPopoverRef, parentId, tasks, reload} _ = do
cpt props@{style, text, nodeId, session, nodeType, setPopoverRef, parentId, tasks, reload, reloadForest} _ = do
let sid = sessionId session
let dispatch a = performAction a {setPopoverRef, session, nodeId, parentId, tasks, reload}
let dispatch a = performAction a {setPopoverRef, session, nodeId, parentId, tasks, reload, reloadForest}
popoverRef <- R.useRef null
R.useEffect' $ do
......@@ -253,6 +257,7 @@ type PerformActionProps =
, parentId :: Int
, tasks :: T.Box GAT.Storage
, reload :: T.Box T2.Reload
, reloadForest :: T.Box T2.Reload
)
performAction :: Action -> Record PerformActionProps -> Aff Unit
......@@ -280,6 +285,7 @@ performAction = performAction' where
refreshFolders p = do
liftEffect $ T2.reload p.reload
liftEffect $ T2.reload p.reloadForest
closePopover p
deleteNode' nt p@{ nodeId: id, parentId: parent_id } = do
......
......@@ -15,9 +15,9 @@ import Effect (Effect)
import Effect.Aff (Aff, launchAff_, throwError)
import Effect.Class (liftEffect)
import Effect.Exception (error)
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.CodeEditor as CE
import Gargantext.Components.FolderView as FV
import Gargantext.AsyncTasks as GAT
import Gargantext.Components.InputWithEnter (inputWithEnter)
import Gargantext.Components.Node (NodePoly(..), HyperdataList)
import Gargantext.Components.Nodes.Corpus.Types (CorpusData, Hyperdata(..))
......@@ -38,15 +38,15 @@ import Toestand as T
here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Corpus"
type Props = ( nodeId :: Int, session :: Session, tasks :: T.Box GAT.Storage )
type Props = ( nodeId :: Int, session :: Session, tasks :: T.Box GAT.Storage, reloadForest :: T2.ReloadS )
corpusLayout :: R2.Leaf Props
corpusLayout props = R.createElement corpusLayoutCpt props []
corpusLayoutCpt :: R.Component Props
corpusLayoutCpt = here.component "corpusLayout" cpt where
cpt { nodeId, session, tasks } _ = do
pure $ corpusLayoutMain { key, nodeId, session, tasks }
cpt { nodeId, session, tasks, reloadForest } _ = do
pure $ corpusLayoutMain { key, nodeId, session, tasks, reloadForest }
where
key = show (sessionId session) <> "-" <> show nodeId
......@@ -55,6 +55,7 @@ type KeyProps =
, key :: String
, session :: Session
, tasks :: T.Box GAT.Storage
, reloadForest :: T2.ReloadS
)
corpusLayoutMain :: R2.Leaf KeyProps
......@@ -63,7 +64,7 @@ corpusLayoutMain props = R.createElement corpusLayoutMainCpt props []
corpusLayoutMainCpt :: R.Component KeyProps
corpusLayoutMainCpt = here.component "corpusLayoutMain" cpt
where
cpt { nodeId, key, session, tasks } _ = do
cpt { nodeId, key, session, tasks, reloadForest } _ = do
viewType <- T.useBox Folders
pure $ H.div {} [
......@@ -73,7 +74,7 @@ corpusLayoutMainCpt = here.component "corpusLayoutMain" cpt
, H.div { className: "col-1" } [ FV.homeButton ]
]
]
, H.div {} [corpusLayoutSelection {state: viewType, key, session, nodeId, tasks}]
, H.div {} [corpusLayoutSelection {state: viewType, key, session, nodeId, tasks, reloadForest}]
]
type SelectionProps =
......@@ -82,6 +83,7 @@ type SelectionProps =
, session :: Session
, state :: T.Box ViewType
, tasks :: T.Box GAT.Storage
, reloadForest :: T2.ReloadS
)
corpusLayoutSelection :: R2.Leaf SelectionProps
......@@ -89,14 +91,14 @@ corpusLayoutSelection props = R.createElement corpusLayoutSelectionCpt props []
corpusLayoutSelectionCpt :: R.Component SelectionProps
corpusLayoutSelectionCpt = here.component "corpusLayoutSelection" cpt where
cpt { nodeId, session, key, state, tasks} _ = do
cpt { nodeId, session, key, state, tasks, reloadForest} _ = do
state' <- T.useLive T.unequal state
viewType <- T.read state
pure $ renderContent viewType nodeId session key tasks
pure $ renderContent viewType nodeId session key tasks reloadForest
renderContent Folders nodeId session key tasks = FV.folderView { nodeId, session, backFolder: true, tasks }
renderContent Code nodeId session key tasks = corpusLayoutWithKey { key, nodeId, session }
renderContent Folders nodeId session key tasks reloadForest = FV.folderView { nodeId, session, backFolder: true, tasks, reloadForest }
renderContent Code nodeId session key tasks _ = corpusLayoutWithKey { key, nodeId, session }
type CorpusKeyProps =
( nodeId :: Int
......
......@@ -24,6 +24,7 @@ import Reactix as R
import Reactix.DOM.HTML as H
import Routing.Hash (setHash)
import Toestand as T
import Gargantext.Utils.Toestand as T2
here :: R2.Here
here = R2.here "Gargantext.Components.Nodes.Home"
......@@ -59,6 +60,7 @@ type HomeProps s l =
, sessions :: s
, showLogin :: l
, tasks :: T.Box GAT.Storage
, reloadForest :: T.Box T2.Reload
)
homeLayout :: forall s l. T.Read s Sessions => T.ReadWrite l Boolean
......@@ -68,7 +70,7 @@ homeLayoutCpt :: forall s l. T.Read s Sessions => T.ReadWrite l Boolean
=> R.Component (HomeProps s l)
homeLayoutCpt = here.component "homeLayout" cpt
where
cpt { backend, lang, sessions, showLogin, tasks} _ = do
cpt { backend, lang, sessions, showLogin, tasks, reloadForest} _ = do
backend' <- T.useLive T.unequal backend
sessions' <- T.useLive T.unequal sessions
let landingData = langLandingData lang
......@@ -77,7 +79,7 @@ homeLayoutCpt = here.component "homeLayout" cpt
[ H.div { className: "home-title container1" }
[ jumboTitle landingData ]
, H.div { className: "home-research-form container1" } [] -- TODO
, joinButtonOrTutorial tasks sessions' (click backend')
, joinButtonOrTutorial tasks reloadForest sessions' (click backend')
, H.div { className: "home-public container1" }
[ renderPublic { }
, H.div { className:"col-12 d-flex justify-content-center" }
......@@ -98,11 +100,11 @@ homeLayoutCpt = here.component "homeLayout" cpt
T.write_ true showLogin
Just b -> T.write_ true showLogin
joinButtonOrTutorial :: forall e. T.Box GAT.Storage -> Sessions -> (e -> Effect Unit) -> R.Element
joinButtonOrTutorial tasks sessions click =
joinButtonOrTutorial :: forall e. T.Box GAT.Storage -> T2.ReloadS -> Sessions -> (e -> Effect Unit) -> R.Element
joinButtonOrTutorial tasks reloadForest sessions click =
if Sessions.null sessions
then joinButton click
else tutorial {tasks, sessions: Sessions.unSessions sessions}
else tutorial {tasks, reloadForest, sessions: Sessions.unSessions sessions}
joinButton :: forall e. (e -> Effect Unit) -> R.Element
joinButton click =
......@@ -148,12 +150,12 @@ summary =
, H.ol {} (map toSummary tutos) ] ]
toSummary (Tuto x) = H.li {} [ H.a {href: "#" <> x.id} [ H.text x.title ]]
tutorial :: R2.Leaf (sessions :: Array Session, tasks :: T.Box GAT.Storage)
tutorial :: R2.Leaf (sessions :: Array Session, tasks :: T.Box GAT.Storage, reloadForest :: T.Box T2.Reload)
tutorial props = R.createElement tutorialCpt props []
tutorialCpt :: R.Component (sessions :: Array Session, tasks:: T.Box GAT.Storage)
tutorialCpt :: R.Component (sessions :: Array Session, tasks :: T.Box GAT.Storage, reloadForest :: T.Box T2.Reload)
tutorialCpt = here.component "tutorial" cpt where
cpt {sessions, tasks} _ = do
cpt {sessions, tasks, reloadForest} _ = do
let folders = makeFolders sessions
pure $ H.div { className: "mx-auto container" }
......@@ -177,7 +179,7 @@ tutorialCpt = here.component "tutorial" cpt where
sessionToFolder session@(Session {treeId, username, backend: (Backend {name})}) =
H.tr {} [
H.div { className: "d-flex justify-content-center" } [ H.text (username <> "@" <> name) ]
, H.div {} [ FV.folderView {session, tasks, nodeId: treeId, backFolder: false} ] ]
, H.div {} [ FV.folderView {session, tasks, reloadForest, nodeId: treeId, backFolder: false} ] ]
startTutos :: Array Tuto
startTutos =
......
......@@ -281,7 +281,7 @@ corpusCpt = here.component "corpus" cpt where
cpt props@{ boxes, nodeId } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed (Record.merge { content: \session ->
corpusLayout { nodeId, session, tasks: boxes.tasks } } sessionProps) []
corpusLayout { nodeId, session, tasks: boxes.tasks, reloadForest: boxes.reloadForest } } sessionProps) []
type CorpusDocumentProps =
( corpusId :: CorpusId
......@@ -353,8 +353,8 @@ home :: R2.Component Props
home = R.createElement homeCpt
homeCpt :: R.Component Props
homeCpt = here.component "home" cpt where
cpt props@{ boxes: boxes@{ backend, sessions, showLogin, tasks } } _ = do
pure $ homeLayout { backend, lang: LL_EN, sessions, showLogin, tasks }
cpt props@{ boxes: boxes@{ backend, sessions, showLogin, tasks, reloadForest} } _ = do
pure $ homeLayout { backend, lang: LL_EN, sessions, showLogin, tasks, reloadForest }
lists :: R2.Component SessionNodeProps
lists = R.createElement listsCpt
......@@ -423,7 +423,7 @@ teamCpt = here.component "team" cpt where
cpt props@{ boxes, nodeId } _ = do
let sessionProps = RE.pick props :: Record SessionProps
pure $ authed (Record.merge { content: \session ->
corpusLayout { nodeId, session, tasks: boxes.tasks} } sessionProps) []
corpusLayout { nodeId, session, tasks: boxes.tasks, reloadForest: boxes.reloadForest } } sessionProps) []
texts :: R2.Component SessionNodeProps
texts = R.createElement textsCpt
......
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