Scope history clear to active tab
This commit is contained in:
parent
c72443b3c6
commit
fbf93fc9a3
|
|
@ -207,7 +207,7 @@ func BuildHistorySidebar(
|
||||||
activeJobs []HistoryEntry,
|
activeJobs []HistoryEntry,
|
||||||
onEntryClick func(HistoryEntry),
|
onEntryClick func(HistoryEntry),
|
||||||
onEntryDelete func(HistoryEntry),
|
onEntryDelete func(HistoryEntry),
|
||||||
onClearAll func(),
|
onClearAll func(int),
|
||||||
selectedTab int,
|
selectedTab int,
|
||||||
onTabChanged func(int),
|
onTabChanged func(int),
|
||||||
titleColor, bgColor, textColor color.Color,
|
titleColor, bgColor, textColor color.Color,
|
||||||
|
|
@ -254,9 +254,17 @@ func BuildHistorySidebar(
|
||||||
title.TextStyle = fyne.TextStyle{Monospace: true, Bold: true}
|
title.TextStyle = fyne.TextStyle{Monospace: true, Bold: true}
|
||||||
title.TextSize = 18
|
title.TextSize = 18
|
||||||
clearBtn := widget.NewButton("Clear All", func() {
|
clearBtn := widget.NewButton("Clear All", func() {
|
||||||
if onClearAll != nil {
|
if onClearAll == nil {
|
||||||
onClearAll()
|
return
|
||||||
}
|
}
|
||||||
|
idx := 0
|
||||||
|
for i, tab := range tabs.Items {
|
||||||
|
if tab == tabs.Selected() {
|
||||||
|
idx = i
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onClearAll(idx)
|
||||||
})
|
})
|
||||||
clearBtn.Importance = widget.LowImportance
|
clearBtn.Importance = widget.LowImportance
|
||||||
|
|
||||||
|
|
|
||||||
23
main.go
23
main.go
|
|
@ -1460,13 +1460,24 @@ func (s *appState) deleteHistoryEntry(entry ui.HistoryEntry) {
|
||||||
s.refreshMainMenuThrottled()
|
s.refreshMainMenuThrottled()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *appState) clearHistoryEntries() {
|
func (s *appState) clearHistoryEntries(tabIndex int) {
|
||||||
for _, entry := range s.historyEntries {
|
if tabIndex == 0 {
|
||||||
if entry.LogPath != "" {
|
return
|
||||||
_ = os.Remove(entry.LogPath)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
s.historyEntries = nil
|
keep := s.historyEntries[:0]
|
||||||
|
for _, entry := range s.historyEntries {
|
||||||
|
isCompleted := entry.Status == queue.JobStatusCompleted
|
||||||
|
isFailed := entry.Status != queue.JobStatusCompleted
|
||||||
|
shouldClear := (tabIndex == 1 && isCompleted) || (tabIndex == 2 && isFailed)
|
||||||
|
if shouldClear {
|
||||||
|
if entry.LogPath != "" {
|
||||||
|
_ = os.Remove(entry.LogPath)
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
keep = append(keep, entry)
|
||||||
|
}
|
||||||
|
s.historyEntries = keep
|
||||||
cfg := historyConfig{Entries: s.historyEntries}
|
cfg := historyConfig{Entries: s.historyEntries}
|
||||||
if err := saveHistoryConfig(cfg); err != nil {
|
if err := saveHistoryConfig(cfg); err != nil {
|
||||||
logging.Debug(logging.CatUI, "failed to save history after clear: %v", err)
|
logging.Debug(logging.CatUI, "failed to save history after clear: %v", err)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user