feat(ui): open ListSettingsModal via context menu and gear button

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Mika Kuns
2026-04-22 13:27:05 +02:00
parent 5348220e60
commit 5784dbee94
5 changed files with 73 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using ClaudeDo.Data;
using ClaudeDo.Data.Repositories;
using ClaudeDo.Ui.Services;
using ClaudeDo.Ui.ViewModels.Modals;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
@@ -15,12 +16,14 @@ public sealed partial class ListsIslandViewModel : ViewModelBase
{
private readonly IDbContextFactory<ClaudeDoDbContext> _dbFactory;
private readonly IServiceProvider? _services;
private readonly WorkerClient? _worker;
public event EventHandler? SelectionChanged;
public event EventHandler? FocusSearchRequested;
public void RequestFocusSearch() => FocusSearchRequested?.Invoke(this, EventArgs.Empty);
public Func<SettingsModalViewModel, Task>? ShowSettingsModal { get; set; }
public Func<ListSettingsModalViewModel, System.Threading.Tasks.Task>? ShowListSettingsModal { get; set; }
[RelayCommand]
private async Task OpenSettings()
@@ -31,6 +34,16 @@ public sealed partial class ListsIslandViewModel : ViewModelBase
await ShowSettingsModal(settingsVm);
}
[RelayCommand]
private async System.Threading.Tasks.Task OpenListSettingsAsync(ListNavItemViewModel? row)
{
if (row is null || ShowListSettingsModal is null || _services is null) return;
var vm = _services.GetRequiredService<ListSettingsModalViewModel>();
await vm.LoadAsync(row.Id, row.Name, row.WorkingDir, row.DefaultCommitType);
await ShowListSettingsModal(vm);
await RefreshRowAsync(row.Id);
}
public ObservableCollection<ListNavItemViewModel> Items { get; } = new();
public ObservableCollection<ListNavItemViewModel> SmartLists { get; } = new();
public ObservableCollection<ListNavItemViewModel> UserLists { get; } = new();
@@ -42,16 +55,20 @@ public sealed partial class ListsIslandViewModel : ViewModelBase
public string MachineName { get; } = Environment.MachineName;
public string UserInitials { get; }
public ListsIslandViewModel(IDbContextFactory<ClaudeDoDbContext> dbFactory, IServiceProvider? services = null)
public ListsIslandViewModel(IDbContextFactory<ClaudeDoDbContext> dbFactory, IServiceProvider? services = null, WorkerClient? worker = null)
{
_dbFactory = dbFactory;
_services = services;
_worker = worker;
var parts = Environment.UserName.Split('.', '_', '-', ' ');
UserInitials = parts.Length >= 2
? $"{parts[0][0]}{parts[1][0]}".ToUpperInvariant()
: Environment.UserName.Length >= 2
? Environment.UserName[..2].ToUpperInvariant()
: Environment.UserName.ToUpperInvariant();
if (_worker is not null)
_worker.ListUpdatedEvent += id => _ = RefreshRowAsync(id);
}
public async Task LoadAsync(CancellationToken ct = default)
@@ -85,6 +102,8 @@ public sealed partial class ListsIslandViewModel : ViewModelBase
Kind = ListKind.User,
IconKey = "Folder",
DotColorKey = dotColors[idx % dotColors.Length],
WorkingDir = l.WorkingDir,
DefaultCommitType = l.DefaultCommitType,
};
Items.Add(item);
UserLists.Add(item);
@@ -109,4 +128,23 @@ public sealed partial class ListsIslandViewModel : ViewModelBase
foreach (var i in Items) i.IsActive = ReferenceEquals(i, value);
SelectionChanged?.Invoke(this, EventArgs.Empty);
}
private async System.Threading.Tasks.Task RefreshRowAsync(string rowId)
{
try
{
var rawId = rowId.StartsWith("user:") ? rowId["user:".Length..] : rowId;
var row = UserLists.FirstOrDefault(r => r.Id == rowId);
if (row is null) return;
await using var ctx = await _dbFactory.CreateDbContextAsync();
var lists = new ListRepository(ctx);
var entity = await lists.GetByIdAsync(rawId);
if (entity is null) return;
row.WorkingDir = entity.WorkingDir;
row.DefaultCommitType = entity.DefaultCommitType;
}
catch { /* best-effort refresh */ }
}
}