gitoria
All repositories: gitoria
11.7 KB
// components/pull.hl — ONE PULL REQUEST (gitoria#45, part of the push API #38): `/pulls/N` on <slug>.<domain> and `/<repo>/pulls/N` in an organization.// A function route (lib/api.hl pullPage) renders it only for a PR the viewer may see, so an unknown number is a real 404. Everything comes from lib/prpage.hl// on the SERVER (first HTML and every navigation): the PR, its statuses on the current head, every app's current verdict, the reviews, the threads// (path:line, outdated / resolved marks) and the conversation. Bodies are Markdown as text nodes (components/markdown.hl). A viewer who may write (lib/prpage.hl// mayWritePull) gets the forms and the "Review again" buttons; the faces check it again, so a forged call is refused. Rows are keyed by the PR number and the// thread / comment ids the server gave, never by a position.parent './repo.hl'import Markdown from './markdown.hl'import PullReply from './pull-reply.hl'import { siteName } from '../project.hl'import { slugOfRequest } from '../lib/orgs.hl'import { titleSlug, repoAt } from '../lib/repos.hl'import { pageTitle } from '../lib/repos-helpers.hl'import { px } from '../lib/util.hl'import { prOfRequest, prView, mergeThePull, commentOnPull, replyInThread, setThreadResolved, reviewAgain } from '../lib/prpage.hl'host = nullorepo = ''n = nullsession = nullslug = slugOfRequest(host, orepo)repo = repoAt(slug, session)rec = repo != null ? prOfRequest(host, orepo, session, n) : nullv = rec != null ? prView(slug, rec, session) : nullhasPr = v != nullpr = v != null ? v.pr : nullstatuses = v != null ? v.statuses : []hasStatuses = v != null && v.hasStatusesverdicts = v != null ? v.verdicts : []hasVerdicts = v != null && v.hasVerdictsnoVerdicts = v != null && !v.hasVerdictsapps = v != null ? v.apps : []hasApps = v != null && v.hasAppsreviews = v != null ? v.reviews : []hasReviews = v != null && v.hasReviewsnoReviews = v != null && !v.hasReviewsthreads = v != null ? v.threads : []hasThreads = v != null && v.hasThreadsnoThreads = v != null && !v.hasThreadsconversation = v != null ? v.conversation : []hasConversation = v != null && v.hasConversationnoConversation = v != null && !v.hasConversationcanAct = v != null && v.canActmergeClass = v != null ? v.mergeClass : 'nomerge'readOnly = v != null && v.readOnlycommentBody = ''actError = ''actNotice = ''listHref = px(slug) + '/pulls'__title = pageTitle(siteName, titleSlug(host, orepo, session), 'Pull request ' + (n == null ? '' : '#' + n))View {repoPage {if (hasPr) {pullPage { id = "pullpage"p { a { id = "topulls" href = listHref "← Pull requests" } }h2 { id = "pulltitle"span { Style.spanNumber pr.numberText }for (pt of pr.parts) { if (pt.isText) { span { pt.text } } if (pt.isLink) { a { class = "ticketref" href = pt.href pt.text } } }}p { id = "pullmeta"// Runtime row/state classes have no Style-rule selection form.span { id = "pullstate" class = pr.state pr.state }span { id = "pullbranches" strong { pr.source } " → " strong { pr.target } }span { class = "muted" "by " span { id = "pullauthor" pr.author } " · head " code { pr.head } }}if (hasStatuses) {ul { id = "pullstatuses"for (st of statuses) {// Runtime row/state classes have no Style-rule selection form.li { class = st.clsspan { class = "state" st.state }span { class = "label" st.label }span { class = "muted" st.title }}}}}h3 { "Verdicts" }if (hasVerdicts) {ul { id = "pullverdicts"for (vd of verdicts) {// Runtime row/state classes have no Style-rule selection form.li { class = vd.clsstrong { vd.app }span { vd.text }}}}}if (noVerdicts) { p { id = "noapps" class = "empty" "No app is connected to this repository." } }if (canAct) {div { id = "reviewagain"for (ap of apps) {button { class = "quiet" type = "button" value = ap.id "Review again: " ap.name on click(e) { emit askAgain(e.target.value) } }}}}// Runtime row/state classes have no Style-rule selection form.button { id = "mergepull" class = mergeClass type = "button" "Merge" on click(e) { emit mergeIt() } }p { id = "pullnotice" actNotice }p { id = "pullerror" actError }h3 { "Reviews" }if (noReviews) { p { id = "noreviews" class = "empty" "No review yet." } }ol { id = "reviewlist"for (rv of reviews) {// Runtime row/state classes have no Style-rule selection form.li { class = rv.verdictp { Style.pHeadstrong { rv.app }span { Style.spanTag "app" }span { class = "verdict" rv.words }span { class = "muted" rv.head + " · " + rv.earlier + " · " + rv.created }}Markdown { blocks = rv.blocks }}}}h3 { "Threads" }if (noThreads) { p { id = "nothreads" class = "empty" "No inline comments yet." } }ol { id = "threadlist"for (th of threads) {// Runtime row/state classes have no Style-rule selection form.li { class = th.clsp { Style.pHeadcode { Style.codeWhere th.where }span { Style.spanMark th.mark }span { class = "muted" th.app }}ol { Style.olCommentsfor (c of th.comments) {// Runtime row/state classes have no Style-rule selection form.li { class = c.kindp { Style.pHeadstrong { c.author }span { class = "muted" c.created }}Markdown { blocks = c.blocks }}}}if (canAct) {PullReply { threadId = th.id toggleLabel = th.toggleLabel nextState = th.nextState sendReply = replyIt resolveThread = toggleThread }}}}}h3 { "Conversation" }if (noConversation) { p { id = "noconversation" class = "empty" "Nobody has written here yet." } }ol { id = "conversation"for (c of conversation) {// Runtime row/state classes have no Style-rule selection form.li { class = c.kindp { Style.pHeadstrong { c.author }if (c.isApp) { span { Style.spanTag "app" } }span { class = "muted" c.created }}Markdown { blocks = c.blocks }}}}if (canAct) {form { id = "commentform"on submit(e) {e.preventDefault()emit commentIt(e)}label { "Write a comment (Markdown)"textarea { id = "commentbody" name = "body" rows = "4" maxlength = "65536" required = "required" value = commentBody on input(e) { commentBody = e.target.value } }}button { id = "commentsave" type = "submit" "Comment" }}}if (readOnly) { p { id = "readonlyhint" class = "muted" "Only the owner and the members of this repository can comment here." } }}}}}// what a face answers is the page read again: every list is set from itapply = (r) => {if (r == null || r.error != null) {actError = r != null ? r.error : 'that did not work'return false}w = r.viewpr = w.prstatuses = w.statuseshasStatuses = w.hasStatusesverdicts = w.verdictshasVerdicts = w.hasVerdictsnoVerdicts = !w.hasVerdictsreviews = w.reviewshasReviews = w.hasReviewsnoReviews = !w.hasReviewsthreads = w.threadshasThreads = w.hasThreadsnoThreads = !w.hasThreadsconversation = w.conversationhasConversation = w.hasConversationnoConversation = !w.hasConversationmergeClass = w.mergeClassactError = ''actNotice = r.notice != null ? r.notice : ''return true}on commentIt(e) {r = emit server gitoriaPrComment(slug, n, commentBody)if (apply(r)) { commentBody = '' }}replyIt = (threadId, body) => {r = emit server gitoriaPrReply(slug, n, threadId, body)return apply(r)}toggleThread = (threadId, resolved) => {r = emit server gitoriaPrResolve(slug, n, threadId, resolved)apply(r)}on mergeIt() {r = emit server gitoriaPrMerge(slug, n)apply(r)}on askAgain(appId) {r = emit server gitoriaPrAskAgain(slug, n, appId)apply(r)}on server gitoriaPrComment(slugOf, nText, body, session) { return commentOnPull(slugOf, nText, session, body) }on server gitoriaPrReply(slugOf, nText, threadId, body, session) { return replyInThread(slugOf, nText, session, threadId, body) }on server gitoriaPrResolve(slugOf, nText, threadId, resolved, session) { return setThreadResolved(slugOf, nText, session, threadId, resolved) }on server gitoriaPrMerge(slugOf, nText, session) { return mergeThePull(slugOf, nText, session) }on server gitoriaPrAskAgain(slugOf, nText, appId, session) { return reviewAgain(slugOf, nText, session, appId) }Style {pullPage {display = 'grid'gap = '1rem'minWidth = '0'overflowWrap = 'anywhere'// Direct-child and sibling combinators have no bare language form.'> *' {margin = '0'}// Runtime and theme class predicates have no bare selector form.'.nomerge' {display = 'none'}// Runtime and theme class predicates have no bare selector form.'.muted' {fontSize = '.875rem'}}#pullmeta {display = 'flex'flexWrap = 'wrap'alignItems = 'center'gap = '.25rem .8rem'}#pullstatuses {display = 'flex'flexWrap = 'wrap'gap = '.25rem .5rem'margin = '0'padding = '0'listStyle = 'none'li {display = 'inline-flex'flexWrap = 'wrap'gap = '0 .4rem'padding = '.1rem .6rem'fontSize = '.8125rem'background = 'var(--color-background-sunken)'borderRadius = 'var(--radius-large)'}// Runtime and theme class predicates have no bare selector form.'.success' {color = 'var(--color-success)'}// Runtime and theme class predicates have no bare selector form.'.failure' {color = 'var(--color-danger)'}}#pullverdicts {display = 'grid'gap = '.25rem'margin = '0'padding = '0'listStyle = 'none'li {display = 'flex'flexWrap = 'wrap'gap = '0 .6rem'}// Runtime and theme class predicates have no bare selector form.'.approve' {color = 'var(--color-success)'}// Runtime and theme class predicates have no bare selector form.'.request_changes' {color = 'var(--color-danger)'}}#reviewagain {display = 'flex'flexWrap = 'wrap'gap = '.5rem'}#reviewlist {display = 'grid'gap = '.5rem'margin = '0'padding = '0'listStyle = 'none'li {padding = '.5rem 1rem'background = 'var(--color-surface)'borderRadius = 'var(--radius-large)'}}#threadlist {display = 'grid'gap = '.5rem'margin = '0'padding = '0'listStyle = 'none'// Direct-child and sibling combinators have no bare language form.'> li' {padding = '.5rem 1rem'background = 'var(--color-surface)'borderRadius = 'var(--radius-large)'}// Runtime and theme class predicates have no bare selector form.'.resolved' {opacity = '.75'}}#conversation {display = 'grid'gap = '.5rem'margin = '0'padding = '0'listStyle = 'none'li {padding = '.5rem 1rem'background = 'var(--color-surface)'borderRadius = 'var(--radius-large)'}}#commentform {display = 'grid'gap = '.75rem'}spanNumber {marginRight = '.5rem'color = 'var(--color-text-muted)'fontWeight = '400'}spanTag {padding = '0 .4rem'fontSize = '.75rem'background = 'var(--color-background-sunken)'borderRadius = 'var(--radius-large)'}pHead {display = 'flex'flexWrap = 'wrap'alignItems = 'center'gap = '.25rem .6rem'}spanMark {fontSize = '.875rem'color = 'var(--color-text-muted)'}olComments {display = 'grid'gap = '.5rem'margin = '0'padding = '0'listStyle = 'none'}codeWhere {fontWeight = '600'}#pullnotice {margin = '0'color = 'var(--color-success)'}#pullerror {margin = '0'color = 'var(--color-danger)'empty { display = 'none' }}}
Branches
- f1-broken-json
- f2-api-bugs
- gp-gate-ports
- heap-revert
- hl25-records
- ident-chooser-selector
- mainmain branch
- p51-public-pr-reads
- records-1112
- s25-no-session-on-login-error
- v59
- w52-person-approval
- w52b-approval-followup
- w52c-header-phone
- w53-pulls-speed-pr
- w54-repo-rename-pr
- w55-rename-org
- w56-owner-members
- w62-pr-close
- w63-force-push
- w64-org-slash
Latest commits
- 21aa57calog: parkmre
- e9f950a8reports: G25c soakmre
- a7783686log: deploy 9f41ffcmre
- 9f41ffc1log: W30b mergedmre
- bef635c1Merge branch 'w30b'mre
- 15b996a5Org list: keyed rows by @id, newest first, concat instead of hand loopmre
- c4f6d9e3reports: G25c growth huntmre
- b88e39f1log: privacy cleanup donemre
- bfd7826ddocs: neutral example organisation namemre
- 01b71c2edocs: neutral wording in missions, reports and logmre
- 3eeea733log: 2026-11-09 PR flow plan and membersmre
- e7c2ff1fdocs: neutral name for the apps-api reviewmre
- 120b7abdlog: step 3 queuedmre
- 358474bflog: P50 livemre
- 477d7bdcMerge branch 'p50'mre
- 00efc06fP50 reportmre
- e3f85afblog: commit mention slipmre
- 4d1a4cf4log: #25 numbersmre
- 1af0a60ddocs: H25 run() correctionmre
- eefa2dbcRepo setting: refuse direct pushes to the main branch (pre-receive over HTTPS and ssh)mre