Skip to content

Commit

Permalink
Fix getting selected row
Browse files Browse the repository at this point in the history
  • Loading branch information
RamanaReddy0M committed Feb 3, 2023
1 parent 7d6c489 commit c8349b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 2 additions & 4 deletions internal/ui/select_table.go
Expand Up @@ -71,10 +71,8 @@ func (s *SelectTable) GetSelectedItem() string {
if s.GetSelectedRowIndex() == 0 || s.model.Empty() {
return ""
}
sel, ok := s.GetCell(s.GetSelectedRowIndex(), 0).GetReference().(string)
if !ok {
return ""
}
sel := s.GetCell(s.GetSelectedRowIndex(), 0).Text

if s.selectedFn != nil {
return s.selectedFn(sel)
}
Expand Down
8 changes: 8 additions & 0 deletions internal/view/ec2.go
Expand Up @@ -30,6 +30,7 @@ func (e *EC2) bindKeys(aa ui.KeyActions) {
ui.KeyShiftM: ui.NewKeyAction("Sort Monitoring-State", e.GetTable().SortColCmd("Monitoring-State", true), true),
ui.KeyShiftP: ui.NewKeyAction("Sort Public-DNS", e.GetTable().SortColCmd("Public-DNS", true), true),
tcell.KeyEscape: ui.NewKeyAction("Back", e.App().PrevCmd, true),
tcell.KeyEnter: ui.NewKeyAction("View", e.enterCmd, true),
})
}

Expand All @@ -39,3 +40,10 @@ func (e *EC2) describeInstace(app *App, model ui.Tabular, resource string) {
// app.Flash().Err(err)
// }
}

func (e *EC2) enterCmd(evt *tcell.EventKey) *tcell.EventKey {
instanceId := e.GetTable().GetSelectedItem()
e.App().Flash().Info("Instance-Id: " + instanceId)

return nil
}

0 comments on commit c8349b2

Please sign in to comment.