From 1d8da956931ce0b6a4906033afe406603fe98c53 Mon Sep 17 00:00:00 2001 From: cel Date: Tue, 31 Jan 2017 15:23:44 -0800 Subject: Show issues closed by messages --- lib/render-msg.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'lib/render-msg.js') diff --git a/lib/render-msg.js b/lib/render-msg.js index bc0d383..a9b783f 100644 --- a/lib/render-msg.js +++ b/lib/render-msg.js @@ -55,6 +55,7 @@ RenderMsg.prototype.wrap = function (content, cb) { h('code.ssb-id', {href: this.toUrl(this.msg.key)}, this.msg.key), channel ? [' ', h('a', {href: this.toUrl(channel)}, channel)] : ''), + this.issues(done()), content), h('td.msg-right', this.msg.rel ? [this.msg.rel, ' '] : '', @@ -220,6 +221,19 @@ RenderMsg.prototype.link = function (link, cb) { }) } +RenderMsg.prototype.link1 = function (link, cb) { + var self = this + var ref = u.linkDest(link) + if (!ref) return cb(), '' + var a = h('a', {href: self.toUrl(ref)}, ref) + self.getName(ref, function (err, name) { + if (err) return cb(err) + a.childNodes[0].textContent = name + cb() + }) + return a +} + RenderMsg.prototype.about = function (cb) { var img = u.linkDest(this.c.image) this.wrapMini([ @@ -335,3 +349,23 @@ RenderMsg.prototype.issue = function (cb) { RenderMsg.prototype.object = function (cb) { this.wrapMini(h('pre', this.c.type), cb) } + +RenderMsg.prototype.issues = function (cb) { + var self = this + var done = multicb({pluck: 1, spread: true}) + var els = u.toArray(self.c.issues).map(function (issue) { + var commit = issue.object || issue.label ? [ + issue.object ? h('code', issue.object) : '', ' ', + issue.label ? h('q', issue.label) : ''] : '' + if (issue.merged === true) + return h('div', + 'merged ', self.link1(issue, done()), + commit ? [' in ', commit] : '') + if (issue.open === false) + return h('div', + 'closed ', self.link1(issue, done()), + commit ? [' in ', commit] : '') + }) + done(cb) + return els +} -- cgit v1.2.3