mirror of
https://github.com/anotherhadi/spilltea.git
synced 2026-07-06 20:42:33 +02:00
feat: add "flag" toggle in replay & findings
Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com>
This commit is contained in:
@@ -186,7 +186,7 @@ type findingsKeyMap struct{ width int }
|
||||
func (findingsKeyMap) ShortHelp() []key.Binding {
|
||||
g := keys.Keys.Global
|
||||
f := keys.Keys.Findings
|
||||
return []key.Binding{g.Up, g.Down, f.Dismiss, g.Copy, g.Help}
|
||||
return []key.Binding{g.Up, g.Down, f.Flag, f.Dismiss, f.DismissAll, g.Copy, g.Help}
|
||||
}
|
||||
|
||||
func (m findingsKeyMap) FullHelp() [][]key.Binding {
|
||||
|
||||
@@ -72,6 +72,14 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
m.refreshListViewport()
|
||||
m.refreshBody()
|
||||
}
|
||||
case key.Matches(msg, f.Flag):
|
||||
if len(m.findings) > 0 && m.database != nil {
|
||||
if err := m.database.ToggleFindingFlag(m.findings[m.cursor].ID); err != nil {
|
||||
log.Printf("findings: toggle flag: %v", err)
|
||||
return m, nil
|
||||
}
|
||||
return m, RefreshCmd(m.database)
|
||||
}
|
||||
case key.Matches(msg, f.Dismiss):
|
||||
if len(m.findings) > 0 && m.database != nil {
|
||||
if err := m.database.DismissFinding(m.findings[m.cursor].ID); err != nil {
|
||||
@@ -80,6 +88,14 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
}
|
||||
return m, RefreshCmd(m.database)
|
||||
}
|
||||
case key.Matches(msg, f.DismissAll):
|
||||
if m.database != nil {
|
||||
if err := m.database.DismissAllFindings(); err != nil {
|
||||
log.Printf("findings: dismiss all: %v", err)
|
||||
return m, nil
|
||||
}
|
||||
return m, RefreshCmd(m.database)
|
||||
}
|
||||
case key.Matches(msg, g.ScrollUp):
|
||||
util.ScrollViewport(&m.bodyViewport, -1)
|
||||
case key.Matches(msg, g.ScrollDown):
|
||||
|
||||
@@ -66,9 +66,10 @@ func (m *Model) renderList() string {
|
||||
sevStyle := style.SeverityStyle(f.Severity)
|
||||
sevLabel := sevStyle.Width(8).Render(f.Severity)
|
||||
ts := f.CreatedAt.Format("15:04:05")
|
||||
flagSt := lipgloss.NewStyle().Foreground(ilovetui.S.Primary)
|
||||
|
||||
w := m.listViewport.Width()
|
||||
const fixedW = 2 + 8 + 1 + 8 + 1 + 10 + 1
|
||||
const fixedW = 2 + 2 + 8 + 1 + 8 + 1 + 10 + 1
|
||||
titleW := w - fixedW
|
||||
if titleW < 0 {
|
||||
titleW = 0
|
||||
@@ -79,8 +80,13 @@ func (m *Model) renderList() string {
|
||||
var line string
|
||||
if selected {
|
||||
bg := lipgloss.NewStyle().Background(ilovetui.S.Selection)
|
||||
flagStr := " "
|
||||
if f.Flagged {
|
||||
flagStr = icons.I.Flag + " "
|
||||
}
|
||||
line = lipgloss.JoinHorizontal(lipgloss.Top,
|
||||
bg.Bold(true).Foreground(ilovetui.S.Primary).Width(2).Render(">"),
|
||||
bg.Foreground(ilovetui.S.Primary).Width(2).Render(flagStr),
|
||||
sevStyle.Background(ilovetui.S.Selection).Width(8).Render(f.Severity),
|
||||
bg.Width(1).Render(""),
|
||||
bg.Foreground(ilovetui.S.Subtle).Width(8).Render(util.Truncate(f.PluginName, 8)),
|
||||
@@ -90,8 +96,13 @@ func (m *Model) renderList() string {
|
||||
bg.Bold(true).Width(titleW).Render(f.Title),
|
||||
)
|
||||
} else {
|
||||
flagStr := " "
|
||||
if f.Flagged {
|
||||
flagStr = icons.I.Flag + " "
|
||||
}
|
||||
line = lipgloss.JoinHorizontal(lipgloss.Top,
|
||||
" ",
|
||||
flagSt.Width(2).Render(flagStr),
|
||||
sevLabel,
|
||||
" ",
|
||||
pluginStr,
|
||||
|
||||
Reference in New Issue
Block a user