Commit 7c667c73 authored by Fabien Manière's avatar Fabien Manière

complete breadcrumb

parent 4aca0e4a
Pipeline #4650 failed with stage
in 0 seconds
...@@ -12332,6 +12332,10 @@ select.form-control { ...@@ -12332,6 +12332,10 @@ select.form-control {
.breadcrumb-wrapper .breadcrumb-item .b-icon { .breadcrumb-wrapper .breadcrumb-item .b-icon {
margin: 0 4px; margin: 0 4px;
} }
.breadcrumb-wrapper .fa-spinner {
font-size: 100%;
margin: auto 10px;
}
.dropdown-menu { .dropdown-menu {
background-color: #181A1B; background-color: #181A1B;
......
...@@ -12134,6 +12134,10 @@ select.form-control { ...@@ -12134,6 +12134,10 @@ select.form-control {
.breadcrumb-wrapper .breadcrumb-item .b-icon { .breadcrumb-wrapper .breadcrumb-item .b-icon {
margin: 0 4px; margin: 0 4px;
} }
.breadcrumb-wrapper .fa-spinner {
font-size: 100%;
margin: auto 10px;
}
.btn-secondary, .btn-secondary,
.btn-secondary:hover, .btn-secondary:hover,
......
...@@ -11898,5 +11898,9 @@ select.form-control { ...@@ -11898,5 +11898,9 @@ select.form-control {
.breadcrumb-wrapper .breadcrumb-item .b-icon { .breadcrumb-wrapper .breadcrumb-item .b-icon {
margin: 0 4px; margin: 0 4px;
} }
.breadcrumb-wrapper .fa-spinner {
font-size: 100%;
margin: auto 10px;
}
/*# sourceMappingURL=bootstrap-greyson.css.map */ /*# sourceMappingURL=bootstrap-greyson.css.map */
...@@ -12146,5 +12146,9 @@ select.form-control { ...@@ -12146,5 +12146,9 @@ select.form-control {
.breadcrumb-wrapper .breadcrumb-item .b-icon { .breadcrumb-wrapper .breadcrumb-item .b-icon {
margin: 0 4px; margin: 0 4px;
} }
.breadcrumb-wrapper .fa-spinner {
font-size: 100%;
margin: auto 10px;
}
/*# sourceMappingURL=bootstrap-herbie.css.map */ /*# sourceMappingURL=bootstrap-herbie.css.map */
...@@ -12147,5 +12147,9 @@ select.form-control { ...@@ -12147,5 +12147,9 @@ select.form-control {
.breadcrumb-wrapper .breadcrumb-item .b-icon { .breadcrumb-wrapper .breadcrumb-item .b-icon {
margin: 0 4px; margin: 0 4px;
} }
.breadcrumb-wrapper .fa-spinner {
font-size: 100%;
margin: auto 10px;
}
/*# sourceMappingURL=bootstrap-monotony.css.map */ /*# sourceMappingURL=bootstrap-monotony.css.map */
...@@ -22,9 +22,11 @@ import Gargantext.Components.GraphQL.Tree (BreadcrumbInfo, TreeNode) ...@@ -22,9 +22,11 @@ import Gargantext.Components.GraphQL.Tree (BreadcrumbInfo, TreeNode)
import Gargantext.Components.Login.Types (TreeId, UserId) import Gargantext.Components.Login.Types (TreeId, UserId)
import Gargantext.Ends (Frontends, Backend(..)) import Gargantext.Ends (Frontends, Backend(..))
import Gargantext.Hooks.Session (useSession) import Gargantext.Hooks.Session (useSession)
import Gargantext.Routes (AppRoute(Home), appPath, nodeTypeAppRoute)
import Gargantext.Sessions import Gargantext.Sessions
import Gargantext.Sessions.Types import Gargantext.Sessions.Types
import Gargantext.Types (CorpusId, FrontendError, NodeID, NodeType, SessionId) import Gargantext.Types (CorpusId, FrontendError, NodeID, NodeType, SessionId)
import Gargantext.Types as GT
import Gargantext.Utils as GU import Gargantext.Utils as GU
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Reactix as R import Reactix as R
...@@ -44,13 +46,14 @@ here :: R2.Here ...@@ -44,13 +46,14 @@ here :: R2.Here
here = R2.here "Gargantext.Components.Forest.Breadcrumb" here = R2.here "Gargantext.Components.Forest.Breadcrumb"
type PropsBoxes = ( boxes :: Boxes ) type PropsBoxes = ( boxes :: Boxes )
type Props = type Props =
( nodeId :: Int ( nodeId :: Int
, session :: Maybe Session , session :: Maybe Session
) )
maybeToSession :: Maybe Session -> Session -- maybeToSession :: Maybe Session -> Session
maybeToSession s = fromMaybe Nothing s -- maybeToSession s = fromMaybe Nothing s
component :: R2.Leaf PropsBoxes component :: R2.Leaf PropsBoxes
...@@ -65,28 +68,48 @@ componentCpt = here.component "breadcrumb" cpt where ...@@ -65,28 +68,48 @@ componentCpt = here.component "breadcrumb" cpt where
-- | Effects -- | Effects
-- | -- |
url <- R.unsafeHooksEffect GU.href -- url <- R.unsafeHooksEffect GU.href
-- | Behaviors -- | Behaviors
-- | -- |
let -- let
-- currentUrl = url -- currentUrl = url
-- fragment = Fragment.toString $ Fragment.fromString "http://localhost:8008/#/corpus/user1@localhost:8008/112" -- fragment = Fragment.toString $ Fragment.fromString "http://localhost:8008/#/corpus/user1@localhost:8008/112"
-- fragment = Fragment.toString $ Fragment.fromString url -- fragment = Fragment.toString $ Fragment.fromString url
currentNodeId = fromMaybe 0 $ fromString $ getLastUrlElement url -- currentNodeId = fromMaybe 0 $ fromString $ getLastUrlElement url
case session' of case session' of
Nothing -> pure $ H.div {} [] Nothing -> pure $ H.div {} []
Just (session') -> do Just (session') -> do
url <- R.unsafeHooksEffect GU.href
let nodeId = fromMaybe 0 $ fromString $ getLastUrlElement url
-- breadcrumbData <- R2.useLayoutEffect1' $ getBreadcrumb session' currentNodeId -- breadcrumbData <- R2.useLayoutEffect1' $ getBreadcrumb session' currentNodeId
let session'' = Just session'
pure $ pure $
-- breadcrumb layout -- breadcrumb layout
H.div {} H.nav { className: "breadcrumb-wrapper bg-light"
, "aria-label": "breadcrumb" }
[ [
breadcrumbView { currentNodeId, session' } H.ol { className: "breadcrumb text-small" }
[
H.li { className: "breadcrumb-item" }
[
H.a { href: "/" }
[ H.span { className: "" }
[
B.icon { name: "home" }
]
, H.text "Home"
]
]
,
breadcrumbView { nodeId: nodeId
, session: Just session'
}
]
-- , -- ,
-- H.nav -- H.nav
-- { className: "breadcrumb-wrapper bg-light" -- { className: "breadcrumb-wrapper bg-light"
...@@ -143,17 +166,11 @@ breadcrumbView = R2.leaf breadcrumbViewCpt ...@@ -143,17 +166,11 @@ breadcrumbView = R2.leaf breadcrumbViewCpt
breadcrumbViewCpt :: R.Component Props breadcrumbViewCpt :: R.Component Props
breadcrumbViewCpt = here.component "breadcrumbViewCpt" cpt where breadcrumbViewCpt = here.component "breadcrumbViewCpt" cpt where
cpt { nodeId, session } _ = do cpt { nodeId, session } _ = do
-- session' <- session let session' = session
-- session' <- T.useLive T.unequal session
-- url <- R.unsafeHooksEffect GU.href
-- let nodeId = fromMaybe 0 $ fromString $ getLastUrlElement url
session' <- liftEffect $ maybeToSession session
case session' of case session' of
Nothing -> pure $ H.div {} [] Nothing -> pure $ H.div {} []
Just (session') -> do Just (session') -> do
-- reload <- T.useBox T2.newReload
-- reload' <- T.useLive T.unequal reload
useLoader { errorHandler useLoader { errorHandler
, loader: loadBreadcrumbData , loader: loadBreadcrumbData
, path: { nodeId: nodeId , path: { nodeId: nodeId
...@@ -180,12 +197,17 @@ breadcrumbViewMain :: R2.Component BreadcrumbViewProps ...@@ -180,12 +197,17 @@ breadcrumbViewMain :: R2.Component BreadcrumbViewProps
breadcrumbViewMain = R.createElement breadcrumbViewMainCpt breadcrumbViewMain = R.createElement breadcrumbViewMainCpt
breadcrumbViewMainCpt :: R.Component BreadcrumbViewProps breadcrumbViewMainCpt :: R.Component BreadcrumbViewProps
breadcrumbViewMainCpt = here.component "breadcrumbViewMainCpt" cpt where breadcrumbViewMainCpt = here.component "breadcrumbViewMainCpt" cpt where
cpt props@{ items: { parents } } _ = do cpt props@{ items: { parents }, session } _ = do
-- session' <- T.useLive T.unequal session
let items = makeBreadcrumbElements parents props let items = makeBreadcrumbElements parents props
pure $ -- case session of
H.div { className: "breadcrumb-view" } $ -- Nothing -> pure $ H.div {} []
items -- Just (session) -> do
pure $
R.fragment items
makeBreadcrumbElements :: Array TreeNode -> Record BreadcrumbViewProps -> Array R.Element makeBreadcrumbElements :: Array TreeNode -> Record BreadcrumbViewProps -> Array R.Element
...@@ -198,7 +220,7 @@ breadcrumbViewMainCpt = here.component "breadcrumbViewMainCpt" cpt where ...@@ -198,7 +220,7 @@ breadcrumbViewMainCpt = here.component "breadcrumbViewMainCpt" cpt where
, parentId: props.nodeId , parentId: props.nodeId
-- , reload: props.reload -- , reload: props.reload
, session: props.session , session: props.session
-- , style: FolderChild -- , style: FolderUp
, text: node.name , text: node.name
, disabled: false , disabled: false
} }
...@@ -231,13 +253,42 @@ breadcrumbItemCpt = here.component "breadcrumbItemCpt" cpt where ...@@ -231,13 +253,42 @@ breadcrumbItemCpt = here.component "breadcrumbItemCpt" cpt where
, text , text
, disabled , disabled
} _ = do } _ = do
let sid = sessionId session
let rootId = treeId session
pure $ pure $
H.li { className: "breadcrumb-item" }
H.div { className: "bItem" }
[ [
H.text props.text H.a { className: ""
, href: "/#/" <> createNodeUrl linkId rootId linkNodeType sid
}
[
H.span { className: "" }
[
-- B.icon { name: "folder-open-o" }
B.icon
{ className: ""
, name: GT.getIcon nodeType true
}
]
,
H.text props.text
]
] ]
createNodeUrl :: Int -> Int -> NodeType -> SessionId -> String
createNodeUrl lId rootId nType sId
-- | rootId == lId = appPath Home
| otherwise = appPath $ getFolderPath nType sId lId
getFolderPath :: GT.NodeType -> GT.SessionId -> Int -> AppRoute
getFolderPath nodeType sid nodeId = fromMaybe Home $ nodeTypeAppRoute nodeType sid nodeId
treeId :: Session -> Int
treeId (Session {treeId: tId}) = tId
getLastUrlElement :: String -> String getLastUrlElement :: String -> String
getLastUrlElement str = fromMaybe "" $ A.last $ split (Pattern "/") str getLastUrlElement str = fromMaybe "" $ A.last $ split (Pattern "/") str
......
...@@ -10,4 +10,7 @@ ...@@ -10,4 +10,7 @@
font-weight: bold font-weight: bold
color: $primary color: $primary
.b-icon .b-icon
margin: 0 space-x(0.5) margin: 0 space-x(0.5)
\ No newline at end of file .fa-spinner
font-size: 100%
margin: auto 10px
\ No newline at end of file
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