Skip to content

Commit 705d30c

Browse files
authored
Fix which codeflow subscriptions are shown in BarViz (#4850)
- Wrong forward flow subscriptions where looked up - Resolves #4747 #4732
1 parent 1faef31 commit 705d30c

File tree

2 files changed

+68
-18
lines changed

2 files changed

+68
-18
lines changed

src/ProductConstructionService/ProductConstructionService.BarViz/Pages/Codeflows.razor

Lines changed: 54 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@
2525
color: var(--neutral-foreground-hint) !important;
2626
font-style: italic;
2727
}
28+
29+
.commitSha {
30+
border: none;
31+
color: #888;
32+
font-family: monospace;
33+
font-size: 0.8em;
34+
top: -4px;
35+
position: relative;
36+
margin-left: 5px;
37+
margin-right: 7px;
38+
}
39+
40+
.commitSha a {
41+
height: 23px;
42+
padding: 2px 6px 0px 6px;
43+
}
44+
2845
</style>
2946

3047
<PageTitle>Codeflows – Maestro++</PageTitle>
@@ -66,30 +83,50 @@
6683
<TemplateColumn Title="Backflow"
6784
Sortable="true"
6885
SortBy="@SortBy(sub => sub.BackflowSubscription != null && sub.BackflowSubscription.LastAppliedBuild != null ? sub.BackflowSubscription.LastAppliedBuild.DateProduced.ToString("o") : "1900")"
69-
Align="Align.Center">
86+
Align="Align.Start">
7087
<FluentLabel Title="@(context.BackflowSubscription?.LastAppliedBuild?.DateProduced.ToString("f"))">
71-
@(GetLastAppliedBuildTimeAgo(context.BackflowSubscription))
88+
@if (context.BackflowSubscription?.LastAppliedBuild != null)
89+
{
90+
@(GetLastAppliedBuildTimeAgo(context.BackflowSubscription))
91+
<FluentAnchor Href="@context.BackflowSubscription.LastAppliedBuild.GetCommitLink()" Target="_blank" class="commitSha" title="@context.BackflowSubscription.LastAppliedBuild.Commit">
92+
&commat;@GetShortSha(context.BackflowSubscription.LastAppliedBuild.Commit)
93+
</FluentAnchor>
94+
}
95+
else
96+
{
97+
<span>—</span>
98+
}
99+
72100
@if (context.BackflowPr != null)
73101
{
74-
<span> / </span>
75102
<FluentAnchor Href="@context.BackflowPr" Target="_blank" Appearance="Appearance.Hypertext">Active PR</FluentAnchor>
76103
}
77104
</FluentLabel>
78105
</TemplateColumn>
79106
<TemplateColumn Title="Forward flow"
80107
Sortable="true"
81108
SortBy="@SortBy(sub => sub.ForwardflowSubscription != null && sub.ForwardflowSubscription.LastAppliedBuild != null ? sub.ForwardflowSubscription.LastAppliedBuild.DateProduced.ToString("o") : "1900")"
82-
Align="Align.Center">
109+
Align="Align.Start">
83110
<FluentLabel Title="@(context.ForwardflowSubscription?.LastAppliedBuild?.DateProduced.ToString("f"))">
84-
@(GetLastAppliedBuildTimeAgo(context.ForwardflowSubscription))
111+
@if (context.ForwardflowSubscription?.LastAppliedBuild != null)
112+
{
113+
@(GetLastAppliedBuildTimeAgo(context.ForwardflowSubscription))
114+
<FluentAnchor Href="@context.ForwardflowSubscription.LastAppliedBuild.GetCommitLink()" Target="_blank" class="commitSha" title="@context.ForwardflowSubscription.LastAppliedBuild.Commit">
115+
&commat;@GetShortSha(context.ForwardflowSubscription.LastAppliedBuild.Commit)
116+
</FluentAnchor>
117+
}
118+
else
119+
{
120+
<span>—</span>
121+
}
122+
85123
@if (context.ForwardflowPr != null)
86124
{
87-
<span> / </span>
88125
<FluentAnchor Href="@context.ForwardflowPr" Target="_blank" Appearance="Appearance.Hypertext">Active PR</FluentAnchor>
89126
}
90127
</FluentLabel>
91128
</TemplateColumn>
92-
<TemplateColumn Style="width:60px">
129+
<TemplateColumn Width="60px">
93130
<CodeflowContextMenu Codeflow="@context" ShowDetails="@ShowDetails" />
94131
</TemplateColumn>
95132
</ChildContent>
@@ -144,21 +181,22 @@
144181
// Get all unique mappings
145182
var allMappings = subscriptions
146183
.Select(s => s.SourceDirectory ?? s.TargetDirectory)
147-
.Distinct();
184+
.Where(s => !string.IsNullOrEmpty(s))
185+
.Distinct()
186+
.ToList();
148187

149-
List<CodeflowSubscription> codeflows = new List<CodeflowSubscription>(allMappings.Count());
188+
List<CodeflowSubscription> codeflows = new List<CodeflowSubscription>(allMappings.Count);
150189
foreach (var mapping in allMappings)
151190
{
152-
var backflowSubscription = Subscriptions!.FirstOrDefault(s => s.SourceDirectory == mapping);
153-
var forwardflowSubscription = Subscriptions!.FirstOrDefault(s => s.TargetDirectory == mapping);
191+
var backflowSubscription = subscriptions!.FirstOrDefault(s => s.SourceDirectory == mapping);
192+
var forwardflowSubscription = subscriptions!.FirstOrDefault(s => s.TargetDirectory == mapping);
154193
PullRequests.TryGetValue(backflowSubscription?.Id ?? default, out var backflowPr);
155194
PullRequests.TryGetValue(forwardflowSubscription?.Id ?? default, out var forwardflowPr);
156195
codeflows.Add(new CodeflowSubscription(
157-
RepositoryUrl: backflowSubscription?.TargetRepository ?? forwardflowSubscription?.SourceRepository
158-
?? throw new InvalidOperationException(),
196+
RepositoryUrl: backflowSubscription?.TargetRepository ?? forwardflowSubscription?.SourceRepository!,
159197
RepositoryBranch: backflowSubscription?.TargetBranch,
160198
MappingName: mapping,
161-
Enabled: backflowSubscription?.Enabled ?? forwardflowSubscription?.Enabled ?? false, // TODO
199+
Enabled: backflowSubscription?.Enabled ?? forwardflowSubscription?.Enabled ?? false,
162200
BackflowSubscription: backflowSubscription,
163201
ForwardflowSubscription: forwardflowSubscription,
164202
BackflowPr: backflowPr,
@@ -235,4 +273,6 @@
235273
}
236274
];
237275
}
276+
277+
static string GetShortSha(string sha) => sha.Substring(0, 7);
238278
}

src/ProductConstructionService/ProductConstructionService.BarViz/Pages/Subscriptions.razor

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,20 @@
144144
[SupplyParameterFromQuery(Name = "search")]
145145
private string? searchFilterQuery { get; set; }
146146

147+
[SupplyParameterFromQuery(Name = "showDisabled")]
148+
private string? showDisabledQuery { get; set; }
149+
147150
Dictionary<Guid, string> PullRequests = [];
148151
List<Subscription>? AllSubscriptions = null;
149152
IQueryable<Subscription>? FilteredSubscriptions;
150153
PaginationState Pagination = new() { ItemsPerPage = 25 };
151154
string SearchFilter = string.Empty;
152-
bool ShowDisabled = false;
155+
156+
bool ShowDisabled
157+
{
158+
get => !string.IsNullOrEmpty(showDisabledQuery) && bool.TryParse(showDisabledQuery, out var value) && value;
159+
set => showDisabledQuery = value.ToString();
160+
}
153161

154162
GridSort<Subscription> SortBy(Expression<Func<Subscription, string>> sorter)
155163
=> GridSort<Subscription>.ByAscending(sorter);
@@ -197,7 +205,7 @@
197205
filteredSubscriptions = filteredSubscriptions?
198206
.Where(sub => searchTerms.All(term => IsMatch(sub, term)));
199207

200-
UpdateQueryParams(SearchFilter);
208+
UpdateQueryParams();
201209
}
202210
}
203211

@@ -208,6 +216,7 @@
208216
void SetDisabled(bool value)
209217
{
210218
ShowDisabled = value;
219+
UpdateQueryParams();
211220
FilterSubscriptions();
212221
}
213222

@@ -248,11 +257,12 @@
248257
await DialogService.ShowDialogAsync<SubscriptionDetailDialog>(subscription, parameters);
249258
}
250259

251-
private void UpdateQueryParams(string searchFilter)
260+
private void UpdateQueryParams()
252261
{
253262
var newUri = NavManager.GetUriWithQueryParameters(new Dictionary<string, object?>
254263
{
255-
["search"] = searchFilter,
264+
["search"] = SearchFilter,
265+
["showDisabled"] = ShowDisabled,
256266
});
257267

258268
NavManager.NavigateTo(newUri);

0 commit comments

Comments
 (0)