@@ -4,8 +4,10 @@ import (
44 "fmt"
55 "strings"
66
7+ tea "charm.land/bubbletea/v2"
78 "charm.land/lipgloss/v2"
89
10+ appmsg "github.com/usetero/cli/internal/app/msgs"
911 "github.com/usetero/cli/internal/domain"
1012 "github.com/usetero/cli/internal/format"
1113 "github.com/usetero/cli/internal/styles"
@@ -17,6 +19,7 @@ type detail struct {
1719 theme styles.Theme
1820 category domain.PolicyCategoryStatus
1921 policies []domain.WastePolicy
22+ cursor int
2023}
2124
2225// newDetail creates a detail view for the given category and pre-fetched policies.
@@ -28,6 +31,19 @@ func newDetail(theme styles.Theme, category domain.PolicyCategoryStatus, policie
2831 }
2932}
3033
34+ // Prompt returns a tea.Cmd that emits a DrawerPrompt for the selected policy.
35+ func (d * detail ) Prompt () tea.Cmd {
36+ if len (d .policies ) == 0 {
37+ return nil
38+ }
39+ p := d .policies [d .cursor ]
40+ text := fmt .Sprintf (
41+ "Pull up the %q policy for the %q log event in the %s service." ,
42+ d .category .DisplayName (), p .LogEventName , p .ServiceName ,
43+ )
44+ return func () tea.Msg { return appmsg.DrawerPrompt {Text : text } }
45+ }
46+
3147// View renders the detail: a header with category summary, then a policy table.
3248func (d * detail ) View (width int ) string {
3349 var lines []string
@@ -81,9 +97,17 @@ func (d *detail) renderTable(width int) string {
8197 }
8298 tbl .SetWidth (width )
8399
100+ accent := lipgloss .NewStyle ().Foreground (d .theme .Accent ).Background (d .theme .Bg )
84101 dot := lipgloss .NewStyle ().Foreground (d .theme .Warning ).Background (d .theme .Bg ).Render ("●" )
85102
86- for _ , p := range d .policies {
103+ for i , p := range d .policies {
104+ name := p .LogEventName
105+ if i == d .cursor {
106+ name = accent .Render ("▶ " + name )
107+ } else {
108+ name = dot + " " + name
109+ }
110+
87111 bytes := "—"
88112 if p .BytesPerHour != nil {
89113 bytes = format .Bytes (* p .BytesPerHour ) + "/hr"
@@ -95,9 +119,9 @@ func (d *detail) renderTable(width int) string {
95119 if p .VolumePerHour != nil {
96120 vol = format .Volume (* p .VolumePerHour ) + " evt/hr"
97121 }
98- tbl .Row (dot + " " + p . LogEventName , p .ServiceName , vol , bytes , savings )
122+ tbl .Row (name , p .ServiceName , vol , bytes , savings )
99123 } else {
100- tbl .Row (dot + " " + p . LogEventName , p .ServiceName , bytes , savings )
124+ tbl .Row (name , p .ServiceName , bytes , savings )
101125 }
102126 }
103127
0 commit comments