gitoria

gitoria

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Branchw63-force-push52576cb0force push: defer on a failed scan, one-to-one pairs, docs (#56)mrew63-force-push/components/settings.hl

29.4 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. // "Apps" (gitoria#41, lib/apps.hl): the owner connects outside apps to the repo — the confirm card of connect flow A (an app sent the browser
  6. // here; lib/api.hl appConnectStart parked the request in the session), the list (Remove, Rotate secret) and Add (the manual way). Key and secret
  7. // are shown ONCE, in the page state of the click that made them.
  8. // (The main branch is switched on the code page.)
  9. parent './repo.hl'
  10. import { navigate } from 'hl:web'
  11. import { siteName } from '../project.hl'
  12. import { slugOfRequest } from '../lib/orgs.hl'
  13. import { userOfSession, userIdOfSession } from '../lib/users.hl'
  14. import { orgChoices, orgFor, confirmedTransfer, renameRepo, setRepoTitle, titleSlug, repoAt, repoBySlug, ownsRepo, setTicketsConnection, setRepoPriv, membersOf, changeMember, setProtectMain, isProtectedMain } from '../lib/repos.hl'
  15. import { px } from '../lib/util.hl'
  16. import { pageTitle } from '../lib/repos-helpers.hl'
  17. import { ticketsUrl } from '../lib/tickets-helpers.hl'
  18. import { appRows, addApp, removeApp, rotateSecret, sendPing } from '../lib/apps.hl'
  19. import { hostOfUrl } from '../lib/apps-helpers.hl'
  20. import { announceRequirements } from '../lib/prpage.hl'
  21. import { latestAppContext, requiredRule, requiredList, requireContext, requirePerson, peopleOfRepo, dropRequired } from '../lib/statuses.hl'
  22. import OrgSettings from './orgsettings.hl'
  23. host = null
  24. orepo = ''
  25. session = null
  26. slug = slugOfRequest(host, orepo)
  27. repo = repoAt(slug, session)
  28. hasRepo = repo != null
  29. onOrg = orepo == '' && orgFor(slug, userIdOfSession(session)) != null
  30. pre = px(slug)
  31. connectHref = pre + '/settings/connect'
  32. isOwner = repo != null && ownsRepo(slug, session)
  33. connected = repo != null && repo.ticketsOn
  34. notConnected = repo != null && !repo.ticketsOn
  35. projectTitle = repo != null ? repo.ticketsTitle : ''
  36. projectHref = repo != null && repo.ticketsOn ? ticketsUrl + '/projects/' + repo.ticketsProject : ''
  37. connectNote = session != null && session.data != null && session.data.connectNote != null ? session.data.connectNote : ''
  38. hasConnectNote = connectNote != ''
  39. notOwnerHint = repo != null && !isOwner
  40. settingsError = ''
  41. renameName = repo != null ? (repo.inOrg ? repo.slug.slice(repo.org.length + 1) : repo.slug) : ''
  42. displayName = repo != null ? repo.title : ''
  43. renameError = ''
  44. newOwner = ''
  45. transferConfirm = ''
  46. transferRefused = true
  47. transferError = ''
  48. renameOrg = repo != null && repo.inOrg ? repo.org : ''
  49. ownedOrgs = isOwner ? orgChoices(userIdOfSession(session)) : []
  50. foreignOrg = isOwner && repo != null && repo.inOrg && ownedOrgs.filter((Hybrid o) => { return o.slug == repo.org }).length == 0
  51. foreignOrgName = repo != null && repo.inOrg ? repo.org : ''
  52. titleError = ''
  53. forgetClass = repo != null && repo.ticketsOn ? 'quiet' : 'nomerge'
  54. titleRepo = repoAt(slugOfRequest(host, orepo), session)
  55. __title = pageTitle(siteName, titleSlug(host, orepo, session), 'Settings')
  56. // 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)
  57. isPrivate = repo != null && repo.isPrivate
  58. ownPriv = repo != null && repo.isPrivate && !repo.inOrg
  59. 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.')
  60. privButton = repo != null && repo.isPrivate ? 'Make public' : 'Make private'
  61. // REFUSE DIRECT PUSHES TO THE MAIN BRANCH (gitoria#50): the owner's switch; off by default
  62. isProtected = repo != null && isProtectedMain(slug)
  63. protectText = isProtected ? 'Direct pushes to the main branch are refused: push a branch with a |||PR commit and merge it on the pulls page.' : 'Anybody who may push can push to the main branch.'
  64. protectButton = isProtected ? 'Allow direct pushes' : 'Refuse direct pushes to the main branch'
  65. listed = isOwner ? membersOf('r', slug, userIdOfSession(session)) : null
  66. members = listed != null && listed.members != null ? listed.members : []
  67. noMembers = isOwner && members.length == 0
  68. memberName = ''
  69. memberError = ''
  70. // APPS (gitoria#41): the owner's list; the connect request an app parked in this session (for this repo only); what was just made (shown once)
  71. apps = isOwner ? appRows(repo.id) : []
  72. noApps = isOwner && apps.length == 0
  73. parked = session != null && session.data != null && session.data.appConnect != null && repo != null && session.data.appConnect.slug == slug ? session.data.appConnect : null
  74. hasParked = parked != null
  75. parkedApp = parked != null ? parked.app : ''
  76. parkedHost = parked != null ? hostOfUrl(parked.ret) : ''
  77. parkedNonce = parked != null ? parked.nonce : ''
  78. confirmAction = pre + '/settings/apps/confirm'
  79. parkedSignedOut = hasParked && session != null && userIdOfSession(session) == null
  80. parkedNotOwner = hasParked && userIdOfSession(session) != null && !isOwner
  81. parkedOwner = hasParked && isOwner
  82. // the Apps section is the owner's; a signed-in non-owner who came to connect an app still gets its message (gitoria#45)
  83. showApps = isOwner || hasParked
  84. appName = ''
  85. appHook = ''
  86. appError = ''
  87. hasShown = false
  88. shownName = ''
  89. shownKey = ''
  90. hasShownKey = false
  91. shownSecret = ''
  92. shownText = ''
  93. // REQUIRED BEFORE MERGE (gitoria#46): the contexts the owner requires to be success on a pull request's head
  94. required = isOwner ? requiredList(repo.id) : []
  95. noRequired = isOwner && required.length == 0
  96. hasRequired = required.length > 0
  97. mergeRule = requiredRule(required)
  98. requiredApp = apps.length > 0 ? apps[0].id : ''
  99. requiredContext = isOwner ? latestAppContext(repo.id, requiredApp) : ''
  100. requiredError = ''
  101. people = isOwner ? peopleOfRepo(slug) : []
  102. requiredPerson = people.length > 0 ? people[0].id : ''
  103. View {
  104. if (onOrg) { OrgSettings { } }
  105. repoPage {
  106. if (hasRepo) {
  107. repoSettings { id = "settings"
  108. if (isOwner) {
  109. section { id = "repoIdentity"
  110. h2 { "Name" }
  111. form { id = "titleForm"
  112. on submit(Hybrid e) { emit saveTitle() }
  113. label { "Name"
  114. input { id = "displayName" name = "title" maxlength = "80" autocomplete = "off" value = displayName on input(Hybrid e) { displayName = e.target.value } }
  115. }
  116. button { id = "saveTitle" type = "submit" "Save name" }
  117. p { role = "status" titleError }
  118. }
  119. h2 { "Rename" }
  120. p { class = "muted" "The old address keeps a link here, and existing Git URLs keep working." }
  121. form { id = "renameForm"
  122. on submit(Hybrid e) { emit rename() }
  123. label { "Organization"
  124. select { id = "renameOrg" name = "org" value = renameOrg on change(Hybrid e) { renameOrg = e.target.value }
  125. option { value = "" "None (top level)" }
  126. if (foreignOrg) { option { value = foreignOrgName foreignOrgName } }
  127. for (o of ownedOrgs) { option { value = o.slug o.label } }
  128. }
  129. }
  130. label { "New address name"
  131. input { id = "renameName" name = "name" required = "required" maxlength = "40" autocomplete = "off" autocapitalize = "none" spellcheck = "false" value = renameName on input(Hybrid e) { renameName = e.target.value } }
  132. }
  133. p { class = "muted" "A repository that was private stays private; change that below." }
  134. button { id = "renameRepo" type = "submit" "Rename" }
  135. p { id = "renameError" role = "status" renameError }
  136. }
  137. }
  138. }
  139. if (isOwner) {
  140. section { id = "transferOwnership"
  141. h2 { "Transfer ownership" }
  142. p { "After the transfer you keep access only if you are a member of this repository or of its organization." }
  143. form { id = "transferForm"
  144. on submit(Hybrid e) { e.preventDefault() emit transfer() }
  145. label { "New owner (display name)"
  146. input { id = "newOwner" name = "name" required = "required" autocomplete = "off" value = newOwner on input(Hybrid e) { newOwner = e.target.value } }
  147. }
  148. label { "Type the repository name to confirm"
  149. input { id = "transferConfirm" name = "confirm" required = "required" autocomplete = "off" value = transferConfirm on input(Hybrid e) { transferConfirm = e.target.value transferRefused = transferConfirm != slug } }
  150. }
  151. p { class = "muted" slug }
  152. button { id = "transferRepo" type = "submit" disabled = transferRefused "Transfer ownership" }
  153. p { id = "transferError" role = "status" transferError }
  154. }
  155. }
  156. }
  157. section { id = "visibility"
  158. h2 { "Visibility" }
  159. p { id = "privtext" privText }
  160. if (isOwner) { button { id = "togglepriv" type = "button" privButton on click(e) { emit togglePriv() } } }
  161. p { id = "protecttext" protectText }
  162. if (isOwner) { button { id = "toggleprotect" type = "button" protectButton on click(e) { emit toggleProtect() } } }
  163. if (isOwner) {
  164. h2 { "Members" }
  165. 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." }
  166. if (noMembers) { p { id = "nomembers" class = "empty" "No members yet." } }
  167. ul { id = "members"
  168. for (m of members) {
  169. li { span { class = "slug" m.name } button { class = "quiet" type = "button" "Remove" on click(e) { emit removeMember(m.name) } } }
  170. }
  171. }
  172. form { id = "memberform"
  173. on submit(Hybrid e) {
  174. e.preventDefault()
  175. emit addMember(e)
  176. }
  177. label { "Display name"
  178. input { id = "membername" name = "membername" required = "required" maxlength = "60" autocomplete = "off" value = memberName on input(Hybrid e) { memberName = e.target.value } }
  179. }
  180. button { id = "memberadd" type = "submit" "Add member" }
  181. p { id = "membererror" memberError }
  182. }
  183. }
  184. }
  185. if (showApps) {
  186. section { id = "apps"
  187. h2 { "Apps" }
  188. if (parkedSignedOut) { p { id = "appsignin" "Sign in with the selector at the top to connect " + parkedApp + " to this repository." } }
  189. if (parkedNotOwner) { p { id = "appnotowner" "Only the owner of this repository can connect " + parkedApp + "." } }
  190. if (parkedOwner) {
  191. form { id = "connectapp" method = "post" action = confirmAction
  192. p { id = "connectask" "Connect " + parkedApp + " to " + slug + "?" }
  193. p { class = "muted" "It will get read access to this repository and may review its pull requests. When you say Yes you go back to " + parkedHost + "." }
  194. input { name = "nonce" type = "hidden" value = parkedNonce }
  195. button { id = "connectyes" type = "submit" name = "decision" value = "yes" "Yes, connect" }
  196. button { id = "connectno" class = "quiet" type = "submit" name = "decision" value = "no" "No" }
  197. }
  198. }
  199. if (hasShown) {
  200. div { id = "appshown"
  201. p { shownText }
  202. if (hasShownKey) { p { "Key: " code { id = "shownkey" shownKey } } }
  203. p { "Secret: " code { id = "shownsecret" shownSecret } }
  204. }
  205. }
  206. if (isOwner) {
  207. p { class = "muted" "An app is an outside program (for example a code reviewer) that works on this repository under its own name. Its key and secret are shown once." }
  208. if (noApps) { p { id = "noapps" class = "empty" "No apps connected." } }
  209. ul { id = "applist"
  210. for (a of apps) {
  211. li {
  212. span { class = "slug" a.name }
  213. span { class = "muted" a.host + " · added " + a.created + " · " + a.status }
  214. button { class = "quiet" type = "button" "Send ping" on click(e) { emit pingApp(a.id) } }
  215. button { class = "quiet" type = "button" "Rotate secret" on click(e) { emit rotateApp(a.id) } }
  216. button { class = "quiet" type = "button" "Remove" on click(e) { emit removeAppRow(a.id) } }
  217. }
  218. }
  219. }
  220. form { id = "appform"
  221. on submit(Hybrid e) {
  222. e.preventDefault()
  223. emit addAppRow(e)
  224. }
  225. label { "App name"
  226. input { id = "appname" name = "appname" required = "required" maxlength = "60" autocomplete = "off" value = appName on input(Hybrid e) { appName = e.target.value } }
  227. }
  228. label { "Receiver address"
  229. input { id = "apphook" name = "apphook" type = "url" required = "required" maxlength = "500" autocomplete = "off" placeholder = "https://…" value = appHook on input(Hybrid e) { appHook = e.target.value } }
  230. }
  231. button { id = "appadd" type = "submit" "Add app" }
  232. p { id = "apperror" appError }
  233. }
  234. }
  235. }
  236. }
  237. section { id = "required"
  238. if (isOwner) {
  239. h2 { "Required before merge" }
  240. p { class = "muted" "Require app contexts, people, or both. All required app contexts must succeed, or any one listed person must approve the current head. With only people listed, a person’s approval is needed. A push makes earlier approvals stale." }
  241. if (noRequired) { p { id = "norequired" class = "empty" "Nothing is required: every pull request can be merged." } }
  242. ul { id = "requiredlist"
  243. for (r of required) {
  244. li {
  245. span { class = "slug" r.name }
  246. button { class = "quiet" type = "button" "Remove" on click(e) { emit dropRequiredRow(r.id) } }
  247. }
  248. }
  249. }
  250. if (hasRequired) { p { id = "mergeRule" mergeRule } }
  251. form { id = "requiredPersonForm"
  252. h3 { "Allow a person to approve" }
  253. on submit(Hybrid e) { emit addRequiredPerson() }
  254. label { "Person"
  255. select { id = "requiredPerson" name = "person" value = requiredPerson on change(Hybrid e) { requiredPerson = e.target.value }
  256. for (person of people) { option { value = person.id person.name } }
  257. }
  258. }
  259. button { id = "requirePerson" type = "submit" "Require approval" }
  260. }
  261. form { id = "requiredform"
  262. h3 { "Require an app check" }
  263. on submit(Hybrid e) {
  264. e.preventDefault()
  265. emit addRequiredRow(e)
  266. }
  267. label { "App"
  268. select { id = "requiredapp" name = "requiredapp" value = requiredApp on change(Hybrid e) { requiredApp = e.target.value emit chooseRequiredApp() }
  269. for (a of apps) { option { value = a.id a.name } }
  270. }
  271. }
  272. label { "Status context the app sets"
  273. input { id = "requiredcontext" name = "requiredcontext" required = "required" maxlength = "100" autocomplete = "off" value = requiredContext on input(Hybrid e) { requiredContext = e.target.value } }
  274. }
  275. button { id = "requiredadd" type = "submit" "Require it" }
  276. p { id = "requirederror" requiredError }
  277. }
  278. }
  279. }
  280. section { id = "ticketsettings"
  281. h2 { "Tickets" }
  282. if (hasConnectNote) { p { id = "connectnote" connectNote } }
  283. if (connected) {
  284. p { id = "connectedto" "Connected to the tickets project " a { id = "projectlink" href = projectHref projectTitle } "." }
  285. }
  286. if (notConnected) { p { id = "notconnected" class = "muted" "This repository is not connected to a tickets project yet." } }
  287. if (isOwner) {
  288. p {
  289. a { id = "connecttickets" class = "button" href = connectHref "Tickets: connect" }
  290. }
  291. // Connection-state classes are computed and have no Style-rule selection form.
  292. button { id = "disconnecttickets" class = forgetClass type = "button" "Forget the connection" on click(e) { emit disconnect() } }
  293. p { class = "muted" "Connecting asks tickets which project (you must be its admin there). Tickets can also disconnect gitoria from its side." }
  294. }
  295. if (notOwnerHint) { p { id = "ownerhint" class = "muted" "Only the owner of this repository can connect it." } }
  296. p { id = "settingserror" settingsError }
  297. }
  298. }
  299. }
  300. }
  301. }
  302. on togglePriv() {
  303. memberError = ''
  304. r = emit server gitoriaSetPrivate(slug, !isPrivate)
  305. if (r == null || r.error != null) {
  306. memberError = r != null ? r.error : 'could not change the visibility'
  307. return null
  308. }
  309. isPrivate = r.repo.isPrivate
  310. privText = isPrivate ? 'This repository is private: only its owner and its members can see it.' : 'This repository is public: everybody can read it.'
  311. privButton = isPrivate ? 'Make public' : 'Make private'
  312. }
  313. on toggleProtect() {
  314. memberError = ''
  315. r = emit server gitoriaSetProtect(slug, !isProtected)
  316. if (r == null || r.error != null) {
  317. memberError = r != null ? r.error : 'could not change the setting'
  318. return null
  319. }
  320. isProtected = r.protect
  321. protectText = isProtected ? 'Direct pushes to the main branch are refused: push a branch with a |||PR commit and merge it on the pulls page.' : 'Anybody who may push can push to the main branch.'
  322. protectButton = isProtected ? 'Allow direct pushes' : 'Refuse direct pushes to the main branch'
  323. }
  324. on server gitoriaSetProtect(slugOf, wanted, session) {
  325. return setProtectMain(userIdOfSession(session), slugOf, wanted)
  326. }
  327. on addMember(e) {
  328. memberError = ''
  329. r = emit server gitoriaChangeMember(slug, memberName, true)
  330. if (r == null || r.error != null) {
  331. memberError = r != null ? r.error : 'could not add the member'
  332. return null
  333. }
  334. members = r.members
  335. noMembers = members.length == 0
  336. memberName = ''
  337. }
  338. on removeMember(name) {
  339. memberError = ''
  340. r = emit server gitoriaChangeMember(slug, name, false)
  341. if (r == null || r.error != null) {
  342. memberError = r != null ? r.error : 'could not remove the member'
  343. return null
  344. }
  345. members = r.members
  346. noMembers = members.length == 0
  347. }
  348. on server gitoriaSetPrivate(slugOf, priv, session) {
  349. return setRepoPriv(userIdOfSession(session), slugOf, priv)
  350. }
  351. on addAppRow(e) {
  352. appError = ''
  353. r = emit server gitoriaAppAdd(slug, appName, appHook)
  354. if (r == null || r.error != null) {
  355. appError = r != null ? r.error : 'could not add the app'
  356. return null
  357. }
  358. apps = r.rows
  359. noApps = apps.length == 0
  360. if (requiredApp == '' && apps.length > 0) { requiredApp = apps[0].id emit chooseRequiredApp() }
  361. hasShown = true
  362. shownText = 'Connected ' + r.name + '. Copy the key and the secret now: they are not shown again.'
  363. shownKey = r.key
  364. hasShownKey = true
  365. shownSecret = r.secret
  366. appName = ''
  367. appHook = ''
  368. }
  369. on removeAppRow(id) {
  370. appError = ''
  371. r = emit server gitoriaAppRemove(slug, id)
  372. if (r == null || r.error != null) {
  373. appError = r != null ? r.error : 'could not remove the app'
  374. return null
  375. }
  376. apps = r.rows
  377. noApps = apps.length == 0
  378. if (requiredApp == id) { requiredApp = apps.length > 0 ? apps[0].id : '' emit chooseRequiredApp() }
  379. hasShown = false
  380. }
  381. on pingApp(id) {
  382. appError = ''
  383. r = emit server gitoriaAppPing(slug, id)
  384. if (r == null || r.error != null) {
  385. appError = r != null ? r.error : 'could not send the ping'
  386. return null
  387. }
  388. appError = 'Ping to ' + r.name + ' is on its way. The status of the app shows the answer.'
  389. }
  390. on rotateApp(id) {
  391. appError = ''
  392. r = emit server gitoriaAppRotate(slug, id)
  393. if (r == null || r.error != null) {
  394. appError = r != null ? r.error : 'could not rotate the secret'
  395. return null
  396. }
  397. apps = r.rows
  398. hasShown = true
  399. shownText = 'New secret for ' + r.name + '. Copy it now: it is not shown again. The old secret no longer signs anything.'
  400. shownKey = ''
  401. hasShownKey = false
  402. shownSecret = r.secret
  403. }
  404. on client gitoriaRequiredChanged(String changedSlug) {
  405. if (changedSlug != slug || !isOwner) { return null }
  406. r = emit server gitoriaRequiredRead(slug)
  407. if (r == null) { return null }
  408. required = r.rows
  409. noRequired = required.length == 0
  410. hasRequired = required.length > 0
  411. mergeRule = requiredRule(required)
  412. }
  413. on server gitoriaRequiredRead(String slugOf, Hybrid session) {
  414. if (!ownsRepo(slugOf, session)) { return null }
  415. return { rows = requiredList(repoBySlug(slugOf).id) }
  416. }
  417. on addRequiredPerson() {
  418. requiredError = ''
  419. r = emit server gitoriaRequiredPersonAdd(slug, requiredPerson)
  420. if (r == null || r.error != null) {
  421. requiredError = r != null ? r.error : 'could not save the setting'
  422. return null
  423. }
  424. required = r.rows
  425. noRequired = required.length == 0
  426. hasRequired = required.length > 0
  427. mergeRule = requiredRule(required)
  428. }
  429. on server gitoriaRequiredPersonAdd(String slugOf, String personId, Hybrid session) {
  430. r = requirePerson(userIdOfSession(session), session, slugOf, personId)
  431. if (r.error == null) { announceRequirements(slugOf) }
  432. return r
  433. }
  434. on chooseRequiredApp() {
  435. selected = requiredApp
  436. before = requiredContext
  437. r = emit server gitoriaAppContext(slug, selected)
  438. // A slow reply must not replace a later selection or a context the owner typed.
  439. if (r != null && requiredApp == selected && requiredContext == before) { requiredContext = r.context }
  440. }
  441. on server gitoriaAppContext(String slugOf, String appId, Hybrid session) {
  442. if (!ownsRepo(slugOf, session)) { return null }
  443. return { context = latestAppContext(repoBySlug(slugOf).id, appId) }
  444. }
  445. on addRequiredRow(e) {
  446. requiredError = ''
  447. r = emit server gitoriaRequiredAdd(slug, requiredApp, requiredContext)
  448. if (r == null || r.error != null) {
  449. requiredError = r != null ? r.error : 'could not save the setting'
  450. return null
  451. }
  452. required = r.rows
  453. noRequired = required.length == 0
  454. hasRequired = required.length > 0
  455. mergeRule = requiredRule(required)
  456. requiredContext = ''
  457. }
  458. on dropRequiredRow(id) {
  459. requiredError = ''
  460. r = emit server gitoriaRequiredRemove(slug, id)
  461. if (r == null || r.error != null) {
  462. requiredError = r != null ? r.error : 'could not save the setting'
  463. return null
  464. }
  465. required = r.rows
  466. noRequired = required.length == 0
  467. hasRequired = required.length > 0
  468. mergeRule = requiredRule(required)
  469. }
  470. on server gitoriaRequiredAdd(slugOf, appId, ctxName, session) {
  471. r = requireContext(userIdOfSession(session), session, slugOf, appId, ctxName)
  472. if (r.error == null) { announceRequirements(slugOf) }
  473. return r
  474. }
  475. on server gitoriaRequiredRemove(slugOf, id, session) {
  476. r = dropRequired(userIdOfSession(session), session, slugOf, id)
  477. if (r.error == null) { announceRequirements(slugOf) }
  478. return r
  479. }
  480. on server gitoriaAppAdd(slugOf, name, hook, session) {
  481. return addApp(userIdOfSession(session), session, slugOf, name, hook)
  482. }
  483. on server gitoriaAppRemove(slugOf, id, session) {
  484. return removeApp(userIdOfSession(session), session, slugOf, id)
  485. }
  486. on server gitoriaAppPing(slugOf, id, session) {
  487. return sendPing(userIdOfSession(session), session, slugOf, id)
  488. }
  489. on server gitoriaAppRotate(slugOf, id, session) {
  490. return rotateSecret(userIdOfSession(session), session, slugOf, id)
  491. }
  492. on server gitoriaChangeMember(slugOf, name, add, session) {
  493. return changeMember(userIdOfSession(session), 'r', slugOf, name, add)
  494. }
  495. on disconnect() {
  496. settingsError = ''
  497. r = emit server gitoriaDisconnectTickets(slug)
  498. if (r == null || r.error != null) {
  499. settingsError = r != null ? r.error : 'could not disconnect'
  500. return null
  501. }
  502. connected = false
  503. notConnected = true
  504. forgetClass = 'nomerge'
  505. projectTitle = ''
  506. projectHref = ''
  507. }
  508. on server gitoriaDisconnectTickets(slugOf, session) {
  509. if (session == null || repoAt(slugOf, session) == null) { return { error = 'could not disconnect' } }
  510. if (userOfSession(session) == null || !ownsRepo(slugOf, session)) { return { error = 'only the owner can change this' } }
  511. r = setTicketsConnection(slugOf, '', '', '', '')
  512. if (r.error != null) { return { error = r.error } }
  513. return { ok = true }
  514. }
  515. Style {
  516. #transferOwnership {
  517. maxWidth = '32rem'
  518. form {
  519. display = 'grid'
  520. gap = '.75rem'
  521. justifyItems = 'start'
  522. }
  523. }
  524. #repoIdentity {
  525. display = 'grid'
  526. gap = '.75rem'
  527. maxWidth = '32rem'
  528. form {
  529. display = 'grid'
  530. gap = '.75rem'
  531. justifyItems = 'start'
  532. }
  533. }
  534. #requiredPersonForm {
  535. display = 'grid'
  536. gap = '.75rem'
  537. maxWidth = '32rem'
  538. }
  539. repoSettings {
  540. display = 'grid'
  541. gap = '1rem'
  542. minWidth = '0'
  543. // Direct-child and sibling combinators have no bare language form.
  544. '> *' {
  545. margin = '0'
  546. }
  547. }
  548. #ticketsettings {
  549. display = 'grid'
  550. gap = '.75rem'
  551. justifyItems = 'start'
  552. // Direct-child and sibling combinators have no bare language form.
  553. '> *' {
  554. margin = '0'
  555. }
  556. }
  557. // Runtime and theme class predicates have no bare selector form.
  558. '#disconnecttickets.nomerge' {
  559. display = 'none'
  560. }
  561. #connecttickets {
  562. color = 'var(--color-accent-text)'
  563. background = 'var(--color-accent)'
  564. }
  565. #members {
  566. listStyle = 'none'
  567. margin = '0'
  568. padding = '0'
  569. display = 'grid'
  570. gap = '.25rem'
  571. maxWidth = '32rem'
  572. li {
  573. display = 'flex'
  574. alignItems = 'center'
  575. justifyContent = 'space-between'
  576. gap = '.75rem'
  577. minHeight = '2.75rem'
  578. padding = '0 .5rem 0 1rem'
  579. background = 'var(--color-surface)'
  580. borderRadius = 'var(--radius-large)'
  581. }
  582. }
  583. #memberform {
  584. display = 'grid'
  585. gap = '.75rem'
  586. margin = '.75rem 0 1.5rem'
  587. maxWidth = '32rem'
  588. }
  589. #apps {
  590. display = 'grid'
  591. gap = '.75rem'
  592. margin = '0 0 1.5rem'
  593. justifyItems = 'start'
  594. // Direct-child and sibling combinators have no bare language form.
  595. '> *' {
  596. margin = '0'
  597. }
  598. }
  599. #connectapp {
  600. display = 'grid'
  601. gap = '.75rem'
  602. maxWidth = '32rem'
  603. padding = '1rem'
  604. background = 'var(--color-surface)'
  605. borderRadius = 'var(--radius-large)'
  606. }
  607. #appshown {
  608. margin = '0'
  609. color = 'var(--color-danger)'
  610. empty { display = 'none' }
  611. display = 'grid'
  612. gap = '.5rem'
  613. maxWidth = '100%'
  614. code {
  615. overflowWrap = 'anywhere'
  616. }
  617. }
  618. #applist {
  619. listStyle = 'none'
  620. margin = '0'
  621. padding = '0'
  622. display = 'grid'
  623. gap = '.25rem'
  624. maxWidth = '40rem'
  625. width = '100%'
  626. li {
  627. display = 'flex'
  628. flexWrap = 'wrap'
  629. alignItems = 'center'
  630. gap = '.5rem .75rem'
  631. minHeight = '2.75rem'
  632. padding = '.25rem .5rem .25rem 1rem'
  633. background = 'var(--color-surface)'
  634. borderRadius = 'var(--radius-large)'
  635. }
  636. }
  637. #required {
  638. display = 'grid'
  639. gap = '.75rem'
  640. margin = '0 0 1.5rem'
  641. justifyItems = 'start'
  642. // Direct-child and sibling combinators have no bare language form.
  643. '> *' {
  644. margin = '0'
  645. }
  646. }
  647. #requiredlist {
  648. listStyle = 'none'
  649. margin = '0'
  650. padding = '0'
  651. display = 'grid'
  652. gap = '.25rem'
  653. maxWidth = '40rem'
  654. width = '100%'
  655. li {
  656. display = 'flex'
  657. flexWrap = 'wrap'
  658. alignItems = 'center'
  659. justifyContent = 'space-between'
  660. gap = '.5rem .75rem'
  661. minHeight = '2.75rem'
  662. padding = '.25rem .5rem .25rem 1rem'
  663. background = 'var(--color-surface)'
  664. borderRadius = 'var(--radius-large)'
  665. }
  666. }
  667. #requiredform {
  668. display = 'grid'
  669. gap = '.75rem'
  670. maxWidth = '32rem'
  671. }
  672. #appform {
  673. display = 'grid'
  674. gap = '.75rem'
  675. maxWidth = '32rem'
  676. }
  677. #toggleprotect {
  678. justifySelf = 'start'
  679. }
  680. #togglepriv {
  681. justifySelf = 'start'
  682. }
  683. #visibility {
  684. display = 'grid'
  685. gap = '.75rem'
  686. margin = '0 0 1.5rem'
  687. }
  688. #membererror {
  689. margin = '0'
  690. color = 'var(--color-danger)'
  691. empty { display = 'none' }
  692. }
  693. #appsignin {
  694. margin = '0'
  695. color = 'var(--color-danger)'
  696. empty { display = 'none' }
  697. }
  698. #appnotowner {
  699. margin = '0'
  700. color = 'var(--color-danger)'
  701. empty { display = 'none' }
  702. }
  703. #apperror {
  704. margin = '0'
  705. color = 'var(--color-danger)'
  706. empty { display = 'none' }
  707. }
  708. #requirederror {
  709. margin = '0'
  710. color = 'var(--color-danger)'
  711. empty { display = 'none' }
  712. }
  713. #connectnote {
  714. margin = '0'
  715. color = 'var(--color-danger)'
  716. empty { display = 'none' }
  717. }
  718. #settingserror {
  719. margin = '0'
  720. color = 'var(--color-danger)'
  721. empty { display = 'none' }
  722. }
  723. }
  724. on rename() {
  725. r = emit server gitoriaRenameRepo(slug, renameName, renameOrg)
  726. if (r == null || r.error != null) { renameError = r != null ? r.error : 'could not rename the repository' return null }
  727. navigate(r.repo.address + 'settings')
  728. }
  729. on server gitoriaRenameRepo(String slugOf, String name, String org, Hybrid session) {
  730. return renameRepo(userIdOfSession(session), slugOf, name, org)
  731. }
  732. on saveTitle() {
  733. r = emit server gitoriaSetRepoTitle(slug, displayName)
  734. if (r == null || r.error != null) { titleError = r != null ? r.error : 'could not save the display name' return null }
  735. titleError = 'Saved.'
  736. displayName = r.repo.title
  737. __title = pageTitle(siteName, r.repo.heading, 'Settings')
  738. }
  739. on server gitoriaSetRepoTitle(String slugOf, String title, Hybrid session) {
  740. return setRepoTitle(userIdOfSession(session), slugOf, title)
  741. }
  742. on client repoChanged(Hybrid row) {
  743. if (titleRepo != null && row.id == titleRepo.id) { __title = pageTitle(siteName, row.heading, 'Settings') }
  744. }
  745. on transfer() {
  746. if (transferConfirm != slug) { transferError = 'type the repository name to confirm' return null }
  747. r = emit server gitoriaTransferRepo(slug, newOwner, transferConfirm)
  748. if (r == null || r.error != null) { transferError = r != null ? r.error : 'could not transfer the repository' return null }
  749. navigate(r.repo.address)
  750. }
  751. on server gitoriaTransferRepo(String slugOf, String name, String confirm, Hybrid session) {
  752. return confirmedTransfer(userIdOfSession(session), slugOf, name, confirm)
  753. }
  754. on client membersChanged(String kind, String changedSlug, String changedUser) {
  755. if (kind == 'r' && changedSlug == slug && isOwner) {
  756. r = emit server gitoriaReadRepoMembers(slug)
  757. if (r == null) { isOwner = false members = [] }
  758. else { members = r.members }
  759. noMembers = members.length == 0
  760. }
  761. if (kind == 'o' && isOwner) { refreshOrgChoices() }
  762. }
  763. on client orgChanged(Hybrid row) {
  764. if (isOwner) { refreshOrgChoices() }
  765. }
  766. refreshOrgChoices() {
  767. ownedOrgs = emit server gitoriaReadOrgChoices()
  768. foreignOrg = foreignOrgName != '' && ownedOrgs.filter((Hybrid o) => { return o.slug == foreignOrgName }).length == 0
  769. if (renameOrg != '' && renameOrg != foreignOrgName && ownedOrgs.filter((Hybrid o) => { return o.slug == renameOrg }).length == 0) { renameOrg = '' }
  770. }
  771. on server gitoriaReadOrgChoices(Hybrid session) {
  772. return orgChoices(userIdOfSession(session))
  773. }
  774. on server gitoriaReadRepoMembers(String slugOf, Hybrid session) {
  775. if (!ownsRepo(slugOf, session)) { return null }
  776. return membersOf('r', slugOf, userIdOfSession(session))
  777. }

Branches

Latest commits

  • 52576cb0force push: defer on a failed scan, one-to-one pairs, docs (#56)mre
  • 5a7b3e68|||PR a force push keeps the same pull request (#56)mre
  • cc1be2d6Merge branch 'w62-pr-close' into mainGitoria
  • 6e03be0apull state: keep the resync marker until the sync ran (#56)mre
  • 93bdd26cpull state: wait for a claimed row, resync when it stays busy (#56)mre
  • e53d284bpull state: stop on a failed branch scan, claim the row on writes (#56)mre
  • d8608224close and reopen: keep a manual close against sync (#56)mre
  • ffb60746|||PR close and reopen pull requests (#56)mre
  • fe209ffeMerge branch 'w56-owner-members' into mainGitoria
  • fa0754c8|||PR repository owner transfer and members API (#55)mre
  • 8862e537Merge branch 'w55-rename-org' into mainGitoria
  • 014d2b7fOne immutable readers snapshot per move for the left-organization event (#53)mre
  • 1859d506Decide who hears a repo left its organization by its readers before the move (#53)mre
  • 499f25f2Review fixes for the Settings organization move (#53)mre
  • ed3b922b|||PR move a repository into an organization in Settings (#53)mre
  • 74ec2af8Merge branch 'w54-repo-rename-pr' into mainGitoria
  • 9f7ce8d8Preserve rename compatibility and live page titlesmre
  • c3d95b6e|||PR separate names and addresses, rename repositories in Settings (#53)mre
  • ce08920dMerge branch 'w52c-header-phone' into mainGitoria
  • 0bab9e46|||PR header: ident status wraps on phones instead of clippingmre