Skip to content

Commit edbae77

Browse files
committed
add UI for marking graphs as vintage
1 parent 15dd5d0 commit edbae77

File tree

6 files changed

+42
-27
lines changed

6 files changed

+42
-27
lines changed

Sources/UnidocAPI/Building/Unidoc.LinkerRoute.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ extension Unidoc
66
case uplink
77
case unlink
88
case delete
9+
/// This is not really a linker action, but it is related closely enough to piggyback
10+
/// on the same route.
11+
case vintage
912
}
1013
}
1114
extension Unidoc.LinkerRoute:CustomStringConvertible
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
extension Unidoc.LinkerOperation
2+
{
3+
enum Update
4+
{
5+
case action(Unidoc.LinkerAction)
6+
case vintage(Bool)
7+
}
8+
}

Sources/UnidocServer/Operations/Interactions/Unidoc.LinkerOperation.swift

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,37 @@ extension Unidoc
1010
/// Queues one or more editions for uplinking. The uplinking process itself is asynchronous.
1111
struct LinkerOperation:Sendable
1212
{
13-
let action:LinkerAction
13+
let update:Update
1414
let scope:Edition?
1515
let back:String?
1616

17-
init(action:Unidoc.LinkerAction, scope:Unidoc.Edition?, back:String? = nil)
17+
init(update:Update, scope:Unidoc.Edition?, back:String? = nil)
1818
{
19-
self.action = action
19+
self.update = update
2020
self.scope = scope
2121
self.back = back
2222
}
2323
}
2424
}
25-
extension Unidoc.LinkerOperation
26-
{
27-
init(action:Unidoc.LinkerAction, form:Unidoc.LinkerForm)
28-
{
29-
self.init(action: action, scope: form.edition, back: form.back)
30-
}
31-
}
3225
extension Unidoc.LinkerOperation:Unidoc.AdministrativeOperation
3326
{
3427
func load(from server:Unidoc.Server,
3528
db:Unidoc.DB,
3629
as _:Unidoc.RenderFormat) async throws -> HTTP.ServerResponse?
3730
{
38-
if let scope:Unidoc.Edition = self.scope
31+
switch (self.scope, self.update)
3932
{
40-
try await db.snapshots.queue(id: scope, for: self.action)
41-
}
42-
else
43-
{
44-
try await db.snapshots.queueAll(for: self.action)
33+
case (nil, .action(let action)):
34+
try await db.snapshots.queueAll(for: action)
35+
36+
case (let scope?, .action(let action)):
37+
try await db.snapshots.queue(id: scope, for: action)
38+
39+
case (let scope?, .vintage(let vintage)):
40+
try await db.snapshots.mark(id: scope, vintage: vintage)
41+
42+
default:
43+
return nil
4544
}
4645

4746
return .redirect(.seeOther(self.back ?? "/admin"))

Sources/UnidocServer/Operations/Procedures/Unidoc.BuilderUploadOperation.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,7 @@ extension Unidoc.BuilderUploadOperation:Unidoc.BlockingOperation
8686
case .failure:
8787
// Mark the snapshot as unbuildable, so that automated plugins don’t try to
8888
// build it again.
89-
let _:Unidoc.Snapshot? = try await db.snapshots.modify(
90-
existing: complete.id.edition)
91-
{
92-
$0[.set] { $0[Unidoc.Snapshot[.vintage]] = true }
93-
}
89+
try await db.snapshots.mark(id: complete.id.edition, vintage: true)
9490
}
9591

9692
case .labeling:

Sources/UnidocServer/Requests/Unidoc.Router.swift

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -525,21 +525,25 @@ extension Unidoc.Router
525525
case .uplink: return nil
526526
case .unlink: page = .unlink(uri)
527527
case .delete: page = .delete(uri)
528+
case .vintage: return nil
528529
}
529530

530531
return .syncHTML(page)
531532
}
532533

533-
let action:Unidoc.LinkerAction
534+
let update:Unidoc.LinkerOperation.Update
534535

535536
switch route
536537
{
537-
case .uplink: action = .uplinkRefresh
538-
case .unlink: action = .unlink
539-
case .delete: action = .delete
538+
case .uplink: update = .action(.uplinkRefresh)
539+
case .unlink: update = .action(.unlink)
540+
case .delete: update = .action(.delete)
541+
case .vintage: update = .vintage(true)
540542
}
541543

542-
return .unordered(Unidoc.LinkerOperation.init(action: action, form: form))
544+
return .unordered(Unidoc.LinkerOperation.init(update: update,
545+
scope: form.edition,
546+
back: form.back))
543547
}
544548

545549
private mutating
@@ -646,7 +650,9 @@ extension Unidoc.Router
646650
}
647651

648652
case .uplinkAll:
649-
return .unordered(Unidoc.LinkerOperation.init(action: .uplinkRefresh, scope: nil))
653+
return .unordered(Unidoc.LinkerOperation.init(
654+
update: .action(.uplinkRefresh),
655+
scope: nil))
650656

651657
case .userConfig:
652658
if let account:Unidoc.Account = self.authorization.account,

Sources/UnidocUI/Endpoints/Tags/Unidoc.RefsTable.Row.Graph.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ extension Unidoc.RefsTable.Row.Graph:HTML.OutputStreamable
161161
("Uplink", .uplink),
162162
("Unlink", .unlink),
163163
("Delete", .delete),
164+
("Mark vintage", .vintage)
164165
]
165166
{
166167
$0[.li]
@@ -173,6 +174,8 @@ extension Unidoc.RefsTable.Row.Graph:HTML.OutputStreamable
173174
case .uplink: break
174175
case .unlink: action["y"] = "false"
175176
case .delete: action["y"] = "false"
177+
// Mark vintage does not require confirmation.
178+
case .vintage: break
176179
}
177180

178181
$0[.form]

0 commit comments

Comments
 (0)