-
-
Notifications
You must be signed in to change notification settings - Fork 775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add button to sync Github issue #4899
Changes from 2 commits
543988a
4ee0e61
af7d995
797d69a
9a8a926
d8e37f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -859,6 +859,57 @@ var show_extend_deadline_modal = function() { | |
}); | ||
}; | ||
|
||
const appendGithubSyncButton = function(result) { | ||
if (isBountyOwner(result) || currentProfile.isStaff) { | ||
const title = gettext('Sync Issue'); | ||
|
||
$('#github_actions').append('<button sync-github-issue id="btn-white" type="button" class="btn btn-small">' + title + '</button>'); | ||
|
||
$('#github_actions [sync-github-issue]').on('click', function(e) { | ||
const bountyId = result.pk; | ||
|
||
e.preventDefault(); | ||
|
||
$.get( | ||
'/sync/get_issue_details?url=' + encodeURIComponent(result['github_url']) + '&token=' + currentProfile.githubToken | ||
).then(function(result) { | ||
const payload = JSON.stringify({ | ||
issue_description: result.description | ||
}); | ||
|
||
return $.post('/bounty/change/' + bountyId, payload).then( | ||
function(result) { | ||
result = sanitizeAPIResults(result); | ||
_alert({ message: result.msg }, 'success'); | ||
|
||
if (result.url) { | ||
setTimeout(function() { | ||
document.location.href = result.url; | ||
}, 1000); | ||
} | ||
} | ||
).fail( | ||
function(result) { | ||
var alertMsg = result && result.responseJSON ? result.responseJSON.error : null; | ||
|
||
if (alertMsg === null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thoughts on making it as let alertMsg = result && result.responseJSON ? result.responseJSON.error : gettext('Failed to sync issue. Please reload the page and try again.'); |
||
alertMsg = gettext('Failed to sync issue. Please reload the page and try again.'); | ||
} | ||
_alert({ message: alertMsg }, 'error'); | ||
} | ||
); | ||
}).fail(function(result) { | ||
var alertMsg = result && result.responseJSON ? result.responseJSON.error : null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ^ |
||
|
||
if (alertMsg === null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let alertMsg = result && result.responseJSON ? result.responseJSON.error : gettext('Failed to sync issue. Please reload the page and try again.'); |
||
alertMsg = gettext('Failed to sync issue. Please reload the page and try again.'); | ||
} | ||
_alert({ message: alertMsg }, 'error'); | ||
}); | ||
}); | ||
} | ||
}; | ||
|
||
var build_detail_page = function(result) { | ||
|
||
// setup | ||
|
@@ -933,6 +984,7 @@ var build_detail_page = function(result) { | |
}); | ||
|
||
$('#bounty_details #issue_description code').parent().addClass('code-snippet'); | ||
appendGithubSyncButton(result); | ||
}; | ||
|
||
const is_current_user_interested = function(result) { | ||
|
@@ -1028,7 +1080,7 @@ var do_actions = function(result) { | |
enabled: enabled, | ||
href: result['action_urls']['fulfill'], | ||
text: gettext('Submit Work'), | ||
parent: 'right_actions', | ||
parent: 'bounty_actions', | ||
title: gettext('Submit work for the funder to review'), | ||
work_started: is_interested, | ||
id: 'submit' | ||
|
@@ -1044,7 +1096,7 @@ var do_actions = function(result) { | |
enabled: enabled, | ||
href: '#', | ||
text: gettext('Send Payment Reminder'), | ||
parent: 'right_actions', | ||
parent: 'bounty_actions', | ||
title: gettext('Send Payment Reminder'), | ||
id: 'notifyFunder', | ||
clickhandler: show_modal_handler(url), | ||
|
@@ -1067,7 +1119,7 @@ var do_actions = function(result) { | |
enabled: enabled, | ||
href: is_interested ? '/uninterested' : '/interested', | ||
text: text, | ||
parent: 'right_actions', | ||
parent: 'bounty_actions', | ||
title: is_interested ? gettext('Notify the funder that you will not be working on this project') : gettext('Notify the funder that you would like to take on this project'), | ||
color: is_interested ? '' : '', | ||
id: 'interest' | ||
|
@@ -1082,7 +1134,7 @@ var do_actions = function(result) { | |
enabled: enabled, | ||
href: result['action_urls']['cancel'], | ||
text: gettext('Cancel Bounty'), | ||
parent: 'right_actions', | ||
parent: 'bounty_actions', | ||
title: gettext('Cancel bounty and reclaim funds for this issue'), | ||
buttonclass: 'button--warning' | ||
}; | ||
|
@@ -1097,7 +1149,7 @@ var do_actions = function(result) { | |
href: result['action_urls']['payout'], | ||
text: gettext('Payout Bounty'), | ||
title: gettext('Payout the bounty to one or more submitters.'), | ||
parent: 'right_actions' | ||
parent: 'bounty_actions' | ||
}; | ||
|
||
actions.push(_entry); | ||
|
@@ -1110,7 +1162,7 @@ var do_actions = function(result) { | |
enabled: enabled, | ||
href: result['action_urls']['contribute'], | ||
text: gettext('Contribute'), | ||
parent: 'right_actions', | ||
parent: 'bounty_actions', | ||
title: gettext('Help by funding or promoting this issue') | ||
}; | ||
|
||
|
@@ -1123,7 +1175,7 @@ var do_actions = function(result) { | |
enabled: enabled, | ||
href: '/extend-deadlines', | ||
text: gettext('Extend Expiration'), | ||
parent: 'right_actions', | ||
parent: 'bounty_actions', | ||
title: gettext('Extend deadline of an issue') | ||
}; | ||
|
||
|
@@ -1135,7 +1187,7 @@ var do_actions = function(result) { | |
enabled: true, | ||
href: result['action_urls']['invoice'], | ||
text: gettext('Show Invoice'), | ||
parent: 'right_actions', | ||
parent: 'bounty_actions', | ||
title: gettext('View an Invoice for this Issue') | ||
}; | ||
|
||
|
@@ -1148,16 +1200,9 @@ var do_actions = function(result) { | |
enabled: true, | ||
href: '/bounty/change/' + result['pk'], | ||
text: gettext('Edit Issue Details'), | ||
parent: 'right_actions', | ||
parent: 'bounty_actions', | ||
title: gettext('Update your Bounty Settings to get the right Crowd') | ||
}// , | ||
// { | ||
// enabled: true, | ||
// href: '/issue/refund_request?pk=' + result['pk'], | ||
// text: gettext('Request Fee Refund'), | ||
// parent: 'right_actions', | ||
// title: gettext('Raise a request if you believe you need your fee refunded') | ||
// } | ||
} | ||
]; | ||
|
||
actions.push(..._entry); | ||
|
@@ -1174,9 +1219,9 @@ var do_actions = function(result) { | |
enabled: true, | ||
href: github_url, | ||
text: (result['repo_type'] === 'private' ? '<i class="fas fa-lock"></i> ' + | ||
gettext('Private Repo') : gettext('View On Github')) + | ||
(result['is_issue_closed'] ? gettext(' (Issue is closed)') : ''), | ||
parent: 'right_actions', | ||
gettext('Private Repo') : gettext('View On Github')) + | ||
(result['is_issue_closed'] ? gettext(' (Issue is closed)') : ''), | ||
parent: 'github_actions', | ||
title: gettext('View issue details and comments on Github'), | ||
comments: result['github_comments'], | ||
color: 'white' | ||
|
@@ -1192,7 +1237,7 @@ var do_actions = function(result) { | |
enabled: true, | ||
href: job_url, | ||
text: gettext('View Attached Job Description'), | ||
parent: 'right_actions', | ||
parent: 'bounty_actions', | ||
title: gettext('This bounty funder is hiring for a full time, part time, or contract role and has attached that to this bounty.'), | ||
color: 'white' | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we update this to
let
?