Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
91cd00aa
Commit
91cd00aa
authored
Aug 05, 2019
by
Przemyslaw Kaminski
Committed by
James Laver
Sep 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Layout] rewrite divDropdownRight with end config chooser
parent
31f1b390
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
23 deletions
+44
-23
Specs.purs
src/Gargantext/Pages/Layout/Specs.purs
+44
-23
No files found.
src/Gargantext/Pages/Layout/Specs.purs
View file @
91cd00aa
...
@@ -4,7 +4,9 @@ import Data.Foldable (fold, intercalate)
...
@@ -4,7 +4,9 @@ import Data.Foldable (fold, intercalate)
import Data.Lens (over)
import Data.Lens (over)
import Data.Maybe (Maybe(Nothing, Just))
import Data.Maybe (Maybe(Nothing, Just))
import Data.Tuple.Nested((/\))
import Data.Tuple.Nested((/\))
import DOM.Simple.Console (log2)
import Effect (Effect)
import Effect (Effect)
import Effect.Aff (launchAff)
import React.DOM (button, div, text)
import React.DOM (button, div, text)
import React.DOM.Props (_id, className, onClick, role, style)
import React.DOM.Props (_id, className, onClick, role, style)
import Reactix as R
import Reactix as R
...
@@ -123,7 +125,7 @@ layout0 layout =
...
@@ -123,7 +125,7 @@ layout0 layout =
Nothing ->
Nothing ->
className "col-md-12"
className "col-md-12"
] (render d p s c) ]
] (render d p s c) ]
cont = over _render \render d p s c -> [ div [className "row"
] (render d p s c) ]
cont = over _render \render d p s c -> [ div [className "row" ] (render d p s c) ]
--as = noState Tree.treeview
--as = noState Tree.treeview
bs = innerLayout $ layout
bs = innerLayout $ layout
...
@@ -348,14 +350,49 @@ logLinks d s = case s.loginState.authData of
...
@@ -348,14 +350,49 @@ logLinks d s = case s.loginState.authData of
[H.text " Logout"]
[H.text " Logout"]
divDropdownRight :: (Action -> Effect Unit) -> AppState -> R.Element
divDropdownRight d s = R.createElement el {state: s} []
where
el = R.hooksComponent "DivDropdownRight" cpt
cpt {state} _children = do
(configState /\ setConfigState) <- R.useState' state.configState
pure $ H.ul {className: "nav navbar-nav pull-right"}
[ endConfigChooserCpt d state.configState (configState /\ setConfigState)
, logLinks d state
]
endConfigChooserCpt d s (configState /\ setConfigState) = R.createElement el {state: s} []
where
el = R.hooksComponent "EndConfigChooserCpt" cpt
cpt {state} _children = do
R.useEffect $ pure $
if (configState /= state) then do
_ <- log2 "update state: " configState
_ <- d $ ConfigStateA $ C.UpdateState configState
_ <- log2 "logout" ""
d $ Logout
else
pure $ unit
pure $ H.span {}
[ endConfigChooser (configState /\ setConfigState)
, H.span {className: "text-info"}
[ H.text $ C.endConfigDisplayName configState.endConfig ]
, H.span {className: "text-danger"}
[ H.text $ C.endConfigDisplayName state.endConfig ]
]
endConfigChooser :: R.State C.State -> R.Element
endConfigChooser :: R.State C.State -> R.Element
endConfigChooser (configState /\ setConfigState) = R.createElement el {} []
endConfigChooser (configState /\ setConfigState) = R.createElement el {} []
where
where
el = R.hooksComponent "EndConfigChooser" cpt
el = R.hooksComponent "EndConfigChooser" cpt
cpt {} _ = do
cpt {} _ = do
-- NOTE Need to rebind the component after rerender
-- NOTE Need to rebind the component after rerender
R.useEffect $
R.useEffect do
pure $ createDropdown "end-config-chooser"
_ <- pure $ createDropdown "end-config-chooser"
pure $ pure unit
pure $ H.li {className: "dropdown"}
pure $ H.li {className: "dropdown"}
[ H.a { className: "navbar-text dropdown-toggle"
[ H.a { className: "navbar-text dropdown-toggle"
...
@@ -371,28 +408,12 @@ endConfigChooser (configState /\ setConfigState) = R.createElement el {} []
...
@@ -371,28 +408,12 @@ endConfigChooser (configState /\ setConfigState) = R.createElement el {} []
liItem :: C.EndConfigOption -> R.Element
liItem :: C.EndConfigOption -> R.Element
liItem {endConfig, displayName} =
liItem {endConfig, displayName} =
H.li {on: {click: \_ -> setConfigState $ \st -> st {endConfig = endConfig}}}
H.li {on: {click: onClick endConfig}}
--H.li {}
[ H.a {href: "#"} [H.text displayName] ]
[ H.a {href: "#"} [H.text displayName] ]
onClick endConfig = \_ -> do
divDropdownRight :: (Action -> Effect Unit) -> AppState -> R.Element
log2 "set end config" endConfig
divDropdownRight d s = R.createElement el {} []
setConfigState $ \st -> st {endConfig = endConfig}
where
el = R.hooksComponent "DivDropdownRight" cpt
cpt {} _children = do
(configState /\ setConfigState) <- R.useState' s.configState
R.useEffect $
if (configState /= s.configState) then do
pure $ d $ ConfigStateA $ C.UpdateState configState
else
pure $ pure $ unit
pure $ H.ul {className: "nav navbar-nav pull-right"}
[ endConfigChooser (configState /\ setConfigState)
, logLinks d s
]
layoutFooter :: Spec {} {} Void
layoutFooter :: Spec {} {} Void
layoutFooter = R2.elSpec $ R.hooksComponent "LayoutFooter" cpt
layoutFooter = R2.elSpec $ R.hooksComponent "LayoutFooter" cpt
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment