- Add Control Room page with stacks sidebar and containers list - Implement container actions (start/stop/restart) with snackbars - Add container logs viewer dialog - Add search/filter for both stacks and containers lists - Add external links for Portainer and Netdata (url_launcher) - Add VS Code launch configuration for Flutter web debugging 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
84 lines
2.2 KiB
Dart
84 lines
2.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// Per-row action for DataGrid.
|
|
class DataGridAction<T> {
|
|
const DataGridAction({
|
|
required this.icon,
|
|
required this.label,
|
|
required this.onTap,
|
|
this.showWhen,
|
|
this.destructive = false,
|
|
this.requiresConfirmation = false,
|
|
this.confirmationMessage,
|
|
});
|
|
|
|
/// Icon to display in the action menu.
|
|
final IconData icon;
|
|
|
|
/// Label for the action.
|
|
final String label;
|
|
|
|
/// Callback when the action is triggered.
|
|
final Future<void> Function(T item) onTap;
|
|
|
|
/// Condition to show/hide this action for specific items.
|
|
final bool Function(T item)? showWhen;
|
|
|
|
/// Whether this is a destructive action (styled differently).
|
|
final bool destructive;
|
|
|
|
/// Whether to show a confirmation dialog before executing.
|
|
final bool requiresConfirmation;
|
|
|
|
/// Custom confirmation message. Defaults to "Are you sure?".
|
|
final String? confirmationMessage;
|
|
|
|
/// Checks if this action should be shown for the given item.
|
|
bool shouldShow(T item) => showWhen?.call(item) ?? true;
|
|
}
|
|
|
|
/// Bulk action for selected rows in DataGrid.
|
|
class DataGridBulkAction<T> {
|
|
const DataGridBulkAction({
|
|
required this.icon,
|
|
required this.label,
|
|
required this.onTap,
|
|
this.minSelected = 1,
|
|
this.maxSelected,
|
|
this.destructive = false,
|
|
this.requiresConfirmation = false,
|
|
this.confirmationMessage,
|
|
});
|
|
|
|
/// Icon to display.
|
|
final IconData icon;
|
|
|
|
/// Label for the action.
|
|
final String label;
|
|
|
|
/// Callback when the action is triggered with selected items.
|
|
final Future<void> Function(List<T> items) onTap;
|
|
|
|
/// Minimum number of items that must be selected.
|
|
final int minSelected;
|
|
|
|
/// Maximum number of items that can be selected (null = no limit).
|
|
final int? maxSelected;
|
|
|
|
/// Whether this is a destructive action.
|
|
final bool destructive;
|
|
|
|
/// Whether to show a confirmation dialog before executing.
|
|
final bool requiresConfirmation;
|
|
|
|
/// Custom confirmation message.
|
|
final String? confirmationMessage;
|
|
|
|
/// Checks if this action is available for the given selection count.
|
|
bool isAvailable(int selectedCount) {
|
|
if (selectedCount < minSelected) return false;
|
|
if (maxSelected != null && selectedCount > maxSelected!) return false;
|
|
return true;
|
|
}
|
|
}
|