more use of waiting statuses

pull/1/head
Jesse Duffield 5 years ago
parent 1ed796eb32
commit 2f57561c40

@ -330,11 +330,15 @@ func (c *DockerCommand) GetImages() ([]*Image, error) {
}
nameParts := strings.Split(name, ":")
tag := ""
if len(nameParts) > 1 {
tag = nameParts[1]
}
ownImages[i] = &Image{
ID: image.ID,
Name: nameParts[0],
Tag: nameParts[1],
Tag: tag,
Image: image,
Client: c.Client,
OSCommand: c.OSCommand,

@ -355,24 +355,30 @@ func (gui *Gui) handleContainersRemoveMenu(g *gocui.Gui, v *gocui.View) error {
return nil
}
configOptions := options[index].configOptions
if cerr := container.Remove(configOptions); cerr != nil {
var originalErr commands.ComplexError
if xerrors.As(cerr, &originalErr) {
if originalErr.Code == commands.MustStopContainer {
return gui.createConfirmationPanel(gui.g, v, gui.Tr.SLocalize("Confirm"), gui.Tr.SLocalize("mustForceToRemoveContainer"), func(g *gocui.Gui, v *gocui.View) error {
configOptions.Force = true
if err := container.Remove(configOptions); err != nil {
return err
}
return gui.refreshContainersAndServices()
}, nil)
return gui.WithWaitingStatus(gui.Tr.SLocalize("RemovingStatus"), func() error {
if cerr := container.Remove(configOptions); cerr != nil {
var originalErr commands.ComplexError
if xerrors.As(cerr, &originalErr) {
if originalErr.Code == commands.MustStopContainer {
return gui.createConfirmationPanel(gui.g, v, gui.Tr.SLocalize("Confirm"), gui.Tr.SLocalize("mustForceToRemoveContainer"), func(g *gocui.Gui, v *gocui.View) error {
return gui.WithWaitingStatus(gui.Tr.SLocalize("RemovingStatus"), func() error {
configOptions.Force = true
if err := container.Remove(configOptions); err != nil {
return err
}
return gui.refreshContainersAndServices()
})
}, nil)
}
} else {
return gui.createErrorPanel(gui.g, cerr.Error())
}
} else {
return gui.createErrorPanel(gui.g, cerr.Error())
}
}
return gui.refreshContainersAndServices()
return gui.refreshContainersAndServices()
})
}
return gui.createMenu("", options, len(options), handleMenuPress)

@ -219,11 +219,13 @@ func (gui *Gui) handleServiceRemoveMenu(g *gocui.Gui, v *gocui.View) error {
if options[index].command == "" {
return nil
}
if err := gui.OSCommand.RunCommand(options[index].command); err != nil {
return gui.createErrorPanel(gui.g, err.Error())
}
return gui.WithWaitingStatus(gui.Tr.SLocalize("RemovingStatus"), func() error {
if err := gui.OSCommand.RunCommand(options[index].command); err != nil {
return gui.createErrorPanel(gui.g, err.Error())
}
return gui.refreshContainersAndServices()
return gui.refreshContainersAndServices()
})
}
return gui.createMenu("", options, len(options), handleMenuPress)

@ -784,6 +784,10 @@ func addEnglish(i18nObject *i18n.Bundle) error {
ID: "StoppingStatus",
Other: "stopping",
},
&i18n.Message{
ID: "RemovingStatus",
Other: "removing",
},
&i18n.Message{
ID: "remove",
Other: "remove",

Loading…
Cancel
Save