gitoria
All repositories: gitoria
7.8 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 == 0createError = ''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" }}label { "Description (optional)"input { id = "description" name = "description" maxlength = "200" autocomplete = "off" }}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" }}label { "Visibility — a private repository is seen only by you and the members you add"select { id = "priv" name = "priv"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" }}label { "Visibility — a private organization makes every repository of it private, also new ones"select { id = "orgpriv" name = "orgpriv"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) {f = e.target.elementsr = emit server gitoriaCreateRepo(f.slug.value, f.description.value, f.org.value, f.priv.value == 'private')if (r == null || r.error != null) {createError = r != null ? r.error : 'could not create the repository'return null}createError = ''f.slug.value = ''f.description.value = ''f.priv.value = 'public'createdText = "Created '" + r.repo.slug + "': "createdHref = r.repo.addresshasCreated = true}on createOrgIt(e) {f = e.target.elementsr = emit server gitoriaCreateOrg(f.orgslug.value, f.orgpriv.value == 'private')if (r == null || r.error != null) {orgError = r != null ? r.error : 'could not create the organization'return null}orgError = ''f.orgslug.value = ''f.orgpriv.value = 'public'createdText = "Created the organization '" + r.org.slug + "': "createdHref = r.addresshasCreated = trueorgs = [{ slug = r.org.slug isPrivate = r.org.isPrivate isPublic = !r.org.isPrivate address = r.address }].concat(orgs)hasOrgs = 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 } }emit client repoCreated(r.repo)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
- fb9e7554gitoria#45: browser gate: a /pulls title links to the PR pagemre
- f7198131gitoria#45: tests/pr-page.mjs gatemre
- 483141d0gitoria#45: Settings shows the Apps heading only to the ownermre
- e2eff8f6gitoria#45: the PR page /pulls/N with reviews, threads, verdicts, conversation, comment, reply, resolve and Review againmre
- 7a602839gitoria#45: raiseEvent can send to one app only; people's comments, replies and resolving in reviews.hlmre
- 0a46bf7dgitoria#47: apps API contract v1.3 (status read route, statuses + required on the pull)mre
- 3373f7c3gitoria#38: push API contract v1.2.1, reviews, worker briefs and logmre
- 34143d2cgitoria#46: closing brace of appComments lost in the mergemre
- 54927c9cgitoria#46: PR statuses and required checks before merge (merge w46-status)mre
- 187e1871gitoria#46: badges without decorative bordersmre
- 6b022798gitoria#46: tests/status.mjs in GATESmre
- c6162f00gitoria#46: status badges on /pulls, Required before merge in Settingsmre
- e5a0b64egitoria#46: PUT statuses/<sha>, required contexts block the merge on the servermre
- 26a140e3gitoria#44: reviews, inline threads, replies, conversation for apps (merge w44-reviews)mre
- 888dbf87gitoria#44: unknown API paths answer the contract's JSON 404 and sit above the page routesmre
- ea587d90gitoria#44: reviews with inline threads, replies, resolve and the PR conversation for apps (lib/reviews.hl, tests/reviews.mjs)mre
- 49533a50gitoria#43: signed events to connected apps (merge w43-events)mre
- 1a1e87d5gitoria#43: the sender never writes the apps row; Settings shows the newest deliverymre
- cd442066gitoria#43: app-auth unit test reads the apps table from its new filemre
- 5dccbe38gitoria#43: in-flight rows are left alone by the other process; gate in deploy.sh; READMEmre