Commit 0c889e87 authored by Justin Ho's avatar Justin Ho

Add error handling to Unlink action

Disable other Unlink buttons while one is already loading
parent 44fb7c26
<script>
import { GlButton, GlEmptyState, GlTable } from '@gitlab/ui';
import { isEmpty } from 'lodash';
import { mapMutations } from 'vuex';
import { removeSubscription } from '~/jira_connect/api';
import { reloadPage } from '~/jira_connect/utils';
import { __, s__ } from '~/locale';
import TimeagoTooltip from '~/vue_shared/components/time_ago_tooltip.vue';
import { SET_ALERT } from '../store/mutation_types';
import GroupItemName from './group_item_name.vue';
export default {
......@@ -46,8 +48,12 @@ export default {
emptyDescription: s__(
'Integrations|Namespaces are the GitLab groups and subgroups you link to this Jira instance.',
),
unlinkError: s__('Integrations|Failed to unlink namespace. Please try again.'),
},
methods: {
...mapMutations({
setAlert: SET_ALERT,
}),
isEmpty,
isLoadingItem(item) {
return this.loadingItem === item;
......@@ -63,6 +69,10 @@ export default {
reloadPage();
})
.catch(() => {
this.setAlert({
message: this.$options.i18n.unlinkError,
variant: 'danger',
});
this.loadingItem = null;
});
},
......@@ -89,6 +99,7 @@ export default {
:class="unlinkBtnClass(item)"
category="secondary"
:loading="isLoadingItem(item)"
:disabled="!isEmpty(loadingItem)"
@click.prevent="onClick(item)"
>{{ __('Unlink') }}</gl-button
>
......
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