git ssb

16+

Dominic / patchbay



Commit 4de55198f28a26699cb48dbe58ca2d058e0ebe88

Add close/reopen issue action

Charles Lehner committed on 8/2/2016, 1:51:10 AM
Parent: c76c3ea7deaa59d8cb641d653848825e7c5818c6

Files changed

modules/git.jschanged
modules/message.jschanged
style.csschanged
modules/git.jsView
@@ -4,8 +4,9 @@
44 var human = require('human-time')
55
66 var plugs = require('../plugs')
77 var message_link = plugs.first(exports.message_link = [])
8+var message_confirm = plugs.first(exports.message_confirm = [])
89 var sbot_links = plugs.first(exports.sbot_links = [])
910 var sbot_links2 = plugs.first(exports.sbot_links2 = [])
1011 var sbot_get = plugs.first(exports.sbot_get = [])
1112 var getAvatar = require('ssb-avatar')
@@ -224,8 +225,19 @@
224225 }) : null
225226 )
226227 }
227228
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+
228240 if (c.type === 'issue') {
229241 return h('div',
230242 h('p', 'opened issue on ', repoLink(c.project)),
231243 c.title ? h('h4', c.title) : '',
@@ -255,5 +267,26 @@
255267 return el
256268 }
257269 }
258270
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+}
259292
modules/message.jsView
@@ -37,9 +37,9 @@
3737 h('div.message_meta.row', message_meta(msg))
3838 ),
3939 h('div.message_content', el),
4040 h('div.message_actions.row',
41- h('div.actions', message_action(msg), ' ',
41+ h('div.actions', message_action(msg),
4242 h('a', {href: '#' + msg.key}, 'Reply')
4343 )
4444 ),
4545 backlinks,
style.cssView
@@ -160,12 +160,15 @@
160160 .message_actions {
161161 float: right;
162162 }
163163
164-.dig {
164+.actions > * {
165+ padding-left: 5px;
166+ margin-left: 1px;
167+}
168+.actions > :not(:last-child) {
165169 border-right: 2px solid #eee;
166- padding-right: .6ex;
167- margin-right: .1ex;
170+ padding-right: 5px;
168171 }
169172
170173 .message > .title > .avatar {
171174 margin-left: 0;

Built with git-ssb-web