git ssb

0+

ev / microbay



forked from Dominic / patchbay

Commit 77ca943d1889e9ed48ffceb25d8de3f1b5998515

Fix git issue closing/reopening and rendering

Charles Lehner committed on 8/2/2016, 8:12:02 PM
Parent: 4634187810d6f06d0603f7e7e2935ecf2ba4c000

Files changed

modules/git.jschanged
modules/git.jsView
@@ -82,8 +82,17 @@
8282 })
8383 return el
8484 }
8585
86+function renderIssueEdit(c) {
87+ var id = c.issue || c.link
88+ return [
89+ c.title ? h('p', 'renamed issue ', message_link(id),
90+ ' to ', h('ins', c.title)) : null,
91+ c.open === false ? h('p', 'closed issue ', message_link(id)) : null,
92+ c.open === true ? h('p', 'reopened issue ', message_link(id)) : null]
93+}
94+
8695 exports.message_content = function (msg, sbot) {
8796 var c = msg.value.content
8897
8998 if(c.type === 'git-repo') {
@@ -227,15 +236,10 @@
227236 }
228237
229238 if(c.type === 'issue-edit') {
230239 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- )
240+ c.issue ? renderIssueEdit(c) : null,
241+ c.issues ? c.issues.map(renderIssueEdit) : null)
238242 }
239243
240244 if(c.type === 'issue') {
241245 return h('div',
@@ -257,10 +261,11 @@
257261 }
258262
259263 exports.message_meta = function (msg, sbot) {
260264 var type = msg.value.content.type
261- if (type == 'issue' || type == 'pull-request') {
265+ if (type === 'issue' || type === 'pull-request') {
262266 var el = h('em', '...')
267+ // TODO: update if issue is changed
263268 getIssueState(msg.key, function (err, state) {
264269 if (err) return console.error(err)
265270 el.textContent = state
266271 })
@@ -274,21 +279,30 @@
274279 var isOpen
275280 var a = h('a', {href: '#', onclick: function () {
276281 message_confirm({
277282 type: 'issue-edit',
283+ root: msg.key,
278284 issues: [{
279285 link: msg.key,
280286 open: !isOpen
281287 }]
288+ }, function (err, msg) {
289+ if(err) return alert(err)
290+ if(!msg) return
291+ isOpen = msg.value.content.open
292+ update()
282293 })
283294 }})
284295 getIssueState(msg.key, function (err, state) {
285296 if (err) return console.error(err)
286297 isOpen = state === 'open'
298+ update()
299+ })
300+ function update() {
287301 a.textContent = c.type === 'pull-request'
288302 ? isOpen ? 'Close Pull Request' : 'Reopen Pull Request'
289303 : isOpen ? 'Close Issue' : 'Reopen Issue'
290- })
304+ }
291305 return a
292306 }
293307 }
294308

Built with git-ssb-web