gitoria
All repositories: gitoria
6.8 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 == 0ticketSubject = ''ticketSummary = ''ticketError = ''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" 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" value = ticketSubject on input(e) { ticketSubject = e.target.value } }}label { "Text (Markdown, optional)"textarea { id = "ticketsummary" name = "summary" rows = "5" value = ticketSummary on input(e) { ticketSummary = e.target.value } }}button { id = "ticketsave" type = "submit" "Open ticket" }p { id = "newticketerror" ticketError }}}}if (needsLogin) { p { id = "ticketsloginhint" class = "muted" "Log in with ident (top right) to open a ticket." } }if (hasTicketNotice) { p { id = "ticketnotice" 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 { Style.aNumber href = t.url "#" t.number }a { Style.aTicketSubject href = t.url t.subject }span { 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) {r = emit server gitoriaOpenTicket(slug, ticketSubject, ticketSummary)if (r == null || r.error != null) {ticketError = r != null ? r.error : 'could not open the ticket'return null}ticketError = ''ticketSubject = ''ticketSummary = ''ticketNotice = 'Opened ticket #' + r.ticket.number + '.'hasTicketNotice = trueaddTicket(r.ticket)}addTicket = (row) => {tickets.remove(row.@id)tickets = [row, for (x of tickets) { x }]ticketsShown = 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'// Direct-child and sibling combinators have no bare language form.'> *' {margin = '0'}}#newticketform {display = 'grid'gap = '.75rem'// Direct-child and sibling combinators have no bare language form.'> *' {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'// Direct-child and sibling combinators have no bare language form.'> a' {display = 'inline-flex'alignItems = 'center'minHeight = '2.75rem'}}time {gridColumn = '2 / -1'}}aNumber {justifyContent = 'flex-start'minWidth = '2.75rem'color = 'var(--color-text-muted)'}aTicketSubject {fontWeight = '600'paddingBlock = '.2rem'}#span {fontSize = '.875rem'color = 'var(--color-text-muted)'}#ticketserror {margin = '0'color = 'var(--color-danger)'empty { display = 'none' }}#newticketerror {margin = '0'color = 'var(--color-danger)'empty { display = 'none' }}#ticketnotice {margin = '0'color = 'var(--color-success)'}}
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
- cb634512log: 2026-11-08 keyed lists livemre
- 07c98d4aLists: keyed rows with @id, remove(id) and one whole-list assignment instead of hand-rebuilt loopsmre
- 0db0d81elog: 2026-11-08 day52 live, W30 startedmre
- b05f6d92tests/status: the gate's 3 s app token expired during the restart; it lives 60 s like status-keyedmre
- 1e8f4f0avendor: Hybriel set-day52 (fault-path leak fix #335, keyed rows #331)mre
- f5f0fb7blog: 2026-11-08 day50/#29 live, H25 correction, V52 startedmre
- dc77fb95main: offline note from __hlOnline, tick removed (#29)mre
- 37a86d93tests/reviews: seeded fake hook's DNS failures are not server errors (flaky gate)mre
- 07ab845bvendor: Hybriel set-day50 (run() leak fix #335)mre
- 71b2fa4blog: hybriel#335mre
- bd94cc7elog: #25 cause found (run() leak)mre
- 565cb508log: H25 round 1mre
- 90a0af84log: H25 startedmre
- 87bd53b8mission H25mre
- 71a746cflog: day48 livemre
- bf568e14log: V48 mergedmre
- 09955dedMerge v48: Hybriel set-day48, theme layouts ce4a0bamre
- f2a2b0cevendor: Hybriel set-day48, theme layouts ce4a0bamre
- 5d0834e7log: Apollo model rulemre
- fe8e5bd5log: #25 sample, V48 missionmre