Skip to content

Commit f350082

Browse files
authored
Merge pull request #80 from ethpandaops/feat/lab-overrides-global-toggle
feat(lab): make a/n toggles affect all models globally
2 parents dbc9ca8 + 305f802 commit f350082

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

pkg/configtui/model.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,32 @@ func (m *Model) DisableAllInSection() {
159159
}
160160
}
161161

162+
// EnableAllModels enables all models in both external and transformation sections.
163+
func (m *Model) EnableAllModels() {
164+
for i := range m.externalModels {
165+
m.externalModels[i].Enabled = true
166+
}
167+
168+
for i := range m.transformationModels {
169+
m.transformationModels[i].Enabled = true
170+
}
171+
172+
m.dirty = true
173+
}
174+
175+
// DisableAllModels disables all models in both external and transformation sections.
176+
func (m *Model) DisableAllModels() {
177+
for i := range m.externalModels {
178+
m.externalModels[i].Enabled = false
179+
}
180+
181+
for i := range m.transformationModels {
182+
m.transformationModels[i].Enabled = false
183+
}
184+
185+
m.dirty = true
186+
}
187+
162188
// GetSectionLength returns the number of items in the current section.
163189
func (m *Model) GetSectionLength() int {
164190
switch m.activeSection {

pkg/configtui/update.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,16 @@ func (m Model) handleKeyPress(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
8585

8686
case "a":
8787
if m.activeSection != sectionEnv {
88-
m.EnableAllInSection()
89-
m.statusMsg = "Enabled all models in section"
88+
m.EnableAllModels()
89+
m.statusMsg = "Enabled all models"
9090

9191
return m, nil
9292
}
9393

9494
case "n":
9595
if m.activeSection != sectionEnv {
96-
m.DisableAllInSection()
97-
m.statusMsg = "Disabled all models in section"
96+
m.DisableAllModels()
97+
m.statusMsg = "Disabled all models"
9898

9999
return m, nil
100100
}

pkg/configtui/view.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ func (m Model) renderHelp() string {
315315
case sectionEnv:
316316
help = "[←/→] Switch section [↑/↓] Navigate [0-9] Type value [Backspace] Delete [s] Save [q] Quit"
317317
default:
318-
help = "[←/→] Switch section [↑/↓] Navigate [Space] Toggle [a] All on [n] All off [d] Enable deps [s] Save [q] Quit"
318+
help = "[←/→] Switch section [↑/↓] Navigate [Space] Toggle [a] Enable all [n] Disable all [d] Enable deps [s] Save [q] Quit"
319319
}
320320
}
321321

0 commit comments

Comments
 (0)