gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commita81abdc9a81abdc9gitoria#34: org page via function route, member-reachable orgs, selects, reportmrea81abdc9/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 { slugOfRequest } from '../lib/orgs.hl'
  10. import { infoOfSession, userOfSession } from '../lib/users.hl'
  11. import { titleSlug, 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. orepo = ''
  16. session = null
  17. slug = slugOfRequest(host, orepo)
  18. repo = repoAt(slug, session)
  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, titleSlug(host, orepo, session), 'Tickets')
  36. View {
  37. repoPage {
  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, session) == 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

  • a81abdc9gitoria#34: org page via function route, member-reachable orgs, selects, reportmre
  • 17f031f0gitoria#34: private repos, organizations, members, move tool, gatemre
  • 71b69343gitoria#23: the sidebar's Repositories link was a 404 after any in-page navigation (static menu re-evaluated publicUrl in the browser); the menu is an instance property now; gate taps it after a tab, folder, filemre
  • 90b4f728gitoria#25: restore the homepage cache and the parsed-blocks cache (they store data under immutable keys, no HTML); the page key, the framework readme key and the textHash key stay removedmre
  • a487248cgitoria#25: remove every cache that hid the page build (page key, Markdown render key, homepage cache, parsed-blocks cache) and the gate that only tested themmre
  • 12f2f4fegitoria: re-vendor Hybriel set-day27b, a startup fault in on Error exits 1mre
  • c21c084egitoria: write the standby service out in full so the boot gate can read the main servicemre
  • e307d69agitoria: say what is per process during the hand-overmre
  • f0cbe6a6gitoria: standby service on port 45014 and a deploy that hands over through it without a gapmre
  • 727cd083gitoria#25: README: vendor notes for Hybriel c1b1010f and the page cachemre
  • 61b72dedgitoria#25: re-vendor Hybriel master c1b1010f (W149 page cache), key the repo Readme page by slug and main commit, extend the readme-cache gatemre
  • 5b0b4b9ereadme-cache gate: use the security gate's ports when no own ports are givenmre
  • bc8f20d9gitoria#25: re-vendor Hybriel c09538bb with the W141 render cache, cache the homepage per commit, add the readme-cache gatemre
  • 9feebbd3Re-vendor Hybriel to ded47c13 (W145: Firefox start script fix)mre
  • 28ed41e5gitoria#24: one sign-in comes from hl:web batch 20, the /session/share workaround is gonemre
  • 3b2669e4gs: drop the unbuildable legacy check, fix pwa fetchmre
  • 2a2fdd77gs: C2 check before cookie experimentsmre
  • 76e0587aWIP gs 2mre
  • a80da7bdWIP gs: security gate for lazy sessions, g24 browser checksmre
  • 23fb05d8re-vendor Hybriel aaa39e69 (hl:web batch 20: login emit and Sessions.mint, tab follows a login, signed-in session cookie wins among duplicates and is re-issued with the Domain, W85 faster render, lazy sessions)mre