Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-12-01 12:09:24 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-12-01 12:09:24 +0300
commita7704bf16a51a8c993215a69db17232e3f246b8e (patch)
treef0dc5c1d33e5a898d5340912548057fee3b72e43 /app/assets/javascripts/jira_connect
parent01d4c393e10ad70274aec35492bdf606a243494a (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/jira_connect')
-rw-r--r--app/assets/javascripts/jira_connect/index.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/app/assets/javascripts/jira_connect/index.js b/app/assets/javascripts/jira_connect/index.js
index 37f00d56a05..1723642d36f 100644
--- a/app/assets/javascripts/jira_connect/index.js
+++ b/app/assets/javascripts/jira_connect/index.js
@@ -1,9 +1,68 @@
import Vue from 'vue';
+import $ from 'jquery';
import App from './components/app.vue';
+/**
+ * Initialize necessary form handlers for the Jira Connect app
+ */
+const initJiraFormHandlers = () => {
+ const reqComplete = () => {
+ AP.navigator.reload();
+ };
+
+ const reqFailed = res => {
+ // eslint-disable-next-line no-alert
+ alert(res.responseJSON.error);
+ };
+
+ AP.getLocation(location => {
+ $('.js-jira-connect-sign-in').each(() => {
+ const updatedLink = `${$(this).attr('href')}?return_to=${location}`;
+ $(this).attr('href', updatedLink);
+ });
+ });
+
+ $('#add-subscription-form').on('submit', e => {
+ const actionUrl = $(this).attr('action');
+ e.preventDefault();
+
+ AP.context.getToken(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', e => {
+ const href = $(this).attr('href');
+ e.preventDefault();
+
+ AP.context.getToken(token => {
+ // eslint-disable-next-line no-jquery/no-ajax
+ $.ajax({
+ url: href,
+ method: 'DELETE',
+ data: {
+ jwt: token,
+ format: 'json',
+ },
+ })
+ .done(reqComplete)
+ .fail(reqFailed);
+ });
+ });
+};
+
function initJiraConnect() {
const el = document.querySelector('.js-jira-connect-app');
+ initJiraFormHandlers();
+
return new Vue({
el,
render(createElement) {