@@ -537,7 +537,43 @@ func (m Model) handleEntitiesPageKeyMsg(msg tea.KeyMsg) (Model, tea.Cmd) {
537
537
if key .Matches (msg , m .keyMap .Enter ) {
538
538
selected , selectionActions := m .pages [m .focusedPageType ].(page.EntityPage ).GetSelectionActions ()
539
539
if len (selectionActions ) > constants .ConfirmSelectionActionsThreshold {
540
- return m .promptToConfirmSelectionActions (selected , selectionActions )
540
+ // display a prompt to confirm selection actions
541
+ // use the terminology select & deselect instead of activate, get log scanner, etc.
542
+ var numToActivate , numToDeactivate int
543
+ for _ , getLogScanner := range selectionActions {
544
+ if getLogScanner {
545
+ numToActivate ++
546
+ } else {
547
+ numToDeactivate ++
548
+ }
549
+ }
550
+ topLine := fmt .Sprintf ("Select %d visible containers" , numToActivate )
551
+ if numToActivate > 0 && numToDeactivate > 0 {
552
+ topLine = fmt .Sprintf ("Select %d & deselect %d visible containers" , numToActivate , numToDeactivate )
553
+ } else if numToDeactivate > 0 {
554
+ topLine = fmt .Sprintf ("Deselect %d visible containers" , numToDeactivate )
555
+ }
556
+ topLine = fmt .Sprintf ("%s for %s" , topLine , selected .Type ())
557
+ bottomLine := fmt .Sprintf ("%s?" , selected .Container .HumanReadable ())
558
+ text := []string {topLine , bottomLine }
559
+ return m .promptToConfirmSelectionActions (text , selectionActions )
560
+ } else {
561
+ return m .doSelectionActions (selectionActions )
562
+ }
563
+ }
564
+
565
+ // handle deselecting all containers
566
+ if key .Matches (msg , m .keyMap .DeselectAll ) {
567
+ selectionActions := make (map [model.Entity ]bool )
568
+ containerEntities := m .entityTree .GetContainerEntities ()
569
+ for i := range containerEntities {
570
+ if ! containerEntities [i ].State .ActivatesWhenSelected () {
571
+ selectionActions [containerEntities [i ]] = false
572
+ }
573
+ }
574
+ if len (selectionActions ) > constants .ConfirmSelectionActionsThreshold {
575
+ text := []string {fmt .Sprintf ("Deselect all %d containers?" , len (selectionActions ))}
576
+ return m .promptToConfirmSelectionActions (text , selectionActions )
541
577
} else {
542
578
return m .doSelectionActions (selectionActions )
543
579
}
@@ -555,26 +591,7 @@ func (m Model) handleEntitiesPageKeyMsg(msg tea.KeyMsg) (Model, tea.Cmd) {
555
591
return m , nil
556
592
}
557
593
558
- func (m Model ) promptToConfirmSelectionActions (selected model.Entity , selectionActions map [model.Entity ]bool ) (Model , tea.Cmd ) {
559
- // display a prompt to confirm selection actions
560
- // use the terminology select & deselect instead of activate, get log scanner, etc.
561
- var numToActivate , numToDeactivate int
562
- for _ , getLogScanner := range selectionActions {
563
- if getLogScanner {
564
- numToActivate ++
565
- } else {
566
- numToDeactivate ++
567
- }
568
- }
569
- topLine := fmt .Sprintf ("Select %d visible containers" , numToActivate )
570
- if numToActivate > 0 && numToDeactivate > 0 {
571
- topLine = fmt .Sprintf ("Select %d & deselect %d visible containers" , numToActivate , numToDeactivate )
572
- } else if numToDeactivate > 0 {
573
- topLine = fmt .Sprintf ("Deselect %d visible containers" , numToDeactivate )
574
- }
575
- topLine = fmt .Sprintf ("%s for %s" , topLine , selected .Type ())
576
- bottomLine := fmt .Sprintf ("%s?" , selected .Container .HumanReadable ())
577
- text := []string {topLine , bottomLine }
594
+ func (m Model ) promptToConfirmSelectionActions (text []string , selectionActions map [model.Entity ]bool ) (Model , tea.Cmd ) {
578
595
m .prompt = prompt .New (true , m .width , m .height - m .topBarHeight , text , m .styles .Inverse )
579
596
m .whenPromptConfirm = func () (Model , tea.Cmd ) { return m .doSelectionActions (selectionActions ) }
580
597
return m , nil
0 commit comments