From a395b88ef2b13dc6cc8765173039f2e90a54ac01 Mon Sep 17 00:00:00 2001 From: Philippe Pittoli Date: Sat, 8 Jul 2023 06:29:37 +0200 Subject: [PATCH] Better (pseudo-)routing. --- src/App/Container.purs | 2 +- src/App/Nav.purs | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/App/Container.purs b/src/App/Container.purs index a610869..050dabc 100644 --- a/src/App/Container.purs +++ b/src/App/Container.purs @@ -137,7 +137,7 @@ handleAction = case _ of Routing page -> H.modify_ _ { current_page = page } AuthenticationComponentEvent ev -> case ev of - AF.AuthToken (Tuple uid token) -> H.modify_ _ { uid = Just uid, token = Just token } + AF.AuthToken (Tuple uid token) -> H.modify_ _ { uid = Just uid, token = Just token, current_page = DomainList } AF.MessageToSend message -> H.tell _ws_auth unit (WS.ToSend message) AF.Log message -> H.tell _log unit (Log.Log message) diff --git a/src/App/Nav.purs b/src/App/Nav.purs index af1ad49..e1e5578 100644 --- a/src/App/Nav.purs +++ b/src/App/Nav.purs @@ -31,10 +31,12 @@ netlibre_navbar authenticated admin actionHome actionDomainList actionAuthdAdmin ] , navbar_end [ navbar_item - [ HH.div [HP.classes C.buttons] - [ nav_button_strong "Register" actionRegister - , nav_button_light "Login" actionLogin - ] + [ HH.div [HP.classes C.buttons] $ case authenticated of + false -> [ nav_button_strong "Register" actionRegister + , nav_button_light "Login" actionLogin + , nav_button_code + ] + _ -> [ nav_button_code ] ] ] ] @@ -55,12 +57,14 @@ netlibre_navbar authenticated admin actionHome actionDomainList actionAuthdAdmin link_home = HH.a [HP.classes C.navbar_item, HE.onClick (\_ -> actionHome)] [HH.text "Home"] link_domains = HH.a [HP.classes C.navbar_item, HE.onClick (\_ -> actionDomainList)] [HH.text "Domain List"] link_authd_admin = HH.a [HP.classes C.navbar_item, HE.onClick (\_ -> actionAuthdAdmin)] [HH.text "Authd Admin"] - dropdown title dropdown_elements - = HH.div [HP.classes (C.navbar_item <> C.has_dropdown <> C.is_hoverable)] - [ dropdown_title title, HH.div [HP.classes C.navbar_dropdown] dropdown_elements ] - dropdown_title str = HH.a [HP.classes C.navbar_link] [HH.text str] - dropdown_element str = HH.a [HP.classes C.navbar_item] [HH.text str] - dropdown_separator = HH.hr [HP.classes C.navbar_divider] + --dropdown title dropdown_elements + -- = HH.div [HP.classes (C.navbar_item <> C.has_dropdown <> C.is_hoverable)] + -- [ dropdown_title title, HH.div [HP.classes C.navbar_dropdown] dropdown_elements ] + --dropdown_title str = HH.a [HP.classes C.navbar_link] [HH.text str] + --dropdown_element str = HH.a [HP.classes C.navbar_item] [HH.text str] + --dropdown_separator = HH.hr [HP.classes C.navbar_divider] + nav_button_code + = HH.a [HP.classes (C.button), HP.href "https://git.baguette.netlib.re/Baguette/dnsmanager"] [HH.text "Code"] nav_button_strong str action = HH.a [HP.classes (C.button <> C.is_primary), HE.onClick (\_ -> action)] [HH.strong [] [HH.text str]] nav_button_light str action