Commit fb788ecc6f5461763fcecf1d282fc68adc16da66
Merge serveRepoPullReqs into serveRepoIssues
Charles Lehner committed on 4/17/2016, 12:21:27 AMParent: 351e84025393b1505cc97f2d743bc5be6c97b6ac
Files changed
index.js | changed |
index.js | |||
---|---|---|---|
@@ -1198,12 +1198,12 @@ | |||
1198 | 1198 … | if (filePath.length == 0) | |
1199 | 1199 … | return serveRepoNewIssue(req, repo) | |
1200 | 1200 … | break | |
1201 | 1201 … | default: | |
1202 | - return serveRepoIssues(req, repo, filePath) | ||
1202 … | + return serveRepoIssues(req, repo, false) | ||
1203 | 1203 … | } | |
1204 | 1204 … | case 'pulls': | |
1205 | - return serveRepoPullReqs(req, repo) | ||
1205 … | + return serveRepoIssues(req, repo, true) | ||
1206 | 1206 … | case 'compare': | |
1207 | 1207 … | return serveRepoCompare(req, repo) | |
1208 | 1208 … | case 'comparing': | |
1209 | 1209 … | return serveRepoComparing(req, repo) | |
@@ -2040,74 +2040,31 @@ | |||
2040 | 2040 … | } | |
2041 | 2041 … | ||
2042 | 2042 … | /* Issues */ | |
2043 | 2043 … | ||
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">+ ' + 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) { | ||
2091 | 2045 … | var count = 0 | |
2092 | 2046 … | 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([ | ||
2094 | 2049 … | pull.once( | |
2095 | 2050 … | (isPublic ? '' : | |
2096 | 2051 … | '<form class="right-bar" method="get"' + | |
2097 | - ' action="' + encodeLink([repo.id, 'compare']) + '">' + | ||
2098 | - '<button class="btn">+ ' + req._t('pullRequest.New') + | ||
2052 … | + ' action="' + encodeLink(newPath) + '">' + | ||
2053 … | + '<button class="btn">+ ' + | ||
2054 … | + req._t(isPRs ? 'pullRequest.New' : 'issue.New') + | ||
2099 | 2055 … | '</button>' + | |
2100 | 2056 … | '</form>') + | |
2101 | - '<h3>' + req._t('PullRequests') + '</h3>' + | ||
2057 … | + '<h3>' + req._t(isPRs ? 'PullRequests' : 'Issues') + '</h3>' + | ||
2102 | 2058 … | nav([ | |
2103 | 2059 … | ['?', req._t('issues.Open'), 'open'], | |
2104 | 2060 … | ['?state=closed', req._t('issues.Closed'), 'closed'], | |
2105 | 2061 … | ['?state=all', req._t('issues.All'), 'all'] | |
2106 | 2062 … | ], state)), | |
2107 | 2063 … | pull( | |
2108 | - pullReqs.list({ | ||
2064 … | + (isPRs ? pullReqs : issues).list({ | ||
2109 | 2065 … | repo: repo.id, | |
2066 … | + project: repo.id, | ||
2110 | 2067 … | open: {open: true, closed: false}[state] | |
2111 | 2068 … | }), | |
2112 | 2069 … | pull.map(function (issue) { | |
2113 | 2070 … | count++ | |
@@ -2126,9 +2083,10 @@ | |||
2126 | 2083 … | '</section>' | |
2127 | 2084 … | }) | |
2128 | 2085 … | ), | |
2129 | 2086 … | 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>') | ||
2131 | 2089 … | }) | |
2132 | 2090 … | ])) | |
2133 | 2091 … | } | |
2134 | 2092 … |
Built with git-ssb-web