diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-02 15:09:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-02 15:09:46 +0300 |
commit | 21e08b6197f192c983f8527f4bba1f2aaec8abf2 (patch) | |
tree | bb9183546ba5a3a1d59ed370675d54ac2c90b632 /app/assets/javascripts/jira_connect | |
parent | 43ae0b9e403cf774060267ee6d1a3dd502638068 (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.js | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/app/assets/javascripts/jira_connect/index.js b/app/assets/javascripts/jira_connect/index.js index 1723642d36f..a7dc71ced1c 100644 --- a/app/assets/javascripts/jira_connect/index.js +++ b/app/assets/javascripts/jira_connect/index.js @@ -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.')); }); }); }; |