╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Patches.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1010 for ([_]Status{ .open, .closed, .merged }, status_labels, 0..) |status, status_label, index| { 1011 const route = try thread.searchRoute(ui.RoutablePage.repoPatchesRoute(data.identity, status, data.label, ""), data.search); 1012 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == index); 1013 var label_buf: [64]u8 = undefined; 1014 const label = try thread.countLabel(&label_buf, status_label, data.window(status).*); 1015 try header.addTab(allocator, label, link, index); 1016 } 1017 1018 // labels tab, showing the active label filter 1019 { 1020 const labels_route = try thread.searchRoute(ui.RoutablePage.repoThreadLabelsRoute(.patch, data.identity, data.label), data.search); 1021 const labels_link = try ui.inPageTabLink(session, labels_route, page_selected and selected_index == View.viewIndex(.labels)); 1022 const label = if (data.label.len == 0) labels_tab_label else blk: { 1023 const decoded = std.Uri.percentDecodeInPlace(try aa.dupe(u8, data.label)); 1024 break :blk try std.fmt.allocPrint(aa, labels_tab_label ++ " ({s})", .{decoded}); 1025 }; 1026 try header.addTab(allocator, label, labels_link, View.viewIndex(.labels)); 1027 } 1028 1029 // new-patch tab; an edit or resolve url shows its tab in this place 1030 { 1031 const route = switch (data.view) { 1032 .edit => ui.RoutablePage.repoThreadEditRoute(.patch, data.identity, data.selected_id) orelse return error.RouteTooLong, 1033 .publish => ui.RoutablePage.repoPatchPublishRoute(data.identity, data.selected_id) orelse return error.RouteTooLong, 1034 .merge => ui.RoutablePage.repoPatchMergeRoute(data.identity, data.selected_id) orelse return error.RouteTooLong, 1035 .new_comment => ui.RoutablePage.repoThreadCommentNewRoute(.patch, data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 1036 .edit_comment => ui.RoutablePage.repoThreadCommentEditRoute(.patch, data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 1037 .remove => ui.RoutablePage.repoThreadRemoveRoute(.patch, data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 1038 .resolve => ui.RoutablePage.repoPatchesResolveRoute(data.identity, data.selected_id, data.theirs_picks) orelse return error.RouteTooLong, 1039 else => ui.RoutablePage.repoThreadNewRoute(.patch, data.identity) orelse return error.RouteTooLong, 1040 }; 1041 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == View.viewIndex(.new)); 1042 const label: []const u8 = switch (data.view) { 1043 .edit => edit_tab_label, 1044 .publish => publish_tab_label, 1045 .merge => merge_tab_label, 1046 .new_comment => reply_tab_label, 1047 .edit_comment => edit_tab_label, 1048 .remove => remove_tab_label, 1049 .resolve => resolve_tab_label, 1050 else => new_tab_label, 1051 }; 1052 try header.addTab(allocator, label, link, View.viewIndex(.new)); 1053 } 1054 1055 // drafts belong to the logged-in user and are not available locally 1056 if (session.data.host_kind != .local) { 1057 const route = ui.RoutablePage.repoPatchesDraftsRoute(data.identity) orelse return error.RouteTooLong; 1058 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == View.viewIndex(.drafts)); 1059 var label_buf: [64]u8 = undefined; 1060 const label = try std.fmt.bufPrint(&label_buf, drafts_tab_label ++ " ({d})", .{data.drafts.count}); 1061 try header.addTab(allocator, label, link, View.viewIndex(.drafts)); 1062 } 1063 1064 // conflicts tab, labeled with the conflict count 1065 if (data.conflicts.count > 0) { 1066 const route = ui.RoutablePage.repoPatchesConflictsRoute(data.identity, "") orelse return error.RouteTooLong; 1067 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == View.viewIndex(.conflicts)); 1068 var label_buf: [64]u8 = undefined; 1069 const label = try std.fmt.bufPrint(&label_buf, conflicts_tab_label ++ " ({d})", .{data.conflicts.count}); 1070 try header.addTab(allocator, label, link, View.viewIndex(.conflicts)); 1071 } 1072 1073 header.select(View.viewIndex(data.view)); 1074 return header; 1075 } 1076