╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Issues.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
292 .open => open_root = order_key, 293 .closed => closed_root = order_key, 294 } 295 // form urls keep their view; otherwise the issue's status picks it. 296 if (view != .edit and view != .new_comment and view != .edit_comment and view != .remove) resolved_view = switch (issue_event.event.status) { 297 .open => .open, 298 .closed => .closed, 299 }; 300 301 // a resolve url shows the resolve view only while the issue still 302 // has a conflict entry; otherwise the status list stands. the 303 // wasm client renders from the snapshot, so the diff machinery 304 // this pulls in is gated out of its build. 305 if (comptime !wasm) { 306 if (view == .resolve) { 307 if (conflicts_map) |map| { 308 if (try map.getCursor(order_key)) |conflict_cursor| { 309 const conflict_entry = try DB.HashMap(.read_only).init(conflict_cursor); 310 conflict_data = try thread.readConflict(Self, repo_kind, repo_opts, arena, repo, io, admin_moment, haxy_moment, &id_bytes, issue_event, conflict_entry); 311 resolved_view = .resolve; 312 } 313 } 314 } 315 } 316 } 317 } 318 319 const thread_comments_start = if (empty.comment_id.len == 0) comments_start else 0; 320 const open_window = try thread.loadWindow(Self, repo_opts.hash, arena, admin_moment, haxy_moment, event_id_to_issue, open_set, open_root, conflict_set, empty.selected_id, thread_comments_start); 321 const closed_window = try thread.loadWindow(Self, repo_opts.hash, arena, admin_moment, haxy_moment, event_id_to_issue, closed_set, closed_root, conflict_set, empty.selected_id, thread_comments_start); 322 const conflicts_window = try thread.loadWindow(Self, repo_opts.hash, arena, admin_moment, haxy_moment, event_id_to_issue, conflict_set, conflicts_root, conflict_set, empty.selected_id, thread_comments_start); 323 if (view == .conflicts and conflicts_window.count > 0) resolved_view = .conflicts; 324 325 const comment_page = if (empty.comment_id.len == 0) 326 null 327 else 328 try Comment.init(repo_opts.hash, arena, admin_moment, haxy_moment, empty.selected_id, empty.comment_id, comments_start); 329 330 const tags = try thread.loadTags(Self, repo_opts.hash, arena, haxy_moment); 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