Skip to content

Commit 2d19191

Browse files
committed
Update state UI and iconography for work items.
1 parent 0adcda6 commit 2d19191

4 files changed

Lines changed: 42 additions & 33 deletions

File tree

Nexus/Components/Dashboard/WorkItemList.razor

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
Color="@TypeColor(context.Item.Type)"
2323
Size="Size.Small" />
2424
</MudTooltip>
25-
<MudTooltip Text="@SplitPascal(context.Item.Status)" Placement="Placement.Right">
25+
<MudTooltip Text="@FormatStatus(context.Item.Status)" Placement="Placement.Right">
2626
<MudIcon Icon="@StatusIcon(context.Item.Status)"
2727
Color="@StatusColor(context.Item.Status)"
2828
Size="Size.Small" />
@@ -72,7 +72,7 @@
7272
<MudChip T="string" Size="Size.Small" Icon="@TypeIcon(wi.Type)" Color="@TypeColor(wi.Type)"
7373
Variant="Variant.Outlined" Style="font-weight:600;">@SplitPascal(wi.Type)</MudChip>
7474
<MudChip T="string" Size="Size.Small" Icon="@StatusIcon(wi.Status)" Color="@StatusColor(wi.Status)"
75-
Variant="Variant.Outlined" Style="font-weight:600;"> @SplitPascal(wi.Status)</MudChip>
75+
Variant="Variant.Outlined" Style="font-weight:600;"> @FormatStatus(wi.Status)</MudChip>
7676
@if (details?.Priority is { } priority)
7777
{
7878
<MudChip T="string" Size="Size.Small" Color="Color.Default"
@@ -261,7 +261,7 @@
261261
x.Description ?? "",
262262
x.Assignee?.Name ?? "unassigned",
263263
x.Creator.Name,
264-
x.Status.ToString(),
264+
x.Status,
265265
string.Join(' ', x.Labels)
266266
).ToLowerInvariant();
267267
return term.ToLowerInvariant().Split(' ', StringSplitOptions.RemoveEmptyEntries)
@@ -382,25 +382,37 @@
382382
_ => Color.Default,
383383
};
384384

385-
private static string StatusIcon(WorkItemStatus s) => s switch
385+
private static string FormatStatus(string? status) => string.IsNullOrWhiteSpace(status) ? "Unknown" : status;
386+
387+
private static string NormalizedStatus(string? status) => (status ?? "")
388+
.Replace(" ", "", StringComparison.Ordinal)
389+
.Replace("-", "", StringComparison.Ordinal)
390+
.Replace("_", "", StringComparison.Ordinal)
391+
.ToLowerInvariant();
392+
393+
private static string StatusIcon(string? s) => NormalizedStatus(s) switch
386394
{
387-
WorkItemStatus.New => Icons.Material.Filled.FiberNew,
388-
WorkItemStatus.Active => Icons.Material.Filled.PlayCircle,
389-
WorkItemStatus.InProgress => Icons.Material.Filled.Autorenew,
390-
WorkItemStatus.Resolved => Icons.Material.Filled.CheckCircle,
391-
WorkItemStatus.Closed => Icons.Material.Filled.Cancel,
392-
WorkItemStatus.Blocked => Icons.Material.Filled.Block,
393-
_ => Icons.Material.Filled.Circle,
395+
"new" or "proposed" or "todo" => Icons.Material.Filled.FiberNew,
396+
"active" or "open" => Icons.Material.Filled.PlayCircle,
397+
"inprogress" or "committed" or "doing" => Icons.Material.Filled.Autorenew,
398+
"resolved" => Icons.Material.Filled.CheckCircle,
399+
"readyfortesting" or "readytotest" or "readyfortest" => Icons.Material.Filled.Science,
400+
"readyforrelease" or "readyforrelase" => Icons.Material.Filled.RocketLaunch,
401+
"closed" or "done" or "completed" or "removed" => Icons.Material.Filled.Cancel,
402+
"blocked" or "impediment" => Icons.Material.Filled.Block,
403+
_ => Icons.Material.Filled.Circle,
394404
};
395405

396-
private static Color StatusColor(WorkItemStatus s) => s switch
406+
private static Color StatusColor(string? s) => NormalizedStatus(s) switch
397407
{
398-
WorkItemStatus.New => Color.Info,
399-
WorkItemStatus.Active or WorkItemStatus.InProgress => Color.Primary,
400-
WorkItemStatus.Resolved => Color.Success,
401-
WorkItemStatus.Closed => Color.Default,
402-
WorkItemStatus.Blocked => Color.Error,
403-
_ => Color.Secondary,
408+
"new" or "proposed" or "todo" => Color.Info,
409+
"active" or "open" or "inprogress" or "committed" or "doing" => Color.Primary,
410+
"resolved" => Color.Success,
411+
"readyfortesting" or "readytotest" or "readyfortest" => Color.Tertiary,
412+
"readyforrelease" or "readyforrelase" => Color.Success,
413+
"closed" or "done" or "completed" or "removed" => Color.Default,
414+
"blocked" or "impediment" => Color.Error,
415+
_ => Color.Secondary,
404416
};
405417

406418
private static string Relative(DateTimeOffset dt)

Nexus/Models/WorkItem.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ namespace Nexus.Models;
22

33
public enum WorkItemType { Bug, Task, UserStory, Feature, Epic }
44

5-
public enum WorkItemStatus { New, Active, InProgress, Resolved, Closed, Blocked }
6-
75
public enum DataProvider { GitHub, AzureDevOps }
86

97
public record WorkItem(
@@ -13,7 +11,7 @@ public record WorkItem(
1311
string? Description,
1412
UserReference Creator,
1513
UserReference? Assignee,
16-
WorkItemStatus Status,
14+
string Status,
1715
DateTimeOffset CreatedAt,
1816
DateTimeOffset UpdatedAt,
1917
IReadOnlyList<string> Labels,

Nexus/Providers/AdoProvider.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,7 @@ private Models.WorkItem MapWorkItem(Microsoft.TeamFoundation.WorkItemTracking.We
179179
_ => NexusWiType.Task
180180
};
181181

182-
var status = (Get("System.State") ?? "").ToLowerInvariant() switch
183-
{
184-
"new" => WorkItemStatus.New,
185-
"active" => WorkItemStatus.Active,
186-
"in progress" => WorkItemStatus.InProgress,
187-
"resolved" => WorkItemStatus.Resolved,
188-
"closed" or "done" => WorkItemStatus.Closed,
189-
"blocked" => WorkItemStatus.Blocked,
190-
_ => WorkItemStatus.Active
191-
};
182+
var status = Get("System.State") ?? "Unknown";
192183

193184
string? assigneeName = wi.Fields.TryGetValue("System.AssignedTo", out var at)
194185
? (at is IdentityRef ir ? ir.DisplayName : at?.ToString()) : null;

Nexus/Providers/GitHubProvider.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ private string BuildQuery()
8585
var repoFragment = """
8686
issues(first: 100, states: [OPEN]) {
8787
nodes {
88-
number title body url createdAt updatedAt
88+
number title body url state createdAt updatedAt
8989
author { login avatarUrl ... on User { name } }
9090
assignees(first: 20) { nodes { login avatarUrl name } }
9191
labels(first: 20) { nodes { name } }
@@ -173,7 +173,7 @@ private static MappedIssue MapIssue(GqlIssue node)
173173
Description: node.Body,
174174
Creator: author,
175175
Assignee: assigneeRef,
176-
Status: WorkItemStatus.Active,
176+
Status: FormatGitHubState(node.State),
177177
CreatedAt: node.CreatedAt,
178178
UpdatedAt: node.UpdatedAt,
179179
Labels: node.Labels.Nodes.Select(l => l.Name).ToList(),
@@ -183,6 +183,13 @@ private static MappedIssue MapIssue(GqlIssue node)
183183
return new MappedIssue(workItem, firstAssignee?.Login);
184184
}
185185

186+
private static string FormatGitHubState(string? state) => state switch
187+
{
188+
null or "" => "Open",
189+
_ => string.Join(' ', state.Split('_', StringSplitOptions.RemoveEmptyEntries)
190+
.Select(part => string.Concat(part[..1].ToUpperInvariant(), part[1..].ToLowerInvariant())))
191+
};
192+
186193
private static MappedPr MapPr(GqlPr node)
187194
{
188195
UserReference author = node.Author is { } a
@@ -301,6 +308,7 @@ internal record GqlIssue(
301308
[property: JsonPropertyName("title")] string Title,
302309
[property: JsonPropertyName("body")] string? Body,
303310
[property: JsonPropertyName("url")] string? Url,
311+
[property: JsonPropertyName("state")] string? State,
304312
[property: JsonPropertyName("createdAt")] DateTimeOffset CreatedAt,
305313
[property: JsonPropertyName("updatedAt")] DateTimeOffset UpdatedAt,
306314
[property: JsonPropertyName("author")] GqlActor? Author,

0 commit comments

Comments
 (0)