Skip to content

Commit

Permalink
fix post request key ambiguity (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
mirzakhany authored Jul 19, 2024
1 parent b366630 commit 72062d7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion ui/pages/requests/component/pre_post_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,20 @@ func (p *PrePostRequest) SetEnvForm(gtx layout.Context, theme *chapartheme.Theme
}),
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
return topButtonInset.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
label := "Key"
hint := "e.g. name"
if p.setEnvForm.fromDropDown.GetSelected().Value == domain.PostRequestSetFromResponseBody {
label = "JSON Path"
hint = "e.g. $.data[0].name"
}

lb := &widgets.LabeledInput{
Label: "Path/Key",
Label: label,
SpaceBetween: 5,
MinEditorWidth: unit.Dp(150),
MinLabelWidth: unit.Dp(80),
Editor: &p.setEnvForm.fromEditor,
Hint: hint,
}
return lb.Layout(gtx, theme)
})
Expand Down
3 changes: 2 additions & 1 deletion ui/widgets/labeled_input.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type LabeledInput struct {
MinEditorWidth unit.Dp
MinLabelWidth unit.Dp
Editor *widget.Editor
Hint string
}

func (l *LabeledInput) Layout(gtx layout.Context, theme *chapartheme.Theme) layout.Dimensions {
Expand All @@ -36,7 +37,7 @@ func (l *LabeledInput) Layout(gtx layout.Context, theme *chapartheme.Theme) layo
CornerRadius: unit.Dp(4),
}.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
return layout.UniformInset(unit.Dp(8)).Layout(gtx, func(gtx layout.Context) layout.Dimensions {
editor := material.Editor(theme.Material(), l.Editor, " ")
editor := material.Editor(theme.Material(), l.Editor, l.Hint)
editor.SelectionColor = theme.TextSelectionColor

return editor.Layout(gtx)
Expand Down

0 comments on commit 72062d7

Please sign in to comment.