gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit565cb508565cb508log: H25 round 1mre565cb508/components/pulls.hl

7.7 KB

  1. // components/pulls.hl — THE PULL REQUESTS of a repo (gitoria#11, gitoria#16): `/pulls` on <slug>.<domain>, its
  2. // own route. The repo head is rendered on the server from the request's host. The list comes from git (the
  3. // commits whose message starts with |||PR) on the SERVER too
  4. // (lib/pulls.hl pullsNow — hl:proc run() waits, hybriel#80): it is in the first HTML and in every hl:web navigation.
  5. parent './repo.hl'
  6. import { siteName } from '../project.hl'
  7. import { slugOfRequest } from '../lib/orgs.hl'
  8. import { userOfSession } from '../lib/users.hl'
  9. import { titleSlug, repoAt, repoBySlug, mayPush } from '../lib/repos.hl'
  10. import { pageTitle } from '../lib/repos-helpers.hl'
  11. import { pullsNow, withMerge, pullsView } from '../lib/pulls.hl'
  12. import { mergeAndAnnounce } from '../lib/pullmerge.hl'
  13. import { withPullParts } from '../lib/tickets-helpers.hl'
  14. import { ensurePulls, withNumbers } from '../lib/pullsync.hl'
  15. import { withStatuses } from '../lib/statuses.hl'
  16. host = null
  17. orepo = ''
  18. session = null
  19. slug = slugOfRequest(host, orepo)
  20. repo = repoAt(slug, session)
  21. hasRepo = repo != null
  22. mayMerge = repo != null && userOfSession(session) != null && mayPush(userOfSession(session).id, repoBySlug(slug))
  23. mergeError = ''
  24. numbered = repo != null ? ensurePulls(slug) : null
  25. got = repo != null ? pullsNow(slug, repo.branch) : null
  26. pullsShown = got != null && !got.isMessage
  27. pullsMessage = got != null && got.isMessage
  28. pullsText = got != null && got.isMessage ? got.message : ''
  29. pullsNone = got != null && !got.isMessage && got.noPulls
  30. pullsList = got != null && !got.isMessage ? withNumbers(withStatuses(withPullParts(withMerge(got.pulls, mayMerge), repo.ticketsProject), slug), slug) : []
  31. pullsDefault = got != null && !got.isMessage ? got.defaultName : ''
  32. __title = pageTitle(siteName, titleSlug(host, orepo, session), 'Pull requests')
  33. View {
  34. repoPage {
  35. if (hasRepo) {
  36. repoPulls { id = "pulls"
  37. if (pullsMessage) { p { id = "pullsmessage" class = "empty" pullsText } }
  38. if (pullsShown) {
  39. p { id = "pullshelp" class = "muted" "A commit whose message starts with " code { "|||PR " } " opens a pull request; " code { "|||PR|branch] " } " sets the target (now: " strong { pullsDefault } " by default)." }
  40. if (pullsNone) { p { id = "nopulls" class = "empty" "No pull request yet." } }
  41. p { id = "mergeerror" mergeError }
  42. ol { id = "pulllist"
  43. for (pr of pullsList) {
  44. li {
  45. span { Style.spanSubject span { Style.spanNumber pr.numberText } for (pt of pr.parts) { if (pt.isText) { a { href = pr.pageHref pt.text } } if (pt.isLink) { a { class = "ticketref" href = pt.href pt.text } } } }
  46. // Runtime class selection has no Style-rule expression form.
  47. span { class = pr.state pr.state }
  48. span { Style.spanBranches
  49. if (pr.hasSource) { a { class = "source" href = pr.sourceHref pr.source } }
  50. if (pr.noSource) { span { class = "source muted" "(branch gone)" } }
  51. span { class = "muted" "→" }
  52. if (pr.targetLinked) { a { class = "target" href = pr.targetHref pr.target } }
  53. if (pr.targetMissing) { span { class = "target muted" pr.target " (no such branch)" } }
  54. }
  55. span { Style.spanStatuses
  56. for (st of pr.statuses) {
  57. // Runtime class selection has no Style-rule expression form.
  58. span { class = st.cls
  59. span { Style.spanPullStatusState st.state }
  60. span { class = "label" st.label }
  61. span { class = "muted" st.title }
  62. }
  63. }
  64. }
  65. span { class = "muted" pr.author }
  66. time { pr.date }
  67. span { Style.spanBlocked pr.blockText }
  68. // Runtime class selection has no Style-rule expression form.
  69. button { class = pr.mergeClass type = "button" value = pr.sha "Merge" on click(e) { emit mergePull(e.target.value) } }
  70. }
  71. }
  72. }
  73. }
  74. }
  75. }
  76. }
  77. }
  78. // "Merge" (the owner, only when clicked): the face merges and answers with the list read again
  79. on mergePull(sha) {
  80. mergeError = ''
  81. r = emit server gitoriaMergePull(slug, sha)
  82. if (r == null || r.error != null) {
  83. mergeError = r != null ? r.error : 'could not merge'
  84. return null
  85. }
  86. got = r.result
  87. pullsList = r.list
  88. pullsNone = got.noPulls
  89. }
  90. on server gitoriaMergePull(slugOf, sha, session) {
  91. if (session == null || repoAt(slugOf, session) == null) { return { error = 'could not merge' } }
  92. u = userOfSession(session)
  93. if (u == null || !mayPush(u.id, repoBySlug(slugOf))) { return { error = 'only the owner and the members of this repository can merge a pull request' } }
  94. // the merge, the pull request records (merged, mergeCommit) and the connected apps' event: lib/pullmerge.hl, the same as the API's
  95. r = mergeAndAnnounce(repoBySlug(slugOf), sha, u, '')
  96. if (r.error != null) { return { error = r.error } }
  97. // the list again, with its ticket links made here: tickets-helpers.hl reads the environment, which the browser has not
  98. v = pullsView(slugOf, repoAt(slugOf, session).branch, true, repoAt(slugOf, session).ticketsProject)
  99. return { result = v.result list = withNumbers(v.list, slugOf) }
  100. }
  101. Style {
  102. repoPulls {
  103. display = 'grid'
  104. gap = '1rem'
  105. minWidth = '0'
  106. // Direct-child and sibling combinators have no bare language form.
  107. '> *' {
  108. margin = '0'
  109. }
  110. }
  111. #pulllist {
  112. display = 'grid'
  113. gap = '.4rem'
  114. margin = '0'
  115. padding = '0'
  116. listStyle = 'none'
  117. li {
  118. display = 'flex'
  119. flexWrap = 'wrap'
  120. alignItems = 'center'
  121. gap = '0 .8rem'
  122. margin = '0'
  123. padding = '.1rem 1rem .3rem'
  124. background = 'var(--color-surface)'
  125. borderRadius = 'var(--radius-large)'
  126. overflowWrap = 'anywhere'
  127. }
  128. // Runtime and theme class predicates have no bare selector form.
  129. '.open' {
  130. fontSize = '.875rem'
  131. color = 'var(--color-accent)'
  132. }
  133. // Runtime and theme class predicates have no bare selector form.
  134. '.nomerge' {
  135. display = 'none'
  136. }
  137. // Runtime and theme class predicates have no bare selector form.
  138. '.merged' {
  139. fontSize = '.875rem'
  140. color = 'var(--color-text-muted)'
  141. }
  142. // Runtime and theme class predicates have no bare selector form.
  143. 'button.mergepr' {
  144. marginLeft = 'auto'
  145. color = 'var(--color-accent-text)'
  146. background = 'var(--color-accent)'
  147. }
  148. }
  149. spanNumber {
  150. marginRight = '.5rem'
  151. color = 'var(--color-text-muted)'
  152. fontWeight = '400'
  153. }
  154. spanPullStatusState {
  155. fontWeight = '600'
  156. }
  157. spanSubject {
  158. flex = '1 1 100%'
  159. minWidth = '0'
  160. fontWeight = '600'
  161. a {
  162. display = 'inline-block'
  163. paddingBlock = '.65rem'
  164. }
  165. // Runtime and theme class predicates have no bare selector form.
  166. 'a.ticketref' {
  167. minWidth = '2.75rem'
  168. textAlign = 'center'
  169. }
  170. }
  171. spanBranches {
  172. display = 'inline-flex'
  173. flexWrap = 'wrap'
  174. alignItems = 'center'
  175. gap = '0 .5rem'
  176. a {
  177. display = 'inline-flex'
  178. alignItems = 'center'
  179. justifyContent = 'center'
  180. minWidth = '2.75rem'
  181. minHeight = '2.75rem'
  182. }
  183. }
  184. spanStatuses {
  185. display = 'flex'
  186. flex = '1 1 100%'
  187. flexWrap = 'wrap'
  188. gap = '.25rem .5rem'
  189. // Runtime and theme class predicates have no bare selector form.
  190. '.badge' {
  191. display = 'inline-flex'
  192. flexWrap = 'wrap'
  193. alignItems = 'center'
  194. gap = '0 .4rem'
  195. padding = '.1rem .6rem'
  196. fontSize = '.8125rem'
  197. background = 'var(--color-background-sunken)'
  198. borderRadius = 'var(--radius-large)'
  199. }
  200. // Runtime and theme class predicates have no bare selector form.
  201. '.success' {
  202. color = 'var(--color-success)'
  203. }
  204. // Runtime and theme class predicates have no bare selector form.
  205. '.failure' {
  206. color = 'var(--color-danger)'
  207. }
  208. // Runtime and theme class predicates have no bare selector form.
  209. '.error' {
  210. color = 'var(--color-text-strong)'
  211. fontStyle = 'italic'
  212. }
  213. }
  214. spanBlocked {
  215. fontSize = '.875rem'
  216. color = 'var(--color-text-muted)'
  217. }
  218. #mergeerror {
  219. margin = '0'
  220. color = 'var(--color-danger)'
  221. empty { display = 'none' }
  222. }
  223. }

Branches

Latest commits

  • 565cb508log: H25 round 1mre
  • 90a0af84log: H25 startedmre
  • 87bd53b8mission H25mre
  • 71a746cflog: day48 livemre
  • bf568e14log: V48 mergedmre
  • 09955dedMerge v48: Hybriel set-day48, theme layouts ce4a0bamre
  • f2a2b0cevendor: Hybriel set-day48, theme layouts ce4a0bamre
  • 5d0834e7log: Apollo model rulemre
  • fe8e5bd5log: #25 sample, V48 missionmre
  • 8580c5d9log: theme fix from Atlasmre
  • 46823d93log: Apollo budget correctionmre
  • f6d32341log: Apollo on budget and #25 nextmre
  • d7184f53log: batch live, #25 evidencemre
  • 5e25e816log: W61 mergedmre
  • aafe330dTidy: drop evidence JSON (kept in scratch), collapse blank linesmre
  • aca1fda1Merge W61: theme from layouts 17e0f03, Views refer to Style rules (gitoria#37 #27)mre
  • 03cb650blog: W61 theme decisionmre
  • 248bce85Report final style gates, CSS mappings and 136 whole-image comparisonsmre
  • 153c344bRestore organization metadata exposed by the whole-image comparisonmre
  • 917a1465Update status gate assertions for the referenced state rulemre