-
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
4 changed files
with
56 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package models | ||
|
||
import ( | ||
"fmt" | ||
|
||
tea "github.com/charmbracelet/bubbletea" | ||
) | ||
|
||
type NetworkSearch struct { | ||
Search | ||
} | ||
|
||
func NewNetworkSearch() NetworkSearch { | ||
return NetworkSearch{ | ||
NewSearch(), | ||
} | ||
} | ||
|
||
func (ns NetworkSearch) View() string { | ||
return fmt.Sprintf( | ||
"Search network by name\n\n%s\n\n%s", | ||
ns.textInput.View(), | ||
"(esc to back)", | ||
) + "\n" | ||
} | ||
|
||
func (ns NetworkSearch) Update(msg tea.Msg, m *model) (NetworkSearch, tea.Cmd) { | ||
if m.currentModel != MNetworkSearch { | ||
return ns, nil | ||
} | ||
|
||
switch msg := msg.(type) { | ||
case tea.KeyMsg: | ||
switch msg.String() { | ||
case "enter": | ||
value := ns.textInput.Value() | ||
m.networkList = NewNetworkList(m.dockerClient.Networks, value) | ||
m.currentModel = MNetworkList | ||
} | ||
} | ||
|
||
ns.textInput, _ = ns.textInput.Update(msg) | ||
return ns, nil | ||
} |