feat(ui): add Merge command to DiffModal

This commit is contained in:
Mika Kuns
2026-04-22 09:53:07 +02:00
parent 949911f6c8
commit c911717a3b

View File

@@ -42,6 +42,10 @@ public sealed partial class DiffModalViewModel : ViewModelBase
public required string WorktreePath { get; init; }
public string? BaseRef { get; init; }
public string? TaskId { get; init; }
public string TaskTitle { get; init; } = "";
public Func<MergeModalViewModel, Task>? ShowMergeModal { get; set; }
public Func<MergeModalViewModel>? ResolveMergeVm { get; set; }
public ObservableCollection<DiffFileViewModel> Files { get; } = new();
@@ -58,6 +62,20 @@ public sealed partial class DiffModalViewModel : ViewModelBase
[RelayCommand]
private void Close() => CloseAction?.Invoke();
private bool CanMerge() =>
!string.IsNullOrEmpty(TaskId)
&& ShowMergeModal is not null
&& ResolveMergeVm is not null;
[RelayCommand(CanExecute = nameof(CanMerge))]
private async Task MergeAsync()
{
if (TaskId is null || ShowMergeModal is null || ResolveMergeVm is null) return;
var vm = ResolveMergeVm();
await vm.InitializeAsync(TaskId, TaskTitle);
await ShowMergeModal(vm);
}
public async Task LoadAsync(CancellationToken ct = default)
{
Files.Clear();