╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ NewRepo.zig ──────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
129 const users_dir = self.session.users_dir orelse return; 130 const admin_repo = self.session.admin_repo orelse return; 131 const user_id = self.session.userId() orelse return; 132 const moment = try evt.currentMoment(evt.admin_repo_opts, admin_repo); 133 const user = (try ui.activeUser(moment, self.session.page_arena, user_id)) orelse return; 134 135 const name_input = try formField(self.formBox(), "name"); 136 const description_input = try formField(self.formBox(), "description"); 137 const name = try name_input.text(allocator); 138 defer allocator.free(name); 139 const description = try description_input.text(allocator); 140 defer allocator.free(description); 141 const hash_kind = std.meta.stringToEnum(hash.HashKind, (try formRadio(self.formBox(), "hash")).selected()) orelse unreachable; 142 const access = std.meta.stringToEnum(evt.Repo.Access, (try formRadio(self.formBox(), "access")).selected()) orelse unreachable; 143 144 _ = evt.createRepo(io, allocator, users_dir, &user_id, .{ .name = user.event.name, .email = user.event.email }, name, description, access, hash_kind) catch |err| { 145 const failure = ui.Session.FormFeedback.RepoFailure.fromError(err) orelse return err; 146 const aa = self.session.arena.allocator(); 147 self.session.data.form_feedback = .{ .repo = .{ .failure = failure, .fields = .{ 148 .name = try aa.dupe(u8, name), 149 .description = try aa.dupe(u8, description), 150 .hash = hash_kind, 151 .access = access, 152 } } }; 153 return; 154 }; 155 156 // wipe the form so a return visit starts fresh 157 name_input.clear(allocator); 158 description_input.clear(allocator); 159 160 const identity = try std.fmt.allocPrint(self.session.page_arena.allocator(), "{s}/{s}", .{ user.event.name, name }); 161 try self.session.navigate(ui.RoutablePage.repoFilesRoute(identity, null, "", "", 0) orelse return); 162 } 163 164 fn formBox(self: *View) *wgt.Box(ui.Widget) { 165 return &self.center.child.box; 166 } 167 168 pub fn clearGrid(self: *View) void { 169 self.center.clearGrid(); 170 } 171 172 pub fn getGrid(self: View) ?Grid { 173 return self.center.getGrid(); 174 } 175 176 pub fn getFocus(self: *View) *Focus { 177 return self.center.getFocus(); 178 } 179 180 // up leaves the form from its first control 181 pub fn atTop(self: View) bool { 182 const box = &self.center.child.box; 183 return box.focus.child_id == box.children.keys()[0]; 184 } 185 }; 186