╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Issues.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
331 332 return .{ 333 .identity = empty.identity, 334 .tag = empty.tag, 335 .selected_id = empty.selected_id, 336 .comment_id = empty.comment_id, 337 .comments_start = comments_start, 338 .comment_page = comment_page, 339 .open = open_window, 340 .closed = closed_window, 341 .conflicts = conflicts_window, 342 .conflict = conflict_data, 343 .theirs_picks = empty.theirs_picks, 344 .view = resolved_view, 345 .description_page = empty.description_page, 346 .tags = tags, 347 }; 348 } 349 350 pub const View = thread.View(.issue, Self); 351 pub const Detail = thread.Detail(.issue, Self); 352 pub const detail_widget_name = "repo_issue_detail"; 353 354 pub const Header = thread.Header; 355 356 // tabs switching between the issues page's views 357 pub fn initHeader(allocator: std.mem.Allocator, session: *ui.Session, data: *const Self) !Header { 358 var header = try Header.init(allocator); 359 errdefer header.deinit(allocator); 360 const aa = session.page_arena.allocator(); 361 const selected_index = View.viewIndex(data.view); 362 const page_selected = std.meta.activeTag(session.data.current_page) == .repo_issues; 363 364 // a list tab per status, labeled with its listing's issue count 365 for ([_]evt.Issue.Status{ .open, .closed }, 0..) |status, index| { 366 const route = ui.RoutablePage.repoIssuesRoute(data.identity, status, data.tag, "") orelse return error.RouteTooLong; 367 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == index); 368 var label_buf: [64]u8 = undefined; 369 const label = try std.fmt.bufPrint(&label_buf, "{s} ({d})", .{ @tagName(status), data.window(status).count }); 370 try header.addTab(allocator, label, link, index); 371 } 372 373 // tags tab, labeled with the active tag filter 374 { 375 const tags_route = ui.RoutablePage.repoThreadTagsRoute(.issue, data.identity, data.tag) orelse return error.RouteTooLong; 376 const tags_link = try ui.inPageTabLink(session, tags_route, page_selected and selected_index == View.viewIndex(.tags)); 377 const label = if (data.tag.len == 0) "tags" else blk: { 378 const decoded = std.Uri.percentDecodeInPlace(try aa.dupe(u8, data.tag)); 379 break :blk try std.fmt.allocPrint(aa, "tags ({s})", .{decoded}); 380 }; 381 try header.addTab(allocator, label, tags_link, View.viewIndex(.tags)); 382 } 383 384 // new-issue tab; an edit or resolve url shows its tab in this place 385 { 386 const route = switch (data.view) { 387 .edit => ui.RoutablePage.repoThreadEditRoute(.issue, data.identity, data.selected_id) orelse return error.RouteTooLong, 388 .new_comment => ui.RoutablePage.repoThreadCommentNewRoute(.issue, data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 389 .edit_comment => ui.RoutablePage.repoThreadCommentEditRoute(.issue, data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 390 .remove => ui.RoutablePage.repoThreadRemoveRoute(.issue, data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 391 .resolve => ui.RoutablePage.repoIssuesResolveRoute(data.identity, data.selected_id, data.theirs_picks) orelse return error.RouteTooLong, 392 else => ui.RoutablePage.repoThreadNewRoute(.issue, data.identity) orelse return error.RouteTooLong, 393 }; 394 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == View.viewIndex(.new)); 395 const label: []const u8 = switch (data.view) { 396 .edit => "edit", 397 .new_comment => "reply", 398 .edit_comment => "edit", 399 .remove => "remove", 400 .resolve => "resolve", 401 else => "new", 402 }; 403 try header.addTab(allocator, label, link, View.viewIndex(.new)); 404 } 405 406 // conflicts tab, labeled with the conflict count 407 if (data.conflicts.count > 0) { 408 const route = ui.RoutablePage.repoIssuesConflictsRoute(data.identity, "") orelse return error.RouteTooLong; 409 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == View.viewIndex(.conflicts)); 410 var label_buf: [64]u8 = undefined; 411 const label = try std.fmt.bufPrint(&label_buf, "conflicts ({d})", .{data.conflicts.count}); 412 try header.addTab(allocator, label, link, View.viewIndex(.conflicts)); 413 } 414 415 header.select(View.viewIndex(data.view)); 416 return header; 417 } 418