aboutsummaryrefslogtreecommitdiff
path: root/lib/serve.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-08-24 21:24:31 -0700
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-08-25 13:48:21 -0700
commitfc9a0a9381d5be936e2349d4fd655094bf7e500c (patch)
treebb5f89b4928ff8030e37f54c7ea91c3e54edd9a8 /lib/serve.js
parentf76defc54c292f33838caf35eca329793ff7d733 (diff)
downloadpatchfoo-fc9a0a9381d5be936e2349d4fd655094bf7e500c.tar.gz
patchfoo-fc9a0a9381d5be936e2349d4fd655094bf7e500c.zip
Implement close issue checkbox
Diffstat (limited to 'lib/serve.js')
-rw-r--r--lib/serve.js32
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'})