╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Patches.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
683 }; 684 try header.addTab(allocator, label, tags_link, View.viewIndex(.tags)); 685 } 686 687 // new-patch tab; an edit or resolve url shows its tab in this place 688 if (session.local == null) { 689 const route = switch (data.view) { 690 .edit => ui.RoutablePage.repoThreadEditRoute(.patch, data.identity, data.selected_id) orelse return error.RouteTooLong, 691 .new_comment => ui.RoutablePage.repoThreadCommentNewRoute(.patch, data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 692 .edit_comment => ui.RoutablePage.repoThreadCommentEditRoute(.patch, data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 693 .remove => ui.RoutablePage.repoThreadRemoveRoute(.patch, data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 694 .resolve => ui.RoutablePage.repoPatchesResolveRoute(data.identity, data.selected_id, data.theirs_picks) orelse return error.RouteTooLong, 695 else => ui.RoutablePage.repoThreadNewRoute(.patch, data.identity) orelse return error.RouteTooLong, 696 }; 697 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == View.viewIndex(.new)); 698 const label: []const u8 = switch (data.view) { 699 .edit => "edit", 700 .new_comment => "reply", 701 .edit_comment => "edit", 702 .remove => "remove", 703 .resolve => "resolve", 704 else => "new", 705 }; 706 try header.addTab(allocator, label, link, View.viewIndex(.new)); 707 } 708 709 // drafts belong to the logged-in user and are not available locally 710 if (session.local == null) { 711 const route = ui.RoutablePage.repoPatchesDraftsRoute(data.identity) orelse return error.RouteTooLong; 712 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == View.viewIndex(.drafts)); 713 var label_buf: [64]u8 = undefined; 714 const label = try std.fmt.bufPrint(&label_buf, "drafts ({d})", .{data.drafts.count}); 715 try header.addTab(allocator, label, link, View.viewIndex(.drafts)); 716 } 717 718 // conflicts tab, labeled with the conflict count 719 if (data.conflicts.count > 0) { 720 const route = ui.RoutablePage.repoPatchesConflictsRoute(data.identity, "") orelse return error.RouteTooLong; 721 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == View.viewIndex(.conflicts)); 722 var label_buf: [64]u8 = undefined; 723 const label = try std.fmt.bufPrint(&label_buf, "conflicts ({d})", .{data.conflicts.count}); 724 try header.addTab(allocator, label, link, View.viewIndex(.conflicts)); 725 } 726 727 header.select(View.viewIndex(data.view)); 728 return header; 729 } 730