gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit6e03be0a6e03be0apull state: keep the resync marker until the sync ran (#56)mre6e03be0a/components/tickets.hl

7.0 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. titleRepo = repoAt(slugOfRequest(host, orepo), session)
  38. __title = pageTitle(siteName, titleSlug(host, orepo, session), 'Tickets')
  39. View {
  40. repoPage {
  41. if (hasRepo) {
  42. repoTickets { id = "tickets"
  43. 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" } "." } }
  44. if (ticketsErrorShown) { p { id = "ticketserror" ticketsError } }
  45. if (canCreate) {
  46. details { id = "newticket"
  47. summary { "New ticket" }
  48. form { id = "newticketform"
  49. on submit(e) {
  50. e.preventDefault()
  51. emit openIt(e)
  52. }
  53. label { "Subject"
  54. input { id = "ticketsubject" name = "subject" required = "required" maxlength = "200" autocomplete = "off" value = ticketSubject on input(e) { ticketSubject = e.target.value } }
  55. }
  56. label { "Text (Markdown, optional)"
  57. textarea { id = "ticketsummary" name = "summary" rows = "5" value = ticketSummary on input(e) { ticketSummary = e.target.value } }
  58. }
  59. button { id = "ticketsave" type = "submit" "Open ticket" }
  60. p { id = "newticketerror" ticketError }
  61. }
  62. }
  63. }
  64. if (needsLogin) { p { id = "ticketsloginhint" class = "muted" "Log in with ident (top right) to open a ticket." } }
  65. if (hasTicketNotice) { p { id = "ticketnotice" ticketNotice } }
  66. if (ticketsNone) { p { id = "noticketsyet" class = "empty" "No ticket yet in this project." } }
  67. if (ticketsShown) {
  68. ol { id = "ticketlist"
  69. for (t of tickets) {
  70. li {
  71. a { Style.aNumber href = t.url "#" t.number }
  72. a { Style.aTicketSubject href = t.url t.subject }
  73. span { t.state }
  74. time { t.updated }
  75. }
  76. }
  77. }
  78. p { class = "muted" "Open a ticket to read and answer it in " a { id = "ticketsall" href = ticketsHref "tickets.worldapi.org" } "." }
  79. if (ticketsTruncated) { p { id = "ticketstruncated" class = "muted" "Only the latest tickets are listed here." } }
  80. }
  81. }
  82. }
  83. }
  84. }
  85. on openIt(e) {
  86. r = emit server gitoriaOpenTicket(slug, ticketSubject, ticketSummary)
  87. if (r == null || r.error != null) {
  88. ticketError = r != null ? r.error : 'could not open the ticket'
  89. return null
  90. }
  91. ticketError = ''
  92. ticketSubject = ''
  93. ticketSummary = ''
  94. ticketNotice = 'Opened ticket #' + r.ticket.number + '.'
  95. hasTicketNotice = true
  96. addTicket(r.ticket)
  97. }
  98. addTicket = (row) => {
  99. tickets.remove(row.@id)
  100. tickets = [row, for (x of tickets) { x }]
  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. // Direct-child and sibling combinators have no bare language form.
  134. '> *' {
  135. margin = '0'
  136. }
  137. }
  138. #newticketform {
  139. display = 'grid'
  140. gap = '.75rem'
  141. // Direct-child and sibling combinators have no bare language form.
  142. '> *' {
  143. margin = '0'
  144. }
  145. }
  146. #newticket {
  147. summary {
  148. padding = '.7rem .9rem'
  149. color = 'var(--color-accent)'
  150. }
  151. }
  152. #ticketlist {
  153. display = 'grid'
  154. gap = '.4rem'
  155. margin = '0'
  156. padding = '0'
  157. listStyle = 'none'
  158. li {
  159. display = 'grid'
  160. flexWrap = 'wrap'
  161. alignItems = 'center'
  162. gap = '0 .8rem'
  163. margin = '0'
  164. padding = '.1rem 1rem .3rem'
  165. background = 'var(--color-surface)'
  166. borderRadius = 'var(--radius-large)'
  167. overflowWrap = 'anywhere'
  168. gridTemplateColumns = '3.25rem minmax(0, 1fr) minmax(3.5rem, auto)'
  169. columnGap = '.5rem'
  170. // Direct-child and sibling combinators have no bare language form.
  171. '> a' {
  172. display = 'inline-flex'
  173. alignItems = 'center'
  174. minHeight = '2.75rem'
  175. }
  176. }
  177. time {
  178. gridColumn = '2 / -1'
  179. }
  180. }
  181. aNumber {
  182. justifyContent = 'flex-start'
  183. minWidth = '2.75rem'
  184. color = 'var(--color-text-muted)'
  185. }
  186. aTicketSubject {
  187. fontWeight = '600'
  188. paddingBlock = '.2rem'
  189. }
  190. #span {
  191. fontSize = '.875rem'
  192. color = 'var(--color-text-muted)'
  193. }
  194. #ticketserror {
  195. margin = '0'
  196. color = 'var(--color-danger)'
  197. empty { display = 'none' }
  198. }
  199. #newticketerror {
  200. margin = '0'
  201. color = 'var(--color-danger)'
  202. empty { display = 'none' }
  203. }
  204. #ticketnotice {
  205. margin = '0'
  206. color = 'var(--color-success)'
  207. }
  208. }
  209. on client repoChanged(Hybrid row) {
  210. if (titleRepo != null && row.id == titleRepo.id) { __title = pageTitle(siteName, row.heading, 'Tickets') }
  211. }

Branches

Latest commits

  • 6e03be0apull state: keep the resync marker until the sync ran (#56)mre
  • 93bdd26cpull state: wait for a claimed row, resync when it stays busy (#56)mre
  • e53d284bpull state: stop on a failed branch scan, claim the row on writes (#56)mre
  • d8608224close and reopen: keep a manual close against sync (#56)mre
  • ffb60746|||PR close and reopen pull requests (#56)mre
  • fe209ffeMerge branch 'w56-owner-members' into mainGitoria
  • fa0754c8|||PR repository owner transfer and members API (#55)mre
  • 8862e537Merge branch 'w55-rename-org' into mainGitoria
  • 014d2b7fOne immutable readers snapshot per move for the left-organization event (#53)mre
  • 1859d506Decide who hears a repo left its organization by its readers before the move (#53)mre
  • 499f25f2Review fixes for the Settings organization move (#53)mre
  • ed3b922b|||PR move a repository into an organization in Settings (#53)mre
  • 74ec2af8Merge branch 'w54-repo-rename-pr' into mainGitoria
  • 9f7ce8d8Preserve rename compatibility and live page titlesmre
  • c3d95b6e|||PR separate names and addresses, rename repositories in Settings (#53)mre
  • ce08920dMerge branch 'w52c-header-phone' into mainGitoria
  • 0bab9e46|||PR header: ident status wraps on phones instead of clippingmre
  • e7af3eceMerge branch 'w52b-approval-followup' into mainGitoria
  • c01e66c6|||PR approvals follow-up: live Merge after status writes, helpers (#52)mre
  • 841da497Merge branch 'w53-pulls-speed-pr' into mainGitoria