gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit31cabfcc31cabfccmission 021: E2E script, report, LOG, STATUSmre31cabfcc/components/connect.hl

4.5 KB

  1. // components/connect.hl — `/connect/:nonce` (ticket #21): another app (first: gitoria) asks to be connected to one
  2. // project. The person — logged in through ident, with a display name — picks a project they are ADMIN of, or makes a
  3. // new one, and confirms. Then the page links back to the app with a one-time code (connections.hl); the app's server
  4. // swaps the code for a key that reaches that one project. Everybody else sees the login hint; a used or expired
  5. // request says so. Everything is checked again by the store in the faces.
  6. parent './main.hl'
  7. import { requestOf, requestView, adminProjects, confirmRequest } from '../lib/connections.hl'
  8. import { siteName } from '../project.hl'
  9. import { userOfSession, writerOfSession, canWriteSession } from '../lib/users.hl'
  10. nonce = null
  11. session = null
  12. pending = requestOf(nonce)
  13. valid = pending != null
  14. gone = pending == null
  15. info = pending != null ? requestView(pending) : { app = '' label = '' hasLabel = false host = '' }
  16. appName = info.app
  17. appLabel = info.label
  18. hasLabel = info.hasLabel
  19. appHost = info.host
  20. canWrite = valid && canWriteSession(session)
  21. showForm = valid && canWriteSession(session)
  22. mustLogIn = valid && !canWriteSession(session)
  23. choices = adminProjects(userOfSession(session))
  24. choice = choices.length > 0 ? choices[0].id : ''
  25. makeNew = choices.length == 0
  26. newTitle = ''
  27. message = ''
  28. done = false
  29. doneUrl = ''
  30. doneProject = ''
  31. __title = siteName + ' | connect ' + (pending != null ? pending.app : 'an app')
  32. View {
  33. connectPage {
  34. if (gone) { p { id = "gone" class = "empty" "This connection request is used up or expired. Start again from the app." } }
  35. if (valid) {
  36. h1 { id = "connecttitle" "Connect " appName " to a project" }
  37. p { id = "connectwho" class = "hint"
  38. strong { appName }
  39. if (hasLabel) { " (" appLabel ")" }
  40. " at "
  41. strong { appHost }
  42. " asks for a key to ONE of your projects. With it the app can open tickets, comment and change their state there — for the people who work in it, within their roles. You can disconnect it on the project's page at any time."
  43. }
  44. }
  45. if (mustLogIn) { p { id = "loginhint" class = "hint" "Log in with ident (top right) and choose a display name to connect." } }
  46. if (showForm) {
  47. form { id = "connectform"
  48. on submit(e) {
  49. e.preventDefault()
  50. emit confirm(e)
  51. }
  52. label { "Project"
  53. select { id = "connectproject" name = "project" value = choice on change(e) { emit setChoice(e.target.value) }
  54. for (c of choices) { option { value = c.id c.title } }
  55. option { value = "" "A new project" }
  56. }
  57. }
  58. if (makeNew) {
  59. label { "Title of the new project"
  60. input { id = "connecttitleinput" name = "title" required = "required" maxlength = "100" autocomplete = "off" value = newTitle on input(e) { emit setNewTitle(e.target.value) } }
  61. }
  62. }
  63. button { id = "connectconfirm" type = "submit" "Connect" }
  64. p { id = "connectmessage" class = "message" message }
  65. }
  66. }
  67. if (done) {
  68. p { id = "connected" class = "notice" "Connected to " strong { doneProject } ". " }
  69. a { id = "connectcontinue" class = "button" href = doneUrl "Continue to " appName }
  70. }
  71. }
  72. }
  73. on setChoice(v) {
  74. choice = v
  75. makeNew = v == ''
  76. }
  77. on setNewTitle(v) { newTitle = v }
  78. on confirm(e) {
  79. if (makeNew && newTitle.trim() == '') { return null }
  80. r = emit server connectConfirm(nonce, choice, newTitle)
  81. if (r == null || r.error != null) {
  82. message = r != null ? r.error : 'could not connect'
  83. return null
  84. }
  85. message = ''
  86. showForm = false
  87. doneUrl = r.url
  88. doneProject = r.project
  89. done = true
  90. }
  91. on client signedIn(tag, info) {
  92. r = emit server connectChoices()
  93. if (r != null && r.projects != null) {
  94. choices = r.projects
  95. choice = r.projects.length > 0 ? r.projects[0].id : ''
  96. makeNew = r.projects.length == 0
  97. }
  98. canWrite = valid && info.named
  99. showForm = valid && info.named && !done
  100. mustLogIn = valid && !info.named
  101. }
  102. on client signedOut(tag) {
  103. canWrite = false
  104. showForm = false
  105. mustLogIn = valid
  106. choices = []
  107. }
  108. on server connectChoices(session) {
  109. u = userOfSession(session)
  110. if (u == null) { return { error = 'log in first' } }
  111. return { projects = adminProjects(u) }
  112. }
  113. on server connectConfirm(nonce, projectId, title, session) {
  114. w = writerOfSession(session)
  115. if (w.error != null) { return { error = w.error } }
  116. if (hlTypeName(nonce) != 'String' || hlTypeName(projectId) != 'String' || hlTypeName(title) != 'String') { return { error = 'nonce, project and title must be text' } }
  117. r = confirmRequest(nonce, w.user, projectId, title)
  118. if (r.error != null) { return { error = r.error } }
  119. return { url = r.url project = r.project slug = r.slug }
  120. }

Branches

Latest commits

  • 31cabfccmission 021: E2E script, report, LOG, STATUSmre
  • 6aea8683editor look: .empty rule only for p.empty, files off where tickets has no upload, state note one line, events test scrolls the editor into view; synced md-editor (components d702d76+6f27ad3); gate 377/0, events 52/0mre
  • dce6ffa6Merge branch 'w28-deflake'mre
  • 536092a1tickets (mission 019): de-flake the m016 comment clicks (B: unliked) — calmClick waits until the button stops moving; test only, no app changemre
  • 9c5fd42amission 020: attachments E2E proof (lisbeth Chrome, real-data copy), reportmre
  • 1206404fREADME attachments, report 018, LOG/STATUSmre
  • 3d9e7f3ctests: m017 gate fixes (list count, waits before delete clicks); gate 373/0mre
  • dd41d5bcre-sync components 15be2ac; mission 018mre
  • 420ad1bbtickets (mission 017 WIP, tickets#27): comment attachments — lib/attachments.hl (storage/attachments, limits, type by content, members-only GET /api/attachments/:id, delete drops, edit keeps), multipart POST …/comments (lib/multipart.hl), Respond block in FilesUpload (blocks verbatim from components w27c 1f8d79d), gate m017 checks written (not yet run); report, LOG, STATUSmre
  • a7a1380dmission brief 017mre
  • f83d9c0dtickets (mission 016): report reports/016-comments-block.md, LOG, STATUS, README gate countmre
  • eef80f55tickets (mission 016): comments through the shared Comments block (layouts#2) — edit (author, earlier versions kept), delete (author, asks; leaves one line in the history), like (members, toggle) on the server (lib/comments.hl, append-only tables), faces + API …/comments/:comment/{edit,delete,like}, push commentChanged; every run of comments is a block in place in the history; Markdown fields on the Hybriel MdEditor (shared/md-editor.js retired: it took over the block's <md-editor>); blocks copied verbatim from components.hybriel 9db927d (tools/sync-components.sh); gates browser 351/0 (old 326/0), events 52/0 (old 52/0)mre
  • eb7aeeb9mission brief 016mre
  • e4c34759paths: projects moved into /media/STORAGE/projects/WorldAPI/mre
  • 26efb23freport w6-events (events test)mre
  • c6bfab04mission 015: re-vendor Hybriel 0f396652 (static build), reportmre
  • b7ec5981mission brief 015mre
  • 5dc68731docker-compose: init: true (hybriel#156, PID 1 ignored SIGTERM, every restart waited 10 s)mre
  • 8a460b16mission 014: Apollo's 'stream opened right after the start gets no live events' is not a tickets bug — events.mjs checks early streamsmre
  • 6309ca81mission brief 014mre