Skip to content

Commit ff6226d

Browse files
committed
feat: Update popup menu to conditionally show 'Change group' option based on group count
1 parent a8865b6 commit ff6226d

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

client/lib/features/devices/views/device_card.dart

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,19 @@ class DeviceCard extends StatelessWidget {
187187
iconSize: 18,
188188
icon: Icon(Icons.more_vert, color: fgColor.withValues(alpha: 0.7)),
189189
onSelected: (value) => _handleMenuAction(context, value),
190-
itemBuilder: (BuildContext ctx) => [
191-
PopupMenuItem<String>(value: 'reconnect', child: Text(context.translate('Reconnect'))),
192-
const PopupMenuDivider(),
193-
PopupMenuItem<String>(value: 'change-group', child: Text(context.translate('Change group...'))),
194-
PopupMenuItem<String>(value: 'delete', child: Text(context.translate('Delete...'))),
195-
],
190+
itemBuilder: (BuildContext ctx) {
191+
final showChangeGroup = ctx.read<GroupedDevicesViewModel>().groups.length > 1;
192+
193+
final entries = <PopupMenuEntry<String>>[
194+
PopupMenuItem<String>(value: 'reconnect', child: Text(context.translate('Reconnect'))),
195+
];
196+
entries.add(const PopupMenuDivider());
197+
if (showChangeGroup) {
198+
entries.add(PopupMenuItem<String>(value: 'change-group', child: Text(context.translate('Change group...'))));
199+
}
200+
entries.add(PopupMenuItem<String>(value: 'delete', child: Text(context.translate('Delete...'))));
201+
return entries;
202+
},
196203
);
197204
}
198205

0 commit comments

Comments
 (0)