gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitac5ba6a4ac5ba6a4log: W60, #25 measuredmreac5ba6a4/components/tickets.hl

6.3 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. }
  127. Style {
  128. repoTickets {
  129. display = 'grid'
  130. gap = '1rem'
  131. minWidth = '0'
  132. '> *' {
  133. margin = '0'
  134. }
  135. }
  136. #newticketform {
  137. display = 'grid'
  138. gap = '.75rem'
  139. '> *' {
  140. margin = '0'
  141. }
  142. }
  143. #newticket {
  144. summary {
  145. padding = '.7rem .9rem'
  146. color = 'var(--color-accent)'
  147. }
  148. }
  149. #ticketlist {
  150. display = 'grid'
  151. gap = '.4rem'
  152. margin = '0'
  153. padding = '0'
  154. listStyle = 'none'
  155. li {
  156. display = 'grid'
  157. flexWrap = 'wrap'
  158. alignItems = 'center'
  159. gap = '0 .8rem'
  160. margin = '0'
  161. padding = '.1rem 1rem .3rem'
  162. background = 'var(--color-surface)'
  163. borderRadius = 'var(--radius-large)'
  164. overflowWrap = 'anywhere'
  165. gridTemplateColumns = '3.25rem minmax(0, 1fr) minmax(3.5rem, auto)'
  166. columnGap = '.5rem'
  167. '> a' {
  168. display = 'inline-flex'
  169. alignItems = 'center'
  170. minHeight = '2.75rem'
  171. }
  172. }
  173. '.number' {
  174. justifyContent = 'flex-start'
  175. minWidth = '2.75rem'
  176. color = 'var(--color-text-muted)'
  177. }
  178. '.state' {
  179. fontSize = '.875rem'
  180. color = 'var(--color-text-muted)'
  181. }
  182. time {
  183. gridColumn = '2 / -1'
  184. }
  185. '.subject' {
  186. fontWeight = '600'
  187. paddingBlock = '.2rem'
  188. }
  189. }
  190. }

Branches

Latest commits

  • ac5ba6a4log: W60, #25 measuredmre
  • 452f6a1amission W60: logic clean-upsmre
  • 1448c899log: cleanup, #49 GPTBot, tracker mentions on #36mre
  • fcf95936log: v1.5.1 provenmre
  • 22105420log: W51b livemre
  • 7e8aabeareport: W51b pull source verificationmre
  • 6c18de76fix: preserve pull sources across containing branchesmre
  • fc36fa2elog: W51b pull source bugmre
  • 56bc1220log: v1.5.1 livemre
  • 845fc0aareport: W51mre
  • 83127391fix: return v1.5.1 app and merge error detailsmre
  • b07d0e97log: W51 v1.5.1 startedmre
  • 0b417d06docs: apps-api v1.5 user tokens (#48, W49)mre
  • d046940alog: vinzenz contract note sentmre
  • db443456log: vinzenz note retry 2mre
  • 802f229alog: kunibert repo ping provenmre
  • 2d2eaa92log: Kunibert connected to kunibert repomre
  • 65d5f80alogmre
  • dab74b0dW49 report, logmre
  • fd4fc028Exercise member status reads with a populated check statemre