Replace all relative imports (../../) with package imports (package:tatlock_ui/) across 29 files for cleaner, more maintainable import paths. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
92 lines
2.8 KiB
Dart
92 lines
2.8 KiB
Dart
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
|
import 'package:tatlock_ui/features/control_room/stacks/data/repositories/stack_repository_impl.dart';
|
|
import 'package:tatlock_ui/features/control_room/stacks/domain/entities/stack.dart';
|
|
|
|
part 'stacks_provider.g.dart';
|
|
|
|
/// Provides the list of all stacks.
|
|
@riverpod
|
|
Future<List<Stack>> stacks(StacksRef ref) async {
|
|
final repository = ref.watch(stackRepositoryProvider);
|
|
return repository.getStacks();
|
|
}
|
|
|
|
/// Provides a single stack by ID.
|
|
@riverpod
|
|
Future<Stack> stack(StackRef ref, String id) async {
|
|
final repository = ref.watch(stackRepositoryProvider);
|
|
return repository.getStack(id);
|
|
}
|
|
|
|
/// Currently selected stack ID (null = all containers).
|
|
@riverpod
|
|
class SelectedStack extends _$SelectedStack {
|
|
@override
|
|
String? build() => null;
|
|
|
|
void select(String? stackId) {
|
|
state = stackId;
|
|
}
|
|
|
|
void clear() {
|
|
state = null;
|
|
}
|
|
}
|
|
|
|
/// Provides the YAML content for a stack.
|
|
@riverpod
|
|
Future<String> stackYaml(StackYamlRef ref, String stackId) async {
|
|
final repository = ref.watch(stackRepositoryProvider);
|
|
return repository.getStackYaml(stackId);
|
|
}
|
|
|
|
/// Provides the environment variables for a stack.
|
|
@riverpod
|
|
Future<Map<String, String>> stackEnvVars(StackEnvVarsRef ref, String stackId) async {
|
|
final repository = ref.watch(stackRepositoryProvider);
|
|
return repository.getStackEnvVars(stackId);
|
|
}
|
|
|
|
/// Controller for stack configuration actions.
|
|
@riverpod
|
|
class StackConfigActions extends _$StackConfigActions {
|
|
@override
|
|
AsyncValue<void> build() => const AsyncValue.data(null);
|
|
|
|
Future<void> saveYaml(String stackId, String yaml) async {
|
|
state = const AsyncValue.loading();
|
|
state = await AsyncValue.guard(() async {
|
|
final repository = ref.read(stackRepositoryProvider);
|
|
await repository.updateStackYaml(stackId, yaml);
|
|
ref.invalidate(stackYamlProvider(stackId));
|
|
});
|
|
}
|
|
|
|
Future<void> saveEnvVars(String stackId, Map<String, String> envVars) async {
|
|
state = const AsyncValue.loading();
|
|
state = await AsyncValue.guard(() async {
|
|
final repository = ref.read(stackRepositoryProvider);
|
|
await repository.updateStackEnvVars(stackId, envVars);
|
|
ref.invalidate(stackEnvVarsProvider(stackId));
|
|
});
|
|
}
|
|
|
|
Future<void> deploy(String stackId) async {
|
|
state = const AsyncValue.loading();
|
|
state = await AsyncValue.guard(() async {
|
|
final repository = ref.read(stackRepositoryProvider);
|
|
await repository.deployStack(stackId);
|
|
ref.invalidate(stacksProvider);
|
|
});
|
|
}
|
|
|
|
Future<void> rebuild(String stackId) async {
|
|
state = const AsyncValue.loading();
|
|
state = await AsyncValue.guard(() async {
|
|
final repository = ref.read(stackRepositoryProvider);
|
|
await repository.rebuildStack(stackId);
|
|
ref.invalidate(stacksProvider);
|
|
});
|
|
}
|
|
}
|