feat(ui): TaskRowViewModel with status chip mapping
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using ClaudeDo.Data.Models;
|
||||||
|
using TaskStatus = ClaudeDo.Data.Models.TaskStatus;
|
||||||
|
|
||||||
namespace ClaudeDo.Ui.ViewModels.Islands;
|
namespace ClaudeDo.Ui.ViewModels.Islands;
|
||||||
|
|
||||||
@@ -6,5 +9,37 @@ public sealed partial class TaskRowViewModel : ViewModelBase
|
|||||||
{
|
{
|
||||||
public required string Id { get; init; }
|
public required string Id { get; init; }
|
||||||
[ObservableProperty] private string _title = "";
|
[ObservableProperty] private string _title = "";
|
||||||
|
[ObservableProperty] private string _listName = "";
|
||||||
[ObservableProperty] private bool _done;
|
[ObservableProperty] private bool _done;
|
||||||
|
[ObservableProperty] private bool _isStarred;
|
||||||
|
[ObservableProperty] private bool _isMyDay;
|
||||||
|
[ObservableProperty] private bool _isSelected;
|
||||||
|
[ObservableProperty] private TaskStatus _status;
|
||||||
|
[ObservableProperty] private string? _branch;
|
||||||
|
[ObservableProperty] private string? _diffStat;
|
||||||
|
[ObservableProperty] private string? _liveTail;
|
||||||
|
|
||||||
|
public string StatusChipClass => Status switch
|
||||||
|
{
|
||||||
|
TaskStatus.Running => "running",
|
||||||
|
TaskStatus.Failed => "error",
|
||||||
|
TaskStatus.Done => "review",
|
||||||
|
TaskStatus.Queued => "queued",
|
||||||
|
_ => "idle",
|
||||||
|
};
|
||||||
|
|
||||||
|
partial void OnStatusChanged(TaskStatus value) => OnPropertyChanged(nameof(StatusChipClass));
|
||||||
|
|
||||||
|
public static TaskRowViewModel FromEntity(TaskEntity t) => new()
|
||||||
|
{
|
||||||
|
Id = t.Id,
|
||||||
|
Title = t.Title,
|
||||||
|
ListName = t.List?.Name ?? "",
|
||||||
|
Done = t.Status == TaskStatus.Done,
|
||||||
|
IsStarred = t.IsStarred,
|
||||||
|
IsMyDay = t.IsMyDay,
|
||||||
|
Status = t.Status,
|
||||||
|
Branch = t.Worktree?.BranchName,
|
||||||
|
DiffStat = t.Worktree?.DiffStat,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\ClaudeDo.Worker\ClaudeDo.Worker.csproj" />
|
<ProjectReference Include="..\..\src\ClaudeDo.Worker\ClaudeDo.Worker.csproj" />
|
||||||
<ProjectReference Include="..\..\src\ClaudeDo.Data\ClaudeDo.Data.csproj" />
|
<ProjectReference Include="..\..\src\ClaudeDo.Data\ClaudeDo.Data.csproj" />
|
||||||
|
<ProjectReference Include="..\..\src\ClaudeDo.Ui\ClaudeDo.Ui.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
22
tests/ClaudeDo.Worker.Tests/UiVm/TaskRowViewModelTests.cs
Normal file
22
tests/ClaudeDo.Worker.Tests/UiVm/TaskRowViewModelTests.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using ClaudeDo.Data.Models;
|
||||||
|
using ClaudeDo.Ui.ViewModels.Islands;
|
||||||
|
using Xunit;
|
||||||
|
using TaskStatus = ClaudeDo.Data.Models.TaskStatus;
|
||||||
|
|
||||||
|
namespace ClaudeDo.Worker.Tests.UiVm;
|
||||||
|
|
||||||
|
public class TaskRowViewModelTests
|
||||||
|
{
|
||||||
|
[Theory]
|
||||||
|
[InlineData(TaskStatus.Running, "running")]
|
||||||
|
[InlineData(TaskStatus.Failed, "error")]
|
||||||
|
[InlineData(TaskStatus.Done, "review")]
|
||||||
|
[InlineData(TaskStatus.Queued, "queued")]
|
||||||
|
[InlineData(TaskStatus.Manual, "idle")]
|
||||||
|
public void StatusChipClass_Maps_Correctly(TaskStatus s, string expected)
|
||||||
|
{
|
||||||
|
var vm = new TaskRowViewModel { Id = "t" };
|
||||||
|
vm.Status = s;
|
||||||
|
Assert.Equal(expected, vm.StatusChipClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user