on master help sign in
Use popup for new cipher type selection
commit8d1771ea250256a280cdf2461bd5e3fda1dadb0e authoriko <ilyakooo0@gmail.com> dateSat 13 Aug 2022, 11:22 (4 years ago) parentc9bade6
4 files changed+69−120
frontend/Main.elm+1−38 frontend/Pages/Ciphers.elm+56−6 frontend/Pages/SelectCipherType.elm−76 style.css+12
frontend/Main.elm+1−38
@@ -16,7 +16,6 @@ import Pages.Loader exposing (loader)
1616import Pages.Login as Login
1717import Pages.MasterPassword as MasterPassword
1818import Pages.Navigation as Navigation exposing (TopButton(..))
19−import Pages.SelectCipherType as SelectCipherType
2019import Task
2120import Time
2221import Types exposing (CipherId)
@@ -62,8 +61,6 @@ type Msg
6261 | CreateCipher Bridge.FullCipher
6362 | FireGlobalEvent Event
6463 | GeneratePassword Bridge.PasswordGeneratorConfig
65− | CreateNewCipher
66− | SelectCipherTypeMsg SelectCipherType.Msg
6764 | OpenNewCipherEditPage Bridge.CipherType
6865
6966
@@ -88,7 +85,6 @@ type PageModel
8885 | MasterPasswordModel MasterPassword.Model
8986 | CipherModel Cipher.Model
9087 | CaptchaModel Captcha.Model
91− | SelectCipherTypeModel SelectCipherType.Model
9288
9389
9490showPage :
@@ -175,16 +171,6 @@ showPage email page =
175171 , topButton = Just (BackButton { action = PopView, icon = Just "close" })
176172 }
177173
178− SelectCipherTypeModel model ->
179− let
180− p =
181− SelectCipherType.page selectCipherTypeCallbacks SelectCipherTypeMsg
182− in
183− { title = p.title model
184− , body = p.view model
185− , topButton = Just simpleBackButton
186− }
187−
188174
189175main : Program () Model Msg
190176main =
@@ -279,9 +265,6 @@ doNotStoreInHistory page =
279265 LoadingPage ->
280266 True
281267
282− SelectCipherTypeModel _ ->
283− True
284−
285268 _ ->
286269 False
287270
@@ -543,9 +526,6 @@ update msg model =
543526
544527 CaptchaModel m ->
545528 (Captcha.page captchaCallbacks CaptchaMsg).event m ev |> CaptchaModel
546−
547− SelectCipherTypeModel m ->
548− (SelectCipherType.page selectCipherTypeCallbacks SelectCipherTypeMsg).event m ev |> SelectCipherTypeModel
549529 )
550530 }
551531 , Cmd.none
@@ -554,18 +534,6 @@ update msg model =
554534 GeneratePassword cfg ->
555535 ( model, FFI.sendBridge (Bridge.GeneratePassword cfg) )
556536
557− SelectCipherTypeMsg imsg ->
558− case currentPage of
559− SelectCipherTypeModel page ->
560− (SelectCipherType.page selectCipherTypeCallbacks SelectCipherTypeMsg).update imsg page |> processPage SelectCipherTypeModel
561−
562− _ ->
563− ( model, Cmd.none )
564−
565− CreateNewCipher ->
566− (SelectCipherType.page selectCipherTypeCallbacks SelectCipherTypeMsg).init ()
567− |> Tuple.mapFirst (\pageModel -> appendPageStack <| SelectCipherTypeModel pageModel)
568−
569537 OpenNewCipherEditPage t ->
570538 (EditCipher.page EditCipherMsg).init
571539 { callbacks = createCipherCallbacks
@@ -631,7 +599,7 @@ ciphersCallbacks : Ciphers.Callbacks Msg
631599ciphersCallbacks =
632600 { selected = RequestCipher
633601 , logOut = NeedsReset
634− , createNewCipher = CreateNewCipher
602+ , createNewCipher = OpenNewCipherEditPage
635603 }
636604
637605
@@ -660,8 +628,3 @@ masterPasswordCallbacks =
660628 { submit = SendMasterPassword
661629 , reset = NeedsReset
662630 }
663−
664−
665−selectCipherTypeCallbacks : SelectCipherType.Callbacks Msg
666−selectCipherTypeCallbacks =
667− { choose = OpenNewCipherEditPage }
frontend/Pages/Ciphers.elm+56−6
@@ -21,6 +21,7 @@ type alias Model =
2121 , ciphersListFilter : CiphersFilter
2222 , scroll : InfiniteScroll.Model Msg
2323 , sublist : { end : Int }
24+ , cipherSelectDropdownVisivble : Bool
2425 }
2526
2627
@@ -83,13 +84,14 @@ type Msg
8384 | LogOut
8485 | LoadMore InfiniteScroll.Direction
8586 | InfiniteScrollMsg InfiniteScroll.Msg
86− | CreateNewCipher
87+ | CreateNewCipher Bridge.CipherType
88+ | ToggleSelectCipherTypeVisible
8789
8890
8991type alias Callbacks msg =
9092 { selected : String -> msg
9193 , logOut : msg
92− , createNewCipher : msg
94+ , createNewCipher : Bridge.CipherType -> msg
9395 }
9496
9597
@@ -100,7 +102,7 @@ page callbacks liftMsg =
100102 , update = \msg model -> update callbacks liftMsg msg model
101103 , subscriptions = \model -> subscriptions model |> Sub.map liftMsg
102104 , title =
103− \{ ciphersListFilter } ->
105+ \{ ciphersListFilter, cipherSelectDropdownVisivble } ->
104106 [ text
105107 (case ciphersListFilter of
106108 AllCiphers ->
@@ -120,7 +122,49 @@ page callbacks liftMsg =
120122 Bridge.NoteType ->
121123 "Notes"
122124 )
123− , span [ Attr.class "u-float-right" ] [ iconButton "plus" (liftMsg CreateNewCipher) ]
125+ , span [ Attr.class "u-float-right" ]
126+ [ span [ Attr.class "p-contextual-menu" ]
127+ ([ span [] [ iconButton "plus" (liftMsg ToggleSelectCipherTypeVisible) ]
128+ ]
129+ ++ optionals cipherSelectDropdownVisivble
130+ [ div
131+ [ Attr.class "overlay"
132+ , Ev.onClick (liftMsg ToggleSelectCipherTypeVisible)
133+ ]
134+ []
135+ , span
136+ [ Attr.class "p-contextual-menu__dropdown"
137+ , Attr.attribute "aria-hidden" "false"
138+ ]
139+ (let
140+ create t =
141+ liftMsg (CreateNewCipher t)
142+ in
143+ [ button
144+ [ Attr.class "p-contextual-menu__link"
145+ , Ev.onClick (create Bridge.LoginType)
146+ ]
147+ [ text "Login" ]
148+ , button
149+ [ Attr.class "p-contextual-menu__link"
150+ , Ev.onClick (create Bridge.CardType)
151+ ]
152+ [ text "Card" ]
153+ , button
154+ [ Attr.class "p-contextual-menu__link"
155+ , Ev.onClick (create Bridge.NoteType)
156+ ]
157+ [ text "Note" ]
158+ , button
159+ [ Attr.class "p-contextual-menu__link"
160+ , Ev.onClick (create Bridge.IdentityType)
161+ ]
162+ [ text "Contact" ]
163+ ]
164+ )
165+ ]
166+ )
167+ ]
124168 ]
125169 , event =
126170 \model ev ->
@@ -152,6 +196,7 @@ init ciphers =
152196 , ciphersListFilter = AllCiphers
153197 , scroll = InfiniteScroll.init (LoadMore >> pureCmd)
154198 , sublist = { end = 20 }
199+ , cipherSelectDropdownVisivble = False
155200 }
156201 , Cmd.none
157202 )
@@ -194,8 +239,13 @@ update { logOut, createNewCipher } liftMsg msg model =
194239 in
195240 ( Ok { model | scroll = scroll }, Cmd.map liftMsg cmd )
196241
197− CreateNewCipher ->
198− ( Ok model, pureCmd createNewCipher )
242+ CreateNewCipher t ->
243+ ( Ok { model | cipherSelectDropdownVisivble = False }, pureCmd (createNewCipher t) )
244+
245+ ToggleSelectCipherTypeVisible ->
246+ ( Ok { model | cipherSelectDropdownVisivble = not model.cipherSelectDropdownVisivble }
247+ , Cmd.none
248+ )
199249
200250
201251subscriptions : Model -> Sub Msg
frontend/Pages/SelectCipherType.elmdeleted−76
@@ -1,76 +0,0 @@
1−module Pages.SelectCipherType exposing (..)
2−
3−import Bridge
4−import Html exposing (..)
5−import Html.Attributes as Attr
6−import Html.Events as Ev
7−import Page exposing (..)
8−import Utils exposing (..)
9−
10−
11−type alias Model =
12− {}
13−
14−
15−type Msg
16− = Choose Bridge.CipherType
17−
18−
19−type alias Callbacks msg =
20− { choose : Bridge.CipherType -> msg
21− }
22−
23−
24−page : Callbacks emsg -> Page () Model Msg emsg
25−page callbacks liftMsg =
26− { init = \() -> Tuple.mapSecond (Cmd.map liftMsg) init
27− , view = \model -> view model |> List.map (Html.map liftMsg)
28− , update = \msg model -> update callbacks liftMsg msg model
29− , subscriptions = \model -> subscriptions model |> Sub.map liftMsg
30− , title = always [ text "Select entry type" ]
31− , event = \model _ -> model
32− }
33−
34−
35−init : ( Model, Cmd Msg )
36−init =
37− ( {}, Cmd.none )
38−
39−
40−update : Callbacks emsg -> (Msg -> emsg) -> Msg -> Model -> ( Result String Model, Cmd emsg )
41−update { choose } _ msg model =
42− case msg of
43− Choose t ->
44− ( Ok model, pureCmd (choose t) )
45−
46−
47−subscriptions : Model -> Sub Msg
48−subscriptions model =
49− Sub.none
50−
51−
52−view : Model -> List (Html Msg)
53−view {} =
54− [ div [ Attr.class "select-cipher-type-container" ]
55− [ button
56− [ Attr.class "p-button"
57− , Ev.onClick (Choose Bridge.LoginType)
58− ]
59− [ text "Login" ]
60− , button
61− [ Attr.class "p-button"
62− , Ev.onClick (Choose Bridge.CardType)
63− ]
64− [ text "Card" ]
65− , button
66− [ Attr.class "p-button"
67− , Ev.onClick (Choose Bridge.NoteType)
68− ]
69− [ text "Note" ]
70− , button
71− [ Attr.class "p-button"
72− , Ev.onClick (Choose Bridge.IdentityType)
73− ]
74− [ text "Contact" ]
75− ]
76− ]
style.css+12
@@ -123,3 +123,15 @@ textarea {
123123 margin: 0px;
124124 margin-bottom: 1.5rem;
125125}
126+
127+.overlay {
128+ position: fixed;
129+ top: 0;
130+ left: 0;
131+ right: 0;
132+ bottom: 0;
133+}
134+
135+.p-tabs__list {
136+ overflow: initial;
137+}