gitoria
All repositories: gitoria
8.3 KB
// components/list.hl — THE REPO LIST of the main address (ticket #6, gitoria#16): every repository, newest// first, and "Create a repository" (slug = its address, unique in the whole system) for a named user.// Composed into components/index.hl (route `/`) when the request's host is the main address. Rendered on// the server with its rows; a new repo from any session reaches every open list (push `repoCreated`).import { repoOrigin } from '../lib/util.hl'import Tokens from './tokens.hl'import SshKeys from './sshkeys.hl'import { repoRows, orgRows, createRepoIn, createOrg } from '../lib/repos.hl'import { infoOfSession, userOfSession, userIdOfSession } from '../lib/users.hl'session = nullme = infoOfSession(session)canCreate = me != null && me.namedneedsLogin = me == nullrepos = repoRows(userIdOfSession(session))orgs = orgRows(userIdOfSession(session))hasOrgs = orgs.length > 0noRepos = repos.length == 0repoSlug = ''repoDescription = ''repoOrg = ''repoVisibility = 'public'orgSlug = ''orgVisibility = 'public'createError = ''orgError = ''createdText = ''createdHref = ''hasCreated = false// THE LIST COMES FIRST (mobile first): the repositories are what this page is for; the create form, tokens and keys follow it.// (Before, a phone scrolled past three forms — 5 000 px — to reach the first repository.)View {repoList {h1 { id = "heading" "Repositories" }if (needsLogin) { p { id = "loginhint" class = "muted" "Log in with ident (top right) to create a repository." } }if (noRepos) { p { id = "empty" class = "empty" "No repository yet." } }ol { id = "repos"for (r of repos) {li {a { class = "slug" href = r.address r.slug }if (r.isPrivate) { span { class = "muted" "Private" } }if (r.described) { span { class = "about" r.description } }repoMeta { span { r.owner } time { r.created } }}}}if (hasOrgs) {h2 { "Organizations" }ul { id = "orgs"for (o of orgs) {li { a { class = "slug" href = o.address o.slug } if (o.isPrivate) { span { class = "muted" "Private" } } }}}}if (canCreate) {form { id = "createform"on submit(e) {e.preventDefault()emit createIt(e)}h2 { "Create a repository" }label { "Address — its name is unique in the whole system and becomes NAME.gitoria.worldapi.org"input { id = "slug" name = "slug" required = "required" minlength = "2" maxlength = "40" autocomplete = "off" autocapitalize = "none" spellcheck = "false" value = repoSlug on input(e) { repoSlug = e.target.value } }}label { "Description (optional)"input { id = "description" name = "description" maxlength = "200" autocomplete = "off" value = repoDescription on input(e) { repoDescription = e.target.value } }}label { "Organization (optional) — put the repository inside one of yours: ORG.gitoria.worldapi.org/NAME"input { id = "org" name = "org" maxlength = "40" autocomplete = "off" autocapitalize = "none" spellcheck = "false" value = repoOrg on input(e) { repoOrg = e.target.value } }}label { "Visibility — a private repository is seen only by you and the members you add"select { id = "priv" name = "priv" value = repoVisibility on change(e) { repoVisibility = e.target.value }option { value = "public" "Public" }option { value = "private" "Private" }}}button { id = "createsave" type = "submit" "Create repository" }p { id = "createerror" class = "message" createError }}}if (canCreate) {form { id = "orgform"on submit(e) {e.preventDefault()emit createOrgIt(e)}h2 { "Create an organization" }label { "Name — becomes NAME.gitoria.worldapi.org, its repositories live at NAME.gitoria.worldapi.org/REPO"input { id = "orgslug" name = "orgslug" required = "required" minlength = "2" maxlength = "40" autocomplete = "off" autocapitalize = "none" spellcheck = "false" value = orgSlug on input(e) { orgSlug = e.target.value } }}label { "Visibility — a private organization makes every repository of it private, also new ones"select { id = "orgpriv" name = "orgpriv" value = orgVisibility on change(e) { orgVisibility = e.target.value }option { value = "public" "Public" }option { value = "private" "Private" }}}button { id = "orgsave" type = "submit" "Create organization" }p { id = "orgerror" class = "message" orgError }}}if (hasCreated) { p { id = "created" class = "notice" createdText " " a { id = "createdlink" href = createdHref "Open it" } } }Tokens { }SshKeys { }}}on createIt(e) {r = emit server gitoriaCreateRepo(repoSlug, repoDescription, repoOrg, repoVisibility == 'private')if (r == null || r.error != null) {createError = r != null ? r.error : 'could not create the repository'return null}createError = ''repoSlug = ''repoDescription = ''repoVisibility = 'public'createdText = "Created '" + r.repo.slug + "': "createdHref = r.repo.addresshasCreated = true}on createOrgIt(e) {r = emit server gitoriaCreateOrg(orgSlug, orgVisibility == 'private')if (r == null || r.error != null) {orgError = r != null ? r.error : 'could not create the organization'return null}orgError = ''orgSlug = ''orgVisibility = 'public'createdText = "Created the organization '" + r.org.slug + "': "createdHref = r.addresshasCreated = true// The ack may already sync orgs from session; prepend this slug only once.next = [{ slug = r.org.slug isPrivate = r.org.isPrivate isPublic = !r.org.isPrivate address = r.address }]for (x of orgs) { if (x.slug != r.org.slug) { next.push(x) } }orgs = nexthasOrgs = true}// this session's tabs follow a login / name / logout (the shell's faces push them)on client gitoriaSignedIn(tag, info) {canCreate = info.namedneedsLogin = false}on client gitoriaSignedOut(tag) {canCreate = falseneedsLogin = true}// a new repo, from any session: the list follows liveon client repoCreated(row) {next = [row]for (x of repos) { if (x.id != row.id) { next.push(x) } }repos = nextnoRepos = false}on server gitoriaCreate(slug, description, session) {return makeRepo(slug, description, '', false, session)}on server gitoriaCreateRepo(slug, description, org, priv, session) {return makeRepo(slug, description, org, priv, session)}on server gitoriaCreateOrg(slug, priv, session) {u = userOfSession(session)if (u == null) { return { error = 'log in with ident (top right) first' } }r = createOrg(u.id, slug, priv)if (r.error != null) { return { error = r.error } }return { org = r.org address = repoOrigin(r.org.slug) + '/' }}makeRepo = (slug, description, org, priv, session) => {u = userOfSession(session)if (u == null) { return { error = 'log in with ident (top right) to create a repository' } }r = createRepoIn(u.id, org, slug, description, priv)if (r.error != null) { return { error = r.error } }return r}Style {repoList {display = 'grid'gap = '1rem'minWidth = '0''> *' {margin = '0'}}#createform {display = 'grid'gap = '.75rem'padding = '1rem'background = 'var(--color-surface)'borderRadius = 'var(--radius-large)''> *' {margin = '0'}}#repos {display = 'grid'gap = '.5rem'margin = '0'padding = '0'listStyle = 'none'li {display = 'grid'gap = '.1rem'margin = '0'padding = '.25rem 1rem .6rem'background = 'var(--color-surface)'borderRadius = 'var(--radius-large)'}'.slug' {display = 'flex'alignItems = 'center'minHeight = '2.75rem'fontWeight = '700'fontSize = '1.05rem'overflowWrap = 'anywhere'}'.about' {color = 'var(--color-text)'}}repoMeta {display = 'flex'flexWrap = 'wrap'gap = '.2rem 1rem'fontSize = '.875rem'color = 'var(--color-text-muted)'}@media {minWidth = '60rem'#repos {li {gridTemplateColumns = 'minmax(10rem, 16rem) 1fr auto'alignItems = 'center'gap = '.15rem 1rem'padding = '.25rem 1rem'}}}#orgform {display = 'grid'gap = '.75rem'padding = '1rem'margin = '1rem 0'background = 'var(--color-surface)'borderRadius = 'var(--radius-large)'}#orgs {listStyle = 'none'margin = '0'padding = '0'display = 'grid'gap = '.1rem'li {display = 'flex'alignItems = 'center'gap = '.75rem'minHeight = '2.75rem'}}}
Branches
- f1-broken-json
- f2-api-bugs
- gp-gate-ports
- heap-revert
- hl25-records
- ident-chooser-selector
- mainmain branch
- p51-public-pr-reads
- records-1112
- s25-no-session-on-login-error
- v59
- w52-person-approval
- w52b-approval-followup
- w52c-header-phone
- w53-pulls-speed-pr
- w54-repo-rename-pr
- w55-rename-org
- w56-owner-members
- w62-pr-close
- w63-force-push
- w64-org-slash
Latest commits
- 7e31cac5gitoria#28: restrict reply form layout to reply formsmre
- ae373cfdgitoria#28: keep each reply draft in its thread componentmre
- eeeebd5agitoria: insert a newly created organization oncemre
- 34d2d5cagitoria: clear the bound public-key textarea after creationmre
- 119e54c0W60: restore conductor-owned tracking filesmre
- 24b479e7W60: record final gates, Chrome failures and AE evidencemre
- 5e11184cW60: record partial validation, framework gaps and cleanupmre
- 20fe13fagitoria#33: centralize login and tickets connection statemre
- 859754c0gitoria#29: retain the offline note and record the framework gapmre
- d140bc04gitoria#30: reproduce the upsert ordering constraintmre
- 6960e8f8gitoria#28: keep form values in bound component membersmre
- 0db27200gitoria#32: share character checks and environment lookupmre
- 452f6a1amission W60: logic clean-upsmre
- 1448c899log: cleanup, #49 GPTBot, tracker mentions on #36mre
- fcf95936log: v1.5.1 provenmre
- 22105420log: W51b livemre
- 7e8aabeareport: W51b pull source verificationmre
- 6c18de76fix: preserve pull sources across containing branchesmre
- fc36fa2elog: W51b pull source bugmre
- 56bc1220log: v1.5.1 livemre