╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Patches.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
817 } 818 819 // tags tab, labeled with the active tag filter 820 { 821 const tags_route = ui.RoutablePage.repoThreadTagsRoute(.patch, data.identity, data.tag) orelse return error.RouteTooLong; 822 const tags_link = try ui.inPageTabLink(session, tags_route, page_selected and selected_index == View.viewIndex(.tags)); 823 const label = if (data.tag.len == 0) "tags" else blk: { 824 const decoded = std.Uri.percentDecodeInPlace(try aa.dupe(u8, data.tag)); 825 break :blk try std.fmt.allocPrint(aa, "tags ({s})", .{decoded}); 826 }; 827 try header.addTab(allocator, label, tags_link, View.viewIndex(.tags)); 828 } 829 830 // new-patch tab; an edit or resolve url shows its tab in this place 831 if (session.local == null) { 832 const route = switch (data.view) { 833 .edit => ui.RoutablePage.repoThreadEditRoute(.patch, data.identity, data.selected_id) orelse return error.RouteTooLong, 834 .publish => ui.RoutablePage.repoPatchPublishRoute(data.identity, data.selected_id) orelse return error.RouteTooLong, 835 .merge => ui.RoutablePage.repoPatchMergeRoute(data.identity, data.selected_id) orelse return error.RouteTooLong, 836 .new_comment => ui.RoutablePage.repoThreadCommentNewRoute(.patch, data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 837 .edit_comment => ui.RoutablePage.repoThreadCommentEditRoute(.patch, data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 838 .remove => ui.RoutablePage.repoThreadRemoveRoute(.patch, data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 839 .resolve => ui.RoutablePage.repoPatchesResolveRoute(data.identity, data.selected_id, data.theirs_picks) orelse return error.RouteTooLong, 840 else => ui.RoutablePage.repoThreadNewRoute(.patch, data.identity) orelse return error.RouteTooLong, 841 }; 842 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == View.viewIndex(.new)); 843 const label: []const u8 = switch (data.view) { 844 .edit => "edit", 845 .publish => "publish", 846 .merge => "merge", 847 .new_comment => "reply", 848 .edit_comment => "edit", 849 .remove => "remove", 850 .resolve => "resolve", 851 else => "new", 852 }; 853 try header.addTab(allocator, label, link, View.viewIndex(.new)); 854 } 855 856 // drafts belong to the logged-in user and are not available locally 857 if (session.local == null) { 858 const route = ui.RoutablePage.repoPatchesDraftsRoute(data.identity) orelse return error.RouteTooLong; 859 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == View.viewIndex(.drafts)); 860 var label_buf: [64]u8 = undefined; 861 const label = try std.fmt.bufPrint(&label_buf, "drafts ({d})", .{data.drafts.count}); 862 try header.addTab(allocator, label, link, View.viewIndex(.drafts)); 863 } 864 865 // conflicts tab, labeled with the conflict count 866 if (data.conflicts.count > 0) { 867 const route = ui.RoutablePage.repoPatchesConflictsRoute(data.identity, "") orelse return error.RouteTooLong; 868 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == View.viewIndex(.conflicts)); 869 var label_buf: [64]u8 = undefined; 870 const label = try std.fmt.bufPrint(&label_buf, "conflicts ({d})", .{data.conflicts.count}); 871 try header.addTab(allocator, label, link, View.viewIndex(.conflicts)); 872 } 873 874 header.select(View.viewIndex(data.view)); 875 return header; 876 } 877