gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitc7d3cc87c7d3cc87docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mrec7d3cc87/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 RepoHead from './repohead.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. repoPage {
  38. RepoHead { }
  39. if (hasRepo) {
  40. repoTickets { id = "tickets"
  41. 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" } "." } }
  42. if (ticketsErrorShown) { p { id = "ticketserror" class = "message" ticketsError } }
  43. if (canCreate) {
  44. details { id = "newticket"
  45. summary { "New ticket" }
  46. form { id = "newticketform"
  47. on submit(e) {
  48. e.preventDefault()
  49. emit openIt(e)
  50. }
  51. label { "Subject"
  52. input { id = "ticketsubject" name = "subject" required = "required" maxlength = "200" autocomplete = "off" }
  53. }
  54. label { "Text (Markdown, optional)"
  55. textarea { id = "ticketsummary" name = "summary" rows = "5" }
  56. }
  57. button { id = "ticketsave" type = "submit" "Open ticket" }
  58. p { id = "newticketerror" class = "message" ticketError }
  59. }
  60. }
  61. }
  62. if (needsLogin) { p { id = "ticketsloginhint" class = "muted" "Log in with ident (top right) to open a ticket." } }
  63. if (hasTicketNotice) { p { id = "ticketnotice" class = "notice" ticketNotice } }
  64. if (ticketsNone) { p { id = "noticketsyet" class = "empty" "No ticket yet in this project." } }
  65. if (ticketsShown) {
  66. ol { id = "ticketlist"
  67. for (t of tickets) {
  68. li {
  69. a { class = "number" href = t.url "#" t.number }
  70. a { class = "subject" href = t.url t.subject }
  71. span { class = "state" t.state }
  72. time { t.updated }
  73. }
  74. }
  75. }
  76. p { class = "muted" "Open a ticket to read and answer it in " a { id = "ticketsall" href = ticketsHref "tickets.worldapi.org" } "." }
  77. if (ticketsTruncated) { p { id = "ticketstruncated" class = "muted" "Only the latest tickets are listed here." } }
  78. }
  79. }
  80. }
  81. }
  82. }
  83. on openIt(e) {
  84. f = e.target.elements
  85. r = emit server gitoriaOpenTicket(slug, f.subject.value, f.summary.value)
  86. if (r == null || r.error != null) {
  87. ticketError = r != null ? r.error : 'could not open the ticket'
  88. return null
  89. }
  90. ticketError = ''
  91. f.subject.value = ''
  92. f.summary.value = ''
  93. ticketNotice = 'Opened ticket #' + r.ticket.number + '.'
  94. hasTicketNotice = true
  95. addTicket(r.ticket)
  96. }
  97. addTicket = (row) => {
  98. next = [row]
  99. for (x of tickets) { if (x.number != row.number) { next.push(x) } }
  100. tickets = next
  101. ticketsShown = true
  102. ticketsNone = false
  103. }
  104. // a ticket opened here by anyone: every open tickets page of that repo follows
  105. on client ticketOpened(slugOf, row) {
  106. if (!hasRepo || slugOf != slug) { return null }
  107. addTicket(row)
  108. }
  109. // this session's tabs follow a login / name / logout (the shell's faces push them)
  110. on client gitoriaSignedIn(tag, info) {
  111. canCreate = repo != null && repo.ticketsOn && info.named
  112. needsLogin = false
  113. }
  114. on client gitoriaSignedOut(tag) {
  115. canCreate = false
  116. needsLogin = repo != null && repo.ticketsOn
  117. }
  118. on server gitoriaOpenTicket(slugOf, subject, summary, session) {
  119. if (repoAt(slugOf) == null) { return { error = 'no such repository' } }
  120. u = userOfSession(session)
  121. if (u == null) { return { error = 'log in with ident (top right) to open a ticket' } }
  122. if (u.name == '') { return { error = 'choose a display name first (top of the page)' } }
  123. r = openTicket(slugOf, u.identity, subject, summary)
  124. if (r.error != null) { return { error = r.error } }
  125. emit client ticketOpened(slugOf, r.ticket)
  126. return r
  127. }

Branches

Latest commits

  • 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
  • 6bd7fb3cgitoria 009: theme re-copied from layouts 76f99f6 (menu marks the current page), current = true on the menu item, e2e marker checks, reportmre
  • 44de915cidentkit: refuse a taken ident port, cold-start deadline, abort on dead ident, clear no-code error (as notes)mre
  • 2bf5343egitoria 007: theme re-copied from layouts dbe3de7 (44 px taps), redundant tap overrides dropped, crumbs class, real-browser walk test, reportmre
  • 18843648deploy.sh: a gate without a 'passed,' line (check-theme) no longer ends the script silently (grep under pipefail) — print check-theme's summary, as layouts doesmre
  • e6dff0cbgitoria#23: report 005, STATUS, LOGmre
  • 7f992d62gitoria#23: phone first on the shared theme — brand, branch and pull links 44 px, readme code 14 px; gate block "phone first" (15 pages at 390 + the three dropdowns, fails 20 on old), dropdown-aware login/logout clicks, check-theme in GATESmre
  • a2a840a5gitoria#23 WIP (quota stop): theme from layouts, styles inherit it, shell on the theme's header/menus/sidebar, phone measurement script; gates not runmre
  • 12b665b0mission brief 005mre
  • b680c483Revert "gitoria#22: RepoTabs wrapping component for the repo tabs (active tab, no content for a missing repo)"mre
  • 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