parent
9b498196f9
commit
107c0acd33
|
|
@ -206,6 +206,11 @@ func (t *Table) doUpdate(data render.TableData) {
|
|||
|
||||
if (t.sortCol.name == "" || custData.Header.IndexOf(t.sortCol.name, false) == -1) && len(custData.Header) > 0 && t.sortCol.name != "NONE" {
|
||||
t.sortCol.name = custData.Header[0].Name
|
||||
if t.sortCol.name == "NAMESPACE" && !client.IsAllNamespaces(data.Namespace) {
|
||||
if idx := custData.Header.IndexOf("NAME", false); idx != -1 {
|
||||
t.sortCol.name = custData.Header[idx].Name
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
t.Clear()
|
||||
|
|
|
|||
|
|
@ -63,23 +63,18 @@ func (s *ScaleExtender) showScaleDialog(path string) {
|
|||
s.App().Content.ShowPage(scaleDialogKey)
|
||||
}
|
||||
|
||||
func (s *ScaleExtender) valueOf(col string, index int) (string, error) {
|
||||
data := s.GetTable().GetFilteredData()
|
||||
colIdx := data.IndexOfHeader(col)
|
||||
if colIdx < 0 {
|
||||
func (s *ScaleExtender) valueOf(col string, rowIndex int) (string, error) {
|
||||
colIdx, ok := s.GetTable().HeaderIndex(col)
|
||||
if !ok {
|
||||
return "", fmt.Errorf("no column index for %s", col)
|
||||
}
|
||||
if index > len(data.RowEvents) {
|
||||
return "", fmt.Errorf("invalid row index %d", index)
|
||||
}
|
||||
|
||||
return data.RowEvents[index].Row.Fields[colIdx], nil
|
||||
return s.GetTable().GetSelectedCell(colIdx), nil
|
||||
}
|
||||
|
||||
func (s *ScaleExtender) makeScaleForm(sel string) (*tview.Form, error) {
|
||||
f := s.makeStyledForm()
|
||||
|
||||
replicas, err := s.valueOf("READY", s.GetTable().GetSelectedRowIndex())
|
||||
replicas, err := s.valueOf("READY", s.GetTable().GetSelectedRowIndex()-1)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,15 @@ func (t *Table) Init(ctx context.Context) (err error) {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (t *Table) HeaderIndex(header string) (int, bool) {
|
||||
for i := 0; i < t.GetColumnCount(); i++ {
|
||||
if h := t.GetCell(0, i); h != nil && h.Text == header {
|
||||
return i, true
|
||||
}
|
||||
}
|
||||
return 0, false
|
||||
}
|
||||
|
||||
// SendKey sends an keyboard event (testing only!).
|
||||
func (t *Table) SendKey(evt *tcell.EventKey) {
|
||||
t.app.Prompt().SendKey(evt)
|
||||
|
|
|
|||
Loading…
Reference in New Issue