╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Issues.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
398 pub const Header = thread.Header; 399 400 const open_tab_label = "open"; 401 const closed_tab_label = "closed"; 402 const labels_tab_label = "labels"; 403 const edit_tab_label = "edit"; 404 const reply_tab_label = "reply"; 405 const remove_tab_label = "remove"; 406 const resolve_tab_label = "resolve"; 407 const new_tab_label = "new"; 408 const conflicts_tab_label = "conflicts"; 409 410 // tabs switching between the issues page's views 411 pub fn initHeader(allocator: std.mem.Allocator, session: *ui.Session, data: *const Self) !Header { 412 var header = try Header.init(allocator, session, data.search, .{ 413 .label = if (data.assignee_found) " assignee " else " assignee (not found) ", 414 .text = std.Uri.percentDecodeInPlace(try session.page_arena.allocator().dupe(u8, data.assignee)), 415 }); 416 errdefer header.deinit(allocator); 417 const selected_index = View.viewIndex(data.view); 418 const page_selected = std.meta.activeTag(session.data.current_page) == .repo_issues; 419 420 // a list tab per status, labeled with its listing's issue count 421 const status_labels = [_][]const u8{ open_tab_label, closed_tab_label }; 422 for ([_]evt.Issue.Status{ .open, .closed }, status_labels, 0..) |status, status_label, index| { 423 const route = try thread.searchRoute(ui.RoutablePage.withEncodedAssignee(ui.RoutablePage.repoIssuesRoute(data.identity, status, data.label, ""), data.assignee), data.search); 424 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == index); 425 var label_buf: [64]u8 = undefined; 426 const label = try thread.countLabel(&label_buf, status_label, data.window(status).*); 427 try header.addTab(allocator, label, link, index); 428 } 429 430 // labels tab 431 { 432 const labels_route = try thread.searchRoute(ui.RoutablePage.withEncodedAssignee(ui.RoutablePage.repoThreadLabelsRoute(.issue, data.identity, data.label), data.assignee), data.search); 433 const labels_link = try ui.inPageTabLink(session, labels_route, page_selected and selected_index == View.viewIndex(.labels)); 434 try header.addTab(allocator, labels_tab_label, labels_link, View.viewIndex(.labels)); 435 } 436 437 // new-issue tab; an edit or resolve url shows its tab in this place 438 { 439 const route = switch (data.view) { 440 .edit => ui.RoutablePage.repoThreadEditRoute(.issue, data.identity, data.selected_id) orelse return error.RouteTooLong, 441 .new_comment => ui.RoutablePage.repoThreadCommentNewRoute(.issue, data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 442 .edit_comment => ui.RoutablePage.repoThreadCommentEditRoute(.issue, data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 443 .remove => ui.RoutablePage.repoThreadRemoveRoute(.issue, data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 444 .resolve => ui.RoutablePage.repoIssuesResolveRoute(data.identity, data.selected_id, data.theirs_picks) orelse return error.RouteTooLong, 445 else => ui.RoutablePage.repoThreadNewRoute(.issue, data.identity) orelse return error.RouteTooLong, 446 }; 447 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == View.viewIndex(.new)); 448 const label: []const u8 = switch (data.view) { 449 .edit => edit_tab_label, 450 .new_comment => reply_tab_label, 451 .edit_comment => edit_tab_label, 452 .remove => remove_tab_label, 453 .resolve => resolve_tab_label, 454 else => new_tab_label, 455 }; 456 try header.addTab(allocator, label, link, View.viewIndex(.new)); 457 } 458 459 // conflicts tab, labeled with the conflict count 460 if (data.conflicts.count > 0) { 461 const route = ui.RoutablePage.repoIssuesConflictsRoute(data.identity, "") orelse return error.RouteTooLong; 462 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == View.viewIndex(.conflicts)); 463 var label_buf: [64]u8 = undefined; 464 const label = try std.fmt.bufPrint(&label_buf, conflicts_tab_label ++ " ({d})", .{data.conflicts.count}); 465 try header.addTab(allocator, label, link, View.viewIndex(.conflicts)); 466 } 467 468 header.select(View.viewIndex(data.view)); 469 return header; 470 } 471