tickets
All repositories: gitoria
6.6 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 + { }pMessage = 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" Style.pMessage 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
- 0814ce6bTickets conductor: brief 025 tickets#36 style formmre
- 1b6916c4Tickets conductor: Atlas handover tickets#36mre
- aab95226Tickets conductor: worldapi-conductor paths, deploy blocker = read-only diskmre
- 6372b06dTickets conductor: worker port slotmre
- 836af31cTickets conductor: token pathsmre
- b03f11b6Tickets conductor: CONDUCTOR.md (project part), short STATUS.md, old STATUS to archive/2026-10-31mre
- a4123831tickets#42: the /connect and /login/callback error pages are app pages: the function routes redirect to /connect/failed/<code> and /login/failed/<code> (components/problem.hl, sentences in lib/problems.hl), htmlPage and its hand-written stylesheet are gone; gate tests/error-pages.mjsmre
- cefc7b4atickets: a startup error prints its message before exit 1 (hybriel#247)mre
- 99bd6570tickets: lib/migrate.hl writes no table of another topic any more: projects.hl rewriteSlug / addProjectNamed / hasMembers, tickets.hl moveToProject / ticketRecords / ticketRecordsOf, events.hl renameStates / eventRecords / eventRecordsOf; the migration calls them (tickets#47)mre
- b57161e3tickets: the markup names its own rules (Style.pMessage, Style.olTickets, ...) instead of hand-written class strings that copy a stylesheet rule; the shared bodies sit in lib/looks.hl (tickets#38)mre
- f767b24dtickets: 111 needless let became plain declarations (3 in ticket.hl, ticket_list.hl, comments.hl and 108 never-reassigned, not captured loop-body ones); the 212 really reassigned lets stay (tickets#44)mre
- 16c0d3b5tickets: the modal window is phone first: the full-screen sheet is the base rule, the centred window sits in the min-width 60rem block (tickets#39)mre
- 090ee809tickets: every component's styles in its own nested Style {} block; styles.hl keeps only the theme inherit, the accent and the site-wide rules (tickets#36)mre
- d395763ftickets: ident-access gate ports 8769/8768 (8797 is taken on loreana)mre
- afb9a403tickets: an ident access key (Authorization: Bearer idt_…) works in the API (ident#27 app side): lib/ident-access.hl copied from components, read keys GET only, ident down 503; gate tests/ident-access-tickets.mjsmre
- 48c1ba79tickets: md-paste-files gate with the file manager casesmre
- f04afc43tickets: MdEditor from components 59704ce (a file manager copy still attaches, pipe rows, tickets#49)mre
- 06599fa0tickets: MdEditor from components b0f1ec2 (a clipboard with text always pastes the text, tickets#49); real Ctrl+V gatemre
- 2e1b116ftickets: re-vendor Hybriel master acaceaf3 (framework ec8d6c1d): plugins/web patch queue while a page is built, anonymous session cookies refresh; gate waits for the comment editors to draw (W174) and clicks the form editor when it stands still; security gate: main's code runs on its own binary, lazy-session cookie checksmre
- 361bc0fetickets: re-vendor Hybriel 7a684920 (WIP, not deployed); on Error exits 1 at startup; migrate passes its log by reference; gate checks follow lazy sessions and the 413 refusalmre