Skip to content

Commit 6e74453

Browse files
committed
feat(update container status when interacting with compose)
1 parent 00be2cb commit 6e74453

4 files changed

Lines changed: 29 additions & 1 deletion

File tree

internal/dao/docker/container/container.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (c Container) GetStatusColor() (tcell.Color, tcell.Color) {
7474
lower := strings.ToLower(c.State)
7575

7676
// Fallback to parsed status if State is generic
77-
if strings.Contains(strings.ToLower(c.Status), "starting") {
77+
if strings.Contains(strings.ToLower(c.Status), "starting") && !strings.Contains(strings.ToLower(c.Status), "restarting") {
7878
return styles.ColorStatusBlue, styles.ColorBlack
7979
}
8080

@@ -89,6 +89,10 @@ func (c Container) GetStatusColor() (tcell.Color, tcell.Color) {
8989
return styles.ColorStatusYellow, styles.ColorBlack
9090
case "restarting":
9191
return styles.ColorStatusOrange, styles.ColorBlack
92+
case "stopping":
93+
return styles.ColorStatusRed, styles.ColorBlack
94+
case "starting":
95+
return styles.ColorStatusBlue, styles.ColorBlack
9296
case "exited", "dead":
9397
return styles.ColorStatusGray, styles.ColorBlack
9498
case "created":

internal/ui/app_actions.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,3 +194,12 @@ func (a *App) PerformCopy() {
194194
func (a *App) CopyToClipboard(text string) error {
195195
return clipboard.WriteAll(text)
196196
}
197+
198+
func (a *App) GetActionState(viewName string, id string) (string, tcell.Color, bool) {
199+
if v, ok := a.Views[viewName]; ok {
200+
if state, ok := v.ActionStates[id]; ok {
201+
return state.Label, state.Color, true
202+
}
203+
}
204+
return "", tcell.ColorDefault, false
205+
}

internal/ui/common/common.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ type AppController interface {
3232

3333
// Actions
3434
PerformAction(action func(id string) error, actionName string, color tcell.Color)
35+
GetActionState(viewName string, id string) (string, tcell.Color, bool)
3536
InspectCurrentSelection()
3637

3738
// State

internal/ui/views/containers/containers.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,20 @@ func Fetch(app common.AppController, v *view.ResourceView) ([]dao.Resource, erro
2323
return nil, err
2424
}
2525

26+
// Propagate Action State from Compose View
27+
// If a compose project is restarting, mark its containers as restarting
28+
for i, res := range data {
29+
if c, ok := res.(dao.Container); ok {
30+
if c.ProjectName != "" {
31+
if state, _, active := app.GetActionState(styles.TitleCompose, c.ProjectName); active {
32+
c.State = state
33+
c.Status = strings.Title(state) + "..."
34+
data[i] = c
35+
}
36+
}
37+
}
38+
}
39+
2640
scope := app.GetActiveScope()
2741
if scope != nil {
2842
if scope.Type == "compose" {

0 commit comments

Comments
 (0)