macOS client parity review
This commit is contained in:
@@ -157,6 +157,7 @@ struct ReviewsView: View {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
if let shown {
|
||||
ReviewCard(review: shown, taskId: taskId)
|
||||
.id(shown.id)
|
||||
} else {
|
||||
Muted(text: "No review of snapshot #\(n) yet.")
|
||||
}
|
||||
@@ -200,6 +201,9 @@ struct ReviewCard: View {
|
||||
Spacer(minLength: 0)
|
||||
Text(ago(review.createdAt))
|
||||
.help(isoText(review.createdAt))
|
||||
if review.state == .running {
|
||||
StopReviewButton(reviewId: review.id)
|
||||
}
|
||||
}
|
||||
.font(Fonts.font(11))
|
||||
.foregroundStyle(Palette.muted)
|
||||
@@ -220,6 +224,30 @@ struct ReviewCard: View {
|
||||
}
|
||||
}
|
||||
|
||||
private struct StopReviewButton: View {
|
||||
let reviewId: String
|
||||
@Environment(Store.self) private var store
|
||||
@Environment(Overlays.self) private var overlays
|
||||
@ViewState private var busy = false
|
||||
|
||||
var body: some View {
|
||||
Button("Stop") {
|
||||
busy = true
|
||||
Task {
|
||||
do {
|
||||
_ = try await store.api.client.stopReview(path: .init(reviewId: reviewId)).ok
|
||||
} catch {
|
||||
busy = false
|
||||
overlays.showAlert(errorText(error))
|
||||
}
|
||||
}
|
||||
}
|
||||
.buttonStyle(WebButtonStyle(danger: true))
|
||||
.disabled(busy)
|
||||
.help("End the reviewer and record this review as failed")
|
||||
}
|
||||
}
|
||||
|
||||
private struct ReviewResult: View {
|
||||
let review: Review
|
||||
let taskId: String?
|
||||
@@ -338,6 +366,7 @@ private struct FindingDiff: View {
|
||||
}
|
||||
}
|
||||
.task(id: "\(taskId)/\(n)/\(path)/\(line)/\(end)") {
|
||||
failure = nil
|
||||
do {
|
||||
let patch = try await SnapshotPatches.patch(store.api, taskId, n, path)
|
||||
let lines = patch.map { linesAround($0, line, end) } ?? []
|
||||
|
||||
Reference in New Issue
Block a user