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