Commit d036624920
d0366249200d5fab1f6d8440062f7af4313bf135
parent: 91fe479290
Verified · cmc
cmc <hello@cleberg.net> · 2026-09-07 03:14 UTC
Pick the body markup when writing
Layout: unified · split
gitbay/Views/Issues/IssueListView.swift
+5 −1
| @@ -8,6 +8,7 @@ struct IssueListView: View { |
| 8 | 8 | @State private var filtering = false |
| 9 | 9 | @State private var draftTitle = "" |
| 10 | 10 | @State private var draftBody = "" |
| 11 | @State private var draftFormat = "md" |
| 11 | 12 | |
| 12 | 13 | init(client: GitbayClient, repo: String) { |
| 13 | 14 | _model = State(initialValue: IssueListViewModel(client: client, repoPath: repo)) |
| @@ -83,12 +84,15 @@ struct IssueListView: View { |
| 83 | 84 | working: createModel.working, |
| 84 | 85 | errorMessage: createModel.errorMessage, |
| 85 | 86 | title: $draftTitle, |
| 86 | | bodyText: $draftBody |
| 87 | bodyText: $draftBody, |
| 88 | format: $draftFormat |
| 87 | 89 | ) { |
| 90 | createModel.format = draftFormat |
| 88 | 91 | Task { |
| 89 | 92 | if await createModel.create(title: draftTitle, body: draftBody) != nil { |
| 90 | 93 | draftTitle = "" |
| 91 | 94 | draftBody = "" |
| 95 | draftFormat = "md" |
| 92 | 96 | composing = false |
| 93 | 97 | await model.load() |
| 94 | 98 | } |
gitbay/Views/Issues/IssueView.swift
+15 −3
| @@ -4,11 +4,13 @@ struct IssueView: View { |
| 4 | 4 | |
| 5 | 5 | @State private var model: IssueDetailViewModel |
| 6 | 6 | @State private var commentText = "" |
| 7 | @State private var commentFormat = "md" |
| 7 | 8 | @State private var editingLabel = "" |
| 8 | 9 | @State private var editingAssignee = "" |
| 9 | 10 | @State private var editing = false |
| 10 | 11 | @State private var draftTitle = "" |
| 11 | 12 | @State private var draftBody = "" |
| 13 | @State private var draftFormat = "md" |
| 12 | 14 | |
| 13 | 15 | init(client: GitbayClient, repo: String, number: Int64) { |
| 14 | 16 | _model = State(initialValue: IssueDetailViewModel( |
| @@ -49,10 +51,11 @@ struct IssueView: View { |
| 49 | 51 | working: model.working, |
| 50 | 52 | errorMessage: model.actionError, |
| 51 | 53 | title: $draftTitle, |
| 52 | | bodyText: $draftBody |
| 54 | bodyText: $draftBody, |
| 55 | format: $draftFormat |
| 53 | 56 | ) { |
| 54 | 57 | Task { |
| 55 | | await model.edit(title: draftTitle, body: draftBody) |
| 58 | await model.edit(title: draftTitle, body: draftBody, format: draftFormat) |
| 56 | 59 | if model.actionError == nil { editing = false } |
| 57 | 60 | } |
| 58 | 61 | } |
| @@ -200,10 +203,18 @@ struct IssueView: View { |
| 200 | 203 | HStack { |
| 201 | 204 | TextField("Comment", text: $commentText, axis: .vertical) |
| 202 | 205 | .lineLimit(1...5) |
| 206 | Picker("Format", selection: $commentFormat) { |
| 207 | Text("Markdown").tag("md") |
| 208 | Text("Org").tag("org") |
| 209 | } |
| 210 | .pickerStyle(.segmented) |
| 211 | .labelsHidden() |
| 212 | .fixedSize() |
| 213 | .accessibilityIdentifier("issue-comment-format") |
| 203 | 214 | Button { |
| 204 | 215 | let text = commentText |
| 205 | 216 | commentText = "" |
| 206 | | Task { await model.comment(text) } |
| 217 | Task { await model.comment(text, format: commentFormat) } |
| 207 | 218 | } label: { |
| 208 | 219 | Image(systemName: "arrow.up.circle.fill") |
| 209 | 220 | } |
| @@ -221,6 +232,7 @@ struct IssueView: View { |
| 221 | 232 | Button { |
| 222 | 233 | draftTitle = issue.title |
| 223 | 234 | draftBody = issue.body ?? "" |
| 235 | draftFormat = issue.bodyFormat ?? "md" |
| 224 | 236 | editing = true |
| 225 | 237 | } label: { |
| 226 | 238 | Label("Edit", systemImage: "pencil") |
gitbay/Views/MRs/MRListView.swift
+8
| @@ -90,6 +90,7 @@ private struct MRCreateSheet: View { |
| 90 | 90 | @State private var target = "" |
| 91 | 91 | @State private var title = "" |
| 92 | 92 | @State private var bodyText = "" |
| 93 | @State private var format = "md" |
| 93 | 94 | |
| 94 | 95 | var body: some View { |
| 95 | 96 | NavigationStack { |
| @@ -115,6 +116,12 @@ private struct MRCreateSheet: View { |
| 115 | 116 | .frame(minHeight: 120) |
| 116 | 117 | .autocorrectionDisabled() |
| 117 | 118 | .accessibilityIdentifier("mr-body") |
| 119 | Picker("Format", selection: $format) { |
| 120 | Text("Markdown").tag("md") |
| 121 | Text("Org").tag("org") |
| 122 | } |
| 123 | .pickerStyle(.segmented) |
| 124 | .accessibilityIdentifier("mr-format") |
| 118 | 125 | } |
| 119 | 126 | Section { |
| 120 | 127 | Toggle("Draft", isOn: Bindable(model).draft) |
| @@ -139,6 +146,7 @@ private struct MRCreateSheet: View { |
| 139 | 146 | ProgressView() |
| 140 | 147 | } else { |
| 141 | 148 | Button("Create") { |
| 149 | model.format = format |
| 142 | 150 | Task { |
| 143 | 151 | if await model.create( |
| 144 | 152 | source: source, target: target, |
gitbay/Views/MRs/MRView.swift
+15 −3
| @@ -4,11 +4,13 @@ struct MRView: View { |
| 4 | 4 | |
| 5 | 5 | @State private var model: MRDetailViewModel |
| 6 | 6 | @State private var commentText = "" |
| 7 | @State private var commentFormat = "md" |
| 7 | 8 | @State private var confirmingMerge = false |
| 8 | 9 | @State private var confirmingClose = false |
| 9 | 10 | @State private var editing = false |
| 10 | 11 | @State private var draftTitle = "" |
| 11 | 12 | @State private var draftBody = "" |
| 13 | @State private var draftFormat = "md" |
| 12 | 14 | @State private var editingReviewer = "" |
| 13 | 15 | @State private var retargeting = false |
| 14 | 16 | @State private var pendingRetarget: String? |
| @@ -115,10 +117,11 @@ struct MRView: View { |
| 115 | 117 | working: model.working, |
| 116 | 118 | errorMessage: model.actionError, |
| 117 | 119 | title: $draftTitle, |
| 118 | | bodyText: $draftBody |
| 120 | bodyText: $draftBody, |
| 121 | format: $draftFormat |
| 119 | 122 | ) { |
| 120 | 123 | Task { |
| 121 | | await model.edit(title: draftTitle, body: draftBody) |
| 124 | await model.edit(title: draftTitle, body: draftBody, format: draftFormat) |
| 122 | 125 | if model.actionError == nil { editing = false } |
| 123 | 126 | } |
| 124 | 127 | } |
| @@ -403,10 +406,18 @@ struct MRView: View { |
| 403 | 406 | HStack { |
| 404 | 407 | TextField("Comment", text: $commentText, axis: .vertical) |
| 405 | 408 | .lineLimit(1...5) |
| 409 | Picker("Format", selection: $commentFormat) { |
| 410 | Text("Markdown").tag("md") |
| 411 | Text("Org").tag("org") |
| 412 | } |
| 413 | .pickerStyle(.segmented) |
| 414 | .labelsHidden() |
| 415 | .fixedSize() |
| 416 | .accessibilityIdentifier("mr-comment-format") |
| 406 | 417 | Button { |
| 407 | 418 | let text = commentText |
| 408 | 419 | commentText = "" |
| 409 | | Task { await model.comment(text) } |
| 420 | Task { await model.comment(text, format: commentFormat) } |
| 410 | 421 | } label: { |
| 411 | 422 | Image(systemName: "arrow.up.circle.fill") |
| 412 | 423 | } |
| @@ -424,6 +435,7 @@ struct MRView: View { |
| 424 | 435 | Button { |
| 425 | 436 | draftTitle = mr.title |
| 426 | 437 | draftBody = mr.body ?? "" |
| 438 | draftFormat = mr.bodyFormat ?? "md" |
| 427 | 439 | editing = true |
| 428 | 440 | } label: { |
| 429 | 441 | Label("Edit", systemImage: "pencil") |
gitbay/Views/Shared/ComposeSheet.swift
+11
| @@ -9,6 +9,9 @@ struct ComposeSheet: View { |
| 9 | 9 | let errorMessage: String? |
| 10 | 10 | @Binding var title: String |
| 11 | 11 | @Binding var bodyText: String |
| 12 | /// nil hides the picker entirely — the release editor has no parity |
| 13 | /// row and passes nothing, leaving that call site untouched. |
| 14 | var format: Binding<String>? = nil |
| 12 | 15 | let onSubmit: () -> Void |
| 13 | 16 | |
| 14 | 17 | @Environment(\.dismiss) private var dismiss |
| @@ -30,6 +33,14 @@ struct ComposeSheet: View { |
| 30 | 33 | .font(.gbSans(.body)) |
| 31 | 34 | .autocorrectionDisabled() |
| 32 | 35 | .accessibilityIdentifier("compose-body") |
| 36 | if let format { |
| 37 | Picker("Format", selection: format) { |
| 38 | Text("Markdown").tag("md") |
| 39 | Text("Org").tag("org") |
| 40 | } |
| 41 | .pickerStyle(.segmented) |
| 42 | .accessibilityIdentifier("compose-format") |
| 43 | } |
| 33 | 44 | } |
| 34 | 45 | if let errorMessage { |
| 35 | 46 | Section { |