gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit4fda244f4fda244fgitoria#22: RepoTabs wrapping component for the repo tabs (active tab, no content for a missing repo)mre4fda244f/components/tickets.hl

5.2 KB

  1. // components/tickets.hl — THE TICKETS of a repo (gitoria#10, gitoria#16): `/tickets` on <slug>.<domain>, its own
  2. // route, rendered on the SERVER with its list: the repo comes from the request's host, the tickets from
  3. // tickets.worldapi.org (lib/tickets.hl — hl:fetch answers at once, so the list is in the first HTML and in every
  4. // hl:web navigation). The repo must be connected to a tickets project first (gitoria#18, /settings). A named user
  5. // opens a ticket AS THEMSELVES (the repo's key + their ident id, tickets.hl); a ticket opened here reaches every open
  6. // tickets page of the repo (push `ticketOpened`).
  7. parent './main.hl'
  8. import { siteName } from '../project.hl'
  9. import RepoTabs from './repotabs.hl'
  10. import { slugOfHost } from '../lib/util.hl'
  11. import { infoOfSession, userOfSession } from '../lib/users.hl'
  12. import { repoAt } from '../lib/repos.hl'
  13. import { pageTitle } from '../lib/repos-helpers.hl'
  14. import { loadTickets, openTicket } from '../lib/tickets.hl'
  15. host = null
  16. session = null
  17. slug = slugOfHost(host)
  18. repo = repoAt(slug)
  19. hasRepo = repo != null
  20. me = infoOfSession(session)
  21. canCreate = repo != null && repo.ticketsOn && me != null && me.named
  22. needsLogin = repo != null && repo.ticketsOn && me == null
  23. notConnected = repo != null && repo.ticketsOff
  24. loaded = repo != null && repo.ticketsOn ? loadTickets(slug) : null
  25. ticketsErrorShown = loaded != null && loaded.error != null
  26. ticketsError = loaded != null && loaded.error != null ? loaded.error : ''
  27. tickets = loaded != null && loaded.tickets != null ? loaded.tickets : []
  28. ticketsTruncated = loaded != null && loaded.truncated == true
  29. ticketsHref = loaded != null && loaded.url != null ? loaded.url : ''
  30. ticketsShown = tickets.length > 0
  31. ticketsNone = loaded != null && loaded.error == null && tickets.length == 0
  32. ticketError = ''
  33. ticketNotice = ''
  34. hasTicketNotice = false
  35. __title = pageTitle(siteName, slug, 'Tickets')
  36. View {
  37. RepoTabs { tab = 'tickets'
  38. if (hasRepo) {
  39. repoTickets { id = "tickets"
  40. 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" } "." } }
  41. if (ticketsErrorShown) { p { id = "ticketserror" class = "message" ticketsError } }
  42. if (canCreate) {
  43. details { id = "newticket"
  44. summary { "New ticket" }
  45. form { id = "newticketform"
  46. on submit(e) {
  47. e.preventDefault()
  48. emit openIt(e)
  49. }
  50. label { "Subject"
  51. input { id = "ticketsubject" name = "subject" required = "required" maxlength = "200" autocomplete = "off" }
  52. }
  53. label { "Text (Markdown, optional)"
  54. textarea { id = "ticketsummary" name = "summary" rows = "5" }
  55. }
  56. button { id = "ticketsave" type = "submit" "Open ticket" }
  57. p { id = "newticketerror" class = "message" ticketError }
  58. }
  59. }
  60. }
  61. if (needsLogin) { p { id = "ticketsloginhint" class = "muted" "Log in with ident (top right) to open a ticket." } }
  62. if (hasTicketNotice) { p { id = "ticketnotice" class = "notice" ticketNotice } }
  63. if (ticketsNone) { p { id = "noticketsyet" class = "empty" "No ticket yet in this project." } }
  64. if (ticketsShown) {
  65. ol { id = "ticketlist"
  66. for (t of tickets) {
  67. li {
  68. a { class = "number" href = t.url "#" t.number }
  69. a { class = "subject" href = t.url t.subject }
  70. span { class = "state" t.state }
  71. time { t.updated }
  72. }
  73. }
  74. }
  75. p { class = "muted" "Open a ticket to read and answer it in " a { id = "ticketsall" href = ticketsHref "tickets.worldapi.org" } "." }
  76. if (ticketsTruncated) { p { id = "ticketstruncated" class = "muted" "Only the latest tickets are listed here." } }
  77. }
  78. }
  79. }
  80. }
  81. }
  82. on openIt(e) {
  83. f = e.target.elements
  84. r = emit server gitoriaOpenTicket(slug, f.subject.value, f.summary.value)
  85. if (r == null || r.error != null) {
  86. ticketError = r != null ? r.error : 'could not open the ticket'
  87. return null
  88. }
  89. ticketError = ''
  90. f.subject.value = ''
  91. f.summary.value = ''
  92. ticketNotice = 'Opened ticket #' + r.ticket.number + '.'
  93. hasTicketNotice = true
  94. addTicket(r.ticket)
  95. }
  96. addTicket = (row) => {
  97. next = [row]
  98. for (x of tickets) { if (x.number != row.number) { next.push(x) } }
  99. tickets = next
  100. ticketsShown = true
  101. ticketsNone = false
  102. }
  103. // a ticket opened here by anyone: every open tickets page of that repo follows
  104. on client ticketOpened(slugOf, row) {
  105. if (!hasRepo || slugOf != slug) { return null }
  106. addTicket(row)
  107. }
  108. // this session's tabs follow a login / name / logout (the shell's faces push them)
  109. on client gitoriaSignedIn(tag, info) {
  110. canCreate = repo != null && repo.ticketsOn && info.named
  111. needsLogin = false
  112. }
  113. on client gitoriaSignedOut(tag) {
  114. canCreate = false
  115. needsLogin = repo != null && repo.ticketsOn
  116. }
  117. on server gitoriaOpenTicket(slugOf, subject, summary, session) {
  118. if (repoAt(slugOf) == null) { return { error = 'no such repository' } }
  119. u = userOfSession(session)
  120. if (u == null) { return { error = 'log in with ident (top right) to open a ticket' } }
  121. if (u.name == '') { return { error = 'choose a display name first (top of the page)' } }
  122. r = openTicket(slugOf, u.identity, subject, summary)
  123. if (r.error != null) { return { error = r.error } }
  124. emit client ticketOpened(slugOf, r.ticket)
  125. return r
  126. }

Branches

Latest commits

  • 4fda244fgitoria#22: RepoTabs wrapping component for the repo tabs (active tab, no content for a missing repo)mre
  • 0fd5e280mission brief 004mre
  • e1d425e7paths: projects moved into /media/STORAGE/projects/WorldAPI/mre
  • e59ff114deploy.sh: wait up to DEPLOY_URL_WAIT (120 s) for 200 after the restart, as the other apps (cold compile, hybriel#148)mre
  • bcafcceb003: compose cache volume + tmpfs /tmp, gate start waits 120 s, report/LOG/STATUSmre
  • bed3f2d5Re-vendor Hybriel to the shared static build 0f396652 (plugins; bin/ is git-ignored)mre
  • 3207e128mission brief 003mre
  • 18ab71fbtests/ticketskit: wait up to 120 s for tickets (native Hybriel cold compile ~25 s, hybriel#148)mre
  • 4fffa966docker-compose: init: true (hybriel#156, PID 1 ignored SIGTERM, every restart waited 10 s)mre
  • 4f47843egate: ticket links use the tickets short URL (/<slug>/<n>, tickets#25)mre
  • 86605446mission 002 (code order) 4/4: README file map + import order + 'Same output' test + gate run with a tickets HEAD copy, STATUS (entry, lessons), LOG, report; tests/realdata-baseline.mjs + realdata-compare.py (a cleanup answers the same on live data: pages, modules, API, git over HTTPS and SSH, faces), tests/letcount.pymre
  • cc7bf7bamission 002 (code order) 3/4: let only where a variable is reassigned or re-bound in a loop body (289 lets → plain declarations; 213 left: 125 reassigned, 88 loop-bound; no member/import/param clash). gates 200/0, 46/0, 44/0; real-data reads + writes identical (browser modules: var → const only)mre
  • 090a20c6mission 002 (code order) 2/4: one lib/ file per topic — git.hl split into git (calls, branches, init, temp folder) / homepage / code / pulls / releases (+ git-helpers: paths, ids, |||PR/|||RL markers); repos-helpers, tickets-helpers, transport-helpers; util.hl = localtime + env, storage dir, addresses, lists, text checks, one newest-first sort (was 3 copies); the function routes out of project.hl into lib/api.hl (thin; plumbing in api-helpers.hl), sshgate.hl folded into api.hl + sshkeys.hl keyLine + repos.hl mayPush; 'Make main' and the merge answer out of the faces (code.hl makeMain, pulls.hl pullsView), one login helper (users.hl userOfLoginCode); project.hl is the map. Session-writing routes get &req + &server.sessions. gates 200/0, 46/0, 44/0; real-data identical except /login/failed now shows the parked reason for a browser that already had a session (the old copy-of-req lost it)mre
  • 110c2799mission 002 (code order) 1/4: .hl files out of the root — lib/ (api, git, localtime, markdown, repos, sshgate, sshkeys, tickets, tokens, transport, users), components/styles.hl; jsoncheck.hl removed (imported nowhere); import paths only. gates 200/0, 46/0, 44/0; real-data reads + writes identicalmre
  • fdfb4b1bgitoria: Hybriel master 06617221 (plugin allocators 3a781359 + 413f60e4, mpackdb 2cb7ae5e, http1 773de63e); gates 200/0, 46/0, 44/0mre
  • 5b46ac84antcolony#40: LOG.md — missions 069/072 are antcolony missions (report paths on Byrodin)mre
  • 5602ff41gitoria: Hybriel master 190aa11d (fc838894 GC correctness, #127 mountKids by reference, #126, #48) — tracker README flat; gates 200/0, 46/0, 44/0mre
  • e85eaf01gitoria: 069 round 2 — hybriel 1a096ad3 not adopted (Markdown SSR still grows); browser gate waits for the server-side logout before restartmre
  • 09ce4f3fgitoria: mission 069 re-vendor hybriel 8efba065 stopped (big SSR pages grow + slow down); lambda audit clean; old vendor keptmre
  • 3dc43108antcolony#40: mission references point to the moved missionsmre