Commit a282c43eb17a12a9a7d49e9c95560668ec1f08b7
Deprecate issue/pull-request title field
%b9wdyGH54m8uHkONgqFrMEv7/qDNlRKs5umsOh2Mm0I=.sha256Charles Lehner committed on 7/25/2016, 11:38:08 PM
Parent: c5fd039a4f079653cc7e704ff3e7fac0cf920b7c
Files changed
index.js | changed |
lib/about.js | changed |
lib/repos/issues.js | changed |
lib/repos/pulls.js | changed |
lib/util.js | changed |
locale/en.json | changed |
locale/eo.json | changed |
package.json | changed |
index.js | ||
---|---|---|
@@ -292,21 +292,8 @@ | ||
292 | 292 | if (err) return cb(null, self.serveError(req, err)) |
293 | 293 | cb(null, self.serveRedirect(req, req.url)) |
294 | 294 | }) |
295 | 295 | |
296 | - case 'issue-title': | |
297 | - if (!data.id) | |
298 | - return cb(null, self.serveError(req, | |
299 | - new ParamError(req._t('error.MissingId')), 400)) | |
300 | - if (!data.name) | |
301 | - return cb(null, self.serveError(req, | |
302 | - new ParamError(req._t('error.MissingName')), 400)) | |
303 | - var msg = Issues.schemas.edit(data.id, {title: data.name}) | |
304 | - return self.ssb.publish(msg, function (err) { | |
305 | - if (err) return cb(null, self.serveError(req, err)) | |
306 | - cb(null, self.serveRedirect(req, req.url)) | |
307 | - }) | |
308 | - | |
309 | 296 | case 'comment': |
310 | 297 | if (!data.id) |
311 | 298 | return cb(null, self.serveError(req, |
312 | 299 | new ParamError(req._t('error.MissingId')), 400)) |
@@ -325,9 +312,9 @@ | ||
325 | 312 | cb(null, self.serveRedirect(req, req.url)) |
326 | 313 | }) |
327 | 314 | |
328 | 315 | case 'new-issue': |
329 | - var msg = Issues.schemas.new(dir, data.title, data.text) | |
316 | + var msg = Issues.schemas.new(dir, data.text) | |
330 | 317 | var mentions = Mentions(data.text) |
331 | 318 | if (mentions.length) |
332 | 319 | msg.mentions = mentions |
333 | 320 | return self.ssb.publish(msg, function (err, msg) { |
@@ -336,9 +323,9 @@ | ||
336 | 323 | }) |
337 | 324 | |
338 | 325 | case 'new-pull': |
339 | 326 | var msg = PullRequests.schemas.new(dir, data.branch, |
340 | - data.head_repo, data.head_branch, data.title, data.text) | |
327 | + data.head_repo, data.head_branch, data.text) | |
341 | 328 | var mentions = Mentions(data.text) |
342 | 329 | if (mentions.length) |
343 | 330 | msg.mentions = mentions |
344 | 331 | return self.ssb.publish(msg, function (err, msg) { |
@@ -619,9 +606,9 @@ | ||
619 | 606 | }) + '</section>') |
620 | 607 | }) |
621 | 608 | case 'issue': |
622 | 609 | case 'pull-request': |
623 | - var issueLink = u.link([msg.key], c.title) | |
610 | + var issueLink = u.link([msg.key], u.messageTitle(msg)) | |
624 | 611 | return self.getMsg(c.project, function (err, projectMsg) { |
625 | 612 | if (err) return cb(null, |
626 | 613 | self.repos.serveRepoNotFound(req, c.repo, err)) |
627 | 614 | self.getRepoName(projectMsg.author, c.project, |
lib/about.js | ||
---|---|---|
@@ -9,8 +9,9 @@ | ||
9 | 9 | |
10 | 10 | var pull = require('pull-stream') |
11 | 11 | var cat = require('pull-cat') |
12 | 12 | var asyncMemo = require('asyncmemo') |
13 | +var u = require('./util') | |
13 | 14 | |
14 | 15 | module.exports = function (sbot, id) { |
15 | 16 | var getAbout = asyncMemo(getAboutFull, sbot, id) |
16 | 17 | |
@@ -28,13 +29,8 @@ | ||
28 | 29 | |
29 | 30 | return getAbout |
30 | 31 | } |
31 | 32 | |
32 | -function truncate(str, len) { | |
33 | - str = String(str) | |
34 | - return str.length < len ? str : str.substr(0, len-1) + '…' | |
35 | -} | |
36 | - | |
37 | 33 | // Get About info (name and icon) for a feed. |
38 | 34 | function getAboutFull(sbot, source, dest, cb) { |
39 | 35 | var info = {} |
40 | 36 | var target = dest.target || dest |
@@ -77,9 +73,9 @@ | ||
77 | 73 | if (!info.image && c.image) |
78 | 74 | info.image = c.image.link |
79 | 75 | }, function (err) { |
80 | 76 | if (err && err !== true) return cb(err) |
81 | - if (!info.name) info.name = truncate(target, 20) | |
77 | + if (!info.name) info.name = u.truncate(target, 20) | |
82 | 78 | cb(null, info) |
83 | 79 | }) |
84 | 80 | ) |
85 | 81 |
lib/repos/issues.js | ||
---|---|---|
@@ -88,11 +88,9 @@ | ||
88 | 88 | return this.repo.renderRepoPage(req, repo, 'issues', null, title, pull.once( |
89 | 89 | '<h3>' + req._t('issue.New') + '</h3>' + |
90 | 90 | '<section><form action="" method="post">' + |
91 | 91 | '<input type="hidden" name="action" value="new-issue">' + |
92 | - '<p><input class="wide-input" name="title" placeholder="' + | |
93 | - req._t('issue.Title') + '" size="77" /></p>' + | |
94 | - forms.post(req, repo, req._t('Description'), 8) + | |
92 | + forms.post(req, repo, null, 8) + | |
95 | 93 | '<button type="submit" class="btn">' + req._t('Create') + '</button>' + |
96 | 94 | '</form></section>')) |
97 | 95 | } |
98 | 96 | |
@@ -105,11 +103,9 @@ | ||
105 | 103 | var newestMsg = {key: issue.id, value: {timestamp: issue.created_at}} |
106 | 104 | var title = u.escape(issue.title) + ' · %{author}/%{repo}' |
107 | 105 | return self.repo.renderRepoPage(req, repo, 'issues', null, title, cat([ |
108 | 106 | pull.once( |
109 | - forms.name(req, !self.web.isPublic, issue.id, issue.title, | |
110 | - 'issue-title', null, req._t('issue.Rename'), | |
111 | - '<h3>' + u.link([issue.id], issue.title) + '</h3>') + | |
107 | + '<h3>' + u.link([issue.id], issue.title) + '</h3>' + | |
112 | 108 | '<code>' + issue.id + '</code>' + |
113 | 109 | '<section class="collapse">' + |
114 | 110 | (issue.open |
115 | 111 | ? '<strong class="issue-status open">' + |
@@ -190,13 +186,14 @@ | ||
190 | 186 | return '<section class="collapse mention-preview">' + |
191 | 187 | req._t('issue.MentionedIn', { |
192 | 188 | name: authorLink, |
193 | 189 | type: type, |
194 | - post: u.link([msg.key], String(c.title || msg.key).substr(0, 140)) | |
190 | + post: u.link([msg.key], u.messageTitle(msg)) | |
195 | 191 | }) + '</section>' |
196 | 192 | case 'issue-edit': |
197 | 193 | return '<section class="collapse">' + |
198 | 194 | (msg.key == postId ? '<div class="highlight">' : '') + |
195 | + // handle deprecated rename | |
199 | 196 | (c.title == null ? '' : req._t('issue.Renamed', { |
200 | 197 | author: authorLink, |
201 | 198 | type: type, |
202 | 199 | name: '<q>' + u.escape(c.title) + '</q>' |
lib/repos/pulls.js | ||
---|---|---|
@@ -28,11 +28,9 @@ | ||
28 | 28 | var page = path[0] || 'activity' |
29 | 29 | var title = u.escape(pr.title) + ' · %{author}/%{repo}' |
30 | 30 | return self.repo.renderRepoPage(req, repo, 'pulls', null, title, cat([ |
31 | 31 | pull.once('<div class="pull-request">' + |
32 | - forms.name(req, !self.web.isPublic, pr.id, pr.title, | |
33 | - 'issue-title', null, req._t('pullRequest.Rename'), | |
34 | - '<h3>' + u.link([pr.id], pr.title) + '</h3>') + | |
32 | + '<h3>' + u.link([pr.id], pr.title) + '</h3>' + | |
35 | 33 | '<code>' + pr.id + '</code>'), |
36 | 34 | u.readOnce(function (cb) { |
37 | 35 | var done = multicb({ pluck: 1, spread: true }) |
38 | 36 | var gotHeadRepo = done() |
@@ -371,11 +369,9 @@ | ||
371 | 369 | branch: baseBranch, |
372 | 370 | head_repo: headRepoId, |
373 | 371 | head_branch: headBranch |
374 | 372 | }) + |
375 | - '<input class="wide-input" name="title"' + | |
376 | - ' placeholder="' + req._t('Title') + '" size="77"/>' + | |
377 | - forms.post(req, repo, req._t('Description'), 8) + | |
373 | + forms.post(req, repo, null, 8) + | |
378 | 374 | '<button type="submit" class="btn open">' + |
379 | 375 | req._t('Create') + '</button>' + |
380 | 376 | '</form></section>' |
381 | 377 | : self.web.isPublic ? '' |
lib/util.js | ||
---|---|---|
@@ -148,4 +148,14 @@ | ||
148 | 148 | |
149 | 149 | u.sortMsgs = function (descending) { |
150 | 150 | return u.pullSort(compareMsgs, descending) |
151 | 151 | } |
152 | + | |
153 | +u.truncate = function (str, len) { | |
154 | + str = String(str) | |
155 | + return str.length < len ? str : str.substr(0, len) + '…' | |
156 | +} | |
157 | + | |
158 | +u.messageTitle = function (msg) { | |
159 | + var c = msg.value.content | |
160 | + return u.truncate(c.title || c.text || msg.key, 40) | |
161 | +} |
locale/en.json | ||
---|---|---|
@@ -115,11 +115,8 @@ | ||
115 | 115 | "Open": "Open", |
116 | 116 | "Closed": "Closed" |
117 | 117 | }, |
118 | 118 | "New": "New Issue", |
119 | - "Title": "Issue Title", | |
120 | - "Description": "Description", | |
121 | - "Rename": "Rename the issue", | |
122 | 119 | "Opened": "%{name} opened this issue on %{datetime}", |
123 | 120 | "Reopened": "%{name} reopened this %{type}", |
124 | 121 | "Closed": "%{name} closed this %{type}", |
125 | 122 | "Mentioned": "%{name} mentioned this %{type}", |
@@ -129,9 +126,8 @@ | ||
129 | 126 | "Close": "Close %{type}", |
130 | 127 | "Reopen": "Reopen %{type}" |
131 | 128 | }, |
132 | 129 | "pullRequest": { |
133 | - "Rename": "Rename the pull request", | |
134 | 130 | "WantToMerge": "%{name} wants to merge commits into %{base} from %{head}", |
135 | 131 | "Discussion": "Discussion", |
136 | 132 | "New": "New Pull Request" |
137 | 133 | }, |
locale/eo.json | ||
---|---|---|
@@ -115,11 +115,8 @@ | ||
115 | 115 | "Open": "Malfermita", |
116 | 116 | "Closed": "Fermita" |
117 | 117 | }, |
118 | 118 | "New": "Nova Temo", |
119 | - "Title": "Temo titolo", | |
120 | - "Description": "Priskribo", | |
121 | - "Rename": "Renomiĝi la temon", | |
122 | 119 | "Opened": "%{name} malfermis tiun temon je %{datetime}", |
123 | 120 | "Reopened": "%{name} remalfermis tiun %{type}", |
124 | 121 | "Closed": "%{name} fermis tiun %{type}", |
125 | 122 | "Mentioned": "%{name} menciis tiun %{type}", |
@@ -129,9 +126,8 @@ | ||
129 | 126 | "Close": "Fermi %{type}", |
130 | 127 | "Reopen": "Remalfermi %{type}" |
131 | 128 | }, |
132 | 129 | "pullRequest": { |
133 | - "Rename": "Alinomigado el tiro-petojn", | |
134 | 130 | "WantToMerge": "%{name} volas kunfandi enmetoj en %{base} de %{head}", |
135 | 131 | "Discussion": "Priparolado", |
136 | 132 | "New": "Nova Tiro-peto" |
137 | 133 | }, |
package.json | ||
---|---|---|
@@ -19,14 +19,14 @@ | ||
19 | 19 | "pull-stream": "^3.1.0", |
20 | 20 | "ssb-client": "^3.0.1", |
21 | 21 | "ssb-config": "^1.1.0", |
22 | 22 | "ssb-git-repo": "^1.8.0", |
23 | - "ssb-issues": "^0.1.4", | |
23 | + "ssb-issues": "^0.2.0", | |
24 | 24 | "ssb-keys": "^5.0.0", |
25 | 25 | "ssb-marked": "^0.6.0", |
26 | 26 | "ssb-mentions": "^0.1.0", |
27 | 27 | "ssb-msg-schemas": "^6.1.0", |
28 | - "ssb-pull-requests": "^0.0.4", | |
28 | + "ssb-pull-requests": "^0.1.0", | |
29 | 29 | "ssb-reconnect": "^0.1.0", |
30 | 30 | "ssb-ref": "^2.2.2", |
31 | 31 | "stream-to-pull-stream": "^1.7.0" |
32 | 32 | }, |
Built with git-ssb-web