╭ changed ─────────────╮ │src/ui/Repo/Issues.zig│ ╰──────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │279 .closed => closed_root = order_key, │ │280 } │ │281 // form urls keep their view; otherwise the issue's status picks it. │ │282 - if (view != .edit and view != .new_comment) resolved_view = switch (issue_event.event.status) { │ │282 + if (view != .edit and view != .new_comment and view != .edit_comment) resolved_view = switch (issue_event.event.status) {│ │283 .open => .open, │ │284 .closed => .closed, │ │285 }; │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────╮ │605 .open => open_view_index, │ │606 .closed => closed_view_index, │ │607 .tags => tags_view_index, │ │608 - .new, .edit, .new_comment, .resolve => form_view_index, │ │608 + .new, .edit, .new_comment, .edit_comment, .resolve => form_view_index,│ │609 .conflicts => conflicts_view_index, │ │610 // init resolves a description url to its issue's status list │ │611 .description => unreachable, │ ╰───────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │665 // logged-out session can't create events, so the unauthorized view │ │666 // stands in. │ │667 if (session.data.is_local or session.data.user_id != null) { │ │668 - if (data.view == .new_comment) { │ │669 - const route = ui.RoutablePage.repoCommentNewRoute(data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong; │ │668 + if (data.view == .new_comment or data.view == .edit_comment) { │ │669 + const editing = data.view == .edit_comment; │ │670 + const route = if (editing) │ │671 + ui.RoutablePage.repoCommentEditRoute(data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong │ │672 + else │ │673 + ui.RoutablePage.repoCommentNewRoute(data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong; │ │674 const page_url = try route.toUrl(session.page_arena); │ │671 - const action = try std.fmt.allocPrint(session.page_arena.allocator(), "form:{s}/comment", .{page_url[0 .. page_url.len - "/new".len]}); │ │672 - const parent_route = if (data.comment_page) |page| │ │673 - ui.RoutablePage.repoCommentsRoute(data.identity, data.selected_id, &page.selected.id, 0) │ │675 + const action = if (editing) │ │676 + try std.fmt.allocPrint(session.page_arena.allocator(), "form:{s}", .{page_url}) │ │677 + else │ │678 + try std.fmt.allocPrint(session.page_arena.allocator(), "form:{s}/comment", .{page_url[0 .. page_url.len - "/new".len]}); │ │679 + const page = data.comment_page; │ │680 + const top_level = if (page) |p| std.mem.eql(u8, &p.selected.comment.event.parent_id, &p.selected.comment.event.thread_id) else false; │ │681 + const parent_route = if (editing) │ │682 + if (top_level) │ │683 + ui.RoutablePage.repoIssueCommentsRoute(data.identity, data.selected_id, 0) │ │684 + else if (page) |p| │ │685 + ui.RoutablePage.repoCommentsRoute(data.identity, data.selected_id, &p.selected.comment.event.parent_id, 0) │ │686 + else │ │687 + null │ │688 + else if (page) |p| │ │689 + ui.RoutablePage.repoCommentsRoute(data.identity, data.selected_id, &p.selected.id, 0) │ │690 else │ │691 ui.RoutablePage.repoIssueCommentsRoute(data.identity, data.selected_id, 0); │ │676 - var form = try initCommentForm(allocator, session, action, if (data.comment_page) |page| page.selected.author else if (data.selectedIssue()) |entry| entry.author else .unknown, parent_route orelse return error.RouteTooLong);│ │692 + const parent_author: ui.Author = if (editing) │ │693 + if (top_level) │ │694 + if (data.selectedIssue()) |entry| entry.author else .unknown │ │695 + else if (page) |p| │ │696 + p.selected.parent_author orelse .unknown │ │697 + else │ │698 + .unknown │ │699 + else if (page) |p| │ │700 + p.selected.author │ │701 + else if (data.selectedIssue()) |entry| │ │702 + entry.author │ │703 + else │ │704 + .unknown; │ │705 + const initial_body: ?[]const u8 = if (editing) if (page) |p| p.selected.comment.event.body else null else null; │ │706 + var form = try initCommentForm(allocator, session, action, parent_author, parent_route orelse return error.RouteTooLong, initial_body); │ │707 errdefer form.deinit(allocator); │ │708 try stack.children.put(allocator, form.getFocus().id, .{ .box = form }); │ │709 } else if (data.view == .resolve) { │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │721 try stack.children.put(allocator, form_widget.getFocus().id, form_widget); │ │722 } else { │ │723 const aa = session.page_arena.allocator(); │ │694 - const action = if (data.view == .edit) │ │695 - (if (data.identity.len == 0) │ │696 - try std.fmt.allocPrint(aa, "form:/issue:{s}/edit", .{data.selected_id}) │ │697 - else │ │698 - try std.fmt.allocPrint(aa, "form:/repo/{s}/issue:{s}/edit", .{ data.identity, data.selected_id }))│ │699 - else if (data.identity.len == 0) │ │700 - "form:/issue" │ │724 + const route = if (data.view == .edit) │ │725 + ui.RoutablePage.repoIssuesEditRoute(data.identity, data.selected_id) orelse return error.RouteTooLong │ │726 else │ │702 - try std.fmt.allocPrint(aa, "form:/repo/{s}/issue", .{data.identity}); │ │727 + ui.RoutablePage.repoIssuesNewRoute(data.identity) orelse return error.RouteTooLong; │ │728 + const action = try std.fmt.allocPrint(aa, "form:{s}", .{try route.toUrl(session.page_arena)}); │ │729 const issue = if (data.view == .edit) │ │730 (if (data.selectedIssue()) |entry| &entry.issue else null) │ │731 else │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │879 return box; │ │880 } │ │881 │ │856 - fn initCommentForm(allocator: std.mem.Allocator, session: *ui.Session, action: []const u8, author: ui.Author, parent_route: ui.RoutablePage) !wgt.Box(ui.Widget) { │ │882 + fn initCommentForm(allocator: std.mem.Allocator, session: *ui.Session, action: []const u8, author: ui.Author, parent_route: ui.RoutablePage, initial_body: ?[]const u8) !wgt.Box(ui.Widget) {│ │883 var box = try wgt.Box(ui.Widget).init(allocator, .{ .border_style = null, .direction = .vert }); │ │884 errdefer box.deinit(allocator); │ │885 box.getFocus().kind = .{ .custom = action }; │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │905 }); │ │906 errdefer body.deinit(allocator); │ │907 body.getFocus().focusable = true; │ │908 + if (initial_body) |text| try body.setContent(allocator, text); │ │909 try box.children.put(allocator, body.getFocus().id, .{ .widget = .{ .text_input = body }, .rect = null, .min_size = null });│ │910 } │ │911 │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────╮ │885 - try addSubmitButtonLabeled(allocator, &box, "submit reply"); │ │912 + try addSubmitButtonLabeled(allocator, &box, "submit"); │ │913 box.getFocus().child_id = box.children.keys()[comment_author_field_index];│ │914 return box; │ │915 } │ ╰───────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1265 (switch (self.data.view) { │ │1266 .edit => ui.RoutablePage.repoIssuesEditRoute(self.data.identity, self.data.selected_id), │ │1267 .new_comment => ui.RoutablePage.repoCommentNewRoute(self.data.identity, self.data.selected_id, self.data.comment_id), │ │1268 + .edit_comment => ui.RoutablePage.repoCommentEditRoute(self.data.identity, self.data.selected_id, self.data.comment_id),│ │1269 .resolve => ui.RoutablePage.repoIssuesResolveRoute(self.data.identity, self.data.selected_id, self.data.theirs_picks), │ │1270 else => ui.RoutablePage.repoIssuesNewRoute(self.data.identity), │ │1271 }) │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │1361 try self.session.input_values.put(inputs_arena, fields[title_field_index].widget.text_input.getFocus().id, entry.issue.event.title); │ │1362 try self.session.input_values.put(inputs_arena, fields[tags_field_index].widget.text_input.getFocus().id, entry.issue.event.tags); │ │1363 try self.session.input_values.put(inputs_arena, fields[description_field_index].widget.text_input.getFocus().id, entry.issue.event.description);│ │1364 + } │ │1365 + } │ │1366 + │ │1367 + if (self.data.view == .edit_comment) { │ │1368 + if (self.data.comment_page) |page| { │ │1369 + const body = &form.children.values()[comment_body_field_index].widget.text_input; │ │1370 + try self.session.input_values.put(inputs_arena, body.getFocus().id, page.selected.comment.event.body); │ │1371 } │ │1372 } │ │1373 │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────╮ │1621 if (self.formViewActive()) { │ │1622 if (self.data.view == .resolve) { │ │1623 try self.resolveInput(allocator, key, root_focus); │ │1589 - } else if (self.data.view == .new_comment) { │ │1624 + } else if (self.data.view == .new_comment or self.data.view == .edit_comment) {│ │1625 try self.commentFormInput(allocator, key, root_focus); │ │1626 } else { │ │1627 try self.formInput(allocator, key, root_focus); │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭──────╮ │next →│ ╰──────╯