feat(ui): wire DetailsIsland ApproveMerge through MergeModal

This commit is contained in:
Mika Kuns
2026-04-22 09:52:59 +02:00
parent ee4cd706ef
commit f3a58a6515

View File

@@ -106,6 +106,9 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase
// Set by the view so OpenWorktreeCommand can show the modal as a dialog // Set by the view so OpenWorktreeCommand can show the modal as a dialog
public Func<WorktreeModalViewModel, System.Threading.Tasks.Task>? ShowWorktreeModal { get; set; } public Func<WorktreeModalViewModel, System.Threading.Tasks.Task>? ShowWorktreeModal { get; set; }
// Set by the view so ApproveMergeCommand can show the modal as a dialog
public Func<MergeModalViewModel, System.Threading.Tasks.Task>? ShowMergeModal { get; set; }
// Set by the view so DeleteTaskCommand can prompt yes/no before deleting // Set by the view so DeleteTaskCommand can prompt yes/no before deleting
public Func<string, System.Threading.Tasks.Task<bool>>? ConfirmAsync { get; set; } public Func<string, System.Threading.Tasks.Task<bool>>? ConfirmAsync { get; set; }
@@ -126,6 +129,7 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase
RunNowCommand.NotifyCanExecuteChanged(); RunNowCommand.NotifyCanExecuteChanged();
ContinueCommand.NotifyCanExecuteChanged(); ContinueCommand.NotifyCanExecuteChanged();
ResetCommand.NotifyCanExecuteChanged(); ResetCommand.NotifyCanExecuteChanged();
ApproveMergeCommand.NotifyCanExecuteChanged();
} }
}; };
@@ -304,6 +308,10 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase
{ {
WorktreePath = WorktreePath, WorktreePath = WorktreePath,
BaseRef = WorktreeBaseCommit, BaseRef = WorktreeBaseCommit,
TaskId = Task?.Id,
TaskTitle = Task?.Title ?? "",
ShowMergeModal = ShowMergeModal,
ResolveMergeVm = () => _services.GetRequiredService<MergeModalViewModel>(),
}; };
await diffVm.LoadAsync(); await diffVm.LoadAsync();
await ShowDiffModal(diffVm); await ShowDiffModal(diffVm);
@@ -332,6 +340,7 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase
{ {
OpenDiffCommand.NotifyCanExecuteChanged(); OpenDiffCommand.NotifyCanExecuteChanged();
OpenWorktreeCommand.NotifyCanExecuteChanged(); OpenWorktreeCommand.NotifyCanExecuteChanged();
ApproveMergeCommand.NotifyCanExecuteChanged();
} }
[RelayCommand] [RelayCommand]
@@ -379,14 +388,18 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase
await repo.UpdateAsync(entity); await repo.UpdateAsync(entity);
} }
[RelayCommand] [RelayCommand(CanExecute = nameof(CanMerge))]
private async System.Threading.Tasks.Task ApproveMergeAsync() private async System.Threading.Tasks.Task ApproveMergeAsync()
{ {
if (Task == null) return; if (Task == null || ShowMergeModal == null) return;
// TODO: call worker merge hub method when available var vm = _services.GetRequiredService<MergeModalViewModel>();
await System.Threading.Tasks.Task.CompletedTask; await vm.InitializeAsync(Task.Id, Task.Title);
await ShowMergeModal(vm);
} }
private bool CanMerge() =>
Task != null && _worker.IsConnected && WorktreePath != null;
[RelayCommand] [RelayCommand]
private async System.Threading.Tasks.Task StopAsync() private async System.Threading.Tasks.Task StopAsync()
{ {