Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(play): export masking as test venom + share sandbox as url link #178

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 148 additions & 0 deletions web/play/src/Dropdown.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
module Dropdown exposing (..)

import Css
import Play exposing (..)
import Html.Styled exposing (..)
import Html.Styled.Attributes as Attr exposing (..)
import Style exposing (onCustomClick)
import Svg.Styled as Svg exposing (svg, path)
import Svg.Styled.Attributes as SvgAttr
import Tailwind.Breakpoints as Bp
import Tailwind.Utilities as Tw exposing (..)

on : Attribute msg
on =
css
[ Tw.contents
, Tw.z_10
, Tw.w_44
, Tw.bg_white
, Tw.rounded
, Tw.divide_y
, Tw.divide_gray_100
, Tw.shadow
]

off : Attribute msg
off =
css
[ Tw.hidden
, Tw.z_10
, Tw.w_44
, Tw.bg_white
, Tw.rounded
, Tw.divide_y
, Tw.divide_gray_100
, Tw.shadow
]

view : DropdownView -> Html Msg
view dropdownView =
div
[ css
[ Tw.flex
, Tw.flex_row_reverse
, Tw.mb_5
, Tw.neg_mt_10
, Tw.bg_black
, Tw.text_white
]
]
[button
[ Attr.id "dropdownBottomButton"
, Attr.attribute "data-dropdown-toggle" "dropdownBottom"
, Attr.attribute "data-dropdown-placement" "bottom"
, css
[ Tw.mr_3
, Tw.mb_3
, Tw.text_white
, Tw.bg_blue_700
, Tw.font_medium
, Tw.rounded_lg
, Tw.text_sm
, Tw.px_4
, Tw.py_2_dot_5
, Tw.text_center
, Tw.inline_flex
, Tw.items_center
, Css.focus
[ Tw.ring_4
, Tw.outline_none
, Tw.ring_blue_300
]
, Css.hover
[ Tw.bg_blue_800
]
, Bp.md
[ Tw.mb_0
]
]
, Attr.type_ "button"
, onCustomClick <| ChangeDropdownView Open
]
[ text "Options", svg
[ SvgAttr.css
[ Tw.ml_2
, Tw.w_4
, Tw.h_4
]
, Attr.attribute "aria-hidden" "true"
, SvgAttr.fill "currentColor"
, SvgAttr.viewBox "0 0 20 20"
]
[ path
[ SvgAttr.fillRule "evenodd"
, SvgAttr.d "M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
, SvgAttr.clipRule "evenodd"
]
[]
]
]
, {- Dropdown menu -}
div
[ Attr.id "dropdown"
, case dropdownView of
Open ->
on
_ ->
off
]
[ ul
[ css
[ Tw.py_1
, Tw.text_sm
, Tw.text_white
]
, Attr.attribute "aria-labelledby" "dropdownBottomButton"
]
[ li [Attr.id "share"]
[ a
[ Attr.href "#"
, css
[ Tw.block
, Tw.py_2
, Tw.px_4
, Css.hover
[ Tw.bg_blue_700
]
]
]
[ text "Share : Copy link" ]
]
, li [Attr.id "venom"]
[ a
[ Attr.href "#"
, css
[ Tw.block
, Tw.py_2
, Tw.px_4
, Css.hover
[ Tw.bg_blue_700
]
]
]
[ text "Export as Venom Test" ]
]
]
]
]
11 changes: 9 additions & 2 deletions web/play/src/Header.elm
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import Html.Styled exposing (..)
import Html.Styled.Attributes as Attr exposing (..)
import Play exposing (Msg(..), init_sandbox)
import Style exposing (onCustomClick)
import Tailwind.Breakpoints as Breakpoints
import Tailwind.Utilities as Tw exposing (..)


view : String -> Html Msg
view version =
div
[ Attr.css [ mb_5, flex, space_x_4, items_baseline, bg_black, text_white ] ]
[ Attr.css [ flex, space_x_4, items_baseline, bg_black, text_white ] ]
[ div
[ Attr.css [ m_5, font_sans, text_4xl, font_bold ]
]
Expand All @@ -37,4 +37,11 @@ view version =
[ Attr.css [ grow ]
]
[]
, div
[ Attr.css [ Tw.px_4, Breakpoints.lg [ Tw.px_16 ], Breakpoints.md [ Tw.px_8 ] ] ]
[ div
[ Attr.css [ Tw.grid, Breakpoints.sm [ Tw.grid_cols_2 ], Tw.gap_4, Breakpoints.md [ gap_8 ] ]
]
[]
]
]
24 changes: 16 additions & 8 deletions web/play/src/Main.elm
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module Main exposing (init, main, update, view)

import Browser
import Browser.Events exposing (onClick)
import Css.Global
import Error
import Examples
import Header exposing (view)
import Dropdown exposing (view)
import Html.Styled as Html exposing (..)
import Html.Styled.Attributes as Attr exposing (..)
import Http
Expand All @@ -29,6 +31,7 @@ init version =
, status = Loading
, maskingView = YamlView
, flow = ""
, dropdownView = Close
}
, Cmd.none
)
Expand Down Expand Up @@ -104,11 +107,11 @@ update message model =
GotFlowData result ->
case result of
Ok ( _, flow ) ->
let
cmd = case model.maskingView of
GraphView -> updateFlow flow
let
cmd = case model.maskingView of
GraphView -> updateFlow flow
_ -> Cmd.none
in
in
( { model
| flow = flow
}
Expand Down Expand Up @@ -141,16 +144,19 @@ update message model =
)

ChangeMaskingView maskingView ->
let
cmd = case maskingView of
GraphView -> updateFlow model.flow
let
cmd = case maskingView of
GraphView -> updateFlow model.flow
_ -> Cmd.none
in
in
( { model | maskingView = maskingView }, cmd )

Error errorMessage ->
( { model | error = errorMessage }, Cmd.none )

ChangeDropdownView dropdownView ->
( { model | dropdownView = dropdownView }, Cmd.none )



-- ---------------------------
Expand All @@ -165,6 +171,7 @@ view model =
[]
[ Css.Global.global Tw.globalStyles
, Header.view model.version
, Dropdown.view model.dropdownView
, div
[ Attr.css [ Tw.px_4, Breakpoints.lg [ Tw.px_16 ], Breakpoints.md [ Tw.px_8 ] ] ]
[ div
Expand Down Expand Up @@ -219,6 +226,7 @@ subscriptions _ =
[ maskingUpdater UpdateMasking
, inputUpdater UpdateInput
, maskingAndinputUpdater mapMaskingAndinputUpdater
, onClick (JD.succeed (ChangeDropdownView Close))
]


Expand Down
8 changes: 7 additions & 1 deletion web/play/src/Play.elm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ masking:
}"""
}


type alias Model =
{ version : String
, sandbox : Sandbox
Expand All @@ -34,6 +33,7 @@ type alias Model =
, status : Status
, maskingView : MaskingView
, flow : String
, dropdownView : DropdownView
}


Expand All @@ -54,6 +54,11 @@ type MaskingView
| GraphView


type DropdownView
= Open
| Close


type Msg
= GotMaskedData (Result (Http.Detailed.Error String) ( Http.Metadata, String ))
| GotFlowData (Result (Http.Detailed.Error String) ( Http.Metadata, String ))
Expand All @@ -63,6 +68,7 @@ type Msg
| Refresh
| Error String
| ChangeMaskingView MaskingView
| ChangeDropdownView DropdownView


asMaskingIn : Sandbox -> String -> Sandbox
Expand Down
Loading