Skip to content

Commit

Permalink
Refactor pausing a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
mark2185 committed May 12, 2022
1 parent 0ced576 commit a03f550
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
18 changes: 11 additions & 7 deletions pkg/gui/containers_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -423,13 +423,8 @@ func (gui *Gui) handleContainersRemoveMenu(g *gocui.Gui, v *gocui.View) error {
return gui.createMenu("", options, len(options), handleMenuPress)
}

func (gui *Gui) handleContainerPause(g *gocui.Gui, v *gocui.View) error {
container, err := gui.getSelectedContainer()
if err != nil {
return nil
}

return gui.WithWaitingStatus(gui.Tr.PausingStatus, func() error {
func (gui *Gui) PauseContainer(container *commands.Container) error {
return gui.WithWaitingStatus(gui.Tr.PausingStatus, func() (err error) {
if container.Details.State.Paused {
err = container.Unpause()
} else {
Expand All @@ -444,6 +439,15 @@ func (gui *Gui) handleContainerPause(g *gocui.Gui, v *gocui.View) error {
})
}

func (gui *Gui) handleContainerPause(g *gocui.Gui, v *gocui.View) error {
container, err := gui.getSelectedContainer()
if err != nil {
return nil
}

return gui.PauseContainer(container)
}

func (gui *Gui) handleContainerStop(g *gocui.Gui, v *gocui.View) error {
container, err := gui.getSelectedContainer()
if err != nil {
Expand Down
14 changes: 1 addition & 13 deletions pkg/gui/services_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,19 +228,7 @@ func (gui *Gui) handleServicePause(g *gocui.Gui, v *gocui.View) error {
return nil
}

return gui.WithWaitingStatus(gui.Tr.PausingStatus, func() error {
if service.Container.Details.State.Paused {
err = service.Container.Unpause()
} else {
err = service.Container.Pause()
}

if err != nil {
return gui.createErrorPanel(gui.g, err.Error())
}

return gui.refreshContainersAndServices()
})
return gui.PauseContainer(service.Container)
}

func (gui *Gui) handleServiceStop(g *gocui.Gui, v *gocui.View) error {
Expand Down

0 comments on commit a03f550

Please sign in to comment.