ssm-browse: added mark and delete in dynamo-browse
This commit is contained in:
parent
b3d0fbfe29
commit
c49f3913a8
10 changed files with 151 additions and 201 deletions
|
|
@ -28,8 +28,8 @@ func New() *Model {
|
|||
frameTitle := frame.NewFrameTitle("No table", true)
|
||||
|
||||
return &Model{
|
||||
frameTitle: frameTitle,
|
||||
table: tbl,
|
||||
frameTitle: frameTitle,
|
||||
table: tbl,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -85,6 +85,10 @@ func (m *Model) updateTable() {
|
|||
m.table = newTbl
|
||||
}
|
||||
|
||||
func (m *Model) SelectedItemIndex() int {
|
||||
return m.table.Cursor()
|
||||
}
|
||||
|
||||
func (m *Model) selectedItem() (itemTableRow, bool) {
|
||||
resultSet := m.resultSet
|
||||
if resultSet != nil && len(resultSet.Items) > 0 {
|
||||
|
|
@ -105,3 +109,8 @@ func (m *Model) postSelectedItemChanged() tea.Msg {
|
|||
|
||||
return dynamoitemview.NewItemSelected{ResultSet: item.resultSet, Item: item.item}
|
||||
}
|
||||
|
||||
func (m *Model) Refresh() {
|
||||
m.table.GoDown()
|
||||
m.table.GoUp()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package dynamotableview
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
|
|
@ -10,12 +11,19 @@ import (
|
|||
"github.com/lmika/awstools/internal/dynamo-browse/models"
|
||||
)
|
||||
|
||||
var (
|
||||
markedRowStyle = lipgloss.NewStyle().
|
||||
Background(lipgloss.Color("#e1e1e1"))
|
||||
)
|
||||
|
||||
type itemTableRow struct {
|
||||
resultSet *models.ResultSet
|
||||
item models.Item
|
||||
}
|
||||
|
||||
func (mtr itemTableRow) Render(w io.Writer, model table.Model, index int) {
|
||||
isMarked := mtr.resultSet.Marked(index)
|
||||
|
||||
sb := strings.Builder{}
|
||||
for i, colName := range mtr.resultSet.Columns {
|
||||
if i > 0 {
|
||||
|
|
@ -34,7 +42,13 @@ func (mtr itemTableRow) Render(w io.Writer, model table.Model, index int) {
|
|||
}
|
||||
}
|
||||
if index == model.Cursor() {
|
||||
fmt.Fprintln(w, model.Styles.SelectedRow.Render(sb.String()))
|
||||
style := model.Styles.SelectedRow
|
||||
if isMarked {
|
||||
style = style.Copy().Inherit(markedRowStyle)
|
||||
}
|
||||
fmt.Fprintln(w, style.Render(sb.String()))
|
||||
} else if isMarked {
|
||||
fmt.Fprintln(w, markedRowStyle.Render(sb.String()))
|
||||
} else {
|
||||
fmt.Fprintln(w, sb.String())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue