-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
555 additions
and
323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package models | ||
|
||
import ( | ||
"fmt" | ||
|
||
tea "github.com/charmbracelet/bubbletea" | ||
) | ||
|
||
type ContainerSearch struct { | ||
Search | ||
} | ||
|
||
func NewContainerSearch() ContainerSearch { | ||
return ContainerSearch{ | ||
NewSearch(), | ||
} | ||
} | ||
|
||
func (cs ContainerSearch) View() string { | ||
return fmt.Sprintf( | ||
"Search container by name\n\n%s\n\n%s", | ||
cs.textInput.View(), | ||
"(esc to back)", | ||
) + "\n" | ||
} | ||
|
||
func (cs ContainerSearch) Update(msg tea.Msg, m *model) (ContainerSearch, tea.Cmd) { | ||
switch msg := msg.(type) { | ||
case tea.KeyMsg: | ||
switch msg.String() { | ||
case "enter": | ||
if m.currentModel != MContainerSearch { | ||
return cs, nil | ||
} | ||
value := cs.textInput.Value() | ||
t := NewContainerList(GetContainerRows(m.dockerClient.Containers, value)) | ||
m.containerList = t | ||
m.currentModel = MContainerList | ||
} | ||
} | ||
|
||
cs.textInput, _ = cs.textInput.Update(msg) | ||
return cs, nil | ||
} |
Oops, something went wrong.