gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit1a687b151a687b15Merge branch 'w48-member-merge'mre1a687b15/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. return r
  165. }
  166. Style {
  167. repoList {
  168. display = 'grid'
  169. gap = '1rem'
  170. minWidth = '0'
  171. '> *' {
  172. margin = '0'
  173. }
  174. }
  175. #createform {
  176. display = 'grid'
  177. gap = '.75rem'
  178. padding = '1rem'
  179. background = 'var(--color-surface)'
  180. borderRadius = 'var(--radius-large)'
  181. '> *' {
  182. margin = '0'
  183. }
  184. }
  185. #repos {
  186. display = 'grid'
  187. gap = '.5rem'
  188. margin = '0'
  189. padding = '0'
  190. listStyle = 'none'
  191. li {
  192. display = 'grid'
  193. gap = '.1rem'
  194. margin = '0'
  195. padding = '.25rem 1rem .6rem'
  196. background = 'var(--color-surface)'
  197. borderRadius = 'var(--radius-large)'
  198. }
  199. '.slug' {
  200. display = 'flex'
  201. alignItems = 'center'
  202. minHeight = '2.75rem'
  203. fontWeight = '700'
  204. fontSize = '1.05rem'
  205. overflowWrap = 'anywhere'
  206. }
  207. '.about' {
  208. color = 'var(--color-text)'
  209. }
  210. }
  211. repoMeta {
  212. display = 'flex'
  213. flexWrap = 'wrap'
  214. gap = '.2rem 1rem'
  215. fontSize = '.875rem'
  216. color = 'var(--color-text-muted)'
  217. }
  218. @media {
  219. minWidth = '60rem'
  220. #repos {
  221. li {
  222. gridTemplateColumns = 'minmax(10rem, 16rem) 1fr auto'
  223. alignItems = 'center'
  224. gap = '.15rem 1rem'
  225. padding = '.25rem 1rem'
  226. }
  227. }
  228. }
  229. #orgform {
  230. display = 'grid'
  231. gap = '.75rem'
  232. padding = '1rem'
  233. margin = '1rem 0'
  234. background = 'var(--color-surface)'
  235. borderRadius = 'var(--radius-large)'
  236. }
  237. #orgs {
  238. listStyle = 'none'
  239. margin = '0'
  240. padding = '0'
  241. display = 'grid'
  242. gap = '.1rem'
  243. li {
  244. display = 'flex'
  245. alignItems = 'center'
  246. gap = '.75rem'
  247. minHeight = '2.75rem'
  248. }
  249. }
  250. }

Branches

Latest commits

  • 1a687b15Merge branch 'w48-member-merge'mre
  • 166c775fW48 report, logmre
  • 1b4623f0Members merge pull requests: API route, button on /pulls and /pulls/N, one shared merge pathmre
  • 1075c38cW48 mission, logmre
  • 17bdd0d6V37/V39 missions, logmre
  • 146de5f8Re-vendor gitoria to Hybriel set-day39 (51e921d7)mre
  • e874e44dtests/status-keyed: app token lives 60 s so it outlives the gate's two restartsmre
  • 270b8d61deploy.sh: DEPLOY_STOP_START=1 stops, waits for the old pid, then starts (mpackdb freeze, replaces the standby swap)mre
  • 3f9235b8project.hl: drop the dummy /pulls/:n component route (hybriel#294 is fixed in day37)mre
  • c90daf19Re-vendor gitoria to Hybriel set-day37 (f6b3d45b)mre
  • 03b5bb08W39 report to reports/, drop scratch repro, mission + logmre
  • 154d333fMerge w39-create-api: POST /api/repos with a user token (#39)mre
  • 149dd512Rewrite W39 reportmre
  • e5385075Expect 401 for POST /api/repos without a tokenmre
  • 1a76055cDocument repository creation APImre
  • 4d779b3bAdd create-api gatemre
  • 88563122Add POST /api/repos for user tokensmre
  • b00860e3Create repositories with member checks in createRepoInmre
  • 0a38f236Report repository creation API blockermre
  • b5f72187Record malformed JSON blocker for repository creationmre