Commit 24d9882997
24d9882997bb69cc74a719f3e721c479595d2637
parent: bdc1800126
Unsigned
cmc <hello@cleberg.net> · 2026-03-19 01:07 UTC
Omit resolution when reopening resolved tickets
Layout: unified · split
Hutch/Views/Tickets/TicketDetailView.swift
+1 −4
| @@ -71,10 +71,7 @@ struct TicketDetailView: View { |
| 71 | 71 | if ticket.status == .resolved { |
| 72 | 72 | Button { |
| 73 | 73 | Task { |
| 74 | | await viewModel.updateStatus( |
| 75 | | status: .reported, |
| 76 | | resolution: .unresolved |
| 77 | | ) |
| 74 | await viewModel.updateStatus(status: .reported) |
| 78 | 75 | } |
| 79 | 76 | } label: { |
| 80 | 77 | SwiftUI.Label("Reopen", systemImage: "arrow.uturn.backward") |
Hutch/Views/Tickets/TicketDetailViewModel.swift
+15 −5
| @@ -130,6 +130,19 @@ final class TicketDetailViewModel { |
| 130 | 130 | return lhs.created < rhs.created |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | static func statusUpdateInput( |
| 134 | status: TicketStatus, |
| 135 | resolution: TicketResolution? |
| 136 | ) -> [String: any Sendable] { |
| 137 | var input: [String: any Sendable] = [ |
| 138 | "status": status.rawValue |
| 139 | ] |
| 140 | if status == .resolved, let resolution { |
| 141 | input["resolution"] = resolution.rawValue |
| 142 | } |
| 143 | return input |
| 144 | } |
| 145 | |
| 133 | 146 | init(ownerUsername: String, trackerName: String, trackerId: Int, trackerRid: String, ticketId: Int, client: SRHTClient) { |
| 134 | 147 | self.ownerUsername = ownerUsername |
| 135 | 148 | self.trackerName = trackerName |
| @@ -360,16 +373,13 @@ final class TicketDetailViewModel { |
| 360 | 373 | |
| 361 | 374 | // MARK: - Ticket Actions |
| 362 | 375 | |
| 363 | | func updateStatus(status: TicketStatus, resolution: TicketResolution) async { |
| 376 | func updateStatus(status: TicketStatus, resolution: TicketResolution? = nil) async { |
| 364 | 377 | guard !isPerformingAction else { return } |
| 365 | 378 | isPerformingAction = true |
| 366 | 379 | error = nil |
| 367 | 380 | |
| 368 | 381 | do { |
| 369 | | let input: [String: any Sendable] = [ |
| 370 | | "status": status.rawValue, |
| 371 | | "resolution": resolution.rawValue |
| 372 | | ] |
| 382 | let input = Self.statusUpdateInput(status: status, resolution: resolution) |
| 373 | 383 | _ = try await client.execute( |
| 374 | 384 | service: .todo, |
| 375 | 385 | query: Self.updateStatusMutation, |
HutchTests/TicketDetailViewModelTests.swift
added
+30
| @@ -0,0 +1,30 @@ |
| 1 | import Foundation |
| 2 | import Testing |
| 3 | @testable import Hutch |
| 4 | |
| 5 | struct TicketDetailViewModelTests { |
| 6 | |
| 7 | @Test |
| 8 | @MainActor |
| 9 | func reopenStatusInputOmitsResolution() { |
| 10 | let input = TicketDetailViewModel.statusUpdateInput( |
| 11 | status: .reported, |
| 12 | resolution: .unresolved |
| 13 | ) |
| 14 | |
| 15 | #expect(input["status"] as? String == TicketStatus.reported.rawValue) |
| 16 | #expect(input["resolution"] == nil) |
| 17 | } |
| 18 | |
| 19 | @Test |
| 20 | @MainActor |
| 21 | func resolveStatusInputIncludesResolution() { |
| 22 | let input = TicketDetailViewModel.statusUpdateInput( |
| 23 | status: .resolved, |
| 24 | resolution: .fixed |
| 25 | ) |
| 26 | |
| 27 | #expect(input["status"] as? String == TicketStatus.resolved.rawValue) |
| 28 | #expect(input["resolution"] as? String == TicketResolution.fixed.rawValue) |
| 29 | } |
| 30 | } |