debian-mirror-gitlab/app/assets/javascripts/groups/components/invite_members_banner.vue

83 lines
2.2 KiB
Vue
Raw Normal View History

2020-11-24 15:15:51 +05:30
<script>
import { GlBanner } from '@gitlab/ui';
2021-06-08 01:23:25 +05:30
import eventHub from '~/invite_members/event_hub';
2021-11-11 11:23:49 +05:30
import axios from '~/lib/utils/axios_utils';
2021-03-11 19:13:27 +05:30
import { s__ } from '~/locale';
2020-11-24 15:15:51 +05:30
import Tracking from '~/tracking';
const trackingMixin = Tracking.mixin();
export default {
components: {
GlBanner,
},
mixins: [trackingMixin],
2021-11-11 11:23:49 +05:30
inject: ['svgPath', 'trackLabel', 'calloutsPath', 'calloutsFeatureId', 'groupId'],
2020-11-24 15:15:51 +05:30
data() {
return {
2021-11-11 11:23:49 +05:30
isDismissed: false,
2020-11-24 15:15:51 +05:30
tracking: {
label: this.trackLabel,
},
};
},
mounted() {
this.trackOnShow();
},
methods: {
handleClose() {
2021-11-11 11:23:49 +05:30
axios
.post(this.calloutsPath, {
feature_name: this.calloutsFeatureId,
group_id: this.groupId,
})
.catch((e) => {
// eslint-disable-next-line @gitlab/require-i18n-strings, no-console
console.error('Failed to dismiss banner.', e);
});
2020-11-24 15:15:51 +05:30
this.isDismissed = true;
this.track(this.$options.dismissEvent);
},
trackOnShow() {
2021-04-17 20:07:23 +05:30
this.$nextTick(() => {
if (!this.isDismissed) this.track(this.$options.displayEvent);
});
2020-11-24 15:15:51 +05:30
},
2021-06-08 01:23:25 +05:30
openModal() {
eventHub.$emit('openModal', {
inviteeType: 'members',
source: this.$options.openModalSource,
});
this.track(this.$options.buttonClickEvent);
2020-11-24 15:15:51 +05:30
},
},
i18n: {
title: s__('InviteMembersBanner|Collaborate with your team'),
body: s__(
"InviteMembersBanner|We noticed that you haven't invited anyone to this group. Invite your colleagues so you can discuss issues, collaborate on merge requests, and share your knowledge.",
),
button_text: s__('InviteMembersBanner|Invite your colleagues'),
},
displayEvent: 'invite_members_banner_displayed',
buttonClickEvent: 'invite_members_banner_button_clicked',
2021-06-08 01:23:25 +05:30
openModalSource: 'invite_members_banner',
2020-11-24 15:15:51 +05:30
dismissEvent: 'invite_members_banner_dismissed',
};
</script>
<template>
<gl-banner
v-if="!isDismissed"
ref="banner"
2021-11-11 11:23:49 +05:30
data-testid="invite-members-banner"
2020-11-24 15:15:51 +05:30
:title="$options.i18n.title"
:button-text="$options.i18n.button_text"
:svg-path="svgPath"
@close="handleClose"
2021-06-08 01:23:25 +05:30
@primary="openModal"
2020-11-24 15:15:51 +05:30
>
<p>{{ $options.i18n.body }}</p>
</gl-banner>
</template>