Skip to content

Commit

Permalink
Merge pull request #3619 from canonical/filter-instances-on-select-all
Browse files Browse the repository at this point in the history
[gui] when clicking the select all checkbox, respect instance filters
  • Loading branch information
ricab authored Sep 11, 2024
2 parents 04b3227 + 3ecfcd3 commit 666a798
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/client/gui/lib/vm_table/vm_table_headers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import '../vm_details/cpu_sparkline.dart';
import '../vm_details/ip_addresses.dart';
import '../vm_details/memory_usage.dart';
import '../vm_details/vm_status_icon.dart';
import 'search_box.dart';
import 'table.dart';
import 'vms.dart';

Expand Down Expand Up @@ -78,7 +79,14 @@ class SelectAllCheckbox extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final selectedVms = ref.watch(selectedVmsProvider);
final vmNames = ref.watch(vmNamesProvider);
final searchName = ref.watch(searchNameProvider);
final runningOnly = ref.watch(runningOnlyProvider);
final vmNames = ref
.watch(vmInfosProvider)
.where((i) => !runningOnly || i.instanceStatus.status == Status.RUNNING)
.where((i) => i.name.contains(searchName))
.map((i) => i.name)
.toList();
final allSelected = selectedVms.containsAll(vmNames);

void toggleSelectedAll(bool isSelected) {
Expand Down

0 comments on commit 666a798

Please sign in to comment.