gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit1ce7ac241ce7ac24Reference ticket row and feedback styles from its Viewmre1ce7ac24/components/orglist.hl

5.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. memberName = ''
  22. orgError = ''
  23. View {
  24. orgPage {
  25. h1 { id = "orgname" org }
  26. p { id = "orgprivtext" class = "muted" privText }
  27. if (isOwner) { button { id = "toggleorgpriv" type = "button" privButton on click(e) { emit toggleOrgPriv() } } }
  28. h2 { "Repositories" }
  29. if (noRepos) { p { id = "empty" class = "empty" "No repository in this organization yet." } }
  30. ol { id = "repos"
  31. for (r of repos) {
  32. li {
  33. a { Style.aOrgSlug href = r.address r.slug }
  34. if (r.isPrivate) { span { class = "muted" "Private" } }
  35. if (r.described) { span { Style.spanOrgAbout r.description } }
  36. repoMeta {
  37. display = 'flex'
  38. flexWrap = 'wrap'
  39. gap = '.2rem 1rem'
  40. fontSize = '.875rem'
  41. color = 'var(--color-text-muted)'
  42. }
  43. }
  44. }
  45. }
  46. if (isOwner) {
  47. h2 { "Members" }
  48. 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." }
  49. if (noMembers) { p { id = "nomembers" class = "empty" "No members yet." } }
  50. ul { id = "members"
  51. for (m of members) {
  52. li { span { class = "slug" m.name } button { class = "quiet" type = "button" "Remove" on click(e) { emit removeMember(m.name) } } }
  53. }
  54. }
  55. form { id = "memberform"
  56. on submit(e) {
  57. e.preventDefault()
  58. emit addMember(e)
  59. }
  60. label { "Display name"
  61. input { id = "membername" name = "membername" required = "required" maxlength = "60" autocomplete = "off" value = memberName on input(e) { memberName = e.target.value } }
  62. }
  63. button { id = "memberadd" type = "submit" "Add member" }
  64. }
  65. }
  66. p { id = "orgerror" orgError }
  67. }
  68. }
  69. on toggleOrgPriv() {
  70. orgError = ''
  71. r = emit server gitoriaSetOrgPrivate(org, !isPrivate)
  72. if (r == null || r.error != null) {
  73. orgError = r != null ? r.error : 'could not change the visibility'
  74. return null
  75. }
  76. isPrivate = !isPrivate
  77. privText = isPrivate ? 'This organization is private: only its owner and its members can see it and its repositories.' : 'This organization is public.'
  78. privButton = isPrivate ? 'Make public' : 'Make private'
  79. }
  80. on addMember(e) {
  81. orgError = ''
  82. r = emit server gitoriaChangeOrgMember(org, memberName, true)
  83. if (r == null || r.error != null) {
  84. orgError = r != null ? r.error : 'could not add the member'
  85. return null
  86. }
  87. members = r.members
  88. noMembers = members.length == 0
  89. memberName = ''
  90. }
  91. on removeMember(name) {
  92. orgError = ''
  93. r = emit server gitoriaChangeOrgMember(org, name, false)
  94. if (r == null || r.error != null) {
  95. orgError = r != null ? r.error : 'could not remove the member'
  96. return null
  97. }
  98. members = r.members
  99. noMembers = members.length == 0
  100. }
  101. on server gitoriaSetOrgPrivate(orgSlug, priv, session) {
  102. return setOrgPrivate(userIdOfSession(session), orgSlug, priv)
  103. }
  104. on server gitoriaChangeOrgMember(orgSlug, name, add, session) {
  105. return changeMember(userIdOfSession(session), 'o', orgSlug, name, add)
  106. }
  107. Style {
  108. #members {
  109. listStyle = 'none'
  110. margin = '0'
  111. padding = '0'
  112. display = 'grid'
  113. gap = '.25rem'
  114. maxWidth = '32rem'
  115. li {
  116. display = 'flex'
  117. alignItems = 'center'
  118. justifyContent = 'space-between'
  119. gap = '.75rem'
  120. minHeight = '2.75rem'
  121. padding = '0 .5rem 0 1rem'
  122. background = 'var(--color-surface)'
  123. borderRadius = 'var(--radius-large)'
  124. }
  125. }
  126. #memberform {
  127. display = 'grid'
  128. gap = '.75rem'
  129. margin = '.75rem 0 1.5rem'
  130. maxWidth = '32rem'
  131. }
  132. #toggleorgpriv {
  133. justifySelf = 'start'
  134. }
  135. #repos {
  136. display = 'grid'
  137. gap = '.5rem'
  138. margin = '0'
  139. padding = '0'
  140. listStyle = 'none'
  141. li {
  142. display = 'grid'
  143. gap = '.1rem'
  144. margin = '0'
  145. padding = '.25rem 1rem .6rem'
  146. background = 'var(--color-surface)'
  147. borderRadius = 'var(--radius-large)'
  148. @media {
  149. minWidth = '60rem'
  150. gridTemplateColumns = 'minmax(10rem, 16rem) 1fr auto'
  151. alignItems = 'center'
  152. gap = '.15rem 1rem'
  153. padding = '.25rem 1rem'
  154. }
  155. }
  156. }
  157. repoMeta {
  158. display = 'flex'
  159. flexWrap = 'wrap'
  160. gap = '.2rem 1rem'
  161. fontSize = '.875rem'
  162. color = 'var(--color-text-muted)'
  163. }
  164. aOrgSlug {
  165. display = 'flex'
  166. alignItems = 'center'
  167. minHeight = '2.75rem'
  168. fontWeight = '700'
  169. fontSize = '1.05rem'
  170. overflowWrap = 'anywhere'
  171. }
  172. spanOrgAbout {
  173. color = 'var(--color-text)'
  174. }
  175. #orgerror {
  176. margin = '0'
  177. color = 'var(--color-danger)'
  178. empty { display = 'none' }
  179. }
  180. }

Branches

Latest commits

  • 1ce7ac24Reference ticket row and feedback styles from its Viewmre
  • 10cdf54bGive organization repository rows their own Style referencesmre
  • 0d019521Document shared class selectors in the styles-only filemre
  • c67404a7Scope token labels and feedback through the token Viewmre
  • 944e3dabScope key names, fingerprints and errors to the keys Viewmre
  • 7bcf7bc2Nest repo navigation media rules and document selector gapsmre
  • 46a76272Reference release row styles from the Viewmre
  • a383f428Tie README definition and path styles to its own Viewmre
  • a90812ffConsolidate add-code styles under its existing View idmre
  • 89107a3eDocument the index direct-child selector remaindermre
  • 07403362Scope reply form layout through the component form rulemre
  • 097c52baStyle the login error through its View idmre
  • c6d9c86aOwn the not-found code rule in its componentmre
  • 055424c2Record W61 replacement theme gates, sidebar repro and baselinemre
  • 2ed09441Use layouts theme 17e0f03 for W61 compatibilitymre
  • b8609a91Merge branch 'main' into w61-stylemre
  • 4639caf7Report W61 theme startup blocker and day39 Style probemre
  • 81f0a0bbREADME: two caches were restored by 90b4f72; log W62mre
  • 4a3f557eImport layouts theme ebd00b6 for W61 (startup blocked)mre
  • ab12a257Merge W62: #25 commit page measurements and proc repromre