modules/git.jsView |
---|
4 | 4 | var human = require('human-time') |
5 | 5 | |
6 | 6 | var plugs = require('../plugs') |
7 | 7 | var message_link = plugs.first(exports.message_link = []) |
| 8 | +var message_confirm = plugs.first(exports.message_confirm = []) |
8 | 9 | var sbot_links = plugs.first(exports.sbot_links = []) |
9 | 10 | var sbot_links2 = plugs.first(exports.sbot_links2 = []) |
10 | 11 | var sbot_get = plugs.first(exports.sbot_get = []) |
11 | 12 | var getAvatar = require('ssb-avatar') |
224 | 225 | }) : null |
225 | 226 | ) |
226 | 227 | } |
227 | 228 | |
| 229 | + if(c.type === 'issue-edit') { |
| 230 | + return h('div', |
| 231 | + 0, false, null, undefined, '', 'ok', |
| 232 | + c.title ? h('p', 'renamed issue ', message_link(c.issue), |
| 233 | + ' to ', h('ins', c.title)) : null, |
| 234 | + c.open === false ? h('p', 'closed issue ', message_link(c.issue)) : null, |
| 235 | + c.open === true ? h('p', 'reopened issue ', message_link(c.issue)) : '', |
| 236 | + c.issues ? c.issues : null |
| 237 | + ) |
| 238 | + } |
| 239 | + |
228 | 240 | if (c.type === 'issue') { |
229 | 241 | return h('div', |
230 | 242 | h('p', 'opened issue on ', repoLink(c.project)), |
231 | 243 | c.title ? h('h4', c.title) : '', |
255 | 267 | return el |
256 | 268 | } |
257 | 269 | } |
258 | 270 | |
| 271 | +exports.message_action = function (msg, sbot) { |
| 272 | + var c = msg.value.content |
| 273 | + if(c.type === 'issue' || c.type === 'pull-request') { |
| 274 | + var isOpen |
| 275 | + var a = h('a', {href: '#', onclick: function () { |
| 276 | + message_confirm({ |
| 277 | + type: 'issue-edit', |
| 278 | + issues: [{ |
| 279 | + link: msg.key, |
| 280 | + open: !isOpen |
| 281 | + }] |
| 282 | + }) |
| 283 | + }}) |
| 284 | + getIssueState(msg.key, function (err, state) { |
| 285 | + if (err) return console.error(err) |
| 286 | + isOpen = state === 'open' |
| 287 | + a.textContent = isOpen ? 'Close' : 'Reopen' |
| 288 | + }) |
| 289 | + return a |
| 290 | + } |
| 291 | +} |
259 | 292 | |