Skip to content

Commit

Permalink
Disable buttons during validation
Browse files Browse the repository at this point in the history
  • Loading branch information
mcasperson committed Aug 21, 2024
1 parent b51eb0f commit 81869ba
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 17 deletions.
21 changes: 14 additions & 7 deletions internal/steps/octopus_destination_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ import (

type OctopusDestinationDetails struct {
BaseStep
Wizard wizard.Wizard
server *widget.Entry
apiKey *widget.Entry
spaceId *widget.Entry
result *widget.Label
Wizard wizard.Wizard
server *widget.Entry
apiKey *widget.Entry
spaceId *widget.Entry
result *widget.Label
next *widget.Button
previous *widget.Button
}

func (s OctopusDestinationDetails) GetContainer(parent fyne.Window) *fyne.Container {

bottom, _, next := s.BuildNavigation(func() {
bottom, previous, next := s.BuildNavigation(func() {
s.Wizard.ShowWizardStep(OctopusDetails{
Wizard: s.Wizard,
BaseStep: BaseStep{State: s.getState()}})
Expand All @@ -34,9 +36,13 @@ func (s OctopusDestinationDetails) GetContainer(parent fyne.Window) *fyne.Contai
s.apiKey.Disable()
s.server.Disable()
s.spaceId.Disable()
s.next.Disable()
s.previous.Disable()
defer s.apiKey.Enable()
defer s.server.Enable()
defer s.spaceId.Enable()
defer s.next.Enable()
defer s.previous.Enable()

validationFailed := false
if !validators.ValidateDestinationCreds(s.getState()) {
Expand All @@ -58,7 +64,8 @@ func (s OctopusDestinationDetails) GetContainer(parent fyne.Window) *fyne.Contai
nexCallback(true)
}
})

s.next = next
s.previous = previous
s.result = widget.NewLabel("")

validation := func(input string) {
Expand Down
21 changes: 14 additions & 7 deletions internal/steps/octopus_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ import (

type OctopusDetails struct {
BaseStep
Wizard wizard.Wizard
server *widget.Entry
apiKey *widget.Entry
spaceId *widget.Entry
result *widget.Label
Wizard wizard.Wizard
server *widget.Entry
apiKey *widget.Entry
spaceId *widget.Entry
result *widget.Label
next *widget.Button
previous *widget.Button
}

func (s OctopusDetails) GetContainer(parent fyne.Window) *fyne.Container {

bottom, _, next := s.BuildNavigation(func() {
bottom, previous, next := s.BuildNavigation(func() {
s.Wizard.ShowWizardStep(TestTerraformStep{
Wizard: s.Wizard,
BaseStep: BaseStep{State: s.getState()}})
Expand All @@ -33,9 +35,13 @@ func (s OctopusDetails) GetContainer(parent fyne.Window) *fyne.Container {
s.apiKey.Disable()
s.server.Disable()
s.spaceId.Disable()
s.next.Disable()
s.previous.Disable()
defer s.apiKey.Enable()
defer s.server.Enable()
defer s.spaceId.Enable()
defer s.next.Enable()
defer s.previous.Enable()

validationFailed := false
if !validators.ValidateSourceCreds(s.getState()) {
Expand All @@ -57,7 +63,8 @@ func (s OctopusDetails) GetContainer(parent fyne.Window) *fyne.Container {
nexCallback(true)
}
})

s.next = next
s.previous = previous
s.result = widget.NewLabel("")

validation := func(input string) {
Expand Down
15 changes: 12 additions & 3 deletions internal/steps/test_terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,24 @@ import (

type TestTerraformStep struct {
BaseStep
Wizard wizard.Wizard
result *widget.Label
Wizard wizard.Wizard
result *widget.Label
next *widget.Button
previous *widget.Button
}

func (s TestTerraformStep) GetContainer(parent fyne.Window) *fyne.Container {

bottom, _, _ := s.BuildNavigation(func() {
bottom, previous, next := s.BuildNavigation(func() {
s.Wizard.ShowWizardStep(WelcomeStep{
Wizard: s.Wizard,
BaseStep: BaseStep{State: s.State}})
}, func() {
s.next.Disable()
s.previous.Disable()
defer s.next.Enable()
defer s.previous.Enable()

s.result.SetText("🔵 Testing Terraform installation.")

if s.Execute() {
Expand All @@ -34,6 +41,8 @@ func (s TestTerraformStep) GetContainer(parent fyne.Window) *fyne.Container {
s.notInstalled()
}
})
s.next = next
s.previous = previous

heading := widget.NewLabel("Test Terraform")
heading.TextStyle = fyne.TextStyle{Bold: true}
Expand Down

0 comments on commit 81869ba

Please sign in to comment.