gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit4639caf74639caf7Report W61 theme startup blocker and day39 Style probemre4639caf7/components/list.hl

8.3 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. // The ack may already sync orgs from session; prepend this slug only once.
  132. next = [{ slug = r.org.slug isPrivate = r.org.isPrivate isPublic = !r.org.isPrivate address = r.address }]
  133. for (x of orgs) { if (x.slug != r.org.slug) { next.push(x) } }
  134. orgs = next
  135. hasOrgs = true
  136. }
  137. // this session's tabs follow a login / name / logout (the shell's faces push them)
  138. on client gitoriaSignedIn(tag, info) {
  139. canCreate = info.named
  140. needsLogin = false
  141. }
  142. on client gitoriaSignedOut(tag) {
  143. canCreate = false
  144. needsLogin = true
  145. }
  146. // a new repo, from any session: the list follows live
  147. on client repoCreated(row) {
  148. next = [row]
  149. for (x of repos) { if (x.id != row.id) { next.push(x) } }
  150. repos = next
  151. noRepos = false
  152. }
  153. on server gitoriaCreate(slug, description, session) {
  154. return makeRepo(slug, description, '', false, session)
  155. }
  156. on server gitoriaCreateRepo(slug, description, org, priv, session) {
  157. return makeRepo(slug, description, org, priv, session)
  158. }
  159. on server gitoriaCreateOrg(slug, priv, session) {
  160. u = userOfSession(session)
  161. if (u == null) { return { error = 'log in with ident (top right) first' } }
  162. r = createOrg(u.id, slug, priv)
  163. if (r.error != null) { return { error = r.error } }
  164. return { org = r.org address = repoOrigin(r.org.slug) + '/' }
  165. }
  166. makeRepo = (slug, description, org, priv, session) => {
  167. u = userOfSession(session)
  168. if (u == null) { return { error = 'log in with ident (top right) to create a repository' } }
  169. r = createRepoIn(u.id, org, slug, description, priv)
  170. if (r.error != null) { return { error = r.error } }
  171. return r
  172. }
  173. Style {
  174. repoList {
  175. display = 'grid'
  176. gap = '1rem'
  177. minWidth = '0'
  178. '> *' {
  179. margin = '0'
  180. }
  181. }
  182. #createform {
  183. display = 'grid'
  184. gap = '.75rem'
  185. padding = '1rem'
  186. background = 'var(--color-surface)'
  187. borderRadius = 'var(--radius-large)'
  188. '> *' {
  189. margin = '0'
  190. }
  191. }
  192. #repos {
  193. display = 'grid'
  194. gap = '.5rem'
  195. margin = '0'
  196. padding = '0'
  197. listStyle = 'none'
  198. li {
  199. display = 'grid'
  200. gap = '.1rem'
  201. margin = '0'
  202. padding = '.25rem 1rem .6rem'
  203. background = 'var(--color-surface)'
  204. borderRadius = 'var(--radius-large)'
  205. }
  206. '.slug' {
  207. display = 'flex'
  208. alignItems = 'center'
  209. minHeight = '2.75rem'
  210. fontWeight = '700'
  211. fontSize = '1.05rem'
  212. overflowWrap = 'anywhere'
  213. }
  214. '.about' {
  215. color = 'var(--color-text)'
  216. }
  217. }
  218. repoMeta {
  219. display = 'flex'
  220. flexWrap = 'wrap'
  221. gap = '.2rem 1rem'
  222. fontSize = '.875rem'
  223. color = 'var(--color-text-muted)'
  224. }
  225. @media {
  226. minWidth = '60rem'
  227. #repos {
  228. li {
  229. gridTemplateColumns = 'minmax(10rem, 16rem) 1fr auto'
  230. alignItems = 'center'
  231. gap = '.15rem 1rem'
  232. padding = '.25rem 1rem'
  233. }
  234. }
  235. }
  236. #orgform {
  237. display = 'grid'
  238. gap = '.75rem'
  239. padding = '1rem'
  240. margin = '1rem 0'
  241. background = 'var(--color-surface)'
  242. borderRadius = 'var(--radius-large)'
  243. }
  244. #orgs {
  245. listStyle = 'none'
  246. margin = '0'
  247. padding = '0'
  248. display = 'grid'
  249. gap = '.1rem'
  250. li {
  251. display = 'flex'
  252. alignItems = 'center'
  253. gap = '.75rem'
  254. minHeight = '2.75rem'
  255. }
  256. }
  257. }

Branches

Latest commits

  • 4639caf7Report W61 theme startup blocker and day39 Style probemre
  • 4a3f557eImport layouts theme ebd00b6 for W61 (startup blocked)mre
  • 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
  • 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