Fix broken alias view
parent
fcd2611547
commit
668bc063ef
|
|
@ -3,6 +3,7 @@ package views
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/derailed/k9s/internal/resource"
|
"github.com/derailed/k9s/internal/resource"
|
||||||
|
|
@ -16,7 +17,6 @@ const (
|
||||||
|
|
||||||
type aliasView struct {
|
type aliasView struct {
|
||||||
*tableView
|
*tableView
|
||||||
|
|
||||||
current igniter
|
current igniter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -26,12 +26,18 @@ func newAliasView(app *appView) *aliasView {
|
||||||
v.SetSelectedStyle(tcell.ColorWhite, tcell.ColorFuchsia, tcell.AttrNone)
|
v.SetSelectedStyle(tcell.ColorWhite, tcell.ColorFuchsia, tcell.AttrNone)
|
||||||
v.colorerFn = aliasColorer
|
v.colorerFn = aliasColorer
|
||||||
v.current = app.content.GetPrimitive("main").(igniter)
|
v.current = app.content.GetPrimitive("main").(igniter)
|
||||||
|
v.sortFn = v.sorterFn
|
||||||
}
|
}
|
||||||
v.actions[tcell.KeyEnter] = newKeyAction("Search", v.aliasCmd)
|
v.actions[tcell.KeyEnter] = newKeyAction("Search", v.aliasCmd)
|
||||||
|
v.actions[tcell.KeyEscape] = newKeyAction("Reset", v.resetCmd)
|
||||||
v.actions[KeySlash] = newKeyAction("Filter", v.activateCmd)
|
v.actions[KeySlash] = newKeyAction("Filter", v.activateCmd)
|
||||||
return &v
|
return &v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (v *aliasView) sorterFn(ss []string) {
|
||||||
|
sort.Strings(ss)
|
||||||
|
}
|
||||||
|
|
||||||
// Init the view.
|
// Init the view.
|
||||||
func (v *aliasView) init(context.Context, string) {
|
func (v *aliasView) init(context.Context, string) {
|
||||||
v.update(v.hydrate())
|
v.update(v.hydrate())
|
||||||
|
|
@ -43,6 +49,15 @@ func (v *aliasView) getTitle() string {
|
||||||
return aliasTitle
|
return aliasTitle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (v *aliasView) resetCmd(evt *tcell.EventKey) *tcell.EventKey {
|
||||||
|
if !v.cmdBuff.empty() {
|
||||||
|
v.cmdBuff.reset()
|
||||||
|
v.refresh()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return v.backCmd(evt)
|
||||||
|
}
|
||||||
|
|
||||||
func (v *aliasView) aliasCmd(evt *tcell.EventKey) *tcell.EventKey {
|
func (v *aliasView) aliasCmd(evt *tcell.EventKey) *tcell.EventKey {
|
||||||
if v.cmdBuff.isActive() {
|
if v.cmdBuff.isActive() {
|
||||||
return v.filterCmd(evt)
|
return v.filterCmd(evt)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue