gitoria

gitoria

All repositories: gitoria

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

Branches

Latest commits

  • 3a95252dG3: cache parsed README blocks by sha256 of the text (bounded LRU), reportmre
  • 570138cddeploy: security gate (tests/security.mjs)mre
  • da6b20fcgitoria SG: security audit fixes (uploadMax 0, Secure cookie on https, session rotation at login, nosniff on function routes, no identity in page data) + tests/security.mjs gate + reportmre
  • f98c981fgitoria B1: report wordingmre
  • c6364cedgitoria B1: compact Markdown blocks (one kind flag per block/span, empty and false fields omitted); same rendered HTML, page values -67%mre
  • cd99d2feWIP gitoria#22: always render the repo level's slot (missing-repo boot hang), pages render nothing without a repo; hydration diagnosis in reports/G2-hydrate.mdmre
  • e5404b9breport: commit idsmre
  • 63cfa21ereports/G2-repotabs.mdmre
  • 9b0516fdgitoria#22: mark the tab underline functional (check-theme), chain E2E: serve/measure split, bring the lisbeth tab to frontmre
  • 19bc1df8gitoria#22: all repo pages under ONE layout level (components/repo.hl, hl:web D-CHAIN): a tab click replaces only the page in the slot; head and tab nav stay the same DOM nodesmre
  • 40658417tests/browser.mjs: wait for the page to be live (hydrated) before clicking Merge — a click on the server-rendered button before the client mounted was lost (flaky 'Clashing change' under load)mre
  • 48a6154bre-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
  • e972e8d7tests: short-id-switch (GITORIA_SWITCH_IDENT_PORT/_PORT) and ssh tunnel (GITORIA_GATE_TUNNEL_PORT) ports from env, defaults unchangedmre
  • f06f5349re-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
  • c7d3cc87docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
  • f0e7ff8cdeploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
  • fe5f707cgitoria 010: report, mission, comment on why current = true staysmre
  • 9705ca86gitoria 010: gate: menu marker in the server HTMLmre
  • 8cff663agitoria 010: main-menu.hl from layouts 0bcc629 (route marker)mre
  • 359c79f7gitoria 010: re-vendor Hybriel master f9614007 (plugins whole, bin/ git-ignored)mre