gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit097c52ba097c52baStyle the login error through its View idmre097c52ba/components/tickets.hl

6.5 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. ticketSubject = ''
  33. ticketSummary = ''
  34. ticketError = ''
  35. ticketNotice = ''
  36. hasTicketNotice = false
  37. __title = pageTitle(siteName, titleSlug(host, orepo, session), 'Tickets')
  38. View {
  39. repoPage {
  40. if (hasRepo) {
  41. repoTickets { id = "tickets"
  42. 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" } "." } }
  43. if (ticketsErrorShown) { p { id = "ticketserror" class = "message" ticketsError } }
  44. if (canCreate) {
  45. details { id = "newticket"
  46. summary { "New ticket" }
  47. form { id = "newticketform"
  48. on submit(e) {
  49. e.preventDefault()
  50. emit openIt(e)
  51. }
  52. label { "Subject"
  53. input { id = "ticketsubject" name = "subject" required = "required" maxlength = "200" autocomplete = "off" value = ticketSubject on input(e) { ticketSubject = e.target.value } }
  54. }
  55. label { "Text (Markdown, optional)"
  56. textarea { id = "ticketsummary" name = "summary" rows = "5" value = ticketSummary on input(e) { ticketSummary = e.target.value } }
  57. }
  58. button { id = "ticketsave" type = "submit" "Open ticket" }
  59. p { id = "newticketerror" class = "message" ticketError }
  60. }
  61. }
  62. }
  63. if (needsLogin) { p { id = "ticketsloginhint" class = "muted" "Log in with ident (top right) to open a ticket." } }
  64. if (hasTicketNotice) { p { id = "ticketnotice" class = "notice" ticketNotice } }
  65. if (ticketsNone) { p { id = "noticketsyet" class = "empty" "No ticket yet in this project." } }
  66. if (ticketsShown) {
  67. ol { id = "ticketlist"
  68. for (t of tickets) {
  69. li {
  70. a { class = "number" href = t.url "#" t.number }
  71. a { class = "subject" href = t.url t.subject }
  72. span { class = "state" t.state }
  73. time { t.updated }
  74. }
  75. }
  76. }
  77. p { class = "muted" "Open a ticket to read and answer it in " a { id = "ticketsall" href = ticketsHref "tickets.worldapi.org" } "." }
  78. if (ticketsTruncated) { p { id = "ticketstruncated" class = "muted" "Only the latest tickets are listed here." } }
  79. }
  80. }
  81. }
  82. }
  83. }
  84. on openIt(e) {
  85. r = emit server gitoriaOpenTicket(slug, ticketSubject, ticketSummary)
  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. ticketSubject = ''
  92. ticketSummary = ''
  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, session) == 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. }
  128. Style {
  129. repoTickets {
  130. display = 'grid'
  131. gap = '1rem'
  132. minWidth = '0'
  133. '> *' {
  134. margin = '0'
  135. }
  136. }
  137. #newticketform {
  138. display = 'grid'
  139. gap = '.75rem'
  140. '> *' {
  141. margin = '0'
  142. }
  143. }
  144. #newticket {
  145. summary {
  146. padding = '.7rem .9rem'
  147. color = 'var(--color-accent)'
  148. }
  149. }
  150. #ticketlist {
  151. display = 'grid'
  152. gap = '.4rem'
  153. margin = '0'
  154. padding = '0'
  155. listStyle = 'none'
  156. li {
  157. display = 'grid'
  158. flexWrap = 'wrap'
  159. alignItems = 'center'
  160. gap = '0 .8rem'
  161. margin = '0'
  162. padding = '.1rem 1rem .3rem'
  163. background = 'var(--color-surface)'
  164. borderRadius = 'var(--radius-large)'
  165. overflowWrap = 'anywhere'
  166. gridTemplateColumns = '3.25rem minmax(0, 1fr) minmax(3.5rem, auto)'
  167. columnGap = '.5rem'
  168. '> a' {
  169. display = 'inline-flex'
  170. alignItems = 'center'
  171. minHeight = '2.75rem'
  172. }
  173. }
  174. '.number' {
  175. justifyContent = 'flex-start'
  176. minWidth = '2.75rem'
  177. color = 'var(--color-text-muted)'
  178. }
  179. '.state' {
  180. fontSize = '.875rem'
  181. color = 'var(--color-text-muted)'
  182. }
  183. time {
  184. gridColumn = '2 / -1'
  185. }
  186. '.subject' {
  187. fontWeight = '600'
  188. paddingBlock = '.2rem'
  189. }
  190. }
  191. }

Branches

Latest commits

  • 097c52baStyle the login error through its View idmre
  • c6d9c86aOwn the not-found code rule in its componentmre
  • 055424c2Record W61 replacement theme gates, sidebar repro and baselinemre
  • 2ed09441Use layouts theme 17e0f03 for W61 compatibilitymre
  • b8609a91Merge branch 'main' into w61-stylemre
  • 4639caf7Report W61 theme startup blocker and day39 Style probemre
  • 81f0a0bbREADME: two caches were restored by 90b4f72; log W62mre
  • 4a3f557eImport layouts theme ebd00b6 for W61 (startup blocked)mre
  • ab12a257Merge W62: #25 commit page measurements and proc repromre
  • 41323e49gitoria#25: measure commit request costs and reproduce blocking process waitsmre
  • 53ca42b2log: W60 merged, W61 W62 startedmre
  • 80870a33mission W61: style passmre
  • 560fd208Merge W60: helpers, bound forms, login in topics, two form fixes (gitoria#28 #32 #33)mre
  • ac5ba6a4log: W60, #25 measuredmre
  • 220f6342W60: record corrected form proof, full AE and remaining gapsmre
  • 7e31cac5gitoria#28: restrict reply form layout to reply formsmre
  • ae373cfdgitoria#28: keep each reply draft in its thread componentmre
  • eeeebd5agitoria: insert a newly created organization oncemre
  • 34d2d5cagitoria: clear the bound public-key textarea after creationmre
  • 119e54c0W60: restore conductor-owned tracking filesmre