╭ changed ─────────────╮ │src/ui/Fork/Header.zig│ ╰──────────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭─────────────────────────────────────────────╮ │14 const patch_tab_label = "patch"; │ │15 const diff_tab_label = "diff"; │ │16 const files_tab_label = "files"; │ │17 +const delete_tab_label = "delete fork"; │ │18 const new_tab_label = "new"; │ │19 const new_repo_tab_bottom_label = "repo";│ │20 const new_user_tab_bottom_label = "user";│ ╰─────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │46 first_group_width: usize, │ │47 session: *ui.Session, │ │48 │ │48 - pub fn init(allocator: std.mem.Allocator, data: *const Self, commit_count: ?u64, session: *ui.Session) !View { │ │49 + // `deletable` shows the delete tab, which only the forker may use │ │50 + pub fn init(allocator: std.mem.Allocator, data: *const Self, commit_count: ?u64, deletable: bool, session: *ui.Session) !View {│ │51 var box = try wgt.Box(ui.Widget).init(allocator, .{ .border = .hidden, .round_corners = true, .direction = .horiz }); │ │52 errdefer box.deinit(allocator); │ │53 │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │103 ui.RoutablePage.forkDiffRoute(fork_identity, data.id, "", "", 0, "") orelse return error.RouteTooLong, │ │104 ui.RoutablePage.forkFilesRoute(fork_identity, data.id, data.oid, "", 0) orelse return error.RouteTooLong, │ │105 ui.RoutablePage.forkCommitsRoute(fork_identity, data.id, data.oid) orelse return error.RouteTooLong, │ │106 + ui.RoutablePage.forkDeleteRoute(fork_identity, data.id) orelse return error.RouteTooLong, │ │107 }; │ │105 - const tags = [_]std.meta.Tag(ui.RoutablePage){ .fork_patch, .fork_diff, .fork_files, .fork_commits }; │ │106 - const labels = [_][]const u8{ patch_tab_label, diff_tab_label, files_tab_label, commits_tab_label }; │ │108 + const tags = [_]std.meta.Tag(ui.RoutablePage){ .fork_patch, .fork_diff, .fork_files, .fork_commits, .fork_delete }; │ │109 + const labels = [_][]const u8{ patch_tab_label, diff_tab_label, files_tab_label, commits_tab_label, delete_tab_label };│ │110 // a single commit's diff names the commit under its tab, and commits │ │111 // shows its count there │ │112 const bottom_labels = [_][]const u8{ "", switch (session.data.current_page) { │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │113 .fork_diff => |*d| if (d.oid.len == 0) "" else try ui.clippedBottomLabel(try aa.alloc(u8, ui.clipped_bottom_label_max_len), d.oid.slice()), │ │114 else => "", │ │112 - }, "", if (commit_count) |count| try aa.print("({d})", .{count}) else "" }; │ │115 + }, "", if (commit_count) |count| try aa.print("({d})", .{count}) else "", "" }; │ │116 var selected_tab: ?usize = null; │ │117 │ │115 - for (routes, tags, labels, bottom_labels) |route, tag, label, bottom_label| { │ │118 + // the delete tab is last, so leaving it out keeps the stack's order │ │119 + const tab_count = if (deletable) routes.len else routes.len - 1; │ │120 + for (routes[0..tab_count], tags[0..tab_count], labels[0..tab_count], bottom_labels[0..tab_count]) |route, tag, label, bottom_label| { │ │121 const selected = current_tag == tag; │ │122 var tab = try wgt.TextBox.init(allocator, label, .{ .border = .single, .round_corners = true, .wrap_kind = .none, .bottom_label = .{ .text = bottom_label } });│ │123 errdefer tab.deinit(allocator); │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯