Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cli/commands/catalog/tui/components/buttonbar/buttonbar.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"strings"

tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
tea "github.com/charmbracelet/bubbletea/v2"
lipgloss "github.com/charmbracelet/lipgloss/v2"
)

// SelectBtnMsg is a message that contains the index of the button to select.
Expand Down
15 changes: 8 additions & 7 deletions cli/commands/catalog/tui/delegate.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package tui

import (
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/bubbles/v2/key"
"github.com/charmbracelet/bubbles/v2/list"
"github.com/charmbracelet/lipgloss/v2"
"github.com/charmbracelet/lipgloss/v2/compat"
)

const (
Expand All @@ -18,12 +19,12 @@ func newItemDelegate(keys *delegateKeyMap) list.DefaultDelegate {
d := list.NewDefaultDelegate()

d.Styles.SelectedTitle.
Foreground(lipgloss.AdaptiveColor{Dark: selectedTitleForegroundColorDark}).
BorderForeground(lipgloss.AdaptiveColor{Dark: selectedTitleBorderForegroundColorDark})
Foreground(compat.AdaptiveColor{Dark: lipgloss.Color(selectedTitleForegroundColorDark)}).
BorderForeground(compat.AdaptiveColor{Dark: lipgloss.Color(selectedTitleBorderForegroundColorDark)})

d.Styles.SelectedDesc = d.Styles.SelectedTitle.
Foreground(lipgloss.AdaptiveColor{Dark: selectedDescForegroundColorDark}).
BorderForeground(lipgloss.AdaptiveColor{Dark: selectedDescBorderForegroundColorDark})
Foreground(compat.AdaptiveColor{Dark: lipgloss.Color(selectedDescForegroundColorDark)}).
BorderForeground(compat.AdaptiveColor{Dark: lipgloss.Color(selectedDescBorderForegroundColorDark)})

help := []key.Binding{keys.choose, keys.scaffold}

Expand Down
8 changes: 4 additions & 4 deletions cli/commands/catalog/tui/keys.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package tui

import (
"github.com/charmbracelet/bubbles/help"
"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/bubbles/viewport"
"github.com/charmbracelet/bubbles/v2/help"
"github.com/charmbracelet/bubbles/v2/key"
"github.com/charmbracelet/bubbles/v2/list"
"github.com/charmbracelet/bubbles/v2/viewport"
)

// newListKeyMap returns a set of keybindings for the list view.
Expand Down
12 changes: 7 additions & 5 deletions cli/commands/catalog/tui/model.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package tui

import (
"github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/bubbles/viewport"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/charmbracelet/bubbles/v2/list"
"github.com/charmbracelet/bubbles/v2/viewport"
tea "github.com/charmbracelet/bubbletea/v2"
lipgloss "github.com/charmbracelet/lipgloss/v2"

"github.com/gruntwork-io/terragrunt/cli/commands/catalog/tui/components/buttonbar"
"github.com/gruntwork-io/terragrunt/internal/services/catalog"
Expand Down Expand Up @@ -93,7 +93,9 @@ func NewModel(l log.Logger, opts *options.TerragruntOptions, svc catalog.Catalog
Padding(0, 1)

// Setup the markdown viewer
vp := viewport.New(0, 0)
vp := viewport.New()
vp.SetWidth(0)
vp.SetHeight(0)

// Setup the button bar
bs := make([]string, len(availableButtons))
Expand Down
60 changes: 30 additions & 30 deletions cli/commands/catalog/tui/model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"testing"
"time"

tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/x/exp/teatest"
tea "github.com/charmbracelet/bubbletea/v2"
"github.com/charmbracelet/x/exp/teatest/v2"

"github.com/gruntwork-io/terragrunt/cli/commands/catalog/tui"
"github.com/gruntwork-io/terragrunt/config"
Expand Down Expand Up @@ -125,9 +125,9 @@ func TestTUIFinalModel(t *testing.T) {
tm := teatest.NewTestModel(t, m, teatest.WithInitialTermSize(120, 40))

// Send 'q' to quit the application immediately
tm.Send(tea.KeyMsg{
Type: tea.KeyRunes,
Runes: []rune("q"),
tm.Send(tea.KeyPressMsg{
Text: "q",
Code: 'q',
})

fm := tm.FinalModel(t)
Expand Down Expand Up @@ -155,9 +155,9 @@ func TestTUIInitialOutput(t *testing.T) {
tm := teatest.NewTestModel(t, m, teatest.WithInitialTermSize(120, 40))

// Send 'q' to quit immediately for consistent output
tm.Send(tea.KeyMsg{
Type: tea.KeyRunes,
Runes: []rune("q"),
tm.Send(tea.KeyPressMsg{
Text: "q",
Code: 'q',
})

// Test that we get the expected output
Expand Down Expand Up @@ -186,8 +186,8 @@ func TestTUINavigationToModuleDetails(t *testing.T) {
}, teatest.WithCheckInterval(time.Millisecond*100), teatest.WithDuration(time.Second*2))

// Press Enter to select the first module (assuming it's pre-selected)
tm.Send(tea.KeyMsg{
Type: tea.KeyEnter,
tm.Send(tea.KeyPressMsg{
Code: tea.KeyEnter,
})

// Wait for the pager view to appear
Expand All @@ -198,9 +198,9 @@ func TestTUINavigationToModuleDetails(t *testing.T) {
}, teatest.WithCheckInterval(time.Millisecond*100), teatest.WithDuration(time.Second*3))

// Send 'q' to go back to list
tm.Send(tea.KeyMsg{
Type: tea.KeyRunes,
Runes: []rune("q"),
tm.Send(tea.KeyPressMsg{
Text: "q",
Code: 'q',
})

// Wait for return to list view
Expand All @@ -209,9 +209,9 @@ func TestTUINavigationToModuleDetails(t *testing.T) {
}, teatest.WithCheckInterval(time.Millisecond*100), teatest.WithDuration(time.Second*2))

// Finally quit the application
tm.Send(tea.KeyMsg{
Type: tea.KeyRunes,
Runes: []rune("q"),
tm.Send(tea.KeyPressMsg{
Text: "q",
Code: 'q',
})

tm.WaitFinished(t, teatest.WithFinalTimeout(time.Second*2))
Expand All @@ -236,9 +236,9 @@ func TestTUIModuleFiltering(t *testing.T) {
}, teatest.WithCheckInterval(time.Millisecond*100), teatest.WithDuration(time.Second*2))

// Activate filtering with '/'
tm.Send(tea.KeyMsg{
Type: tea.KeyRunes,
Runes: []rune("/"),
tm.Send(tea.KeyPressMsg{
Text: "/",
Code: '/',
})

// Type filter text
Expand All @@ -252,8 +252,8 @@ func TestTUIModuleFiltering(t *testing.T) {
}, teatest.WithCheckInterval(time.Millisecond*100), teatest.WithDuration(time.Second*3))

// Press Escape to exit filtering
tm.Send(tea.KeyMsg{
Type: tea.KeyEsc,
tm.Send(tea.KeyPressMsg{
Code: tea.KeyEsc,
})

// Wait for return to normal list view
Expand All @@ -264,9 +264,9 @@ func TestTUIModuleFiltering(t *testing.T) {
}, teatest.WithCheckInterval(time.Millisecond*100), teatest.WithDuration(time.Second*2))

// Quit the application
tm.Send(tea.KeyMsg{
Type: tea.KeyRunes,
Runes: []rune("q"),
tm.Send(tea.KeyPressMsg{
Text: "q",
Code: 'q',
})

tm.WaitFinished(t, teatest.WithFinalTimeout(time.Second*2))
Expand Down Expand Up @@ -299,9 +299,9 @@ func TestTUIWindowResize(t *testing.T) {
}, teatest.WithCheckInterval(time.Millisecond*100), teatest.WithDuration(time.Second*2))

// Quit
tm.Send(tea.KeyMsg{
Type: tea.KeyRunes,
Runes: []rune("q"),
tm.Send(tea.KeyPressMsg{
Text: "q",
Code: 'q',
})

tm.WaitFinished(t, teatest.WithFinalTimeout(time.Second*2))
Expand Down Expand Up @@ -343,9 +343,9 @@ func TestTUIScaffoldWithRealRepository(t *testing.T) {
}, teatest.WithCheckInterval(time.Millisecond*100), teatest.WithDuration(time.Second*3))

// Press 'S' to scaffold the first module
tm.Send(tea.KeyMsg{
Type: tea.KeyRunes,
Runes: []rune("S"),
tm.Send(tea.KeyPressMsg{
Text: "S",
Code: 'S',
})

// Wait for scaffold to complete - the application should quit after scaffolding
Expand Down
76 changes: 38 additions & 38 deletions cli/commands/catalog/tui/testdata/TestTUIInitialOutput.golden
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
[?25l[?2004h List of Modules 

2 items 

│ AWS VPC Module 
│ This module creates a VPC in AWS with all the necessary components. 

AWS EKS Module 
This module creates an EKS cluster in AWS. 




























k/↑/ctrl+p move up • j/↓/ctrl+n move down • enter/ctrl-j chooseS Scaffold/ searchq quit? more[?2004l[?25h[?1002l[?1003l[?1006l
[?2004h[>4;1m[?4m[>1u[?u[?25l   List of Modules 

  2 items

│ AWS VPC Module
│ This module creates a VPC in AWS with all the necessary components.

  AWS EKS Module
  This module creates an EKS cluster in AWS.




























  k/↑/ctrl+p move upj/↓/ctrl+n move downenter/ctrl-j chooseS Scaffold/ searchq quit? more[?25h[?2004l
Expand Down
2 changes: 1 addition & 1 deletion cli/commands/catalog/tui/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"context"
"errors"

tea "github.com/charmbracelet/bubbletea"
tea "github.com/charmbracelet/bubbletea/v2"

"github.com/gruntwork-io/terragrunt/internal/services/catalog"
"github.com/gruntwork-io/terragrunt/options"
Expand Down
18 changes: 10 additions & 8 deletions cli/commands/catalog/tui/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package tui
import (
"fmt"

"github.com/charmbracelet/bubbles/key"
"github.com/charmbracelet/bubbles/list"
"github.com/charmbracelet/bubbles/viewport"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/bubbles/v2/key"
"github.com/charmbracelet/bubbles/v2/list"
"github.com/charmbracelet/bubbles/v2/viewport"
tea "github.com/charmbracelet/bubbletea/v2"
"github.com/charmbracelet/glamour"
"github.com/charmbracelet/lipgloss"
lipgloss "github.com/charmbracelet/lipgloss/v2"
"github.com/pkg/browser"

"github.com/gruntwork-io/terragrunt/cli/commands/catalog/tui/command"
Expand Down Expand Up @@ -182,11 +182,13 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// we can initialize the viewport. The initial dimensions come in
// quickly, though asynchronously, which is why we wait for them
// here.
m.viewport = viewport.New(msg.Width, msg.Height-v-lipgloss.Height(m.footerView()))
m.viewport = viewport.New()
m.viewport.SetWidth(msg.Width)
m.viewport.SetHeight(msg.Height - v - lipgloss.Height(m.footerView()))
m.ready = true
} else {
m.viewport.Width = msg.Width
m.viewport.Height = msg.Height - v - lipgloss.Height(m.footerView())
m.viewport.SetWidth(msg.Width)
m.viewport.SetHeight(msg.Height - v - lipgloss.Height(m.footerView()))
}

case scaffoldFinishedMsg:
Expand Down
4 changes: 2 additions & 2 deletions cli/commands/catalog/tui/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"strings"

"github.com/charmbracelet/lipgloss"
lipgloss "github.com/charmbracelet/lipgloss/v2"
)

var (
Expand Down Expand Up @@ -44,7 +44,7 @@ func (m Model) footerView() string {
var percent float64 = 100
info := infoPositionStyle.Render(fmt.Sprintf("%2.f%%", m.viewport.ScrollPercent()*percent))

line := strings.Repeat("─", max(0, m.viewport.Width-lipgloss.Width(info)))
line := strings.Repeat("─", max(0, m.viewport.Width()-lipgloss.Width(info)))
line = infoLineStyle.Render(line)

info = lipgloss.JoinHorizontal(lipgloss.Center, line, info)
Expand Down
Loading
Loading