diff options
Diffstat (limited to 'app/assets/javascripts/jira_connect/components/groups_list_item.vue')
-rw-r--r-- | app/assets/javascripts/jira_connect/components/groups_list_item.vue | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/app/assets/javascripts/jira_connect/components/groups_list_item.vue b/app/assets/javascripts/jira_connect/components/groups_list_item.vue index 15e37ab3cb0..69b09ab0a21 100644 --- a/app/assets/javascripts/jira_connect/components/groups_list_item.vue +++ b/app/assets/javascripts/jira_connect/components/groups_list_item.vue @@ -1,10 +1,18 @@ <script> -import { GlIcon, GlAvatar } from '@gitlab/ui'; +import { GlAvatar, GlButton, GlIcon } from '@gitlab/ui'; +import { addSubscription } from '~/jira_connect/api'; +import { s__ } from '~/locale'; export default { components: { - GlIcon, GlAvatar, + GlButton, + GlIcon, + }, + inject: { + subscriptionsPath: { + default: '', + }, }, props: { group: { @@ -12,6 +20,31 @@ export default { required: true, }, }, + data() { + return { + isLoading: false, + }; + }, + methods: { + onClick() { + this.isLoading = true; + + addSubscription(this.subscriptionsPath, this.group.full_path) + .then(() => { + AP.navigator.reload(); + }) + .catch((error) => { + this.$emit( + 'error', + error?.response?.data?.error || + s__('Integrations|Failed to link namespace. Please try again.'), + ); + }) + .finally(() => { + this.isLoading = false; + }); + }, + }, }; </script> @@ -19,7 +52,7 @@ export default { <li class="gl-border-b-1 gl-border-b-solid gl-border-b-gray-200"> <div class="gl-display-flex gl-align-items-center gl-py-3"> <gl-icon name="folder-o" class="gl-mr-3" /> - <div class="gl-display-none gl-flex-shrink-0 gl-display-sm-flex gl-mr-3"> + <div class="gl-display-none gl-flex-shrink-0 gl-sm-display-flex gl-mr-3"> <gl-avatar :size="32" shape="rect" :entity-name="group.name" :src="group.avatar_url" /> </div> <div class="gl-min-w-0 gl-display-flex gl-flex-grow-1 gl-flex-shrink-1 gl-align-items-center"> @@ -36,6 +69,14 @@ export default { <p class="gl-mt-2! gl-mb-0 gl-text-gray-600" v-text="group.description"></p> </div> </div> + + <gl-button + category="secondary" + variant="success" + :loading="isLoading" + @click.prevent="onClick" + >{{ __('Link') }}</gl-button + > </div> </div> </li> |