gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commita81abdc9a81abdc9gitoria#34: org page via function route, member-reachable orgs, selects, reportmrea81abdc9/components/orglist.hl

4.1 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. }

Branches

Latest commits

  • a81abdc9gitoria#34: org page via function route, member-reachable orgs, selects, reportmre
  • 17f031f0gitoria#34: private repos, organizations, members, move tool, gatemre
  • 71b69343gitoria#23: the sidebar's Repositories link was a 404 after any in-page navigation (static menu re-evaluated publicUrl in the browser); the menu is an instance property now; gate taps it after a tab, folder, filemre
  • 90b4f728gitoria#25: restore the homepage cache and the parsed-blocks cache (they store data under immutable keys, no HTML); the page key, the framework readme key and the textHash key stay removedmre
  • a487248cgitoria#25: remove every cache that hid the page build (page key, Markdown render key, homepage cache, parsed-blocks cache) and the gate that only tested themmre
  • 12f2f4fegitoria: re-vendor Hybriel set-day27b, a startup fault in on Error exits 1mre
  • c21c084egitoria: write the standby service out in full so the boot gate can read the main servicemre
  • e307d69agitoria: say what is per process during the hand-overmre
  • f0cbe6a6gitoria: standby service on port 45014 and a deploy that hands over through it without a gapmre
  • 727cd083gitoria#25: README: vendor notes for Hybriel c1b1010f and the page cachemre
  • 61b72dedgitoria#25: re-vendor Hybriel master c1b1010f (W149 page cache), key the repo Readme page by slug and main commit, extend the readme-cache gatemre
  • 5b0b4b9ereadme-cache gate: use the security gate's ports when no own ports are givenmre
  • bc8f20d9gitoria#25: re-vendor Hybriel c09538bb with the W141 render cache, cache the homepage per commit, add the readme-cache gatemre
  • 9feebbd3Re-vendor Hybriel to ded47c13 (W145: Firefox start script fix)mre
  • 28ed41e5gitoria#24: one sign-in comes from hl:web batch 20, the /session/share workaround is gonemre
  • 3b2669e4gs: drop the unbuildable legacy check, fix pwa fetchmre
  • 2a2fdd77gs: C2 check before cookie experimentsmre
  • 76e0587aWIP gs 2mre
  • a80da7bdWIP gs: security gate for lazy sessions, g24 browser checksmre
  • 23fb05d8re-vendor Hybriel aaa39e69 (hl:web batch 20: login emit and Sessions.mint, tab follows a login, signed-in session cookie wins among duplicates and is re-issued with the Domain, W85 faster render, lazy sessions)mre