╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Patches.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
1025 const tags_route = try thread.searchRoute(ui.RoutablePage.repoThreadTagsRoute(.patch, data.identity, data.tag), data.search); 1026 const tags_link = try ui.inPageTabLink(session, tags_route, page_selected and selected_index == View.viewIndex(.tags)); 1027 const label = if (data.tag.len == 0) tags_tab_label else blk: { 1028 const decoded = std.Uri.percentDecodeInPlace(try aa.dupe(u8, data.tag)); 1029 break :blk try std.fmt.allocPrint(aa, tags_tab_label ++ " ({s})", .{decoded}); 1030 }; 1031 try header.addTab(allocator, label, tags_link, View.viewIndex(.tags)); 1032 } 1033 1034 // new-patch tab; an edit or resolve url shows its tab in this place 1035 { 1036 const route = switch (data.view) { 1037 .edit => ui.RoutablePage.repoThreadEditRoute(.patch, data.identity, data.selected_id) orelse return error.RouteTooLong, 1038 .publish => ui.RoutablePage.repoPatchPublishRoute(data.identity, data.selected_id) orelse return error.RouteTooLong, 1039 .merge => ui.RoutablePage.repoPatchMergeRoute(data.identity, data.selected_id) orelse return error.RouteTooLong, 1040 .new_comment => ui.RoutablePage.repoThreadCommentNewRoute(.patch, data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 1041 .edit_comment => ui.RoutablePage.repoThreadCommentEditRoute(.patch, data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 1042 .remove => ui.RoutablePage.repoThreadRemoveRoute(.patch, data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 1043 .resolve => ui.RoutablePage.repoPatchesResolveRoute(data.identity, data.selected_id, data.theirs_picks) orelse return error.RouteTooLong, 1044 else => ui.RoutablePage.repoThreadNewRoute(.patch, data.identity) orelse return error.RouteTooLong, 1045 }; 1046 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == View.viewIndex(.new)); 1047 const label: []const u8 = switch (data.view) { 1048 .edit => edit_tab_label, 1049 .publish => publish_tab_label, 1050 .merge => merge_tab_label, 1051 .new_comment => reply_tab_label, 1052 .edit_comment => edit_tab_label, 1053 .remove => remove_tab_label, 1054 .resolve => resolve_tab_label, 1055 else => new_tab_label, 1056 }; 1057 try header.addTab(allocator, label, link, View.viewIndex(.new)); 1058 } 1059 1060 // drafts belong to the logged-in user and are not available locally 1061 if (session.data.host_kind != .local) { 1062 const route = ui.RoutablePage.repoPatchesDraftsRoute(data.identity) orelse return error.RouteTooLong; 1063 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == View.viewIndex(.drafts)); 1064 var label_buf: [64]u8 = undefined; 1065 const label = try std.fmt.bufPrint(&label_buf, drafts_tab_label ++ " ({d})", .{data.drafts.count}); 1066 try header.addTab(allocator, label, link, View.viewIndex(.drafts)); 1067 } 1068 1069 // conflicts tab, labeled with the conflict count 1070 if (data.conflicts.count > 0) { 1071 const route = ui.RoutablePage.repoPatchesConflictsRoute(data.identity, "") orelse return error.RouteTooLong; 1072 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == View.viewIndex(.conflicts)); 1073 var label_buf: [64]u8 = undefined; 1074 const label = try std.fmt.bufPrint(&label_buf, conflicts_tab_label ++ " ({d})", .{data.conflicts.count}); 1075 try header.addTab(allocator, label, link, View.viewIndex(.conflicts)); 1076 } 1077 1078 header.select(View.viewIndex(data.view)); 1079 return header; 1080 } 1081