tickets
All repositories: gitoria
6.7 KB
// components/you.hl — `/you` (ticket #7): the logged-in user's own page.// * the display name, and the PER-APP IDENTITY ID ident gave tickets for this identity —// shown ONLY here and only to its owner (an admin adds a person to a project by it). Ticket #20: the// projects the user is a member of, with their role.// * API TOKENS for machine clients (CONCEPT point 5): create (the token is shown ONCE — only// its sha256 is stored), list, revoke. `Authorization: Bearer <token>` acts as this user.// Logged out: a hint. A login in the shell (no reload) fills the page via the face `youData`.parent './main.hl'import { siteName } from '../project.hl'import { youOf, userOfSession, createToken, revokeToken, tokenRows } from '../lib/users.hl'import { projectsOfUser } from '../lib/projects.hl'import { hintLook, messageLook } from '../lib/looks.hl'session = nullyou = youOf(session)present = you != nullabsent = you == nullyouName = you != null ? you.name : ''identity = you != null ? you.identity : ''myProjects = projectsOfUser(userOfSession(session))hasProjects = myProjects.length > 0noProjects = myProjects.length == 0tokens = you != null ? you.tokens : []hasTokens = tokens.length > 0noTokens = tokens.length == 0newLabel = ''newToken = ''hasNewToken = falsetokenMessage = ''__title = siteName + ' | you'Style {pMuted = hintLook + { }'#tokenmessage' = messageLook + { }youView {display = 'grid'gap = '1.2rem'section {display = 'grid'gap = '.6rem'padding = '.8rem'background = 'var(--color-surface)'borderRadius = 'var(--radius-large)'}dl {display = 'grid'gap = '.2rem'margin = '0'}dt {fontSize = '.875rem'color = 'var(--color-text-muted)'}dd {margin = '0 0 .4rem'color = 'var(--color-text-strong)'overflowWrap = 'anywhere'}code {overflowWrap = 'anywhere'wordBreak = 'break-all'}}'#tokenform' {display = 'grid'gap = '.5rem'}tokenShown {display = 'grid'gap = '.4rem'padding = '.7rem'borderRadius = 'var(--radius-small)'p {margin = '0'}}'#newtoken' {color = 'var(--color-success)'fontSize = '.95rem'}'#tokenlist' {listStyle = 'none'margin = '0'padding = '0'display = 'grid'gap = '.4rem'li {display = 'flex'flexWrap = 'wrap'alignItems = 'center'gap = '.3rem .8rem'padding = '.4rem .6rem'background = 'var(--color-background-sunken)'borderRadius = 'var(--radius-small)'}}'#projectlist' {listStyle = 'none'margin = '0'padding = '0'display = 'grid'gap = '.3rem'}spanRole {color = 'var(--color-text-muted)'fontSize = '.875rem'}spanLabel {flex = '1 1 10rem'color = 'var(--color-text-strong)'overflowWrap = 'anywhere'}}View {youView {h1 { "You" }if (absent) { p { id = "youhint" class = "empty" "Log in with ident (top right) to see your account and your API tokens." } }if (present) {section { id = "account"h2 { "Account" }dl {dt { "Display name" }dd { id = "youname" youName }dt { "Your ident id" }dd { code { id = "youidentity" identity } }}p { Style.pMuted "The id ident shows for the identity you logged in with. An admin of a project can add you with it." }}section { id = "myprojects"h2 { "Your projects" }if (noProjects) { p { id = "noprojects" class = "empty" "You are not a member of any project yet." } }ul { id = "projectlist"for (p of myProjects) { li { a { href = p.href p.title } " " span { Style.spanRole p.role } } }}}section { id = "tokens"h2 { "API tokens" }p { Style.pMuted "For machine clients (the architect, the scheduler): a token acts as you on every API write — send it as " code { "Authorization: Bearer <token>" } ". It is shown once." }form { id = "tokenform"on submit(e) {e.preventDefault()emit makeToken(e)}label { "Label (optional, e.g. what uses it)"input { id = "tokenlabel" name = "label" maxlength = "60" autocomplete = "off" value = newLabel on input(e) { emit setLabel(e.target.value) } }}button { id = "tokencreate" type = "submit" "Create a token" }}if (hasNewToken) {tokenShown { id = "newtokenbox"p { "Your new token — copy it now, it is not shown again:" }code { id = "newtoken" newToken }button { id = "tokendone" type = "button" class = "quiet" "I copied it" on click(e) { emit hideToken(e) } }}}p { id = "tokenmessage" tokenMessage }if (noTokens) { p { id = "notokens" class = "empty" "No tokens." } }ul { id = "tokenlist"for (t of tokens) {li {span { Style.spanLabel t.label }time { t.created }button { type = "button" class = "quiet danger revoke" value = t.id "Revoke" on click(e) { emit revoke(e.target.value) } }}}}}}}}fill = (y) => {you = ypresent = y != nullabsent = y == nullyouName = y != null ? y.name : ''identity = y != null ? y.identity : ''showTokens(y != null ? y.tokens : [])}showTokens = (list) => {tokens = listhasTokens = list.length > 0noTokens = list.length == 0}on setLabel(v) { newLabel = v }on makeToken(e) {r = emit server tokenCreate(newLabel)if (r == null || r.error != null) {tokenMessage = r != null ? r.error : 'could not create the token'return null}tokenMessage = ''newLabel = ''newToken = r.tokenhasNewToken = trueshowTokens(r.tokens)}on hideToken(e) {newToken = ''hasNewToken = false}on revoke(id) {r = emit server tokenRevoke(id)if (r == null || r.error != null) {tokenMessage = r != null ? r.error : 'could not revoke the token'return null}tokenMessage = ''showTokens(r.tokens)}// a login / name / logout in the shell, without a reloadon client signedIn(tag, info) {y = emit server youData()fill(y)mine = emit server myProjectsData()myProjects = mine != null && mine.projects != null ? mine.projects : []hasProjects = myProjects.length > 0noProjects = myProjects.length == 0}on client signedOut(tag) {fill(null)newToken = ''hasNewToken = false}// ---- the faces (#31: only a real session) -------------------------------------------------on server youData(session) { return youOf(session) }on server myProjectsData(session) { return { projects = projectsOfUser(userOfSession(session)) } }on server tokenCreate(label, session) {u = userOfSession(session)if (u == null) { return { error = 'log in with ident first' } }if (u.name == '') { return { error = 'choose a display name first' } }return createToken(u.id, label)}on server tokenRevoke(id, session) {u = userOfSession(session)if (u == null) { return { error = 'log in with ident first' } }return revokeToken(u.id, id)}
Branches
Latest commits
- 7bcfdc22|||PR drop worker edits to conductor recordsmre
- 2617b6ee|||PR dialogs: host flag cleared on close, dialog gate (tickets#40)mre
- 6e701371|||PR record partial day72 dialog validationmre
- b9fb9a91|||PR bind ticket dialog visibility to member flagsmre
- 0788e65f|||PR re-vendor Hybriel day72mre
- 8a7f475aMerge branch 'records-t33' into mainTickets
- e685d0c2|||PR records: PROCEDURES merge callmre
- b42aff2b|||PR records: GO 2026-11-23, workers L33 O34, PROCEDURES.mdmre
- ed091d44Merge branch 'records' into mainTickets
- 180c0cdb|||PR records: ticket move live (M32), hybriel#439mre
- 497cae7bMerge branch 'm32-move' into mainTickets
- 772e0696|||PR Allow project admins to move tickets between their projectsmre
- be92a560Merge branch 'records' into mainTickets
- 0daf2ea8|||PR records: PR-only workflow, #50 donemre
- 0185d0b6Log PR 1 deploymre
- f5bf16e2Mission 031: deploy PR 1mre
- c69cd5f3Merge branch 'pr-flow' into mainTickets
- cc56798cLog gitoria PR-only requestmre
- d876d0b2|||PR README: changes land as PRsmre
- fd83ac1fconductor: caramboleyo is the user, not owner/creatorApollo