╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Settings.zig ─────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
368 const issue_role = labelRole((try formRadio(self.formBox(), "issue_role")).selected()) catch unreachable; 369 const patch_role = labelRole((try formRadio(self.formBox(), "patch_role")).selected()) catch unreachable; 370 371 const route = update(io, allocator, users_dir, actor, self.data.identity, name, description, access, discuss_role, issue_role, patch_role) catch |err| { 372 const failure = ui.Session.FormFeedback.RepoFailure.fromError(err) orelse return err; 373 const aa = self.session.arena.allocator(); 374 self.session.data.form_feedback = .{ .repo_settings = .{ .failure = failure, .fields = .{ 375 .name = try aa.dupe(u8, name), 376 .description = try aa.dupe(u8, description), 377 .access = access, 378 .discuss_role = discuss_role, 379 .issue_role = issue_role, 380 .patch_role = patch_role, 381 } } }; 382 return; 383 }; 384 try self.session.navigate(route); 385 } 386 387 fn formBox(self: *Form) *wgt.Box(ui.Widget) { 388 return &self.scroll.child.center.child.box; 389 } 390 391 pub fn clearGrid(self: *Form) void { 392 self.scroll.clearGrid(); 393 } 394 395 pub fn getGrid(self: Form) ?Grid { 396 return self.scroll.getGrid(); 397 } 398 399 pub fn getFocus(self: *Form) *Focus { 400 return self.scroll.getFocus(); 401 } 402 403 // up leaves the form from its first control 404 pub fn atTop(self: Form) bool { 405 const box = &self.scroll.child.center.child.box; 406 return box.focus.child_id == box.children.keys()[0]; 407 } 408 }; 409 410 // change the repo `identity` names as `actor`, its owner, returning its 411 // settings route under its new name 412 pub fn update( 413 io: std.Io, 414 allocator: std.mem.Allocator, 415 users_dir: []const u8, 416 actor: ui.Actor, 417 identity: []const u8, 418 name: []const u8, 419 description: []const u8, 420 access: evt.Repo.Access, 421 discuss_role: ?evt.Repo.Role, 422 issue_role: ?evt.Repo.Role, 423 patch_role: ?evt.Repo.Role, 424 ) !ui.RoutablePage { 425 const parsed = ui.RoutablePage.RepoIdentity.parse(identity) orelse return error.NotFound; 426 const owner_id = actor.repo_user_id orelse return error.NotFound; 427 try evt.updateRepo(io, allocator, users_dir, &owner_id, actor.author, parsed.name, name, description, access, discuss_role, issue_role, patch_role); 428 var buf: [ui.RoutablePage.repo_route_max_len]u8 = undefined; 429 const new_identity = std.fmt.bufPrint(&buf, "{s}:{s}", .{ parsed.owner, name }) catch return error.RouteTooLong; 430 return ui.RoutablePage.repoSettingsRoute(new_identity) orelse error.RouteTooLong; 431 } 432