╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Issues.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
320 if (try map.getCursor(order_key)) |conflict_cursor| { 321 const conflict_entry = try DB.HashMap(.read_only).init(conflict_cursor); 322 conflict_data = try thread.readConflict(Self, repo_kind, repo_opts, arena, repo, io, admin_moment, haxy_moment, &id_bytes, issue_event, conflict_entry); 323 resolved_view = .resolve; 324 } 325 } 326 } 327 } 328 } 329 } 330 331 const thread_comments_start = if (empty.comment_id.len == 0) comments_start else 0; 332 const open_window = try thread.loadWindow(Self, .issue, repo_opts.hash, arena, admin_moment, haxy_moment, event_id_to_issue, open_set, open_root, conflict_set, empty.selected_id, thread_comments_start, empty.search, viewer); 333 const closed_window = try thread.loadWindow(Self, .issue, repo_opts.hash, arena, admin_moment, haxy_moment, event_id_to_issue, closed_set, closed_root, conflict_set, empty.selected_id, thread_comments_start, empty.search, viewer); 334 const conflicts_window = try thread.loadWindow(Self, .issue, repo_opts.hash, arena, admin_moment, haxy_moment, event_id_to_issue, conflict_set, conflicts_root, conflict_set, empty.selected_id, thread_comments_start, null, viewer); 335 if (view == .conflicts and conflicts_window.count > 0) resolved_view = .conflicts; 336 337 const comment_page = if (empty.comment_id.len == 0) 338 null 339 else 340 try Comment.init(repo_opts.hash, arena, admin_moment, haxy_moment, empty.selected_id, empty.comment_id, comments_start, viewer); 341 342 const labels = try thread.loadLabels(Self, repo_opts.hash, arena, haxy_moment); 343 344 return .{ 345 .identity = empty.identity, 346 .label = empty.label, 347 .search = empty.search, 348 .selected_id = empty.selected_id, 349 .comment_id = empty.comment_id, 350 .comments_start = comments_start, 351 .comment_page = comment_page, 352 .viewer = viewer, 353 .open = open_window, 354 .closed = closed_window, 355 .conflicts = conflicts_window, 356 .conflict = conflict_data, 357 .theirs_picks = empty.theirs_picks, 358 .view = resolved_view, 359 .description_page = empty.description_page, 360 .labels = labels, 361 }; 362 } 363 364 pub const View = thread.View(.issue, Self); 365 pub const Detail = thread.Detail(.issue, Self); 366 pub const detail_widget_name = "repo_issue_detail"; 367 368 pub const Header = thread.Header; 369 370 const open_tab_label = "open"; 371 const closed_tab_label = "closed"; 372 const labels_tab_label = "labels"; 373 const edit_tab_label = "edit"; 374 const reply_tab_label = "reply"; 375 const remove_tab_label = "remove"; 376 const resolve_tab_label = "resolve"; 377 const new_tab_label = "new"; 378 const conflicts_tab_label = "conflicts"; 379 380 // tabs switching between the issues page's views 381 pub fn initHeader(allocator: std.mem.Allocator, session: *ui.Session, data: *const Self) !Header { 382 var header = try Header.init(allocator, session, data.search); 383 errdefer header.deinit(allocator); 384 const selected_index = View.viewIndex(data.view); 385 const page_selected = std.meta.activeTag(session.data.current_page) == .repo_issues; 386 387 // a list tab per status, labeled with its listing's issue count 388 const status_labels = [_][]const u8{ open_tab_label, closed_tab_label }; 389 for ([_]evt.Issue.Status{ .open, .closed }, status_labels, 0..) |status, status_label, index| { 390 const route = try thread.searchRoute(ui.RoutablePage.repoIssuesRoute(data.identity, status, data.label, ""), data.search); 391 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == index); 392 var label_buf: [64]u8 = undefined; 393 const label = try thread.countLabel(&label_buf, status_label, data.window(status).*); 394 try header.addTab(allocator, label, link, index); 395 } 396 397 // labels tab 398 { 399 const labels_route = try thread.searchRoute(ui.RoutablePage.repoThreadLabelsRoute(.issue, data.identity, data.label), data.search); 400 const labels_link = try ui.inPageTabLink(session, labels_route, page_selected and selected_index == View.viewIndex(.labels)); 401 try header.addTab(allocator, labels_tab_label, labels_link, View.viewIndex(.labels)); 402 } 403 404 // new-issue tab; an edit or resolve url shows its tab in this place 405 { 406 const route = switch (data.view) { 407 .edit => ui.RoutablePage.repoThreadEditRoute(.issue, data.identity, data.selected_id) orelse return error.RouteTooLong, 408 .new_comment => ui.RoutablePage.repoThreadCommentNewRoute(.issue, data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 409 .edit_comment => ui.RoutablePage.repoThreadCommentEditRoute(.issue, data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 410 .remove => ui.RoutablePage.repoThreadRemoveRoute(.issue, data.identity, data.selected_id, data.comment_id) orelse return error.RouteTooLong, 411 .resolve => ui.RoutablePage.repoIssuesResolveRoute(data.identity, data.selected_id, data.theirs_picks) orelse return error.RouteTooLong, 412 else => ui.RoutablePage.repoThreadNewRoute(.issue, data.identity) orelse return error.RouteTooLong, 413 }; 414 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == View.viewIndex(.new)); 415 const label: []const u8 = switch (data.view) { 416 .edit => edit_tab_label, 417 .new_comment => reply_tab_label, 418 .edit_comment => edit_tab_label, 419 .remove => remove_tab_label, 420 .resolve => resolve_tab_label, 421 else => new_tab_label, 422 }; 423 try header.addTab(allocator, label, link, View.viewIndex(.new)); 424 } 425 426 // conflicts tab, labeled with the conflict count 427 if (data.conflicts.count > 0) { 428 const route = ui.RoutablePage.repoIssuesConflictsRoute(data.identity, "") orelse return error.RouteTooLong; 429 const link = try ui.inPageTabLink(session, route, page_selected and selected_index == View.viewIndex(.conflicts)); 430 var label_buf: [64]u8 = undefined; 431 const label = try std.fmt.bufPrint(&label_buf, conflicts_tab_label ++ " ({d})", .{data.conflicts.count}); 432 try header.addTab(allocator, label, link, View.viewIndex(.conflicts)); 433 } 434 435 header.select(View.viewIndex(data.view)); 436 return header; 437 } 438