diff options
-rw-r--r-- | lib/serve.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/serve.js b/lib/serve.js index 1206b36..64c96df 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -3694,6 +3694,7 @@ Serve.prototype.composer = function (opts, cb) { ' fork thread' ) ) : '', + closeIssueCheckbox(done()), h('textarea', { id: opts.id, name: 'text', @@ -3861,6 +3862,17 @@ Serve.prototype.composer = function (opts, cb) { content.root = opts.root || undefined content.branch = u.fromArray(opts.branches) || undefined } + if (data.close_issue) { + content.issue = opts.root || undefined + content.project = data.project || undefined + content.repo = data.repo || undefined + content.issues = [ + { + link: opts.root, + open: false + } + ] + } if (channel) content.channel = data.channel done(function (err) { @@ -3868,6 +3880,26 @@ Serve.prototype.composer = function (opts, cb) { }) } + function closeIssueCheckbox(cb) { + var container = h('div') + if (opts.root) self.getMsgDecryptedMaybeOoo(opts.root, function (err, rootMsg) { + if (err) return console.trace(err), cb(null) + var rootC = rootMsg && rootMsg.value.content && rootMsg.value.content + if (!rootC) return cb(null) + var canCloseIssue = rootC.type === 'issue' + var canClosePR = rootC.type === 'pull-request' + if (canCloseIssue || canClosePR) container.appendChild(h('label', {for: 'close_issue'}, + h('input', {id: 'close_issue', type: 'checkbox', name: 'close_issue', value: 'post', checked: data.close_issue || undefined}), + ' close ' + (canClosePR ? 'pull-request' : 'issue'), + rootC.project ? h('input', {type: 'hidden', name: 'project', value: rootC.project}) : '', + rootC.repo ? h('input', {type: 'hidden', name: 'repo', value: rootC.repo}) : '' + )) + cb(null) + }) + else cb(null) + return container + } + function preview(raw, cb) { var msgContainer = h('table.ssb-msgs') var contentInput = h('input', {type: 'hidden', name: 'content'}) |