diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /app/assets/javascripts/jira_connect.js | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) | |
download | gitlab-ce-85dc423f7090da0a52c73eb66faf22ddb20efff9.tar.gz |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'app/assets/javascripts/jira_connect.js')
-rw-r--r-- | app/assets/javascripts/jira_connect.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/app/assets/javascripts/jira_connect.js b/app/assets/javascripts/jira_connect.js new file mode 100644 index 00000000000..895cdc4562c --- /dev/null +++ b/app/assets/javascripts/jira_connect.js @@ -0,0 +1,56 @@ +/* eslint-disable func-names, no-var, no-alert */ +/* global $ */ +/* global AP */ + +/** + * This script is not going through Webpack bundling + * as it is only included in `app/views/jira_connect/subscriptions/index.html.haml` + * which is going to be rendered within iframe on Jira app dashboard + * hence any code written here needs to be IE11+ compatible (no fully ES6) + */ + +function onLoaded() { + var reqComplete = function() { + AP.navigator.reload(); + }; + + var reqFailed = function(res) { + alert(res.responseJSON.error); + }; + + $('#add-subscription-form').on('submit', function(e) { + var actionUrl = $(this).attr('action'); + e.preventDefault(); + + AP.context.getToken(function(token) { + // eslint-disable-next-line no-jquery/no-ajax + $.post(actionUrl, { + jwt: token, + namespace_path: $('#namespace-input').val(), + format: 'json', + }) + .done(reqComplete) + .fail(reqFailed); + }); + }); + + $('.remove-subscription').on('click', function(e) { + var href = $(this).attr('href'); + e.preventDefault(); + + AP.context.getToken(function(token) { + // eslint-disable-next-line no-jquery/no-ajax + $.ajax({ + url: href, + method: 'DELETE', + data: { + jwt: token, + format: 'json', + }, + }) + .done(reqComplete) + .fail(reqFailed); + }); + }); +} +document.addEventListener('DOMContentLoaded', onLoaded); |