Commit fa473b2f8c

fa473b2f8c289d7c650fe54eab8595bfec8b0403

parent: 9119a6de9b

Verified · cmc ci/accessibility: success

cmc <hello@cleberg.net> · 2026-10-23 04:52 UTC

Share screen scaffolding, ref pickers, build submit toolbar and confirmations

- ModelContent and AddToolbarItem for the loading state and + button.
- Binding.isPresent for optional-driven sheets, alerts and destinations.
- RefChoiceButton for the git and hg ref pickers.
- BuildDraftToolbar over a BuildSubmitting protocol.
- destructiveConfirmation for the settings and profile alerts.
- Project resource sections and Home's cursor paging each in one place.
- Qlty: nested_control_flow off for Swift, where else-if chains count
  as nesting.

Layout: unified · split

.qlty/qlty.toml +5
@@ -48,3 +48,8 @@ enabled = false
4848# Exhaustive switch-over-enum lookup tables share shape but not content.
4949[language.swift.smells.duplication]
5050filter_patterns = ["(import_declaration _)", "(switch_statement _)"]
51
52# tree-sitter-swift nests each `else if` inside the previous branch, so a one-line `if` in the
53# fourth branch of a flat chain reports level 5.
54[language.swift.smells.nested_control_flow]
55enabled = false
Hutch/Views/Builds/BuildDetailView.swift +7 −53
@@ -17,13 +17,7 @@ struct BuildDetailView: View {
1717 }
1818
1919 var body: some View {
20 Group {
21 if let viewModel {
22 detailContent(viewModel)
23 } else {
24 SRHTLoadingStateView(message: "Loading build…")
25 }
26 }
20 ModelContent(model: viewModel, loadingMessage: "Loading build…") { detailContent($0) }
2721 .navigationTitle("Job #\(jobId)")
2822 .navigationBarTitleDisplayMode(.inline)
2923 .toolbar {
@@ -71,14 +65,7 @@ struct BuildDetailView: View {
7165 }
7266 }
7367 }
74 .navigationDestination(isPresented: Binding(
75 get: { rebuiltJobId != nil },
76 set: { isPresented in
77 if !isPresented {
78 rebuiltJobId = nil
79 }
80 }
81 )) {
68 .navigationDestination(isPresented: .isPresent($rebuiltJobId)) {
8269 if let rebuiltJobId {
8370 BuildDetailView(jobId: rebuiltJobId)
8471 }
@@ -91,14 +78,7 @@ struct BuildDetailView: View {
9178 }
9279 }
9380 }
94 .sheet(isPresented: Binding(
95 get: { selectedTaskName != nil },
96 set: { isPresented in
97 if !isPresented {
98 selectedTaskName = nil
99 }
100 }
101 )) {
81 .sheet(isPresented: .isPresent($selectedTaskName)) {
10282 if let selectedTaskName, let viewModel {
10383 NavigationStack {
10484 BuildTaskLogView(taskName: selectedTaskName, viewModel: viewModel)
@@ -530,36 +510,10 @@ private struct EditResubmitBuildSheet: View {
530510 viewModel.dismissActionError()
531511 }
532512 .toolbar {
533 ToolbarItem(placement: .cancellationAction) {
534 Button("Cancel") {
535 viewModel.dismissActionError()
536 dismiss()
537 }
538 }
539 ToolbarItem(placement: .confirmationAction) {
540 Button {
541 Task {
542 if let jobId = await viewModel.submitBuild(
543 manifest: draft.manifest,
544 tags: draft.tags,
545 note: draft.note,
546 secrets: draft.secrets,
547 execute: draft.execute,
548 visibility: draft.visibility
549 ) {
550 onSubmitted(jobId)
551 }
552 }
553 } label: {
554 if viewModel.isSubmittingEditedBuild {
555 ProgressView()
556 .controlSize(.small)
557 } else {
558 Text("Submit Build")
559 }
560 }
561 .disabled(!draft.hasManifest || viewModel.isSubmittingEditedBuild)
562 }
513 BuildDraftToolbar(draft: draft, submitter: viewModel, isSubmitting: viewModel.isSubmittingEditedBuild) {
514 viewModel.dismissActionError()
515 dismiss()
516 } onSubmitted: { onSubmitted($0) }
563517 }
564518 .themedList()
565519 }
Hutch/Views/Builds/BuildDraftForm.swift +55
@@ -81,3 +81,58 @@ struct BuildDraftForm: View {
8181 }
8282 }
8383}
84
85/// Something a build draft can be submitted to, answering the new job's id.
86@MainActor
87protocol BuildSubmitting {
88 func submitBuild(
89 manifest: String,
90 tags: [String],
91 note: String,
92 secrets: Bool,
93 execute: Bool,
94 visibility: Visibility
95 ) async -> Int?
96}
97
98extension BuildListViewModel: BuildSubmitting {}
99extension BuildDetailViewModel: BuildSubmitting {}
100
101/// Cancel, and Submit Build once the draft has a manifest.
102struct BuildDraftToolbar: ToolbarContent {
103 let draft: BuildDraft
104 let submitter: any BuildSubmitting
105 let isSubmitting: Bool
106 let cancel: () -> Void
107 let onSubmitted: (Int) -> Void
108
109 var body: some ToolbarContent {
110 ToolbarItem(placement: .cancellationAction) {
111 Button("Cancel", action: cancel)
112 }
113 ToolbarItem(placement: .confirmationAction) {
114 Button {
115 Task {
116 if let jobId = await submitter.submitBuild(
117 manifest: draft.manifest,
118 tags: draft.tags,
119 note: draft.note,
120 secrets: draft.secrets,
121 execute: draft.execute,
122 visibility: draft.visibility
123 ) {
124 onSubmitted(jobId)
125 }
126 }
127 } label: {
128 if isSubmitting {
129 ProgressView()
130 .controlSize(.small)
131 } else {
132 Text("Submit Build")
133 }
134 }
135 .disabled(!draft.hasManifest || isSubmitting)
136 }
137 }
138}
Hutch/Views/Builds/BuildListView.swift +8 −52
@@ -17,13 +17,7 @@ struct BuildListView: View {
1717 }
1818
1919 var body: some View {
20 Group {
21 if let viewModel {
22 listContent(viewModel)
23 } else {
24 SRHTLoadingStateView(message: "Loading builds…")
25 }
26 }
20 ModelContent(model: viewModel, loadingMessage: "Loading builds…") { listContent($0) }
2721 .navigationTitle("Builds")
2822 .toolbar {
2923 if let viewModel {
@@ -86,13 +80,8 @@ struct BuildListView: View {
8680 }
8781 .accessibilityLabel("Build filters")
8882 }
89 ToolbarItem(placement: .topBarTrailing) {
90 Button {
91 showSubmitSheet = true
92 } label: {
93 Image(systemName: "plus")
94 }
95 .accessibilityLabel("Submit build")
83 AddToolbarItem(label: "Submit build") {
84 showSubmitSheet = true
9685 }
9786 }
9887 }
@@ -107,14 +96,7 @@ struct BuildListView: View {
10796 .navigationDestination(for: JobSummary.self) { job in
10897 BuildDetailView(jobId: job.id)
10998 }
110 .navigationDestination(isPresented: Binding(
111 get: { submittedJobId != nil },
112 set: { isPresented in
113 if !isPresented {
114 submittedJobId = nil
115 }
116 }
117 )) {
99 .navigationDestination(isPresented: .isPresent($submittedJobId)) {
118100 if let submittedJobId {
119101 BuildDetailView(jobId: submittedJobId)
120102 }
@@ -329,36 +311,10 @@ private struct SubmitBuildSheet: View {
329311 viewModelBindable.error = nil
330312 }
331313 .toolbar {
332 ToolbarItem(placement: .cancellationAction) {
333 Button("Cancel") {
334 viewModelBindable.error = nil
335 dismiss()
336 }
337 }
338 ToolbarItem(placement: .confirmationAction) {
339 Button {
340 Task {
341 if let jobId = await viewModel.submitBuild(
342 manifest: draft.manifest,
343 tags: draft.tags,
344 note: draft.note,
345 secrets: draft.secrets,
346 execute: draft.execute,
347 visibility: draft.visibility
348 ) {
349 onSubmitted(jobId)
350 }
351 }
352 } label: {
353 if viewModel.isSubmitting {
354 ProgressView()
355 .controlSize(.small)
356 } else {
357 Text("Submit Build")
358 }
359 }
360 .disabled(!draft.hasManifest || viewModel.isSubmitting)
361 }
314 BuildDraftToolbar(draft: draft, submitter: viewModel, isSubmitting: viewModel.isSubmitting) {
315 viewModelBindable.error = nil
316 dismiss()
317 } onSubmitted: { onSubmitted($0) }
362318 }
363319 }
364320 }
Hutch/Views/Home/HomeView.swift +3 −23
@@ -15,13 +15,7 @@ struct HomeView: View {
1515 @State private var isShowingSystemStatus = false
1616
1717 var body: some View {
18 Group {
19 if let viewModel {
20 content(viewModel)
21 } else {
22 SRHTLoadingStateView(message: "Loading Home…")
23 }
24 }
18 ModelContent(model: viewModel, loadingMessage: "Loading Home…") { content($0) }
2519 .navigationTitle("Home")
2620 .toolbar {
2721 ToolbarItem(placement: .topBarTrailing) {
@@ -36,26 +30,12 @@ struct HomeView: View {
3630 .accessibilityLabel("System status")
3731 }
3832 }
39 .navigationDestination(isPresented: Binding(
40 get: { selectedPinnedProject != nil },
41 set: { isPresented in
42 if !isPresented {
43 selectedPinnedProject = nil
44 }
45 }
46 )) {
33 .navigationDestination(isPresented: .isPresent($selectedPinnedProject)) {
4734 if let selectedPinnedProject {
4835 ProjectDetailView(project: selectedPinnedProject)
4936 }
5037 }
51 .navigationDestination(isPresented: Binding(
52 get: { selectedPinnedUser != nil },
53 set: { isPresented in
54 if !isPresented {
55 selectedPinnedUser = nil
56 }
57 }
58 )) {
38 .navigationDestination(isPresented: .isPresent($selectedPinnedUser)) {
5939 if let selectedPinnedUser {
6040 UserProfileView(user: selectedPinnedUser)
6141 }
Hutch/Views/Home/HomeViewModel.swift +43 −40
@@ -819,7 +819,31 @@ final class HomeViewModel {
819819 }
820820
821821 private func fetchInboxMailingLists(forceRefresh: Bool) async throws -> [InboxMailingListReference] {
822 var subscriptions: [HomeInboxSubscription] = []
822 let subscriptions = try await fetchAllPages(
823 service: .lists,
824 query: Self.inboxSubscriptionsQuery,
825 responseType: HomeInboxSubscriptionsResponse.self,
826 page: { ($0.subscriptions.results, $0.subscriptions.cursor) },
827 cacheKey: { APICacheKeys.inboxSubscriptions(cursor: $0) },
828 ttl: APICacheTTLs.inboxSummary,
829 forceRefresh: forceRefresh
830 )
831
832 var seen = Set<String>()
833 return subscriptions.compactMap(\.list).filter { seen.insert($0.rid).inserted }
834 }
835
836 /// Every page of a cursor-paged query, each read through the cache under `cacheKey(cursor)`.
837 private func fetchAllPages<Response: Decodable, Item>(
838 service: SRHTService,
839 query: String,
840 responseType _: Response.Type,
841 page: (Response) -> (results: [Item], cursor: String?),
842 cacheKey: (String?) -> String,
843 ttl: TimeInterval,
844 forceRefresh: Bool
845 ) async throws -> [Item] {
846 var items: [Item] = []
823847 var cursor: String?
824848
825849 while true {
@@ -829,26 +853,25 @@ final class HomeViewModel {
829853 }
830854
831855 let cached = try await client.executeCached(
832 service: .lists,
833 query: Self.inboxSubscriptionsQuery,
856 service: service,
857 query: query,
834858 variables: variables.isEmpty ? nil : variables,
835 responseType: HomeInboxSubscriptionsResponse.self,
836 cacheKey: APICacheKeys.inboxSubscriptions(cursor: cursor),
859 responseType: Response.self,
860 cacheKey: cacheKey(cursor),
837861 resourceType: .ticketList,
838 ttl: APICacheTTLs.inboxSummary,
862 ttl: ttl,
839863 policy: forceRefresh ? .refreshIgnoringCache : .cacheFirstThenRefresh
840864 )
841 let response = cached.value
865 let (results, nextCursor) = page(cached.value)
842866
843 subscriptions.append(contentsOf: response.subscriptions.results)
844 guard let nextCursor = response.subscriptions.cursor else {
867 items.append(contentsOf: results)
868 guard let nextCursor else {
845869 break
846870 }
847871 cursor = nextCursor
848872 }
849873
850 var seen = Set<String>()
851 return subscriptions.compactMap(\.list).filter { seen.insert($0.rid).inserted }
874 return items
852875 }
853876
854877 private func fetchUnreadThreadSnapshot(for mailingList: InboxMailingListReference, forceRefresh: Bool) async throws -> HomeInboxUnreadSnapshot {
@@ -934,35 +957,15 @@ final class HomeViewModel {
934957 }
935958
936959 private func fetchAllTrackers(forceRefresh: Bool) async throws -> [TrackerSummary] {
937 var allTrackers: [TrackerSummary] = []
938 var cursor: String?
939
940 while true {
941 var variables: [String: any Sendable] = [:]
942 if let cursor {
943 variables["cursor"] = cursor
944 }
945
946 let cached = try await client.executeCached(
947 service: .todo,
948 query: Self.trackersQuery,
949 variables: variables.isEmpty ? nil : variables,
950 responseType: HomeTrackersResponse.self,
951 cacheKey: APICacheKeys.trackers(cursor: cursor),
952 resourceType: .ticketList,
953 ttl: APICacheTTLs.ticketList,
954 policy: forceRefresh ? .refreshIgnoringCache : .cacheFirstThenRefresh
955 )
956 let response = cached.value
957
958 allTrackers.append(contentsOf: response.trackers.results)
959 guard let nextCursor = response.trackers.cursor else {
960 break
961 }
962 cursor = nextCursor
963 }
964
965 return allTrackers
960 try await fetchAllPages(
961 service: .todo,
962 query: Self.trackersQuery,
963 responseType: HomeTrackersResponse.self,
964 page: { ($0.trackers.results, $0.trackers.cursor) },
965 cacheKey: { APICacheKeys.trackers(cursor: $0) },
966 ttl: APICacheTTLs.ticketList,
967 forceRefresh: forceRefresh
968 )
966969 }
967970
968971 private func fetchAssignedTickets(for trackers: [TrackerSummary], forceRefresh: Bool) async throws -> [HomeAssignedTicket] {
Hutch/Views/Inbox/ThreadDetailView.swift +1 −7
@@ -35,13 +35,7 @@ struct ThreadDetailView: View {
3535 }
3636
3737 var body: some View {
38 Group {
39 if let viewModel {
40 content(viewModel)
41 } else {
42 SRHTLoadingStateView(message: "Loading thread…")
43 }
44 }
38 ModelContent(model: viewModel, loadingMessage: "Loading thread…") { content($0) }
4539 .navigationTitle("Thread")
4640 .navigationBarTitleDisplayMode(.inline)
4741 .task(id: thread.id) {
Hutch/Views/Lists/MailingListListView.swift +1 −7
@@ -334,13 +334,7 @@ struct MailingListListView: View {
334334 }
335335
336336 var body: some View {
337 Group {
338 if let viewModel {
339 content(viewModel)
340 } else {
341 SRHTLoadingStateView(message: "Loading mailing lists…")
342 }
343 }
337 ModelContent(model: viewModel, loadingMessage: "Loading mailing lists…") { content($0) }
344338 .navigationTitle("Mailing Lists")
345339 .task {
346340 if viewModel == nil {
Hutch/Views/Lookup/LookupView.swift +1 −7
@@ -348,13 +348,7 @@ struct LookupView: View {
348348 }
349349
350350 var body: some View {
351 Group {
352 if let viewModel {
353 content(viewModel)
354 } else {
355 SRHTLoadingStateView(message: "Preparing lookup…")
356 }
357 }
351 ModelContent(model: viewModel, loadingMessage: "Preparing lookup…") { content($0) }
358352 .navigationTitle("Look Up")
359353 .task {
360354 if viewModel == nil {
Hutch/Views/More/AccountSwitcherView.swift +1 −8
@@ -89,14 +89,7 @@ struct AccountSwitcherView: View {
8989 }
9090 .alert(
9191 "Remove Account?",
92 isPresented: Binding(
93 get: { pendingRemoval != nil },
94 set: { isPresented in
95 if !isPresented {
96 pendingRemoval = nil
97 }
98 }
99 )
92 isPresented: .isPresent($pendingRemoval)
10093 ) {
10194 Button("Cancel", role: .cancel) {
10295 /* Dismiss only; removal uses the destructive button. */
Hutch/Views/More/ProfileView.swift +8 −37
@@ -13,13 +13,7 @@ struct ProfileView: View {
1313 @State private var pendingDestructiveAction: ProfileDestructiveAction?
1414
1515 var body: some View {
16 Group {
17 if let viewModel {
18 profileContent(viewModel)
19 } else {
20 SRHTLoadingStateView(message: "Loading profile…")
21 }
22 }
16 ModelContent(model: viewModel, loadingMessage: "Loading profile…") { profileContent($0) }
2317 .navigationTitle("Profile")
2418 .task {
2519 if viewModel == nil {
@@ -120,35 +114,12 @@ struct ProfileView: View {
120114 Text(error)
121115 }
122116 }
123 .alert(
124 pendingDestructiveAction?.title ?? "",
125 isPresented: Binding(
126 get: { pendingDestructiveAction != nil },
127 set: { isPresented in
128 if !isPresented {
129 pendingDestructiveAction = nil
130 }
131 }
132 )
133 ) {
134 Button("Cancel", role: .cancel) {
135 /* Dismiss only; destructive action is separate. */
136 }
137 Button(pendingDestructiveAction?.confirmationLabel ?? "Confirm", role: .destructive) {
138 guard let action = pendingDestructiveAction else { return }
139 pendingDestructiveAction = nil
140 Task {
141 switch action {
142 case .deleteSSHKey(let key):
143 await viewModel.deleteSSHKey(key)
144 case .deletePGPKey(let key):
145 await viewModel.deletePGPKey(key)
146 }
147 }
148 }
149 } message: {
150 if let pendingDestructiveAction {
151 Text(pendingDestructiveAction.message)
117 .destructiveConfirmation($pendingDestructiveAction) { action in
118 switch action {
119 case .deleteSSHKey(let key):
120 await viewModel.deleteSSHKey(key)
121 case .deletePGPKey(let key):
122 await viewModel.deletePGPKey(key)
152123 }
153124 }
154125 .refreshable {
@@ -713,7 +684,7 @@ private struct EditProfileSheet: View {
713684 }
714685}
715686
716private enum ProfileDestructiveAction {
687private enum ProfileDestructiveAction: DestructiveAction {
717688 case deleteSSHKey(SSHKey)
718689 case deletePGPKey(PGPKey)
719690
Hutch/Views/Pastes/PasteDetailView.swift +1 −7
@@ -18,13 +18,7 @@ struct PasteDetailView: View {
1818 @AppStorage(AppStorageKeys.wrapPasteFileLines) private var wrapLines = false
1919
2020 var body: some View {
21 Group {
22 if let viewModel {
23 content(viewModel)
24 } else {
25 SRHTLoadingStateView(message: "Loading paste…")
26 }
27 }
21 ModelContent(model: viewModel, loadingMessage: "Loading paste…") { content($0) }
2822 .navigationTitle(displayTitle)
2923 .navigationBarTitleDisplayMode(.inline)
3024 .toolbar {
Hutch/Views/Pastes/PasteListView.swift +4 −22
@@ -9,23 +9,12 @@ struct PasteListView: View {
99 @State private var pasteToDelete: Paste?
1010
1111 var body: some View {
12 Group {
13 if let viewModel {
14 content(viewModel)
15 } else {
16 SRHTLoadingStateView(message: "Loading pastes…")
17 }
18 }
12 ModelContent(model: viewModel, loadingMessage: "Loading pastes…") { content($0) }
1913 .navigationTitle("Pastes")
2014 .toolbar {
2115 if viewModel != nil {
22 ToolbarItem(placement: .topBarTrailing) {
23 Button {
24 showCreatePasteSheet = true
25 } label: {
26 Image(systemName: "plus")
27 }
28 .accessibilityLabel("Create paste")
16 AddToolbarItem(label: "Create paste") {
17 showCreatePasteSheet = true
2918 }
3019 }
3120 }
@@ -37,14 +26,7 @@ struct PasteListView: View {
3726 }
3827 }
3928 }
40 .navigationDestination(isPresented: Binding(
41 get: { createdPaste != nil },
42 set: { isPresented in
43 if !isPresented {
44 createdPaste = nil
45 }
46 }
47 )) {
29 .navigationDestination(isPresented: .isPresent($createdPaste)) {
4830 if let createdPaste {
4931 PasteDetailView(
5032 paste: createdPaste,
Hutch/Views/Patchsets/PatchsetDetailView.swift +1 −7
@@ -10,13 +10,7 @@ struct PatchsetDetailView: View {
1010 @State private var expandedPatchIDs: Set<Int> = []
1111
1212 var body: some View {
13 Group {
14 if let viewModel {
15 content(viewModel)
16 } else {
17 SRHTLoadingStateView(message: "Loading Patchset…")
18 }
19 }
13 ModelContent(model: viewModel, loadingMessage: "Loading Patchset…") { content($0) }
2014 .navigationTitle("Patchset")
2115 .navigationBarTitleDisplayMode(.inline)
2216 .toolbar {
Hutch/Views/Projects/DiscoverProjectsView.swift +1 −7
@@ -63,13 +63,7 @@ struct DiscoverProjectsView: View {
6363 @State private var viewModel: DiscoverProjectsViewModel?
6464
6565 var body: some View {
66 Group {
67 if let viewModel {
68 content(viewModel)
69 } else {
70 SRHTLoadingStateView(message: "Loading projects…")
71 }
72 }
66 ModelContent(model: viewModel, loadingMessage: "Loading projects…") { content($0) }
7367 .navigationTitle("Discover")
7468 .navigationBarTitleDisplayMode(.inline)
7569 .task {
Hutch/Views/Projects/ManageProjectResourcesView.swift +1 −7
@@ -107,13 +107,7 @@ struct ManageProjectResourcesView: View {
107107
108108 var body: some View {
109109 NavigationStack {
110 Group {
111 if let viewModel {
112 content(viewModel)
113 } else {
114 SRHTLoadingStateView(message: "Loading…")
115 }
116 }
110 ModelContent(model: viewModel, loadingMessage: "Loading…") { content($0) }
117111 .navigationTitle("Linked Resources")
118112 .navigationBarTitleDisplayMode(.inline)
119113 .toolbar {
Hutch/Views/Projects/ProjectDetailView.swift +35 −35
@@ -224,26 +224,33 @@ struct ProjectDetailView: View {
224224 }
225225 }
226226
227 /// A section of rows that each open their resource and dismiss, or say why they couldn't.
227228 @ViewBuilder
228 private var repositoriesSection: some View {
229 if !displayedProject.sources.isEmpty {
230 Section("Repositories") {
231 ForEach(displayedProject.sources) { source in
229 private func openSection<Resource: ProjectResource & Identifiable>(
230 _ title: LocalizedStringKey,
231 _ resources: [Resource],
232 noun: String,
233 systemImage: String,
234 open: @escaping (Resource) async throws -> Void
235 ) -> some View {
236 if !resources.isEmpty {
237 Section(title) {
238 ForEach(resources) { resource in
232239 Button {
233240 Task {
234241 do {
235 try await appState.openProjectSource(source)
242 try await open(resource)
236243 dismiss()
237244 } catch {
238 self.error = "Couldn’t open repository. \(error.userFacingMessage)"
245 self.error = "Couldn’t open \(noun). \(error.userFacingMessage)"
239246 }
240247 }
241248 } label: {
242249 ProjectResourceRow(
243 title: source.displayName,
244 subtitle: source.ownerDisplayName,
245 detail: source.displayDescription,
246 systemImage: "book.closed"
250 title: resource.displayName,
251 subtitle: resource.ownerDisplayName,
252 detail: resource.displayDescription,
253 systemImage: systemImage
247254 )
248255 }
249256 .buttonStyle(.plain)
@@ -253,32 +260,15 @@ struct ProjectDetailView: View {
253260 }
254261 }
255262
256 @ViewBuilder
263 private var repositoriesSection: some View {
264 openSection("Repositories", displayedProject.sources, noun: "repository", systemImage: "book.closed") {
265 try await appState.openProjectSource($0)
266 }
267 }
268
257269 private var trackersSection: some View {
258 if !displayedProject.trackers.isEmpty {
259 Section("Trackers") {
260 ForEach(displayedProject.trackers) { tracker in
261 Button {
262 Task {
263 do {
264 try await appState.openProjectTracker(tracker)
265 dismiss()
266 } catch {
267 self.error = "Couldn’t open tracker. \(error.userFacingMessage)"
268 }
269 }
270 } label: {
271 ProjectResourceRow(
272 title: tracker.displayName,
273 subtitle: tracker.ownerDisplayName,
274 detail: tracker.displayDescription,
275 systemImage: "checklist"
276 )
277 }
278 .buttonStyle(.plain)
279 }
280 .themedRow()
281 }
270 openSection("Trackers", displayedProject.trackers, noun: "tracker", systemImage: "checklist") {
271 try await appState.openProjectTracker($0)
282272 }
283273 }
284274
@@ -382,6 +372,16 @@ private struct ProjectLink: Identifiable {
382372 let url: URL
383373}
384374
375/// A project's repository, tracker or mailing list, as its row shows it.
376private protocol ProjectResource {
377 var displayName: String { get }
378 var ownerDisplayName: String { get }
379 var displayDescription: String? { get }
380}
381
382extension Project.SourceRepo: ProjectResource {}
383extension Project.Tracker: ProjectResource {}
384
385385private struct ProjectResourceRow: View {
386386 let title: String
387387 let subtitle: String
Hutch/Views/Projects/ProjectMailingListView.swift +1 −7
@@ -419,13 +419,7 @@ struct MailingListDetailView: View {
419419 }
420420
421421 var body: some View {
422 Group {
423 if let viewModel {
424 content(viewModel)
425 } else {
426 SRHTLoadingStateView(message: "Loading mailing list…")
427 }
428 }
422 ModelContent(model: viewModel, loadingMessage: "Loading mailing list…") { content($0) }
429423 .navigationTitle(mailingList.name)
430424 .navigationBarTitleDisplayMode(.inline)
431425 .toolbar {
Hutch/Views/Projects/ProjectsListView.swift +2 −7
@@ -85,13 +85,8 @@ struct ProjectsListView: View {
8585 .accessibilityLabel("Discover public projects")
8686 }
8787 if appState.currentUser != nil {
88 ToolbarItem(placement: .topBarTrailing) {
89 Button {
90 isPresentingCreate = true
91 } label: {
92 Image(systemName: "plus")
93 }
94 .accessibilityLabel("Create project")
88 AddToolbarItem(label: "Create project") {
89 isPresentingCreate = true
9590 }
9691 }
9792 }
Hutch/Views/Repositories/FileTreeView.swift +9 −65
@@ -10,12 +10,8 @@ struct FileTreeView: View {
1010 @State private var viewModel: FileTreeViewModel?
1111
1212 var body: some View {
13 Group {
14 if let viewModel {
15 FileTreeContentView(viewModel: viewModel)
16 } else {
17 SRHTLoadingStateView(message: "Loading files…")
18 }
13 ModelContent(model: viewModel, loadingMessage: "Loading files…") { viewModel in
14 FileTreeContentView(viewModel: viewModel)
1915 }
2016 .task {
2117 if viewModel == nil {
@@ -787,40 +783,14 @@ private struct RefPickerSheet: View {
787783 NavigationStack {
788784 List {
789785 Section {
790 Button {
791 Task {
792 await viewModel.changeRevspec("HEAD")
793 isPresented = false
794 }
795 } label: {
796 refRow(
797 title: "HEAD",
798 systemImage: "arrow.triangle.branch",
799 color: .blue,
800 isSelected: viewModel.revspec == "HEAD"
801 )
802 }
803 .buttonStyle(.plain)
786 choice("HEAD", title: "HEAD", systemImage: "arrow.triangle.branch", color: .blue)
804787 .themedRow()
805788 }
806789
807790 if !viewModel.branches.isEmpty {
808791 Section("Branches") {
809792 ForEach(viewModel.branches, id: \.name) { ref in
810 Button {
811 Task {
812 await viewModel.changeRevspec(ref.name)
813 isPresented = false
814 }
815 } label: {
816 refRow(
817 title: ref.name.replacingOccurrences(of: "refs/heads/", with: ""),
818 systemImage: "arrow.triangle.branch",
819 color: .blue,
820 isSelected: viewModel.revspec == ref.name
821 )
822 }
823 .buttonStyle(.plain)
793 choice(ref.name, title: ref.name.replacingOccurrences(of: "refs/heads/", with: ""), systemImage: "arrow.triangle.branch", color: .blue)
824794 }
825795 .themedRow()
826796 }
@@ -829,20 +799,7 @@ private struct RefPickerSheet: View {
829799 if !viewModel.tags.isEmpty {
830800 Section("Tags") {
831801 ForEach(viewModel.tags, id: \.name) { ref in
832 Button {
833 Task {
834 await viewModel.changeRevspec(ref.name)
835 isPresented = false
836 }
837 } label: {
838 refRow(
839 title: ref.name.replacingOccurrences(of: "refs/tags/", with: ""),
840 systemImage: "tag",
841 color: .orange,
842 isSelected: viewModel.revspec == ref.name
843 )
844 }
845 .buttonStyle(.plain)
802 choice(ref.name, title: ref.name.replacingOccurrences(of: "refs/tags/", with: ""), systemImage: "tag", color: .orange)
846803 }
847804 .themedRow()
848805 }
@@ -867,23 +824,10 @@ private struct RefPickerSheet: View {
867824 }
868825 }
869826
870 private func refRow(title: String, systemImage: String, color: ViewColor, isSelected: Bool) -> some View {
871 HStack(spacing: 12) {
872 Image(systemName: systemImage)
873 .foregroundStyle(color)
874
875 Text(title)
876 .font(.body.monospaced())
877 .foregroundStyle(.primary)
878
879 Spacer()
880
881 if isSelected {
882 Image(systemName: "checkmark")
883 .font(.caption.weight(.semibold))
884 .foregroundStyle(.tint)
885 }
827 private func choice(_ revspec: String, title: String, systemImage: String, color: ViewColor) -> some View {
828 RefChoiceButton(title: title, systemImage: systemImage, color: color, isSelected: viewModel.revspec == revspec) {
829 await viewModel.changeRevspec(revspec)
830 isPresented = false
886831 }
887 .contentShape(Rectangle())
888832 }
889833}
Hutch/Views/Repositories/HgRepositoryDetailView.swift +9 −80
@@ -47,13 +47,7 @@ struct HgRepositoryDetailView: View {
4747 }
4848
4949 var body: some View {
50 Group {
51 if let viewModel {
52 content(viewModel)
53 } else {
54 SRHTLoadingStateView(message: "Loading repository…")
55 }
56 }
50 ModelContent(model: viewModel, loadingMessage: "Loading repository…") { content($0) }
5751 .navigationTitle(repository.name)
5852 .navigationBarTitleDisplayMode(.inline)
5953 .toolbar {
@@ -672,40 +666,14 @@ private struct HgBrowseRefPickerSheet: View {
672666 NavigationStack {
673667 List {
674668 Section {
675 Button {
676 Task {
677 await viewModel.changeBrowseRevspec("tip")
678 isPresented = false
679 }
680 } label: {
681 refRow(
682 title: "tip",
683 systemImage: "arrow.triangle.branch",
684 color: .blue,
685 isSelected: viewModel.browseRevspec == "tip"
686 )
687 }
688 .buttonStyle(.plain)
669 choice("tip", title: "tip", systemImage: "arrow.triangle.branch", color: .blue)
689670 .themedRow()
690671 }
691672
692673 if !viewModel.branches.isEmpty {
693674 Section("Branches") {
694675 ForEach(viewModel.branches) { revision in
695 Button {
696 Task {
697 await viewModel.changeBrowseRevspec(revision.name)
698 isPresented = false
699 }
700 } label: {
701 refRow(
702 title: revision.name,
703 systemImage: "arrow.triangle.branch",
704 color: .blue,
705 isSelected: viewModel.browseRevspec == revision.name
706 )
707 }
708 .buttonStyle(.plain)
676 choice(revision.name, title: revision.name, systemImage: "arrow.triangle.branch", color: .blue)
709677 }
710678 .themedRow()
711679 }
@@ -714,20 +682,7 @@ private struct HgBrowseRefPickerSheet: View {
714682 if !viewModel.tags.isEmpty {
715683 Section("Tags") {
716684 ForEach(viewModel.tags) { revision in
717 Button {
718 Task {
719 await viewModel.changeBrowseRevspec(revision.name)
720 isPresented = false
721 }
722 } label: {
723 refRow(
724 title: revision.name,
725 systemImage: "tag",
726 color: .orange,
727 isSelected: viewModel.browseRevspec == revision.name
728 )
729 }
730 .buttonStyle(.plain)
685 choice(revision.name, title: revision.name, systemImage: "tag", color: .orange)
731686 }
732687 .themedRow()
733688 }
@@ -736,20 +691,7 @@ private struct HgBrowseRefPickerSheet: View {
736691 if !viewModel.bookmarks.isEmpty {
737692 Section("Bookmarks") {
738693 ForEach(viewModel.bookmarks) { revision in
739 Button {
740 Task {
741 await viewModel.changeBrowseRevspec(revision.name)
742 isPresented = false
743 }
744 } label: {
745 refRow(
746 title: revision.name,
747 systemImage: "bookmark",
748 color: .purple,
749 isSelected: viewModel.browseRevspec == revision.name
750 )
751 }
752 .buttonStyle(.plain)
694 choice(revision.name, title: revision.name, systemImage: "bookmark", color: .purple)
753695 }
754696 .themedRow()
755697 }
@@ -769,24 +711,11 @@ private struct HgBrowseRefPickerSheet: View {
769711 }
770712 }
771713
772 private func refRow(title: String, systemImage: String, color: Color, isSelected: Bool) -> some View {
773 HStack(spacing: 12) {
774 Image(systemName: systemImage)
775 .foregroundStyle(color)
776
777 Text(title)
778 .font(.body.monospaced())
779 .foregroundStyle(.primary)
780
781 Spacer()
782
783 if isSelected {
784 Image(systemName: "checkmark")
785 .font(.caption.weight(.semibold))
786 .foregroundStyle(.tint)
787 }
714 private func choice(_ revspec: String, title: String, systemImage: String, color: Color) -> some View {
715 RefChoiceButton(title: title, systemImage: systemImage, color: color, isSelected: viewModel.browseRevspec == revspec) {
716 await viewModel.changeBrowseRevspec(revspec)
717 isPresented = false
788718 }
789 .contentShape(Rectangle())
790719 }
791720}
792721
Hutch/Views/Repositories/HgRepositorySettingsView.swift +1 −8
@@ -73,14 +73,7 @@ struct HgRepositorySettingsView: View {
7373 } message: {
7474 Text("This cannot be undone.")
7575 }
76 .alert("Remove Access?", isPresented: Binding(
77 get: { pendingACLDeletion != nil },
78 set: { isPresented in
79 if !isPresented {
80 pendingACLDeletion = nil
81 }
82 }
83 )) {
76 .alert("Remove Access?", isPresented: .isPresent($pendingACLDeletion)) {
8477 Button("Cancel", role: .cancel) {
8578 // Alert dismissal is implicit; no additional action required.
8679 }
Hutch/Views/Repositories/RefChoiceButton.swift added +35
@@ -0,0 +1,35 @@
1import SwiftUI
2
3/// A branch, tag or bookmark to browse at, checked when it's the one shown.
4struct RefChoiceButton: View {
5 let title: String
6 let systemImage: String
7 let color: Color
8 let isSelected: Bool
9 let choose: () async -> Void
10
11 var body: some View {
12 Button {
13 Task { await choose() }
14 } label: {
15 HStack(spacing: 12) {
16 Image(systemName: systemImage)
17 .foregroundStyle(color)
18
19 Text(title)
20 .font(.body.monospaced())
21 .foregroundStyle(.primary)
22
23 Spacer()
24
25 if isSelected {
26 Image(systemName: "checkmark")
27 .font(.caption.weight(.semibold))
28 .foregroundStyle(.tint)
29 }
30 }
31 .contentShape(Rectangle())
32 }
33 .buttonStyle(.plain)
34 }
35}
Hutch/Views/Repositories/RepositoryACLView.swift +4 −22
@@ -12,13 +12,7 @@ struct RepositoryACLView: View {
1212 @State private var showAddSheet = false
1313
1414 var body: some View {
15 Group {
16 if let viewModel {
17 content(viewModel)
18 } else {
19 SRHTLoadingStateView(message: "Loading access…")
20 }
21 }
15 ModelContent(model: viewModel, loadingMessage: "Loading access…") { content($0) }
2216 .navigationTitle("Access")
2317 .navigationBarTitleDisplayMode(.inline)
2418 .toolbar {
@@ -29,13 +23,8 @@ struct RepositoryACLView: View {
2923 }
3024
3125 if viewModel != nil {
32 ToolbarItem(placement: .primaryAction) {
33 Button {
34 showAddSheet = true
35 } label: {
36 Image(systemName: "plus")
37 }
38 .accessibilityLabel("Add User")
26 AddToolbarItem(label: "Add User", placement: .primaryAction) {
27 showAddSheet = true
3928 }
4029 }
4130 }
@@ -102,14 +91,7 @@ struct RepositoryACLView: View {
10291 set: { viewModel.error = $0 }
10392 )
10493 )
105 .alert("Remove Access?", isPresented: Binding(
106 get: { pendingDeletion != nil },
107 set: { isPresented in
108 if !isPresented {
109 pendingDeletion = nil
110 }
111 }
112 )) {
94 .alert("Remove Access?", isPresented: .isPresent($pendingDeletion)) {
11395 Button("Cancel", role: .cancel) {
11496 /* Dismiss only; removal is confirmed separately. */
11597 }
Hutch/Views/Repositories/RepositoryDeployKeysView.swift +3 −14
@@ -77,13 +77,7 @@ struct RepositoryDeployKeysView: View {
7777 @State private var pendingDeletion: RepositoryDeployKey?
7878
7979 var body: some View {
80 Group {
81 if let viewModel {
82 content(viewModel)
83 } else {
84 SRHTLoadingStateView(message: "Loading deploy keys…")
85 }
86 }
80 ModelContent(model: viewModel, loadingMessage: "Loading deploy keys…") { content($0) }
8781 .navigationTitle("Deploy Keys")
8882 .navigationBarTitleDisplayMode(.inline)
8983 .toolbar {
@@ -93,13 +87,8 @@ struct RepositoryDeployKeysView: View {
9387 }
9488 }
9589 if viewModel != nil {
96 ToolbarItem(placement: .topBarTrailing) {
97 Button {
98 showAddSheet = true
99 } label: {
100 Image(systemName: "plus")
101 }
102 .accessibilityLabel("Add deploy key")
90 AddToolbarItem(label: "Add deploy key") {
91 showAddSheet = true
10392 }
10493 }
10594 }
Hutch/Views/Repositories/RepositoryDetailView.swift +1 −7
@@ -45,13 +45,7 @@ struct RepositoryDetailView: View {
4545 if currentRepository.service == .hg {
4646 HgRepositoryDetailView(repository: currentRepository, onDeleted: onDeleted)
4747 } else {
48 Group {
49 if let viewModel {
50 detailContent(viewModel)
51 } else {
52 SRHTLoadingStateView(message: "Loading repository…")
53 }
54 }
48 ModelContent(model: viewModel, loadingMessage: "Loading repository…") { detailContent($0) }
5549 .navigationTitle(currentRepository.name)
5650 .navigationBarTitleDisplayMode(.inline)
5751 .toolbar {
Hutch/Views/Repositories/RepositoryListView.swift +4 −22
@@ -9,23 +9,12 @@ struct RepositoryListView: View {
99 @State private var createdRepository: RepositorySummary?
1010
1111 var body: some View {
12 Group {
13 if let viewModel {
14 listContent(viewModel)
15 } else {
16 SRHTLoadingStateView(message: "Loading repositories…")
17 }
18 }
12 ModelContent(model: viewModel, loadingMessage: "Loading repositories…") { listContent($0) }
1913 .navigationTitle("Repositories")
2014 .toolbar {
2115 if viewModel != nil {
22 ToolbarItem(placement: .topBarTrailing) {
23 Button {
24 showCreateRepositorySheet = true
25 } label: {
26 Image(systemName: "plus")
27 }
28 .accessibilityLabel("Create repository")
16 AddToolbarItem(label: "Create repository") {
17 showCreateRepositorySheet = true
2918 }
3019 }
3120 }
@@ -37,14 +26,7 @@ struct RepositoryListView: View {
3726 }
3827 }
3928 }
40 .navigationDestination(isPresented: Binding(
41 get: { createdRepository != nil },
42 set: { isPresented in
43 if !isPresented {
44 createdRepository = nil
45 }
46 }
47 )) {
29 .navigationDestination(isPresented: .isPresent($createdRepository)) {
4830 if let createdRepository {
4931 RepositoryDetailView(
5032 repository: createdRepository,
Hutch/Views/Settings/SettingsView.swift +7 −30
@@ -30,35 +30,12 @@ struct SettingsView: View {
3030 .sheet(isPresented: $showAccountSwitcher) {
3131 AccountSwitcherView()
3232 }
33 .alert(
34 pendingDestructiveAction?.title ?? "",
35 isPresented: Binding(
36 get: { pendingDestructiveAction != nil },
37 set: { isPresented in
38 if !isPresented {
39 pendingDestructiveAction = nil
40 }
41 }
42 )
43 ) {
44 Button("Cancel", role: .cancel) {
45 /* Dismiss only; destructive action is separate. */
46 }
47 Button(pendingDestructiveAction?.confirmationLabel ?? "Confirm", role: .destructive) {
48 guard let action = pendingDestructiveAction else { return }
49 pendingDestructiveAction = nil
50 Task {
51 switch action {
52 case .resetAppData:
53 await appState.resetAppData()
54 case .signOut:
55 await appState.signOut()
56 }
57 }
58 }
59 } message: {
60 if let pendingDestructiveAction {
61 Text(pendingDestructiveAction.message)
33 .destructiveConfirmation($pendingDestructiveAction) { action in
34 switch action {
35 case .resetAppData:
36 await appState.resetAppData()
37 case .signOut:
38 await appState.signOut()
6239 }
6340 }
6441 }
@@ -238,7 +215,7 @@ func settingsBioAttributedString(_ markdown: String) -> AttributedString {
238215 profileBioAttributedString(markdown)
239216}
240217
241private enum SettingsDestructiveAction {
218private enum SettingsDestructiveAction: DestructiveAction {
242219 case resetAppData
243220 case signOut
244221
Hutch/Views/Shared/DestructiveConfirmation.swift added +36
@@ -0,0 +1,36 @@
1import SwiftUI
2
3/// Something that can't be undone, with what its confirmation alert says.
4protocol DestructiveAction {
5 var title: String { get }
6 var confirmationLabel: String { get }
7 var message: String { get }
8}
9
10extension View {
11 /// Asks to confirm `pending` while it's set, and runs `perform` with it once confirmed.
12 func destructiveConfirmation<Action: DestructiveAction>(
13 _ pending: Binding<Action?>,
14 perform: @escaping (Action) async -> Void
15 ) -> some View {
16 alert(
17 pending.wrappedValue?.title ?? "",
18 isPresented: .isPresent(pending)
19 ) {
20 Button("Cancel", role: .cancel) {
21 /* Dismiss only; destructive action is separate. */
22 }
23 Button(pending.wrappedValue?.confirmationLabel ?? "Confirm", role: .destructive) {
24 guard let action = pending.wrappedValue else { return }
25 pending.wrappedValue = nil
26 Task {
27 await perform(action)
28 }
29 }
30 } message: {
31 if let action = pending.wrappedValue {
32 Text(action.message)
33 }
34 }
35 }
36}
Hutch/Views/Shared/ModelContent.swift added +32
@@ -0,0 +1,32 @@
1import SwiftUI
2
3/// A screen's content once its view model exists, and a loading state until then.
4struct ModelContent<Model, Content: View>: View {
5 let model: Model?
6 let loadingMessage: String
7 @ViewBuilder let content: (Model) -> Content
8
9 var body: some View {
10 if let model {
11 content(model)
12 } else {
13 SRHTLoadingStateView(message: loadingMessage)
14 }
15 }
16}
17
18/// The + button a list adds with.
19struct AddToolbarItem: ToolbarContent {
20 let label: LocalizedStringKey
21 var placement: ToolbarItemPlacement = .topBarTrailing
22 let action: () -> Void
23
24 var body: some ToolbarContent {
25 ToolbarItem(placement: placement) {
26 Button(action: action) {
27 Image(systemName: "plus")
28 }
29 .accessibilityLabel(label)
30 }
31 }
32}
Hutch/Views/Shared/PresentedItem.swift added +9
@@ -0,0 +1,9 @@
1import SwiftUI
2
3extension Binding where Value == Bool {
4 /// True while `item` holds a value; dismissing clears it. Presents a
5 /// dialog or alert about whatever `item` names.
6 static func isPresent<Item>(_ item: Binding<Item?>) -> Binding<Bool> {
7 Binding(get: { item.wrappedValue != nil }, set: { if !$0 { item.wrappedValue = nil } })
8 }
9}
Hutch/Views/SystemStatus/SystemStatusView.swift +1 −7
@@ -5,13 +5,7 @@ struct SystemStatusView: View {
55 @State private var viewModel: SystemStatusViewModel?
66
77 var body: some View {
8 Group {
9 if let viewModel {
10 content(viewModel)
11 } else {
12 SRHTLoadingStateView(message: "Loading system status…")
13 }
14 }
8 ModelContent(model: viewModel, loadingMessage: "Loading system status…") { content($0) }
159 .navigationTitle("System Status")
1610 .navigationBarTitleDisplayMode(.inline)
1711 .task {
Hutch/Views/Tickets/TicketDetailView.swift +1 −7
@@ -36,13 +36,7 @@ struct TicketDetailView: View {
3636 }
3737
3838 var body: some View {
39 Group {
40 if let viewModel {
41 detailContent(viewModel)
42 } else {
43 SRHTLoadingStateView(message: "Loading ticket…")
44 }
45 }
39 ModelContent(model: viewModel, loadingMessage: "Loading ticket…") { detailContent($0) }
4640 .navigationTitle("#\(ticketId)")
4741 .navigationBarTitleDisplayMode(.inline)
4842 .toolbar {
Hutch/Views/Tickets/TicketListView.swift +2 −15
@@ -58,13 +58,7 @@ struct TicketListView: View {
5858 }
5959
6060 var body: some View {
61 Group {
62 if let viewModel {
63 listContent(viewModel)
64 } else {
65 SRHTLoadingStateView(message: "Loading tickets…")
66 }
67 }
61 ModelContent(model: viewModel, loadingMessage: "Loading tickets…") { listContent($0) }
6862 .navigationTitle(navigationTitle)
6963 .navigationBarTitleDisplayMode(.inline)
7064 .toolbar {
@@ -210,14 +204,7 @@ struct TicketListView: View {
210204 dismissButton: .default(Text("OK"))
211205 )
212206 }
213 .navigationDestination(isPresented: Binding(
214 get: { createdTicket != nil },
215 set: { isPresented in
216 if !isPresented {
217 createdTicket = nil
218 }
219 }
220 )) {
207 .navigationDestination(isPresented: .isPresent($createdTicket)) {
221208 if let createdTicket {
222209 TicketDetailView(
223210 ownerUsername: String(tracker.owner.canonicalName.dropFirst()),
Hutch/Views/Tickets/TrackerListView.swift +5 −30
@@ -9,23 +9,12 @@ struct TrackerListView: View {
99 @State private var pendingDeletion: TrackerSummary?
1010
1111 var body: some View {
12 Group {
13 if let viewModel {
14 listContent(viewModel)
15 } else {
16 SRHTLoadingStateView(message: "Loading trackers…")
17 }
18 }
12 ModelContent(model: viewModel, loadingMessage: "Loading trackers…") { listContent($0) }
1913 .navigationTitle("Trackers")
2014 .toolbar {
2115 if viewModel != nil {
22 ToolbarItem(placement: .topBarTrailing) {
23 Button {
24 showCreateTrackerSheet = true
25 } label: {
26 Image(systemName: "plus")
27 }
28 .accessibilityLabel("Create tracker")
16 AddToolbarItem(label: "Create tracker") {
17 showCreateTrackerSheet = true
2918 }
3019 }
3120 }
@@ -78,14 +67,7 @@ struct TrackerListView: View {
7867 }
7968 }
8069 }
81 .navigationDestination(isPresented: Binding(
82 get: { createdTracker != nil },
83 set: { isPresented in
84 if !isPresented {
85 createdTracker = nil
86 }
87 }
88 )) {
70 .navigationDestination(isPresented: .isPresent($createdTracker)) {
8971 if let createdTracker {
9072 TicketListView(tracker: createdTracker) { updatedTracker in
9173 viewModel?.applyTrackerUpdate(updatedTracker)
@@ -99,14 +81,7 @@ struct TrackerListView: View {
9981 }
10082 }
10183 }
102 .alert("Delete Tracker?", isPresented: Binding(
103 get: { pendingDeletion != nil },
104 set: { isPresented in
105 if !isPresented {
106 pendingDeletion = nil
107 }
108 }
109 )) {
84 .alert("Delete Tracker?", isPresented: .isPresent($pendingDeletion)) {
11085 Button("Cancel", role: .cancel) {
11186 // no-op: .cancel role handles alert dismissal
11287 }
Hutch/Views/Tickets/TrackerManagementView.swift +2 −16
@@ -825,14 +825,7 @@ struct TrackerACLManagementSheet: View {
825825 await viewModel.updateDefaultACL(permissions)
826826 }
827827 }
828 .alert("Remove Access?", isPresented: Binding(
829 get: { pendingDeletion != nil },
830 set: { isPresented in
831 if !isPresented {
832 pendingDeletion = nil
833 }
834 }
835 )) {
828 .alert("Remove Access?", isPresented: .isPresent($pendingDeletion)) {
836829 Button("Cancel", role: .cancel) {
837830 // no-op: .cancel role handles alert dismissal
838831 }
@@ -1194,14 +1187,7 @@ struct TrackerLabelManagementSheet: View {
11941187 )
11951188 }
11961189 }
1197 .alert("Delete Label?", isPresented: Binding(
1198 get: { pendingDeletion != nil },
1199 set: { isPresented in
1200 if !isPresented {
1201 pendingDeletion = nil
1202 }
1203 }
1204 )) {
1190 .alert("Delete Label?", isPresented: .isPresent($pendingDeletion)) {
12051191 Button("Cancel", role: .cancel) {
12061192 // no-op: .cancel role handles alert dismissal
12071193 }
Hutch/Views/Work/WorkView.swift +1 −7
@@ -25,13 +25,7 @@ struct WorkView: View {
2525 }
2626
2727 var body: some View {
28 Group {
29 if let viewModel {
30 content(viewModel)
31 } else {
32 SRHTLoadingStateView(message: "Loading Work…")
33 }
34 }
28 ModelContent(model: viewModel, loadingMessage: "Loading Work…") { content($0) }
3529 .navigationTitle("Work")
3630 .navigationBarTitleDisplayMode(.inline)
3731 .toolbar {