Skip to content

Commit

Permalink
feat: refresh packages and artifacts panes
Browse files Browse the repository at this point in the history
  • Loading branch information
vadimklimov committed Jan 25, 2025
1 parent 11d9a7f commit 6720ed6
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
24 changes: 15 additions & 9 deletions internal/ui/common/keymap/keymap.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ package keymap
import "github.com/charmbracelet/bubbles/key"

type KeyMap struct {
Up key.Binding
Down key.Binding
Left key.Binding
Right key.Binding
Enter key.Binding
Tab key.Binding
Quit key.Binding
Layout key.Binding
Open key.Binding
Up key.Binding
Down key.Binding
Left key.Binding
Right key.Binding
Enter key.Binding
Tab key.Binding
Quit key.Binding
Layout key.Binding
Refresh key.Binding
Open key.Binding
}

func DefaultKeyMap() *KeyMap {
Expand Down Expand Up @@ -57,6 +58,11 @@ func DefaultKeyMap() *KeyMap {
key.WithHelp("l", "layout"),
)

keymap.Refresh = key.NewBinding(
key.WithKeys("r"),
key.WithHelp("r", "refresh"),
)

keymap.Open = key.NewBinding(
key.WithKeys("o"),
key.WithHelp("o", "open"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,19 @@ func (model *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

case IntegrationFlowsMsg:
model.integrationflows.SetItems(convertArtifactsToListItems(msg))
model.integrationflows.ResetSelected()

case ValueMappingsMsg:
model.valuemappings.SetItems(convertArtifactsToListItems(msg))
model.valuemappings.ResetSelected()

case MessageMappingsMsg:
model.messagemappings.SetItems(convertArtifactsToListItems(msg))
model.messagemappings.ResetSelected()

case ScriptCollectionsMsg:
model.scriptcollections.SetItems(convertArtifactsToListItems(msg))
model.scriptcollections.ResetSelected()
}

return model, tea.Batch(cmds...)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func (model *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

case ContentPackagesMsg:
model.packages.SetItems(convertPackagesToListItems(msg))
model.packages.ResetSelected()
}

return model, tea.Batch(cmds...)
Expand Down
23 changes: 23 additions & 0 deletions internal/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,23 @@ func (model Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
)
}

case key.Matches(msg, model.common.KeyMap.Refresh):
switch model.activePane {
case PackagesPane:
cmds = append(cmds,
model.artifacts.Init(),
model.tabs.Init(),
model.packages.ContentPackagesCmd,
)

case ArtifactsPane:
if model.packages.SelectedPackageID() != nil {
cmds = append(cmds,
model.artifacts.IntegrationArtifactsByPackageCmd(*model.packages.SelectedPackageID()),
)
}
}

case key.Matches(msg, model.common.KeyMap.Open):
switch model.activePane {
case PackagesPane:
Expand Down Expand Up @@ -223,6 +240,12 @@ func (model Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
cmds = append(cmds, cmd)
}

if model.activePane == ArtifactsPane {
cmds = append(cmds,
model.attributes.AttributesCmd(model.artifacts.SelectedArtifactAttributes()),
)
}

case attribute.AttributesMsg:
a, cmd := model.attributes.Update(msg)
model.attributes = a.(*attribute.Model)
Expand Down

0 comments on commit 6720ed6

Please sign in to comment.