gitoria
All repositories: gitoria
10.8 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 { 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.readOnlyactError = ''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) {form { class = "replyform"on submit(e) {e.preventDefault()emit replyIt(e, th.id)}label { "Reply"textarea { name = "body" rows = "3" maxlength = "65536" required = "required" }}button { type = "submit" "Reply" }button { class = "quiet" type = "button" th.toggleLabel on click(e) { emit toggleThread(th.id, th.nextState) } }}}}}}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" }}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) {f = e.target.elementsr = emit server gitoriaPrComment(slug, n, f.body.value)if (apply(r)) { f.body.value = '' }}on replyIt(e, threadId) {f = e.target.elementsr = emit server gitoriaPrReply(slug, n, threadId, f.body.value)if (apply(r)) { f.body.value = '' }}on 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'}'.replyform' {display = 'grid'gap = '.5rem'justifyItems = 'start'}}
Branches
Latest commits
- ac5ba6a4log: W60, #25 measuredmre
- 452f6a1amission W60: logic clean-upsmre
- 1448c899log: cleanup, #49 GPTBot, tracker mentions on #36mre
- fcf95936log: v1.5.1 provenmre
- 22105420log: W51b livemre
- 7e8aabeareport: W51b pull source verificationmre
- 6c18de76fix: preserve pull sources across containing branchesmre
- fc36fa2elog: W51b pull source bugmre
- 56bc1220log: v1.5.1 livemre
- 845fc0aareport: W51mre
- 83127391fix: return v1.5.1 app and merge error detailsmre
- b07d0e97log: W51 v1.5.1 startedmre
- 0b417d06docs: apps-api v1.5 user tokens (#48, W49)mre
- d046940alog: vinzenz contract note sentmre
- db443456log: vinzenz note retry 2mre
- 802f229alog: kunibert repo ping provenmre
- 2d2eaa92log: Kunibert connected to kunibert repomre
- 65d5f80alogmre
- dab74b0dW49 report, logmre
- fd4fc028Exercise member status reads with a populated check statemre