-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
event.go
35 lines (30 loc) 路 1 KB
/
event.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package view
import (
"github.com/derailed/k9s/internal/client"
"github.com/derailed/k9s/internal/render"
"github.com/derailed/k9s/internal/ui"
"github.com/gdamore/tcell"
)
// Event represents a command alias view.
type Event struct {
ResourceViewer
}
// NewEvent returns a new alias view.
func NewEvent(gvr client.GVR) ResourceViewer {
e := Event{
ResourceViewer: NewBrowser(gvr),
}
e.GetTable().SetColorerFn(render.Event{}.ColorerFunc())
e.SetBindKeysFn(e.bindKeys)
e.GetTable().SetSortCol(ageCol, true)
return &e
}
func (e *Event) bindKeys(aa ui.KeyActions) {
aa.Delete(tcell.KeyCtrlD, ui.KeyE)
aa.Add(ui.KeyActions{
ui.KeyShiftY: ui.NewKeyAction("Sort Type", e.GetTable().SortColCmd("TYPE", true), false),
ui.KeyShiftR: ui.NewKeyAction("Sort Reason", e.GetTable().SortColCmd("REASON", true), false),
ui.KeyShiftE: ui.NewKeyAction("Sort Source", e.GetTable().SortColCmd("SOURCE", true), false),
ui.KeyShiftC: ui.NewKeyAction("Sort Count", e.GetTable().SortColCmd("COUNT", true), false),
})
}