From 88ee626cb3686dc176cd7911b073c4e65fa54d34 Mon Sep 17 00:00:00 2001 From: Melodi <62381002+Melodi17@users.noreply.github.com> Date: Mon, 14 Sep 2026 06:15:40 +1000 Subject: feat: ui cleanup --- src/marlin.core/functional/GitBinaryClient.cs | 3 + src/marlin.web/Controllers/VCSController.cs | 43 ++++++++++--- src/marlin.web/Models/VersionControlSource.cs | 2 +- .../Services/VersionControlSyncService.cs | 1 + src/marlin.web/Views/Agents/Create.cshtml | 9 ++- src/marlin.web/Views/VCS/Create.cshtml | 1 - src/marlin.web/Views/VCS/Details.cshtml | 74 ++++++++++++++-------- src/marlin.web/Views/VCS/ListSecret.cshtml | 16 ++++- src/marlin.web/wwwroot/css/site.css | 8 +++ 9 files changed, 114 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/marlin.core/functional/GitBinaryClient.cs b/src/marlin.core/functional/GitBinaryClient.cs index 001f2c8..3a703da 100644 --- a/src/marlin.core/functional/GitBinaryClient.cs +++ b/src/marlin.core/functional/GitBinaryClient.cs @@ -125,6 +125,9 @@ public class GitBinaryClient : IGitClient if (parts.Length != 2) continue; // ignore a malformed line rather than throw over one bad entry + if (parts[1].EndsWith("^{}", StringComparison.Ordinal)) + continue; // peeled tag marker from ls-remote, not a real ref/refspec + result[parts[1]] = parts[0]; } diff --git a/src/marlin.web/Controllers/VCSController.cs b/src/marlin.web/Controllers/VCSController.cs index 8086e99..10ef59b 100644 --- a/src/marlin.web/Controllers/VCSController.cs +++ b/src/marlin.web/Controllers/VCSController.cs @@ -22,8 +22,6 @@ public class VCSController(ApplicationDbContext dbContext, VersionControlSyncSer return this.View(items); } - public record SecretOption(Guid Id, string Label); - [HttpGet("details/{id}")] public async Task Details(Guid id, CancellationToken ct) { @@ -37,12 +35,7 @@ public class VCSController(ApplicationDbContext dbContext, VersionControlSyncSer if (item == null) return this.NotFound(); - var secretOptions = await dbContext.Secrets - .Where(x => x.SourceId == id) - .Select(x => new SecretOption(x.Id, x.Label)) - .ToListAsync(ct); - - return this.View((item, secretOptions)); + return this.View(item); } [HttpGet("details/{sourceId}/{commitId}/blobs")] @@ -87,9 +80,7 @@ public class VCSController(ApplicationDbContext dbContext, VersionControlSyncSer item.UpstreamUrl = vcs.UpstreamUrl; item.BranchFilter = vcs.BranchFilter; - item.MainBranch = vcs.MainBranch; item.MinPollingInterval = vcs.MinPollingInterval; - item.AccessSecretId = vcs.AccessSecretId; await dbContext.SaveChangesAsync(ct); await syncService.FetchSources(ct); @@ -97,6 +88,37 @@ public class VCSController(ApplicationDbContext dbContext, VersionControlSyncSer return this.RedirectToAction("List"); } + [HttpPost("details/{sourceId}/secrets/access")] + public async Task SetAccessSecret(Guid sourceId, Guid? secretId, CancellationToken ct) + { + var item = await dbContext.Sources + .FirstOrDefaultAsync(x => x.Id == sourceId, ct); + + if (item == null) + return this.NotFound(); + + item.AccessSecretId = secretId; + await dbContext.SaveChangesAsync(ct); + await syncService.FetchSources(ct); + + return this.RedirectToAction("ListSecret", new { sourceId }); + } + + [HttpPost("details/{sourceId}/main-branch")] + public async Task SetMainBranch(Guid sourceId, string branchName, CancellationToken ct) + { + var item = await dbContext.Sources + .FirstOrDefaultAsync(x => x.Id == sourceId, ct); + + if (item == null) + return this.NotFound(); + + item.MainBranch = branchName; + await dbContext.SaveChangesAsync(ct); + + return this.RedirectToAction("Details", new { id = sourceId }); + } + [HttpGet("create")] public async Task Create() { @@ -107,6 +129,7 @@ public class VCSController(ApplicationDbContext dbContext, VersionControlSyncSer public async Task CreatePost(VersionControlSource vcs, CancellationToken ct) { vcs.Id = Guid.Empty; + vcs.MainBranch = ""; await dbContext.AddAsync(vcs, ct); await dbContext.SaveChangesAsync(ct); diff --git a/src/marlin.web/Models/VersionControlSource.cs b/src/marlin.web/Models/VersionControlSource.cs index 270df12..12d5a7a 100644 --- a/src/marlin.web/Models/VersionControlSource.cs +++ b/src/marlin.web/Models/VersionControlSource.cs @@ -5,7 +5,7 @@ public class VersionControlSource public Guid Id { get; set; } public string UpstreamUrl { get; set; } - public string MainBranch { get; set; } + public string? MainBranch { get; set; } public string BranchFilter { get; set; } public int MinPollingInterval { get; set; } diff --git a/src/marlin.web/Services/VersionControlSyncService.cs b/src/marlin.web/Services/VersionControlSyncService.cs index cd75ed6..8f2046e 100644 --- a/src/marlin.web/Services/VersionControlSyncService.cs +++ b/src/marlin.web/Services/VersionControlSyncService.cs @@ -142,6 +142,7 @@ public class VersionControlSyncService : BackgroundService await dbContext.SourceCommits .Include(x => x.Branches) .Where(x => !x.Branches.Any()) + .Where(x => !dbContext.Jobs.Any(j => j.CommitId == x.Id)) .ExecuteDeleteAsync(ct); } diff --git a/src/marlin.web/Views/Agents/Create.cshtml b/src/marlin.web/Views/Agents/Create.cshtml index 4f0f31a..e112eeb 100644 --- a/src/marlin.web/Views/Agents/Create.cshtml +++ b/src/marlin.web/Views/Agents/Create.cshtml @@ -1,8 +1,13 @@ @using marlin.core.models
- Name:
- Max Concurrent Jobs:
+
+
Name
+
+ +
Max Concurrent Jobs
+
+
diff --git a/src/marlin.web/Views/VCS/Create.cshtml b/src/marlin.web/Views/VCS/Create.cshtml index e04592d..5f76192 100644 --- a/src/marlin.web/Views/VCS/Create.cshtml +++ b/src/marlin.web/Views/VCS/Create.cshtml @@ -4,7 +4,6 @@
URL:
Filter:
- Main Branch:
Polling Interval:
diff --git a/src/marlin.web/Views/VCS/Details.cshtml b/src/marlin.web/Views/VCS/Details.cshtml index a9ef0ea..44fa91e 100644 --- a/src/marlin.web/Views/VCS/Details.cshtml +++ b/src/marlin.web/Views/VCS/Details.cshtml @@ -1,55 +1,73 @@ @using marlin.core @using marlin.core.models -@using marlin.web.Controllers -@model (VersionControlSource Source, List SecretOptions) +@model VersionControlSource -
- URL:
- Filter:
- Main Branch:
- Polling Interval:
- Access Secret: -
- -
+
+
+

Details

+
+
+
+
URL
+
+
Filter
+
+ +
Polling Interval
+
+
+ + + Secrets + Back +
+
+
+
+ +

Branches

+
- - + - @foreach (var branch in Model.Source.Branches) + @foreach (var branch in Model.Branches.OrderByDescending(b => b.Name == Model.MainBranch)) { - - - + + } -
branch commitstatusactions
@(branch.Name == Model.Source.MainBranch ? "@" : "")@branch.Name
+ @branch.Name + @if (branch.Name == Model.MainBranch) + { + (primary) + } + @branch.Commit.Hash @if (branch.Commit.BlobsFetched) { blobs } - + @if (branch.Commit.WorkflowScanned) { workflow } + + @if (branch.Name != Model.MainBranch) + { +
+ + +
+ }
- -Secrets -Back + \ No newline at end of file diff --git a/src/marlin.web/Views/VCS/ListSecret.cshtml b/src/marlin.web/Views/VCS/ListSecret.cshtml index 25db7fe..84e3061 100644 --- a/src/marlin.web/Views/VCS/ListSecret.cshtml +++ b/src/marlin.web/Views/VCS/ListSecret.cshtml @@ -1,5 +1,19 @@ @model (VersionControlSource Source, List Secrets) +
+ + +
+ New @@ -42,4 +56,4 @@
-back +back diff --git a/src/marlin.web/wwwroot/css/site.css b/src/marlin.web/wwwroot/css/site.css index fa66346..d5d64db 100644 --- a/src/marlin.web/wwwroot/css/site.css +++ b/src/marlin.web/wwwroot/css/site.css @@ -66,6 +66,14 @@ table tr:hover { background-color: #fafafa } +table tr.highlighted { + background-color: #e1eaf6; +} + +table tr.highlighted:hover { + background-color: #d3e9f6; +} + th, td { border: 1px solid #ccc; text-align: left; -- cgit v1.3.1