Commit a65a8805 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[forest] add key to user page, to refresh it

Also, key is generated based on session id and node id.
parent 50bd539c
...@@ -4,6 +4,10 @@ import Data.Array (fromFoldable) ...@@ -4,6 +4,10 @@ import Data.Array (fromFoldable)
import Data.Foldable (intercalate) import Data.Foldable (intercalate)
import Data.Maybe (Maybe(..), maybe') import Data.Maybe (Maybe(..), maybe')
import Data.Tuple (fst, snd) import Data.Tuple (fst, snd)
import Prelude
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Components.Forest (forest) import Gargantext.Components.Forest (forest)
import Gargantext.Components.GraphExplorer (explorerLayout) import Gargantext.Components.GraphExplorer (explorerLayout)
import Gargantext.Components.Lang (LandingLang(..)) import Gargantext.Components.Lang (LandingLang(..))
...@@ -26,9 +30,6 @@ import Gargantext.Routes (AppRoute(..)) ...@@ -26,9 +30,6 @@ import Gargantext.Routes (AppRoute(..))
import Gargantext.Sessions (Sessions, useSessions) import Gargantext.Sessions (Sessions, useSessions)
import Gargantext.Sessions as Sessions import Gargantext.Sessions as Sessions
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Prelude
import Reactix as R
import Reactix.DOM.HTML as H
-- TODO (what does this mean?) -- TODO (what does this mean?)
-- tree changes endConfig state => trigger endConfig change in outerLayout, layoutFooter etc -- tree changes endConfig state => trigger endConfig change in outerLayout, layoutFooter etc
...@@ -48,39 +49,39 @@ appCpt = R.hooksComponent "G.C.App.app" cpt where ...@@ -48,39 +49,39 @@ appCpt = R.hooksComponent "G.C.App.app" cpt where
treeReload <- R.useState' 0 treeReload <- R.useState' 0
let forested child = forestLayout { child let backends = fromFoldable defaultBackends
, frontends let ff f session = R.fragment [ f session, footer { session } ]
, reload: treeReload let forested child = forestLayout { child
, route: fst route , frontends
, sessions: fst sessions , reload: treeReload
, showLogin: snd showLogin } , route: fst route
let mCurrentRoute = fst route , sessions: fst sessions
let backends = fromFoldable defaultBackends , showLogin: snd showLogin }
let ff f session = R.fragment [ f session, footer { session } ] let mCurrentRoute = fst route
let mkKey sid nodeId = show sid <> "-" <> show nodeId
let withSession sid f = let withSession sid f =
maybe' (const $ forested $ homeLayout LL_EN) (ff f) $ Sessions.lookup sid (fst sessions) maybe' (const $ forested $ homeLayout LL_EN) (ff f) $ Sessions.lookup sid (fst sessions)
pure $ case fst showLogin of pure $ case fst showLogin of
true -> forested $ login { sessions, backends, visible: showLogin } true -> forested $ login { backends, sessions, visible: showLogin }
false -> false ->
case fst route of case fst route of
Home -> forested $ homeLayout LL_EN Home -> forested $ homeLayout LL_EN
Login -> login { sessions, backends, visible: showLogin } Login -> login { backends, sessions, visible: showLogin }
--Folder sid _ -> withSession sid $ \_ -> forested (folder {}) Folder sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: mkKey sid nodeId, nodeId, session }
Folder sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: show nodeId, nodeId, session } FolderPrivate sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: mkKey sid nodeId, nodeId, session }
FolderPrivate sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: show nodeId, nodeId, session } FolderPublic sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: mkKey sid nodeId, nodeId, session }
FolderPublic sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: show nodeId, nodeId, session } FolderShared sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: mkKey sid nodeId, nodeId, session }
FolderShared sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: show nodeId, nodeId, session } Team sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: mkKey sid nodeId, nodeId, session }
Team sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: show nodeId, nodeId, session } RouteFrameWrite sid nodeId -> withSession sid $ \session -> forested $ frameLayout { key: mkKey sid nodeId, nodeId, session }
RouteFrameWrite sid nodeId -> withSession sid $ \session -> forested $ frameLayout { key: show nodeId, nodeId, session } RouteFrameCalc sid nodeId -> withSession sid $ \session -> forested $ frameLayout { key: mkKey sid nodeId, nodeId, session }
RouteFrameCalc sid nodeId -> withSession sid $ \session -> forested $ frameLayout { key: show nodeId, nodeId, session } Corpus sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: mkKey sid nodeId, nodeId, session }
Corpus sid nodeId -> withSession sid $ \session -> forested $ corpusLayout { key: show nodeId, nodeId, session }
Texts sid nodeId -> withSession sid $ \session -> forested $ textsLayout { nodeId, session, frontends } Texts sid nodeId -> withSession sid $ \session -> forested $ textsLayout { nodeId, session, frontends }
Lists sid nodeId -> withSession sid $ \session -> forested $ listsLayout { nodeId, session } Lists sid nodeId -> withSession sid $ \session -> forested $ listsLayout { nodeId, session }
Dashboard sid nodeId -> withSession sid $ \session -> forested $ dashboardLayout { nodeId, session } Dashboard sid nodeId -> withSession sid $ \session -> forested $ dashboardLayout { nodeId, session }
Annuaire sid nodeId -> withSession sid $ \session -> forested $ annuaireLayout { frontends, nodeId, session } Annuaire sid nodeId -> withSession sid $ \session -> forested $ annuaireLayout { frontends, nodeId, session }
UserPage sid nodeId -> withSession sid $ \session -> forested $ userLayout { frontends, nodeId, session } UserPage sid nodeId -> withSession sid $ \session -> forested $ userLayout { frontends, key: mkKey sid nodeId, nodeId, session }
ContactPage sid aId nodeId -> withSession sid $ \session -> forested $ annuaireUserLayout { annuaireId: aId, frontends, nodeId, session } ContactPage sid aId nodeId -> withSession sid $ \session -> forested $ annuaireUserLayout { annuaireId: aId, frontends, key: mkKey sid nodeId, nodeId, session }
CorpusDocument sid corpusId listId nodeId -> withSession sid $ \session -> forested $ documentLayout { nodeId, listId, session, corpusId: Just corpusId } CorpusDocument sid corpusId listId nodeId -> withSession sid $ \session -> forested $ documentLayout { nodeId, listId, session, corpusId: Just corpusId }
Document sid listId nodeId -> Document sid listId nodeId ->
withSession sid $ withSession sid $
...@@ -107,13 +108,24 @@ type ForestLayoutProps = ...@@ -107,13 +108,24 @@ type ForestLayoutProps =
) )
forestLayout :: Record ForestLayoutProps -> R.Element forestLayout :: Record ForestLayoutProps -> R.Element
forestLayout { child, frontends, reload, route, sessions, showLogin } = do forestLayout props = R.createElement forestLayoutCpt props []
R.fragment [ topBar {}, R2.row [main] ]
forestLayoutCpt :: R.Component ForestLayoutProps
forestLayoutCpt = R.hooksComponent "G.C.A.forestLayout" cpt
where
cpt props _ = do
pure $ R.fragment [ topBar {}, forestLayoutMain props ]
forestLayoutMain :: Record ForestLayoutProps -> R.Element
forestLayoutMain props = R.createElement forestLayoutMainCpt props []
forestLayoutMainCpt :: R.Component ForestLayoutProps
forestLayoutMainCpt = R.hooksComponent "G.C.A.forestLayoutMain" cpt
where where
main = cpt { child, frontends, reload, route, sessions, showLogin } _ = do
R.fragment pure $ R2.row [
[ H.div {className: "col-md-2", style: {paddingTop: "60px"}} H.div { className: "col-md-2", style: { paddingTop: "60px" } }
[ forest { frontends, reload, route, sessions, showLogin } ] [ forest { frontends, reload, route, sessions, showLogin } ]
, mainPage child , mainPage child
] ]
......
...@@ -135,7 +135,12 @@ infoRender (Tuple title content) = ...@@ -135,7 +135,12 @@ infoRender (Tuple title content) =
[ H.span { className: "badge badge-default badge-pill"} [ H.text title ] [ H.span { className: "badge badge-default badge-pill"} [ H.text title ]
, H.span {} [H.text content] ] , H.span {} [H.text content] ]
type LayoutProps = ( frontends :: Frontends, nodeId :: Int, session :: Session ) type LayoutProps = (
frontends :: Frontends
, key :: String
, nodeId :: Int
, session :: Session
)
userLayout :: Record LayoutProps -> R.Element userLayout :: Record LayoutProps -> R.Element
userLayout props = R.createElement userLayoutCpt props [] userLayout props = R.createElement userLayoutCpt props []
......
...@@ -41,7 +41,7 @@ versionCpt = R.hooksComponent "G.C.A.version" cpt ...@@ -41,7 +41,7 @@ versionCpt = R.hooksComponent "G.C.A.version" cpt
pure $ case version == versionBack of pure $ case version == versionBack of
true -> H.a { className: "fa fa-check-circle-o" true -> H.a { className: "fa fa-check-circle-o"
, "text-decoration": "none" , textDecoration: "none"
, title: "Versions match: frontend (" , title: "Versions match: frontend ("
<> version <> version
<> "), backend (" <> "), backend ("
...@@ -49,7 +49,7 @@ versionCpt = R.hooksComponent "G.C.A.version" cpt ...@@ -49,7 +49,7 @@ versionCpt = R.hooksComponent "G.C.A.version" cpt
<> ")" <> ")"
} [] } []
false -> H.a { className: "fa fa-exclamation-triangle" false -> H.a { className: "fa fa-exclamation-triangle"
, "text-decoration": "none" , textDecoration: "none"
, title: "Versions mismatch: frontend (" , title: "Versions mismatch: frontend ("
<> version <> version
<> "), backend (" <> "), backend ("
......
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