summaryrefslogtreecommitdiff
path: root/Hutch/Views/Tickets/TicketDetailView.swift
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-04-01 23:25:54 -0500
committerChristian Cleberg <[email protected]>2026-04-01 23:25:54 -0500
commita83893afa086f0050c825144fa818024db4df056 (patch)
treec11c90f50acc633d2388e9a4940a4f3e7662b2a6 /Hutch/Views/Tickets/TicketDetailView.swift
parent7fe5ec3f69211712d39f3a1dff090119340e05d9 (diff)
downloadhutch-2.8.0.tar.gz
hutch-2.8.0.tar.bz2
hutch-2.8.0.zip
feat: add Look Up screen and restrict management actions to ownersv2.8.0
Implements: https://todo.sr.ht/~ccleberg/Hutch/4
Diffstat (limited to 'Hutch/Views/Tickets/TicketDetailView.swift')
-rw-r--r--Hutch/Views/Tickets/TicketDetailView.swift16
1 files changed, 14 insertions, 2 deletions
diff --git a/Hutch/Views/Tickets/TicketDetailView.swift b/Hutch/Views/Tickets/TicketDetailView.swift
index 6ed5df0..22ebaa9 100644
--- a/Hutch/Views/Tickets/TicketDetailView.swift
+++ b/Hutch/Views/Tickets/TicketDetailView.swift
@@ -20,6 +20,11 @@ struct TicketDetailView: View {
// Comment composer mode
@State private var commentMode: CommentMode = .write
+ private var isOwnedByCurrentUser: Bool {
+ guard let currentUser = appState.currentUser else { return false }
+ return normalizedUsername(currentUser.username) == normalizedUsername(ownerUsername)
+ }
+
private enum CommentMode: String, CaseIterable {
case write = "Write"
case preview = "Preview"
@@ -41,7 +46,7 @@ struct TicketDetailView: View {
Image(systemName: "square.and.arrow.up")
}
- if let viewModel, viewModel.ticket != nil {
+ if let viewModel, viewModel.ticket != nil, isOwnedByCurrentUser {
actionsMenu(viewModel)
}
}
@@ -195,7 +200,9 @@ struct TicketDetailView: View {
Spacer(minLength: 12)
- assignToMeButton(ticket: ticket, viewModel: viewModel)
+ if isOwnedByCurrentUser {
+ assignToMeButton(ticket: ticket, viewModel: viewModel)
+ }
}
HStack(spacing: 8) {
@@ -334,6 +341,11 @@ struct TicketDetailView: View {
}
.padding()
}
+
+ private func normalizedUsername(_ value: String) -> String {
+ let trimmed = value.trimmingCharacters(in: .whitespacesAndNewlines)
+ return trimmed.hasPrefix("~") ? String(trimmed.dropFirst()) : trimmed
+ }
}
// MARK: - Self-Sizing Markdown Web View