gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit34143d2c34143d2cgitoria#46: closing brace of appComments lost in the mergemre34143d2c/components/orglist.hl

4.6 KB

  1. // components/orglist.hl — THE ADDRESS OF AN ORGANIZATION (ticket gitoria#34, GO34): `/` on <org>.<domain> lists the organization's repos
  2. // (the ones the viewer may see), newest first; every repo opens at <org>.<domain>/<repo> and looks like a repo page on <repo>.<domain>.
  3. // The organization's owner sees whether it is private (every repo of it is then private, also new ones) and can switch that.
  4. // Composed into components/index.hl when the host is an organization the viewer may see.
  5. import { slugOfHost } from '../lib/util.hl'
  6. import { orgFor, orgRepoRows, setOrgPrivate, membersOf, changeMember } from '../lib/repos.hl'
  7. import { userIdOfSession } from '../lib/users.hl'
  8. host = null
  9. session = null
  10. org = slugOfHost(host)
  11. orgRow = orgFor(org, userIdOfSession(session))
  12. isOwner = orgRow != null && userIdOfSession(session) != null && orgRow.owner == userIdOfSession(session)
  13. isPrivate = orgRow != null && orgRow.priv == true
  14. privText = isPrivate ? 'This organization is private: only its owner and its members can see it and its repositories.' : 'This organization is public.'
  15. privButton = isPrivate ? 'Make public' : 'Make private'
  16. repos = orgRow != null ? orgRepoRows(org, userIdOfSession(session)) : []
  17. noRepos = repos.length == 0
  18. listed = isOwner ? membersOf('o', org, userIdOfSession(session)) : null
  19. members = listed != null && listed.members != null ? listed.members : []
  20. noMembers = isOwner && members.length == 0
  21. orgError = ''
  22. View {
  23. orgPage {
  24. h1 { id = "orgname" org }
  25. p { id = "orgprivtext" class = "muted" privText }
  26. if (isOwner) { button { id = "toggleorgpriv" type = "button" privButton on click(e) { emit toggleOrgPriv() } } }
  27. h2 { "Repositories" }
  28. if (noRepos) { p { id = "empty" class = "empty" "No repository in this organization yet." } }
  29. ol { id = "repos"
  30. for (r of repos) {
  31. li {
  32. a { class = "slug" href = r.address r.slug }
  33. if (r.isPrivate) { span { class = "muted" "Private" } }
  34. if (r.described) { span { class = "about" r.description } }
  35. repoMeta { span { r.owner } time { r.created } }
  36. }
  37. }
  38. }
  39. if (isOwner) {
  40. h2 { "Members" }
  41. p { class = "muted" "Members see the organization's repositories even when it is private, and may push to them. Add somebody by the display name they chose." }
  42. if (noMembers) { p { id = "nomembers" class = "empty" "No members yet." } }
  43. ul { id = "members"
  44. for (m of members) {
  45. li { span { class = "slug" m.name } button { class = "quiet" type = "button" "Remove" on click(e) { emit removeMember(m.name) } } }
  46. }
  47. }
  48. form { id = "memberform"
  49. on submit(e) {
  50. e.preventDefault()
  51. emit addMember(e)
  52. }
  53. label { "Display name"
  54. input { id = "membername" name = "membername" required = "required" maxlength = "60" autocomplete = "off" }
  55. }
  56. button { id = "memberadd" type = "submit" "Add member" }
  57. }
  58. }
  59. p { id = "orgerror" class = "message" orgError }
  60. }
  61. }
  62. on toggleOrgPriv() {
  63. orgError = ''
  64. r = emit server gitoriaSetOrgPrivate(org, !isPrivate)
  65. if (r == null || r.error != null) {
  66. orgError = r != null ? r.error : 'could not change the visibility'
  67. return null
  68. }
  69. isPrivate = !isPrivate
  70. privText = isPrivate ? 'This organization is private: only its owner and its members can see it and its repositories.' : 'This organization is public.'
  71. privButton = isPrivate ? 'Make public' : 'Make private'
  72. }
  73. on addMember(e) {
  74. orgError = ''
  75. r = emit server gitoriaChangeOrgMember(org, e.target.elements.membername.value, true)
  76. if (r == null || r.error != null) {
  77. orgError = r != null ? r.error : 'could not add the member'
  78. return null
  79. }
  80. members = r.members
  81. noMembers = members.length == 0
  82. e.target.elements.membername.value = ''
  83. }
  84. on removeMember(name) {
  85. orgError = ''
  86. r = emit server gitoriaChangeOrgMember(org, name, false)
  87. if (r == null || r.error != null) {
  88. orgError = r != null ? r.error : 'could not remove the member'
  89. return null
  90. }
  91. members = r.members
  92. noMembers = members.length == 0
  93. }
  94. on server gitoriaSetOrgPrivate(orgSlug, priv, session) {
  95. return setOrgPrivate(userIdOfSession(session), orgSlug, priv)
  96. }
  97. on server gitoriaChangeOrgMember(orgSlug, name, add, session) {
  98. return changeMember(userIdOfSession(session), 'o', orgSlug, name, add)
  99. }
  100. Style {
  101. #members {
  102. listStyle = 'none'
  103. margin = '0'
  104. padding = '0'
  105. display = 'grid'
  106. gap = '.25rem'
  107. maxWidth = '32rem'
  108. li {
  109. display = 'flex'
  110. alignItems = 'center'
  111. justifyContent = 'space-between'
  112. gap = '.75rem'
  113. minHeight = '2.75rem'
  114. padding = '0 .5rem 0 1rem'
  115. background = 'var(--color-surface)'
  116. borderRadius = 'var(--radius-large)'
  117. }
  118. }
  119. #memberform {
  120. display = 'grid'
  121. gap = '.75rem'
  122. margin = '.75rem 0 1.5rem'
  123. maxWidth = '32rem'
  124. }
  125. #toggleorgpriv {
  126. justifySelf = 'start'
  127. }
  128. }

Branches

Latest commits

  • 34143d2cgitoria#46: closing brace of appComments lost in the mergemre
  • 54927c9cgitoria#46: PR statuses and required checks before merge (merge w46-status)mre
  • 187e1871gitoria#46: badges without decorative bordersmre
  • 6b022798gitoria#46: tests/status.mjs in GATESmre
  • c6162f00gitoria#46: status badges on /pulls, Required before merge in Settingsmre
  • e5a0b64egitoria#46: PUT statuses/<sha>, required contexts block the merge on the servermre
  • 26a140e3gitoria#44: reviews, inline threads, replies, conversation for apps (merge w44-reviews)mre
  • 888dbf87gitoria#44: unknown API paths answer the contract's JSON 404 and sit above the page routesmre
  • ea587d90gitoria#44: reviews with inline threads, replies, resolve and the PR conversation for apps (lib/reviews.hl, tests/reviews.mjs)mre
  • 49533a50gitoria#43: signed events to connected apps (merge w43-events)mre
  • 1a1e87d5gitoria#43: the sender never writes the apps row; Settings shows the newest deliverymre
  • cd442066gitoria#43: app-auth unit test reads the apps table from its new filemre
  • 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