Blog/Components/Pages/Git/GitIndex.razor 2.4 K · 68 lines · raw · history

1 @page "/git"
2 @inherits GitPage
3
4 <PageTitle>git — mb.bes.is</PageTitle>
5
6 <GitBar/>
7
8 <main class="git-main">
9 <section class="block">
10 <h2 class="block-head">
11 <span>repositories</span>
12 <span class="block-note">@Repositories.Count</span>
13 </h2>
14
15 @if (Repositories.Count == 0)
16 {
17 <p class="empty">Nothing to browse: there are no repositories under @Service.Root.</p>
18 }
19 else
20 {
21 <div class="scroll">
22 <table>
23 <thead>
24 <tr>
25 <th>name</th>
26 <th class="wide">description</th>
27 <th class="when-wide">branch</th>
28 @if (Owned)
29 {
30 <th class="when-wide">owner</th>
31 }
32 <th class="num">idle</th>
33 </tr>
34 </thead>
35 <tbody>
36 @foreach (var repository in Repositories)
37 {
38 <tr>
39 <td><a href="/git/@Uri.EscapeDataString(repository.Name)">@repository.DisplayName</a></td>
40 <td class="wide dim">@(repository.Description ?? "")</td>
41 <td class="dim when-wide">@(repository.Head ?? "")</td>
42 @if (Owned)
43 {
44 <td class="dim when-wide">@(repository.Owner ?? "")</td>
45 }
46 <td class="num dim" title="@Exact(repository.Tip?.Committer.When)">
47 @Age(repository.Tip?.Committer.When)
48 </td>
49 </tr>
50 }
51 </tbody>
52 </table>
53 </div>
54 }
55 </section>
56 </main>
57
58 @code {
59 private IReadOnlyList<GitRepoSummary> Repositories { get; set; } = [];
60
61 /// <summary>
62 /// Owner comes from each repository's <c>gitweb.owner</c>, and most never set it. A column of
63 /// nothing is the opposite of what this page is for, so it only appears once it says something.
64 /// </summary>
65 private bool Owned => Repositories.Any(repository => repository.Owner is { Length: > 0 });
66
67 protected override void OnParametersSet() => Repositories = Service.ListRepositories();
68 }