From 4925b93f56284b0f7afcbbe5d82e0534c2388bd4 Mon Sep 17 00:00:00 2001
From: Abinaya Sudhir <abinaya@atomicits.com>
Date: Mon, 16 Apr 2018 21:03:07 +0530
Subject: [PATCH] Tree is hide based on login condition

---
 src/Login.purs      | 42 ++++++++++++++++++++++++++++++++++++++++--
 src/Navigation.purs |  9 ++++++---
 2 files changed, 46 insertions(+), 5 deletions(-)

diff --git a/src/Login.purs b/src/Login.purs
index 4fa7540f..ba906219 100644
--- a/src/Login.purs
+++ b/src/Login.purs
@@ -34,6 +34,7 @@ newtype State = State
   , password :: String
   , response :: LoginRes
   , errorMessage :: String
+  , loginC :: Boolean
   }
 
 
@@ -43,6 +44,7 @@ initialState = State
  , password : ""
  , response : LoginRes {token : ""}
  , errorMessage : ""
+ , loginC : false
   }
 
 data Action
@@ -54,7 +56,7 @@ data Action
 
 performAction :: forall eff props. PerformAction ( console :: CONSOLE
                                                  , ajax    :: AJAX
-                                                 , dom     :: DOM 
+                                                 , dom     :: DOM
                                                  | eff
                                                  ) State props Action
 performAction NoOp _ _ = void do
@@ -71,7 +73,7 @@ performAction (SetPassword pwd) _ _ = void do
 
 performAction Login _ (State state) = void do
   lift $ setHash "/search"
-  modifyState id
+  modifyState \(State state) -> State $ state {loginC = true}
   -- res <- lift $ loginReq $ LoginReq { username : state.username, password : state.password }
   -- case res of
   --   Left e -> do
@@ -148,6 +150,42 @@ renderSpec = simpleSpec performAction render
       ]
 
 
+
+-- div [ className "modal fade myModal"
+--                    , role "dialog"
+--                    , _data {show : true}
+--                    ][ div [ className "modal-dialog"
+--                           , role "document"
+--                           ] [ div [ className "modal-content"]
+--                                   [ div [ className "modal-header"]
+--                                         [ h5 [ className "modal-title"
+--                                              ]
+--                                              [ text "CorpusView"
+--                                              ]
+--                                         , button [ _type "button"
+--                                                  , className "close"
+--                                                  , _data { dismiss : "modal"}
+--                                                  ] [ span [ aria {hidden : true}]
+--                                                           [ text "X"]
+--                                                    ]
+--                                         ]
+
+--                                   , div [ className "modal-body"]
+--                                         [ ul [ className "list-group"] ( map fn1 state.response ) ]
+
+--                                   , div [className "modal-footer"]
+--                                         [ button [ _type "button"
+--                                                  , className "btn btn-secondary"
+--                                                  , _data {dismiss : "modal"}
+--                                                  ] [ text "GO"]
+--                                         ]
+--                                    ]
+--                             ]
+--                      ]
+--         ]
+
+
+
 unsafeEventValue :: forall event. event -> String
 unsafeEventValue e = (unsafeCoerce e).target.value
 
diff --git a/src/Navigation.purs b/src/Navigation.purs
index e4f7e837..cc00a838 100644
--- a/src/Navigation.purs
+++ b/src/Navigation.purs
@@ -2,7 +2,6 @@ module Navigation where
 
 import DOM
 import Gargantext.Data.Lang
-import Prelude hiding (div)
 
 import AddCorpusview as AC
 import AnnotationDocumentView as D
@@ -22,6 +21,7 @@ import Login as LN
 import NTree as NT
 import Network.HTTP.Affjax (AJAX)
 import PageRouter (Routes(..))
+import Prelude hiding (div)
 import React (ReactElement)
 import React.DOM (a, button, div, footer, form, hr, i, img, input, li, p, span, text, ul)
 import React.DOM.Props (Props, _data, _id, _type, aria, className, href, name, onChange, onClick, placeholder, role, src, style, tabIndex, target, title)
@@ -29,7 +29,7 @@ import React.DOM.Props as RP
 import Routing.Hash.Aff (setHash)
 import SearchForm as S
 import Tabview as TV
-import Thermite (PerformAction, Render, Spec, _render, cotransform, defaultRender, focus, modifyState, simpleSpec, withState)
+import Thermite (PerformAction, Render, Spec, _render, cotransform, defaultPerformAction, defaultRender, focus, modifyState, simpleSpec, withState)
 import Unsafe.Coerce (unsafeCoerce)
 import UserPage as UP
 
@@ -255,10 +255,13 @@ layout0 layout =
   , layoutFooter
   ]
   where
+    outerLayout1 = simpleSpec defaultPerformAction defaultRender
     outerLayout :: Spec (E eff) AppState props Action
     outerLayout =
       cont $ fold
-      [ ls as
+      [ withState \st ->
+         if ((\(LN.State s) -> s.loginC) st.loginState == true) then ls as
+         else outerLayout1
       , rs bs      ]
     ls = over _render \render d p s c ->
       [div [className "col-md-3"] (render d p s c)]
-- 
2.21.0