gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit5dccbe385dccbe38gitoria#43: in-flight rows are left alone by the other process; gate in deploy.sh; READMEmre5dccbe38/components/list.hl

7.8 KB

  1. // components/list.hl — THE REPO LIST of the main address (ticket #6, gitoria#16): every repository, newest
  2. // first, and "Create a repository" (slug = its address, unique in the whole system) for a named user.
  3. // Composed into components/index.hl (route `/`) when the request's host is the main address. Rendered on
  4. // the server with its rows; a new repo from any session reaches every open list (push `repoCreated`).
  5. import { repoOrigin } from '../lib/util.hl'
  6. import Tokens from './tokens.hl'
  7. import SshKeys from './sshkeys.hl'
  8. import { repoRows, orgRows, createRepoIn, createOrg } from '../lib/repos.hl'
  9. import { infoOfSession, userOfSession, userIdOfSession } from '../lib/users.hl'
  10. session = null
  11. me = infoOfSession(session)
  12. canCreate = me != null && me.named
  13. needsLogin = me == null
  14. repos = repoRows(userIdOfSession(session))
  15. orgs = orgRows(userIdOfSession(session))
  16. hasOrgs = orgs.length > 0
  17. noRepos = repos.length == 0
  18. createError = ''
  19. orgError = ''
  20. createdText = ''
  21. createdHref = ''
  22. hasCreated = false
  23. // THE LIST COMES FIRST (mobile first): the repositories are what this page is for; the create form, tokens and keys follow it.
  24. // (Before, a phone scrolled past three forms — 5 000 px — to reach the first repository.)
  25. View {
  26. repoList {
  27. h1 { id = "heading" "Repositories" }
  28. if (needsLogin) { p { id = "loginhint" class = "muted" "Log in with ident (top right) to create a repository." } }
  29. if (noRepos) { p { id = "empty" class = "empty" "No repository yet." } }
  30. ol { id = "repos"
  31. for (r of repos) {
  32. li {
  33. a { class = "slug" href = r.address r.slug }
  34. if (r.isPrivate) { span { class = "muted" "Private" } }
  35. if (r.described) { span { class = "about" r.description } }
  36. repoMeta { span { r.owner } time { r.created } }
  37. }
  38. }
  39. }
  40. if (hasOrgs) {
  41. h2 { "Organizations" }
  42. ul { id = "orgs"
  43. for (o of orgs) {
  44. li { a { class = "slug" href = o.address o.slug } if (o.isPrivate) { span { class = "muted" "Private" } } }
  45. }
  46. }
  47. }
  48. if (canCreate) {
  49. form { id = "createform"
  50. on submit(e) {
  51. e.preventDefault()
  52. emit createIt(e)
  53. }
  54. h2 { "Create a repository" }
  55. label { "Address — its name is unique in the whole system and becomes NAME.gitoria.worldapi.org"
  56. input { id = "slug" name = "slug" required = "required" minlength = "2" maxlength = "40" autocomplete = "off" autocapitalize = "none" spellcheck = "false" }
  57. }
  58. label { "Description (optional)"
  59. input { id = "description" name = "description" maxlength = "200" autocomplete = "off" }
  60. }
  61. label { "Organization (optional) — put the repository inside one of yours: ORG.gitoria.worldapi.org/NAME"
  62. input { id = "org" name = "org" maxlength = "40" autocomplete = "off" autocapitalize = "none" spellcheck = "false" }
  63. }
  64. label { "Visibility — a private repository is seen only by you and the members you add"
  65. select { id = "priv" name = "priv"
  66. option { value = "public" "Public" }
  67. option { value = "private" "Private" }
  68. }
  69. }
  70. button { id = "createsave" type = "submit" "Create repository" }
  71. p { id = "createerror" class = "message" createError }
  72. }
  73. }
  74. if (canCreate) {
  75. form { id = "orgform"
  76. on submit(e) {
  77. e.preventDefault()
  78. emit createOrgIt(e)
  79. }
  80. h2 { "Create an organization" }
  81. label { "Name — becomes NAME.gitoria.worldapi.org, its repositories live at NAME.gitoria.worldapi.org/REPO"
  82. input { id = "orgslug" name = "orgslug" required = "required" minlength = "2" maxlength = "40" autocomplete = "off" autocapitalize = "none" spellcheck = "false" }
  83. }
  84. label { "Visibility — a private organization makes every repository of it private, also new ones"
  85. select { id = "orgpriv" name = "orgpriv"
  86. option { value = "public" "Public" }
  87. option { value = "private" "Private" }
  88. }
  89. }
  90. button { id = "orgsave" type = "submit" "Create organization" }
  91. p { id = "orgerror" class = "message" orgError }
  92. }
  93. }
  94. if (hasCreated) { p { id = "created" class = "notice" createdText " " a { id = "createdlink" href = createdHref "Open it" } } }
  95. Tokens { }
  96. SshKeys { }
  97. }
  98. }
  99. on createIt(e) {
  100. f = e.target.elements
  101. r = emit server gitoriaCreateRepo(f.slug.value, f.description.value, f.org.value, f.priv.value == 'private')
  102. if (r == null || r.error != null) {
  103. createError = r != null ? r.error : 'could not create the repository'
  104. return null
  105. }
  106. createError = ''
  107. f.slug.value = ''
  108. f.description.value = ''
  109. f.priv.value = 'public'
  110. createdText = "Created '" + r.repo.slug + "': "
  111. createdHref = r.repo.address
  112. hasCreated = true
  113. }
  114. on createOrgIt(e) {
  115. f = e.target.elements
  116. r = emit server gitoriaCreateOrg(f.orgslug.value, f.orgpriv.value == 'private')
  117. if (r == null || r.error != null) {
  118. orgError = r != null ? r.error : 'could not create the organization'
  119. return null
  120. }
  121. orgError = ''
  122. f.orgslug.value = ''
  123. f.orgpriv.value = 'public'
  124. createdText = "Created the organization '" + r.org.slug + "': "
  125. createdHref = r.address
  126. hasCreated = true
  127. orgs = [{ slug = r.org.slug isPrivate = r.org.isPrivate isPublic = !r.org.isPrivate address = r.address }].concat(orgs)
  128. hasOrgs = true
  129. }
  130. // this session's tabs follow a login / name / logout (the shell's faces push them)
  131. on client gitoriaSignedIn(tag, info) {
  132. canCreate = info.named
  133. needsLogin = false
  134. }
  135. on client gitoriaSignedOut(tag) {
  136. canCreate = false
  137. needsLogin = true
  138. }
  139. // a new repo, from any session: the list follows live
  140. on client repoCreated(row) {
  141. next = [row]
  142. for (x of repos) { if (x.id != row.id) { next.push(x) } }
  143. repos = next
  144. noRepos = false
  145. }
  146. on server gitoriaCreate(slug, description, session) {
  147. return makeRepo(slug, description, '', false, session)
  148. }
  149. on server gitoriaCreateRepo(slug, description, org, priv, session) {
  150. return makeRepo(slug, description, org, priv, session)
  151. }
  152. on server gitoriaCreateOrg(slug, priv, session) {
  153. u = userOfSession(session)
  154. if (u == null) { return { error = 'log in with ident (top right) first' } }
  155. r = createOrg(u.id, slug, priv)
  156. if (r.error != null) { return { error = r.error } }
  157. return { org = r.org address = repoOrigin(r.org.slug) + '/' }
  158. }
  159. makeRepo = (slug, description, org, priv, session) => {
  160. u = userOfSession(session)
  161. if (u == null) { return { error = 'log in with ident (top right) to create a repository' } }
  162. r = createRepoIn(u.id, org, slug, description, priv)
  163. if (r.error != null) { return { error = r.error } }
  164. emit client repoCreated(r.repo)
  165. return r
  166. }
  167. Style {
  168. repoList {
  169. display = 'grid'
  170. gap = '1rem'
  171. minWidth = '0'
  172. '> *' {
  173. margin = '0'
  174. }
  175. }
  176. #createform {
  177. display = 'grid'
  178. gap = '.75rem'
  179. padding = '1rem'
  180. background = 'var(--color-surface)'
  181. borderRadius = 'var(--radius-large)'
  182. '> *' {
  183. margin = '0'
  184. }
  185. }
  186. #repos {
  187. display = 'grid'
  188. gap = '.5rem'
  189. margin = '0'
  190. padding = '0'
  191. listStyle = 'none'
  192. li {
  193. display = 'grid'
  194. gap = '.1rem'
  195. margin = '0'
  196. padding = '.25rem 1rem .6rem'
  197. background = 'var(--color-surface)'
  198. borderRadius = 'var(--radius-large)'
  199. }
  200. '.slug' {
  201. display = 'flex'
  202. alignItems = 'center'
  203. minHeight = '2.75rem'
  204. fontWeight = '700'
  205. fontSize = '1.05rem'
  206. overflowWrap = 'anywhere'
  207. }
  208. '.about' {
  209. color = 'var(--color-text)'
  210. }
  211. }
  212. repoMeta {
  213. display = 'flex'
  214. flexWrap = 'wrap'
  215. gap = '.2rem 1rem'
  216. fontSize = '.875rem'
  217. color = 'var(--color-text-muted)'
  218. }
  219. @media {
  220. minWidth = '60rem'
  221. #repos {
  222. li {
  223. gridTemplateColumns = 'minmax(10rem, 16rem) 1fr auto'
  224. alignItems = 'center'
  225. gap = '.15rem 1rem'
  226. padding = '.25rem 1rem'
  227. }
  228. }
  229. }
  230. #orgform {
  231. display = 'grid'
  232. gap = '.75rem'
  233. padding = '1rem'
  234. margin = '1rem 0'
  235. background = 'var(--color-surface)'
  236. borderRadius = 'var(--radius-large)'
  237. }
  238. #orgs {
  239. listStyle = 'none'
  240. margin = '0'
  241. padding = '0'
  242. display = 'grid'
  243. gap = '.1rem'
  244. li {
  245. display = 'flex'
  246. alignItems = 'center'
  247. gap = '.75rem'
  248. minHeight = '2.75rem'
  249. }
  250. }
  251. }

Branches

Latest commits

  • 5dccbe38gitoria#43: in-flight rows are left alone by the other process; gate in deploy.sh; READMEmre
  • 8c8805f3merge main (gitoria#42), delivery log and redelivery routes, sweep fixmre
  • 5a996ea8gitoria#42: short-lived app tokens, read-only git fetch with them (merge w42-app-token)mre
  • afdb0cbfgitoria#43: rename the moved helper (name clash in the browser build)mre
  • 15e01e94gitoria#43: tests/events.mjs and its probemre
  • 77829b73gitoria#43: signed events to connected apps (deliveries table, sender timer, pull_request events, ping)mre
  • b5d696fegitoria#42: app tokens (gat_, one hour), appOfRequest, app token as the git read passwordmre
  • 1997e77dgitoria#40: stable PR numbers, refs/pull/N/head, ssh pushes reach the app (merge w40-pr-number)mre
  • 9364fb16gitoria#40: ssh pushes call /__git/pushed before and after (ensurePulls, notifyPush, syncPulls); gate over the sshd imagemre
  • fdb9ed28gitoria#41: repo owners can connect an app (merge w41-apps-connect)mre
  • 2ef23df0gitoria#40: the browser gate reads the title without the #Nmre
  • 9af07ecegitoria#41: connect an app to a repo (apps table, connect flow, manual add, allow-list, settings)mre
  • b9137ff0gitoria#40: pull requests are stored with a number, refs/pull/N/head, syncPulls and pullObject; /pulls shows #Nmre
  • 06d622daown image tag gitoria-runtime:debian12 for gitoria and standby (shared tag lost git)mre
  • 20caa33agitoria#37: media queries in the language's @media block (minWidth = '60rem') in list, codebrowser and repomre
  • c4175e6dgitoria: a startup error prints its message before exit 1 (hybriel#247)mre
  • c50d17efKeep function-route not-found style in shared stylesheetmre
  • e42d78d3Preserve ticket state CSS and document function-route style gapmre
  • c6b7154eWIP gitoria#26: move styles into nested component blocksmre
  • 77a2c31cgitoria#31: plain declarations instead of needless let in lib/ and tools/ (103 let removed, 137 kept because reassigned); no other changemre