gitoria
All repositories: gitoria
6.5 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" 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" 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" 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) {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) => {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
- 097c52baStyle the login error through its View idmre
- c6d9c86aOwn the not-found code rule in its componentmre
- 055424c2Record W61 replacement theme gates, sidebar repro and baselinemre
- 2ed09441Use layouts theme 17e0f03 for W61 compatibilitymre
- b8609a91Merge branch 'main' into w61-stylemre
- 4639caf7Report W61 theme startup blocker and day39 Style probemre
- 81f0a0bbREADME: two caches were restored by 90b4f72; log W62mre
- 4a3f557eImport layouts theme ebd00b6 for W61 (startup blocked)mre
- ab12a257Merge W62: #25 commit page measurements and proc repromre
- 41323e49gitoria#25: measure commit request costs and reproduce blocking process waitsmre
- 53ca42b2log: W60 merged, W61 W62 startedmre
- 80870a33mission W61: style passmre
- 560fd208Merge W60: helpers, bound forms, login in topics, two form fixes (gitoria#28 #32 #33)mre
- ac5ba6a4log: W60, #25 measuredmre
- 220f6342W60: record corrected form proof, full AE and remaining gapsmre
- 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