gitoria
All repositories: gitoria
10.5 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 { class = "number" 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"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) {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) {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) } }}}}button { id = "mergepull" class = mergeClass type = "button" "Merge" on click(e) { emit mergeIt() } }p { id = "pullnotice" class = "notice" actNotice }p { id = "pullerror" class = "message" actError }h3 { "Reviews" }if (noReviews) { p { id = "noreviews" class = "empty" "No review yet." } }ol { id = "reviewlist"for (rv of reviews) {li { class = rv.verdictp { class = "head"strong { rv.app }span { class = "tag" "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) {li { class = th.clsp { class = "head"code { class = "where" th.where }span { class = "mark" th.mark }span { class = "muted" th.app }}ol { class = "comments"for (c of th.comments) {li { class = c.kindp { class = "head"strong { 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) {li { class = c.kindp { class = "head"strong { c.author }if (c.isApp) { span { class = "tag" "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''> *' {margin = '0'}'.nomerge' {display = 'none'}'.number' {marginRight = '.5rem'color = 'var(--color-text-muted)'fontWeight = '400'}'.muted' {fontSize = '.875rem'}'.tag' {padding = '0 .4rem'fontSize = '.75rem'background = 'var(--color-background-sunken)'borderRadius = 'var(--radius-large)'}'.head' {display = 'flex'flexWrap = 'wrap'alignItems = 'center'gap = '.25rem .6rem'}'.mark' {fontSize = '.875rem'color = 'var(--color-text-muted)'}}#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)'}'.success' {color = 'var(--color-success)'}'.failure' {color = 'var(--color-danger)'}}#pullverdicts {display = 'grid'gap = '.25rem'margin = '0'padding = '0'listStyle = 'none'li {display = 'flex'flexWrap = 'wrap'gap = '0 .6rem'}'.approve' {color = 'var(--color-success)'}'.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''> li' {padding = '.5rem 1rem'background = 'var(--color-surface)'borderRadius = 'var(--radius-large)'}'.resolved' {opacity = '.75'}'.comments' {display = 'grid'gap = '.5rem'margin = '0'padding = '0'listStyle = 'none'}'.where' {fontWeight = '600'}}#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'}}
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
- f3e196b5Document Markdown direct-child selector remaindersmre
- 70597528Reference pull list rules and explain runtime class predicatesmre
- 1ce7ac24Reference ticket row and feedback styles from its Viewmre
- 10cdf54bGive organization repository rows their own Style referencesmre
- 0d019521Document shared class selectors in the styles-only filemre
- c67404a7Scope token labels and feedback through the token Viewmre
- 944e3dabScope key names, fingerprints and errors to the keys Viewmre
- 7bcf7bc2Nest repo navigation media rules and document selector gapsmre
- 46a76272Reference release row styles from the Viewmre
- a383f428Tie README definition and path styles to its own Viewmre
- a90812ffConsolidate add-code styles under its existing View idmre
- 89107a3eDocument the index direct-child selector remaindermre
- 07403362Scope reply form layout through the component form rulemre
- 097c52baStyle the login error through its View idmre
- c6d9c86aOwn the not-found code rule in its componentmre
- 055424c2Record W61 replacement theme gates, sidebar repro and baselinemre
- 2ed09441Use layouts theme 17e0f03 for W61 compatibilitymre
- b8609a91Merge branch 'main' into w61-stylemre
- 4639caf7Report W61 theme startup blocker and day39 Style probemre
- 81f0a0bbREADME: two caches were restored by 90b4f72; log W62mre