gitoria
All repositories: gitoria
6.3 KB
// components/tickets.hl — THE TICKETS of a repo (gitoria#10, gitoria#16): `/tickets` on <slug>.<domain>, its own// route, rendered on the SERVER with its list: the repo comes from the request's host, the tickets from// tickets.worldapi.org (lib/tickets.hl — hl:fetch answers at once, so the list is in the first HTML and in every// hl:web navigation). The repo must be connected to a tickets project first (gitoria#18, /settings). A named user// opens a ticket AS THEMSELVES (the repo's key + their ident id, tickets.hl); a ticket opened here reaches every open// tickets page of the repo (push `ticketOpened`).parent './repo.hl'import { siteName } from '../project.hl'import { slugOfRequest } from '../lib/orgs.hl'import { infoOfSession, userOfSession } from '../lib/users.hl'import { titleSlug, repoAt } from '../lib/repos.hl'import { pageTitle } from '../lib/repos-helpers.hl'import { loadTickets, openTicket } from '../lib/tickets.hl'host = nullorepo = ''session = nullslug = slugOfRequest(host, orepo)repo = repoAt(slug, session)hasRepo = repo != nullme = infoOfSession(session)canCreate = repo != null && repo.ticketsOn && me != null && me.namedneedsLogin = repo != null && repo.ticketsOn && me == nullnotConnected = repo != null && repo.ticketsOffloaded = repo != null && repo.ticketsOn ? loadTickets(slug) : nullticketsErrorShown = loaded != null && loaded.error != nullticketsError = loaded != null && loaded.error != null ? loaded.error : ''tickets = loaded != null && loaded.tickets != null ? loaded.tickets : []ticketsTruncated = loaded != null && loaded.truncated == trueticketsHref = loaded != null && loaded.url != null ? loaded.url : ''ticketsShown = tickets.length > 0ticketsNone = loaded != null && loaded.error == null && tickets.length == 0ticketError = ''ticketNotice = ''hasTicketNotice = false__title = pageTitle(siteName, titleSlug(host, orepo, session), 'Tickets')View {repoPage {if (hasRepo) {repoTickets { id = "tickets"if (notConnected) { p { id = "ticketsnotconnected" class = "empty" "This repository is not connected to a tickets project. The owner connects it under " a { id = "tosettings" href = "/settings" "Settings" } "." } }if (ticketsErrorShown) { p { id = "ticketserror" class = "message" ticketsError } }if (canCreate) {details { id = "newticket"summary { "New ticket" }form { id = "newticketform"on submit(e) {e.preventDefault()emit openIt(e)}label { "Subject"input { id = "ticketsubject" name = "subject" required = "required" maxlength = "200" autocomplete = "off" }}label { "Text (Markdown, optional)"textarea { id = "ticketsummary" name = "summary" rows = "5" }}button { id = "ticketsave" type = "submit" "Open ticket" }p { id = "newticketerror" class = "message" ticketError }}}}if (needsLogin) { p { id = "ticketsloginhint" class = "muted" "Log in with ident (top right) to open a ticket." } }if (hasTicketNotice) { p { id = "ticketnotice" class = "notice" ticketNotice } }if (ticketsNone) { p { id = "noticketsyet" class = "empty" "No ticket yet in this project." } }if (ticketsShown) {ol { id = "ticketlist"for (t of tickets) {li {a { class = "number" href = t.url "#" t.number }a { class = "subject" href = t.url t.subject }span { class = "state" t.state }time { t.updated }}}}p { class = "muted" "Open a ticket to read and answer it in " a { id = "ticketsall" href = ticketsHref "tickets.worldapi.org" } "." }if (ticketsTruncated) { p { id = "ticketstruncated" class = "muted" "Only the latest tickets are listed here." } }}}}}}on openIt(e) {f = e.target.elementsr = emit server gitoriaOpenTicket(slug, f.subject.value, f.summary.value)if (r == null || r.error != null) {ticketError = r != null ? r.error : 'could not open the ticket'return null}ticketError = ''f.subject.value = ''f.summary.value = ''ticketNotice = 'Opened ticket #' + r.ticket.number + '.'hasTicketNotice = trueaddTicket(r.ticket)}addTicket = (row) => {next = [row]for (x of tickets) { if (x.number != row.number) { next.push(x) } }tickets = nextticketsShown = trueticketsNone = false}// a ticket opened here by anyone: every open tickets page of that repo followson client ticketOpened(slugOf, row) {if (!hasRepo || slugOf != slug) { return null }addTicket(row)}// this session's tabs follow a login / name / logout (the shell's faces push them)on client gitoriaSignedIn(tag, info) {canCreate = repo != null && repo.ticketsOn && info.namedneedsLogin = false}on client gitoriaSignedOut(tag) {canCreate = falseneedsLogin = repo != null && repo.ticketsOn}on server gitoriaOpenTicket(slugOf, subject, summary, session) {if (repoAt(slugOf, session) == null) { return { error = 'no such repository' } }u = userOfSession(session)if (u == null) { return { error = 'log in with ident (top right) to open a ticket' } }if (u.name == '') { return { error = 'choose a display name first (top of the page)' } }r = openTicket(slugOf, u.identity, subject, summary)if (r.error != null) { return { error = r.error } }emit client ticketOpened(slugOf, r.ticket)return r}Style {repoTickets {display = 'grid'gap = '1rem'minWidth = '0''> *' {margin = '0'}}#newticketform {display = 'grid'gap = '.75rem''> *' {margin = '0'}}#newticket {summary {padding = '.7rem .9rem'color = 'var(--color-accent)'}}#ticketlist {display = 'grid'gap = '.4rem'margin = '0'padding = '0'listStyle = 'none'li {display = 'grid'flexWrap = 'wrap'alignItems = 'center'gap = '0 .8rem'margin = '0'padding = '.1rem 1rem .3rem'background = 'var(--color-surface)'borderRadius = 'var(--radius-large)'overflowWrap = 'anywhere'gridTemplateColumns = '3.25rem minmax(0, 1fr) minmax(3.5rem, auto)'columnGap = '.5rem''> a' {display = 'inline-flex'alignItems = 'center'minHeight = '2.75rem'}}'.number' {justifyContent = 'flex-start'minWidth = '2.75rem'color = 'var(--color-text-muted)'}'.state' {fontSize = '.875rem'color = 'var(--color-text-muted)'}time {gridColumn = '2 / -1'}'.subject' {fontWeight = '600'paddingBlock = '.2rem'}}}
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
- b554cd5flogmre
- f4c9440ddeploy.sh: tar --hard-dereference for the live data backupmre
- 1a687b15Merge branch 'w48-member-merge'mre
- 166c775fW48 report, logmre
- 1b4623f0Members merge pull requests: API route, button on /pulls and /pulls/N, one shared merge pathmre
- 1075c38cW48 mission, logmre
- 17bdd0d6V37/V39 missions, logmre
- 146de5f8Re-vendor gitoria to Hybriel set-day39 (51e921d7)mre
- e874e44dtests/status-keyed: app token lives 60 s so it outlives the gate's two restartsmre
- 270b8d61deploy.sh: DEPLOY_STOP_START=1 stops, waits for the old pid, then starts (mpackdb freeze, replaces the standby swap)mre
- 3f9235b8project.hl: drop the dummy /pulls/:n component route (hybriel#294 is fixed in day37)mre
- c90daf19Re-vendor gitoria to Hybriel set-day37 (f6b3d45b)mre
- 03b5bb08W39 report to reports/, drop scratch repro, mission + logmre
- 154d333fMerge w39-create-api: POST /api/repos with a user token (#39)mre
- 149dd512Rewrite W39 reportmre
- e5385075Expect 401 for POST /api/repos without a tokenmre
- 1a76055cDocument repository creation APImre
- 4d779b3bAdd create-api gatemre
- 88563122Add POST /api/repos for user tokensmre
- b00860e3Create repositories with member checks in createRepoInmre