git ssb

30+

cel / git-ssb-web



Commit fb788ecc6f5461763fcecf1d282fc68adc16da66

Merge serveRepoPullReqs into serveRepoIssues

Charles Lehner committed on 4/17/2016, 12:21:27 AM
Parent: 351e84025393b1505cc97f2d743bc5be6c97b6ac

Files changed

index.jschanged
index.jsView
@@ -1198,12 +1198,12 @@
11981198 if (filePath.length == 0)
11991199 return serveRepoNewIssue(req, repo)
12001200 break
12011201 default:
1202- return serveRepoIssues(req, repo, filePath)
1202 + return serveRepoIssues(req, repo, false)
12031203 }
12041204 case 'pulls':
1205- return serveRepoPullReqs(req, repo)
1205 + return serveRepoIssues(req, repo, true)
12061206 case 'compare':
12071207 return serveRepoCompare(req, repo)
12081208 case 'comparing':
12091209 return serveRepoComparing(req, repo)
@@ -2040,74 +2040,31 @@
20402040 }
20412041
20422042 /* Issues */
20432043
2044- function serveRepoIssues(req, repo, path) {
2045- var numIssues = 0
2046- var state = req._u.query.state || 'open'
2047- return renderRepoPage(req, repo, 'issues', null, cat([
2048- pull.once(
2049- (isPublic ? '' :
2050- '<form class="right-bar" method="get"' +
2051- ' action="' + encodeLink([repo.id, 'issues', 'new']) + '">' +
2052- '<button class="btn">&plus; ' + req._t('issue.New') + '</button>' +
2053- '</form>') +
2054- '<h3>' + req._t('Issues') + '</h3>' +
2055- nav([
2056- ['?', req._t('issues.Open'), 'open'],
2057- ['?state=closed', req._t('issues.Closed'), 'closed'],
2058- ['?state=all', req._t('issues.All'), 'all']
2059- ], state)),
2060- pull(
2061- issues.createFeedStream({ project: repo.id }),
2062- pull.filter(function (issue) {
2063- return state == 'all' ? true : (state == 'closed') == !issue.open
2064- }),
2065- pull.map(function (issue) {
2066- numIssues++
2067- var state = (issue.open ? 'open' : 'closed')
2068- var stateStr = req._t(issue.open ?
2069- 'issue.state.Open' : 'issue.state.Closed')
2070- return '<section class="collapse">' +
2071- '<i class="issue-state issue-state-' + state + '"' +
2072- ' title="' + stateStr + '">◼</i> ' +
2073- '<a href="' + encodeLink(issue.id) + '">' +
2074- escapeHTML(issue.title) +
2075- '<span class="right-bar">' +
2076- new Date(issue.created_at).toLocaleString(req._locale) +
2077- '</span>' +
2078- '</a>' +
2079- '</section>'
2080- })
2081- ),
2082- readOnce(function (cb) {
2083- cb(null, numIssues > 0 ? '' : '<p>' + req._t('NoIssues') + '</p>')
2084- })
2085- ]))
2086- }
2087-
2088- /* Pull Requests */
2089-
2090- function serveRepoPullReqs(req, repo) {
2044 + function serveRepoIssues(req, repo, isPRs) {
20912045 var count = 0
20922046 var state = req._u.query.state || 'open'
2093- return renderRepoPage(req, repo, 'pulls', null, cat([
2047 + var newPath = isPRs ? [repo.id, 'compare'] : [repo.id, 'issues', 'new']
2048 + return renderRepoPage(req, repo, isPRs ? 'pulls' : 'issues', null, cat([
20942049 pull.once(
20952050 (isPublic ? '' :
20962051 '<form class="right-bar" method="get"' +
2097- ' action="' + encodeLink([repo.id, 'compare']) + '">' +
2098- '<button class="btn">&plus; ' + req._t('pullRequest.New') +
2052 + ' action="' + encodeLink(newPath) + '">' +
2053 + '<button class="btn">&plus; ' +
2054 + req._t(isPRs ? 'pullRequest.New' : 'issue.New') +
20992055 '</button>' +
21002056 '</form>') +
2101- '<h3>' + req._t('PullRequests') + '</h3>' +
2057 + '<h3>' + req._t(isPRs ? 'PullRequests' : 'Issues') + '</h3>' +
21022058 nav([
21032059 ['?', req._t('issues.Open'), 'open'],
21042060 ['?state=closed', req._t('issues.Closed'), 'closed'],
21052061 ['?state=all', req._t('issues.All'), 'all']
21062062 ], state)),
21072063 pull(
2108- pullReqs.list({
2064 + (isPRs ? pullReqs : issues).list({
21092065 repo: repo.id,
2066 + project: repo.id,
21102067 open: {open: true, closed: false}[state]
21112068 }),
21122069 pull.map(function (issue) {
21132070 count++
@@ -2126,9 +2083,10 @@
21262083 '</section>'
21272084 })
21282085 ),
21292086 readOnce(function (cb) {
2130- cb(null, count > 0 ? '' : '<p>' + req._t('NoPullRequests') + '</p>')
2087 + cb(null, count > 0 ? '' :
2088 + '<p>' + req._t(isPRs ? 'NoPullRequests' : 'NoIssues') + '</p>')
21312089 })
21322090 ]))
21332091 }
21342092

Built with git-ssb-web