gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit24b479e724b479e7W60: record final gates, Chrome failures and AE evidencemre24b479e7/components/list.hl

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

Branches

Latest commits

  • 24b479e7W60: record final gates, Chrome failures and AE evidencemre
  • 5e11184cW60: record partial validation, framework gaps and cleanupmre
  • 20fe13fagitoria#33: centralize login and tickets connection statemre
  • 859754c0gitoria#29: retain the offline note and record the framework gapmre
  • d140bc04gitoria#30: reproduce the upsert ordering constraintmre
  • 6960e8f8gitoria#28: keep form values in bound component membersmre
  • 0db27200gitoria#32: share character checks and environment lookupmre
  • 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