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