╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Members.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
328 switch (key) { 329 .arrow_left, .arrow_right => _ = ui.widget.moveInSelectedRow(rows, root_focus, key == .arrow_right), 330 else => { 331 // the text, the add row and the previous link, when there is one, sit above the rows 332 const offset: usize = add_index + 1 + @as(usize, @intFromBool(self.data.start > 0)); 333 if (current < offset or current - offset >= self.data.rows.len) return; 334 const row = self.data.rows[current - offset]; 335 const row_box = &rows.children.values()[current].widget.box; 336 // remove and demote are links to their confirmations, which the host follows 337 if (row.role == .owner) return; 338 const button_id = row_box.getFocus().child_id orelse return; 339 if (row_box.children.getIndex(button_id) != 1 or !inp.activated(root_focus, button_id, key)) return; 340 try self.act(allocator, .promote, row.name); 341 }, 342 } 343 } 344 345 // the terminal performs the action itself; the web posts the form instead 346 fn act(self: *View, allocator: std.mem.Allocator, action: Action, name: []const u8) !void { 347 if (comptime wasm) return; 348 const io = self.session.io orelse return; 349 const users_dir = self.session.users_dir orelse return; 350 const admin_repo = self.session.admin_repo orelse return; 351 const actor = (try self.session.authorize(self.data.identity, .owner, null)) orelse return; 352 const moment = try evt.currentMoment(evt.admin_repo_opts, admin_repo); 353 const failure = perform(io, allocator, moment, users_dir, actor, self.data.identity, action, name) catch |err| switch (err) { 354 // a stale row; the refresh below shows the list as it is 355 error.EventNotFound => null, 356 else => return err, 357 }; 358 if (failure) |value| { 359 self.session.data.form_feedback = .{ .repo_members = .{ .failure = value, .name = try self.session.arena.allocator().dupe(u8, name) } }; 360 return; 361 } 362 try self.session.navigate(landingRoute(self.data.identity, self.data.start, actor, action, name) orelse return error.RouteTooLong); 363 } 364 365 pub fn clearGrid(self: *View) void { 366 self.scroll.clearGrid(); 367 } 368 369 pub fn getGrid(self: View) ?Grid { 370 return self.scroll.getGrid(); 371 } 372 373 pub fn getFocus(self: *View) *Focus { 374 return self.scroll.getFocus(); 375 } 376 377 // up leaves the view from the explanatory text or the confirmation 378 pub fn atTop(self: *View) bool { 379 return self.data.confirm != null or self.contentBox().getFocus().child_id == self.aboutBox().getFocus().id; 380 } 381 }; 382