gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit2ef23df02ef23df0gitoria#40: the browser gate reads the title without the #Nmre2ef23df0/components/settings.hl

7.6 KB

  1. // components/settings.hl — THE SETTINGS of a repo (gitoria#18): `/settings` on <slug>.<domain>. For now one section,
  2. // "Tickets": connect the repo to a tickets.worldapi.org project (the owner clicks "Tickets: connect", tickets asks which
  3. // project, and brings them back — lib/api.hl /settings/connect and /settings/connected; lib/tickets.hl). Anyone sees
  4. // whether the repo is connected; only the owner sees the buttons. Rendered on the server from the request's host.
  5. // (The main branch is switched on the code page.)
  6. parent './repo.hl'
  7. import { siteName } from '../project.hl'
  8. import { slugOfRequest } from '../lib/orgs.hl'
  9. import { userOfSession, userIdOfSession } from '../lib/users.hl'
  10. import { titleSlug, repoAt, ownsRepo, setTicketsConnection, setRepoPriv, membersOf, changeMember } from '../lib/repos.hl'
  11. import { px } from '../lib/util.hl'
  12. import { pageTitle } from '../lib/repos-helpers.hl'
  13. import { ticketsUrl } from '../lib/tickets-helpers.hl'
  14. host = null
  15. orepo = ''
  16. session = null
  17. slug = slugOfRequest(host, orepo)
  18. repo = repoAt(slug, session)
  19. hasRepo = repo != null
  20. pre = px(slug)
  21. connectHref = pre + '/settings/connect'
  22. isOwner = repo != null && ownsRepo(slug, session)
  23. connected = repo != null && repo.ticketsOn
  24. notConnected = repo != null && !repo.ticketsOn
  25. projectTitle = repo != null ? repo.ticketsTitle : ''
  26. projectHref = repo != null && repo.ticketsOn ? ticketsUrl + '/projects/' + repo.ticketsProject : ''
  27. connectNote = session != null && session.data != null && session.data.connectNote != null ? session.data.connectNote : ''
  28. hasConnectNote = connectNote != ''
  29. notOwnerHint = repo != null && !isOwner
  30. settingsError = ''
  31. forgetClass = repo != null && repo.ticketsOn ? 'quiet' : 'nomerge'
  32. __title = pageTitle(siteName, titleSlug(host, orepo, session), 'Settings')
  33. // VISIBILITY AND MEMBERS (GO34): the owner makes the repo private / public and keeps the member list (people who see a private repo and may push)
  34. isPrivate = repo != null && repo.isPrivate
  35. ownPriv = repo != null && repo.isPrivate && !repo.inOrg
  36. privText = repo == null ? '' : (repo.isPrivate ? 'This repository is private: only its owner and its members can see it.' : 'This repository is public: everybody can read it.')
  37. privButton = repo != null && repo.isPrivate ? 'Make public' : 'Make private'
  38. listed = isOwner ? membersOf('r', slug, userIdOfSession(session)) : null
  39. members = listed != null && listed.members != null ? listed.members : []
  40. noMembers = isOwner && members.length == 0
  41. memberName = ''
  42. memberError = ''
  43. View {
  44. repoPage {
  45. if (hasRepo) {
  46. repoSettings { id = "settings"
  47. section { id = "visibility"
  48. h2 { "Visibility" }
  49. p { id = "privtext" privText }
  50. if (isOwner) { button { id = "togglepriv" type = "button" privButton on click(e) { emit togglePriv() } } }
  51. if (isOwner) {
  52. h2 { "Members" }
  53. p { class = "muted" "Members see this repository even when it is private, and may push to it. Add somebody by the display name they chose." }
  54. if (noMembers) { p { id = "nomembers" class = "empty" "No members yet." } }
  55. ul { id = "members"
  56. for (m of members) {
  57. li { span { class = "slug" m.name } button { class = "quiet" type = "button" "Remove" on click(e) { emit removeMember(m.name) } } }
  58. }
  59. }
  60. form { id = "memberform"
  61. on submit(e) {
  62. e.preventDefault()
  63. emit addMember(e)
  64. }
  65. label { "Display name"
  66. input { id = "membername" name = "membername" required = "required" maxlength = "60" autocomplete = "off" }
  67. }
  68. button { id = "memberadd" type = "submit" "Add member" }
  69. p { id = "membererror" class = "message" memberError }
  70. }
  71. }
  72. }
  73. section { id = "ticketsettings"
  74. h2 { "Tickets" }
  75. if (hasConnectNote) { p { id = "connectnote" class = "message" connectNote } }
  76. if (connected) {
  77. p { id = "connectedto" "Connected to the tickets project " a { id = "projectlink" href = projectHref projectTitle } "." }
  78. }
  79. if (notConnected) { p { id = "notconnected" class = "muted" "This repository is not connected to a tickets project yet." } }
  80. if (isOwner) {
  81. p {
  82. a { id = "connecttickets" class = "button" href = connectHref "Tickets: connect" }
  83. }
  84. button { id = "disconnecttickets" class = forgetClass type = "button" "Forget the connection" on click(e) { emit disconnect() } }
  85. p { class = "muted" "Connecting asks tickets which project (you must be its admin there). Tickets can also disconnect gitoria from its side." }
  86. }
  87. if (notOwnerHint) { p { id = "ownerhint" class = "muted" "Only the owner of this repository can connect it." } }
  88. p { id = "settingserror" class = "message" settingsError }
  89. }
  90. }
  91. }
  92. }
  93. }
  94. on togglePriv() {
  95. memberError = ''
  96. r = emit server gitoriaSetPrivate(slug, !isPrivate)
  97. if (r == null || r.error != null) {
  98. memberError = r != null ? r.error : 'could not change the visibility'
  99. return null
  100. }
  101. isPrivate = r.repo.isPrivate
  102. privText = isPrivate ? 'This repository is private: only its owner and its members can see it.' : 'This repository is public: everybody can read it.'
  103. privButton = isPrivate ? 'Make public' : 'Make private'
  104. }
  105. on addMember(e) {
  106. memberError = ''
  107. r = emit server gitoriaChangeMember(slug, e.target.elements.membername.value, true)
  108. if (r == null || r.error != null) {
  109. memberError = r != null ? r.error : 'could not add the member'
  110. return null
  111. }
  112. members = r.members
  113. noMembers = members.length == 0
  114. e.target.elements.membername.value = ''
  115. }
  116. on removeMember(name) {
  117. memberError = ''
  118. r = emit server gitoriaChangeMember(slug, name, false)
  119. if (r == null || r.error != null) {
  120. memberError = r != null ? r.error : 'could not remove the member'
  121. return null
  122. }
  123. members = r.members
  124. noMembers = members.length == 0
  125. }
  126. on server gitoriaSetPrivate(slugOf, priv, session) {
  127. return setRepoPriv(userIdOfSession(session), slugOf, priv)
  128. }
  129. on server gitoriaChangeMember(slugOf, name, add, session) {
  130. return changeMember(userIdOfSession(session), 'r', slugOf, name, add)
  131. }
  132. on disconnect() {
  133. settingsError = ''
  134. r = emit server gitoriaDisconnectTickets(slug)
  135. if (r == null || r.error != null) {
  136. settingsError = r != null ? r.error : 'could not disconnect'
  137. return null
  138. }
  139. connected = false
  140. notConnected = true
  141. forgetClass = 'nomerge'
  142. projectTitle = ''
  143. projectHref = ''
  144. }
  145. on server gitoriaDisconnectTickets(slugOf, session) {
  146. if (session == null || repoAt(slugOf, session) == null) { return { error = 'could not disconnect' } }
  147. if (userOfSession(session) == null || !ownsRepo(slugOf, session)) { return { error = 'only the owner can change this' } }
  148. r = setTicketsConnection(slugOf, '', '', '', '')
  149. if (r.error != null) { return { error = r.error } }
  150. return { ok = true }
  151. }
  152. Style {
  153. repoSettings {
  154. display = 'grid'
  155. gap = '1rem'
  156. minWidth = '0'
  157. '> *' {
  158. margin = '0'
  159. }
  160. }
  161. #ticketsettings {
  162. display = 'grid'
  163. gap = '.75rem'
  164. justifyItems = 'start'
  165. '> *' {
  166. margin = '0'
  167. }
  168. }
  169. '#disconnecttickets.nomerge' {
  170. display = 'none'
  171. }
  172. #connecttickets {
  173. color = 'var(--color-accent-text)'
  174. background = 'var(--color-accent)'
  175. }
  176. #members {
  177. listStyle = 'none'
  178. margin = '0'
  179. padding = '0'
  180. display = 'grid'
  181. gap = '.25rem'
  182. maxWidth = '32rem'
  183. li {
  184. display = 'flex'
  185. alignItems = 'center'
  186. justifyContent = 'space-between'
  187. gap = '.75rem'
  188. minHeight = '2.75rem'
  189. padding = '0 .5rem 0 1rem'
  190. background = 'var(--color-surface)'
  191. borderRadius = 'var(--radius-large)'
  192. }
  193. }
  194. #memberform {
  195. display = 'grid'
  196. gap = '.75rem'
  197. margin = '.75rem 0 1.5rem'
  198. maxWidth = '32rem'
  199. }
  200. #togglepriv {
  201. justifySelf = 'start'
  202. }
  203. #visibility {
  204. display = 'grid'
  205. gap = '.75rem'
  206. margin = '0 0 1.5rem'
  207. }
  208. }

Branches

Latest commits

  • 2ef23df0gitoria#40: the browser gate reads the title without the #Nmre
  • b9137ff0gitoria#40: pull requests are stored with a number, refs/pull/N/head, syncPulls and pullObject; /pulls shows #Nmre
  • 06d622daown image tag gitoria-runtime:debian12 for gitoria and standby (shared tag lost git)mre
  • 20caa33agitoria#37: media queries in the language's @media block (minWidth = '60rem') in list, codebrowser and repomre
  • c4175e6dgitoria: a startup error prints its message before exit 1 (hybriel#247)mre
  • c50d17efKeep function-route not-found style in shared stylesheetmre
  • e42d78d3Preserve ticket state CSS and document function-route style gapmre
  • c6b7154eWIP gitoria#26: move styles into nested component blocksmre
  • 77a2c31cgitoria#31: plain declarations instead of needless let in lib/ and tools/ (103 let removed, 137 kept because reassigned); no other changemre
  • 4b98ab62gitoria: an ident access key (idt_) works as the git password; read key clones only, bad key 401, ident down 503 (ident#27); gate tests/ident-access-gitoria.mjs in deploy.shmre
  • 1185f686gitoria#36: a failed return from tickets shows a note on the settings page and leaves one log line per outcome; no code is exchangedmre
  • 5d2c385agitoria: the sign-in callback keeps the session it finds and signs it in (same cookie, nothing signed out; ident#28); security gate 71+5 failing → 76 passed; deploy.sh runs tests/private.mjs toomre
  • 241ef3f9deploy.sh: rebuild the sshd image before up -d (GO34c)mre
  • 821cdbb1gitoria#34b: styles, create-repo tool, docs, push/ssh gates sign in through the selector, shots scriptmre
  • 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