Added the clone command in SSM
This commit is contained in:
parent
ee6011bc3e
commit
306640abdb
9 changed files with 102 additions and 10 deletions
|
|
@ -3,11 +3,13 @@ package ui
|
|||
import (
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/lmika/awstools/internal/common/ui/commandctrl"
|
||||
"github.com/lmika/awstools/internal/common/ui/events"
|
||||
"github.com/lmika/awstools/internal/dynamo-browse/ui/teamodels/layout"
|
||||
"github.com/lmika/awstools/internal/dynamo-browse/ui/teamodels/statusandprompt"
|
||||
"github.com/lmika/awstools/internal/ssm-browse/controllers"
|
||||
"github.com/lmika/awstools/internal/ssm-browse/ui/ssmdetails"
|
||||
"github.com/lmika/awstools/internal/ssm-browse/ui/ssmlist"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Model struct {
|
||||
|
|
@ -27,6 +29,17 @@ func NewModel(controller *controllers.SSMController, cmdController *commandctrl.
|
|||
layout.NewVBox(layout.LastChildFixedAt(17), ssmList, ssmdDetails),
|
||||
"")
|
||||
|
||||
cmdController.AddCommands(&commandctrl.CommandContext{
|
||||
Commands: map[string]commandctrl.Command{
|
||||
"clone": func(args []string) tea.Cmd {
|
||||
if currentParam := ssmList.CurrentParameter(); currentParam != nil {
|
||||
return controller.Clone(*currentParam)
|
||||
}
|
||||
return events.SetError(errors.New("no parameter selected"))
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
root := layout.FullScreen(statusAndPrompt)
|
||||
|
||||
return Model{
|
||||
|
|
|
|||
|
|
@ -85,6 +85,14 @@ func (m *Model) emitNewSelectedParameter() tea.Cmd {
|
|||
}
|
||||
}
|
||||
|
||||
func (m *Model) CurrentParameter() *models.SSMParameter {
|
||||
if row, ok := m.table.SelectedRow().(itemTableRow); ok {
|
||||
return &(row.item)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Model) View() string {
|
||||
return lipgloss.JoinVertical(lipgloss.Top, m.frameTitle.View(), m.table.View())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue