Skip to content

Commit 0ed1eee

Browse files
committed
Use readerT to move the UI wallet type around
1 parent 6010fef commit 0ed1eee

File tree

5 files changed

+34
-17
lines changed

5 files changed

+34
-17
lines changed

lib/ui/src/Cardano/Wallet/UI/Common/Html/Pages/Wallet.hs

+14-13
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ import Cardano.Wallet.UI.Common.Html.Lib
2121
import Cardano.Wallet.UI.Common.Html.Pages.Lib
2222
( copyButton
2323
)
24-
import Control.Monad
25-
( when
24+
import Cardano.Wallet.UI.Type
25+
( WHtml
26+
, onShelley
2627
)
2728
import Data.Text
2829
( Text
@@ -60,7 +61,7 @@ mnemonicH (Just mnemonic) = do
6061
$ T.intercalate " " mnemonic
6162
copyButton "copy-mnemonic"
6263

63-
newWalletH :: (Maybe Bool -> Link) -> PostWalletConfig -> Html ()
64+
newWalletH :: (Maybe Bool -> Link) -> PostWalletConfig -> WHtml ()
6465
newWalletH walletMnemonicLink config = do
6566
useHtmxExtension "json-enc"
6667
div_ [class_ "btn-group mb-3", role_ "group"] $ do
@@ -88,11 +89,10 @@ newWalletH walletMnemonicLink config = do
8889

8990
data PostWalletConfig = PostWalletConfig
9091
{ passwordVisibility :: Maybe Visible
91-
, namePresence :: Bool
9292
, walletDataLink :: Link
9393
}
9494

95-
postWalletForm :: PostWalletConfig -> Html ()
95+
postWalletForm :: PostWalletConfig -> WHtml ()
9696
postWalletForm PostWalletConfig{..} = form_
9797
[ hxPost_ $ linkText walletDataLink
9898
, hxExt_ "json-enc"
@@ -106,19 +106,20 @@ postWalletForm PostWalletConfig{..} = form_
106106
, name_ "mnemonicSentence"
107107
, placeholder_ "Mnemonic Sentence"
108108
]
109-
when namePresence $
110-
input_
109+
onShelley
110+
$ input_
111111
[ class_ "form-control form-control-lg mb-3"
112112
, type_ "text"
113113
, name_ "name"
114114
, placeholder_ "Wallet Name"
115115
]
116-
input_
117-
[ class_ "form-control form-control-lg mb-3"
118-
, visibility
119-
, name_ "passphrase"
120-
, placeholder_ "Passphrase"
121-
]
116+
onShelley
117+
$ input_
118+
[ class_ "form-control form-control-lg mb-3"
119+
, visibility
120+
, name_ "passphrase"
121+
, placeholder_ "Passphrase"
122+
]
122123
button_
123124
[ class_ "btn btn-primary btn-block mb-3"
124125
, type_ "submit"

lib/ui/src/Cardano/Wallet/UI/Deposit/Html/Pages/Page.hs

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE AllowAmbiguousTypes #-}
22
{-# LANGUAGE FlexibleContexts #-}
3+
{-# LANGUAGE RankNTypes #-}
34
{-# LANGUAGE RecordWildCards #-}
45
{-# LANGUAGE TemplateHaskell #-}
56

@@ -47,6 +48,10 @@ import Cardano.Wallet.UI.Deposit.Html.Pages.Wallet
4748
( WalletPresent
4849
, walletH
4950
)
51+
import Cardano.Wallet.UI.Type
52+
( WalletType (..)
53+
, runWHtml
54+
)
5055
import Control.Lens.Extras
5156
( is
5257
)
@@ -79,6 +84,7 @@ page
7984
-> RawHtml
8085
page c@PageConfig{..} p wp = RawHtml
8186
$ renderBS
87+
$ runWHtml Deposit
8288
$ pageFromBodyH faviconLink c
8389
$ bodyH (headerH prefix p)
8490
$ case p of

lib/ui/src/Cardano/Wallet/UI/Deposit/Html/Pages/Wallet.hs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE RankNTypes #-}
12
module Cardano.Wallet.UI.Deposit.Html.Pages.Wallet
23
where
34

@@ -25,6 +26,9 @@ import Cardano.Wallet.UI.Deposit.API
2526
( walletLink
2627
, walletMnemonicLink
2728
)
29+
import Cardano.Wallet.UI.Type
30+
( WHtml
31+
)
2832
import Codec.Binary.Encoding
2933
( AbstractEncoding (..)
3034
, encode
@@ -46,7 +50,7 @@ import qualified Data.Text.Encoding as T
4650

4751
data WalletPresent = WalletPresent WalletPublicIdentity | WalletAbsent
4852

49-
walletH :: WalletPresent -> Html ()
53+
walletH :: WalletPresent -> WHtml ()
5054
walletH walletPresent = do
5155
-- sseH sseLink walletLink "wallet" ["wallet"]
5256
case walletPresent of
@@ -55,7 +59,6 @@ walletH walletPresent = do
5559
newWalletH walletMnemonicLink $ PostWalletConfig
5660
{ walletDataLink = walletLink
5761
, passwordVisibility = Just Hidden
58-
, namePresence = False
5962
}
6063

6164
base16 :: ByteString -> Text

lib/ui/src/Cardano/Wallet/UI/Shelley/Html/Pages/Page.hs

+5
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ import Cardano.Wallet.UI.Shelley.Html.Pages.Wallet
5555
import Cardano.Wallet.UI.Shelley.Html.Pages.Wallets
5656
( walletsH
5757
)
58+
import Cardano.Wallet.UI.Type
59+
( WalletType (..)
60+
, runWHtml
61+
)
5862
import Control.Lens.Extras
5963
( is
6064
)
@@ -89,6 +93,7 @@ page
8993
-> RawHtml
9094
page c@PageConfig{..} p wp = RawHtml
9195
$ renderBS
96+
$ runWHtml Shelley
9297
$ pageFromBodyH faviconLink c
9398
$ bodyH (headerH prefix p)
9499
$ case p of

lib/ui/src/Cardano/Wallet/UI/Shelley/Html/Pages/Wallets.hs

+4-2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ import Cardano.Wallet.UI.Shelley.API
4949
import Cardano.Wallet.UI.Shelley.Html.Pages.Wallet
5050
( renderState
5151
)
52+
import Cardano.Wallet.UI.Type
53+
( WHtml
54+
)
5255
import Control.Monad
5356
( forM_
5457
)
@@ -72,13 +75,12 @@ import Lucid
7275

7376
data Selected = Selected | NotSelected
7477

75-
walletsH :: Html ()
78+
walletsH :: WHtml ()
7679
walletsH = do
7780
sseH sseLink walletsListLink "content" ["wallets"]
7881
newWalletH walletMnemonicLink $ PostWalletConfig
7982
{ walletDataLink = walletLink
8083
, passwordVisibility = Just Hidden
81-
, namePresence = True
8284
}
8385

8486
walletListH :: Maybe WalletId -> [(ApiWallet, UTCTime)] -> Html ()

0 commit comments

Comments
 (0)