tickets
All repositories: gitoria
4.5 KB
// components/connect.hl — `/connect/:nonce` (ticket #21): another app (first: gitoria) asks to be connected to one// project. The person — logged in through ident, with a display name — picks a project they are ADMIN of, or makes a// new one, and confirms. Then the page links back to the app with a one-time code (connections.hl); the app's server// swaps the code for a key that reaches that one project. Everybody else sees the login hint; a used or expired// request says so. Everything is checked again by the store in the faces.parent './main.hl'import { requestOf, requestView, adminProjects, confirmRequest } from '../lib/connections.hl'import { siteName } from '../project.hl'import { userOfSession, writerOfSession, canWriteSession } from '../lib/users.hl'nonce = nullsession = nullpending = requestOf(nonce)valid = pending != nullgone = pending == nullinfo = pending != null ? requestView(pending) : { app = '' label = '' hasLabel = false host = '' }appName = info.appappLabel = info.labelhasLabel = info.hasLabelappHost = info.hostcanWrite = valid && canWriteSession(session)showForm = valid && canWriteSession(session)mustLogIn = valid && !canWriteSession(session)choices = adminProjects(userOfSession(session))choice = choices.length > 0 ? choices[0].id : ''makeNew = choices.length == 0newTitle = ''message = ''done = falsedoneUrl = ''doneProject = ''__title = siteName + ' | connect ' + (pending != null ? pending.app : 'an app')View {connectPage {if (gone) { p { id = "gone" class = "empty" "This connection request is used up or expired. Start again from the app." } }if (valid) {h1 { id = "connecttitle" "Connect " appName " to a project" }p { id = "connectwho" class = "hint"strong { appName }if (hasLabel) { " (" appLabel ")" }" at "strong { appHost }" 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."}}if (mustLogIn) { p { id = "loginhint" class = "hint" "Log in with ident (top right) and choose a display name to connect." } }if (showForm) {form { id = "connectform"on submit(e) {e.preventDefault()emit confirm(e)}label { "Project"select { id = "connectproject" name = "project" value = choice on change(e) { emit setChoice(e.target.value) }for (c of choices) { option { value = c.id c.title } }option { value = "" "A new project" }}}if (makeNew) {label { "Title of the new project"input { id = "connecttitleinput" name = "title" required = "required" maxlength = "100" autocomplete = "off" value = newTitle on input(e) { emit setNewTitle(e.target.value) } }}}button { id = "connectconfirm" type = "submit" "Connect" }p { id = "connectmessage" class = "message" message }}}if (done) {p { id = "connected" class = "notice" "Connected to " strong { doneProject } ". " }a { id = "connectcontinue" class = "button" href = doneUrl "Continue to " appName }}}}on setChoice(v) {choice = vmakeNew = v == ''}on setNewTitle(v) { newTitle = v }on confirm(e) {if (makeNew && newTitle.trim() == '') { return null }r = emit server connectConfirm(nonce, choice, newTitle)if (r == null || r.error != null) {message = r != null ? r.error : 'could not connect'return null}message = ''showForm = falsedoneUrl = r.urldoneProject = r.projectdone = true}on client signedIn(tag, info) {r = emit server connectChoices()if (r != null && r.projects != null) {choices = r.projectschoice = r.projects.length > 0 ? r.projects[0].id : ''makeNew = r.projects.length == 0}canWrite = valid && info.namedshowForm = valid && info.named && !donemustLogIn = valid && !info.named}on client signedOut(tag) {canWrite = falseshowForm = falsemustLogIn = validchoices = []}on server connectChoices(session) {u = userOfSession(session)if (u == null) { return { error = 'log in first' } }return { projects = adminProjects(u) }}on server connectConfirm(nonce, projectId, title, session) {w = writerOfSession(session)if (w.error != null) { return { error = w.error } }if (hlTypeName(nonce) != 'String' || hlTypeName(projectId) != 'String' || hlTypeName(title) != 'String') { return { error = 'nonce, project and title must be text' } }r = confirmRequest(nonce, w.user, projectId, title)if (r.error != null) { return { error = r.error } }return { url = r.url project = r.project slug = r.slug }}
Branches
Latest commits
- d74a5482sync components.hybriel 134b4e3: MdEditor builds an editor put into the page at once, redraws a surface put in anew (F5, hybriel#211)mre
- 9d02c540sync components.hybriel 6b0936a: the 'edited' foldable drops the theme's border and marginmre
- 22751914sync components.hybriel 8d79ff7: bubble hugs its content, quiet 'edited' label; gate checksmre
- c8452453sync components 9a: shared Icon (icons/icons.hl), md-editor toolbar icons + single focus ring (components f4-icons ba96735)mre
- 52ba11e8sync-components: copy icons/icons.hl + README (F4); testsmre
- 138d198dmd-editor.hl: verbatim copy of components f3-mdvalue (an older text handed back is kept)mre
- 18d2df60md-editor.hl: verbatim copy of components f3-mdvalue (an outside value change is shown by the editor)mre
- f6764bedreports/H1-hydrate.mdmre
- 1bbbf0edtests/browser.mjs: wait for hydration before clicking the login button on / (device B)mre
- 6f503cfctests/cdp.mjs: HL_CPU_THROTTLE=<rate> optional CPU throttling for gate runsmre
- e17e2855re-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
- a6ddccd2re-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
- 81e036b7docker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
- 5d8d2cf6deploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
- 58e8c02cmission 024: report, LOG, STATUS, e2e fixmre
- 50778073tests/e2e-route-marker.mjs: first paint marker, comments post/edit redrawmre
- c5203298mission 024: MainMenu marks the page from the route (layouts 0bcc629 main-menu.hl); browser-side marker removed; gate: marker in the server HTMLmre
- b1a4c270re-vendor Hybriel master f9614007: bin/ (git-ignored) and plugins wholemre
- 866397a0mission 023: theme from layouts 76f99f6 (current marker, menu count badge), components from 3794c59 (MdEditor keys); Inbox count as badge, current by address; gates and E2E; reportmre
- 7ed2e5e5deploy.sh: a gate without a 'passed,' line (check-theme) no longer ends the script silently (grep under pipefail), as gitoria/layoutsmre