Commit 4671763a authored by Tom Quirk's avatar Tom Quirk

Fix lexical "this" bug in jquery for Jira connect

- Also, add fallback message for jira connect errors
parent fa60193b
......@@ -10,19 +10,20 @@ const initJiraFormHandlers = () => {
AP.navigator.reload();
};
const reqFailed = res => {
const reqFailed = (res, fallbackErrorMessage) => {
const { responseJSON: { error } = {} } = res || {};
// eslint-disable-next-line no-alert
alert(res.responseJSON.error);
alert(error || fallbackErrorMessage);
};
AP.getLocation(location => {
$('.js-jira-connect-sign-in').each(() => {
$('.js-jira-connect-sign-in').each(function updateSignInLink() {
const updatedLink = `${$(this).attr('href')}?return_to=${location}`;
$(this).attr('href', updatedLink);
});
});
$('#add-subscription-form').on('submit', e => {
$('#add-subscription-form').on('submit', function onAddSubscriptionForm(e) {
const actionUrl = $(this).attr('action');
e.preventDefault();
......@@ -34,11 +35,11 @@ const initJiraFormHandlers = () => {
format: 'json',
})
.done(reqComplete)
.fail(reqFailed);
.fail(err => reqFailed(err, 'Failed to add namespace. Please try again.'));
});
});
$('.remove-subscription').on('click', e => {
$('.remove-subscription').on('click', function onRemoveSubscriptionClick(e) {
const href = $(this).attr('href');
e.preventDefault();
......@@ -53,7 +54,7 @@ const initJiraFormHandlers = () => {
},
})
.done(reqComplete)
.fail(reqFailed);
.fail(err => reqFailed(err, 'Failed to remove namespace. Please try again.'));
});
});
};
......
---
title: Resolve Cannot remove namespace
merge_request: 48973
author:
type: fixed
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment