Skip to content

Commit

Permalink
Add services pause functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
mark2185 committed May 11, 2022
1 parent a789831 commit 0c2730b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/gui/keybindings.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,13 @@ func (gui *Gui) GetInitialKeybindings() []*Binding {
Handler: gui.handleServiceStop,
Description: gui.Tr.Stop,
},
{
ViewName: "services",
Key: 'p',
Modifier: gocui.ModNone,
Handler: gui.handleServicePause,
Description: gui.Tr.Pause,
},
{
ViewName: "services",
Key: 'r',
Expand Down
21 changes: 21 additions & 0 deletions pkg/gui/services_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,27 @@ func (gui *Gui) handleServiceRemoveMenu(g *gocui.Gui, v *gocui.View) error {
return gui.createServiceCommandMenu(options, gui.Tr.RemovingStatus)
}

func (gui *Gui) handleServicePause(g *gocui.Gui, v *gocui.View) error {
service, err := gui.getSelectedService()
if err != nil {
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()
})
}

func (gui *Gui) handleServiceStop(g *gocui.Gui, v *gocui.View) error {
service, err := gui.getSelectedService()
if err != nil {
Expand Down

0 comments on commit 0c2730b

Please sign in to comment.