1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
<script>
import { GlAlert, GlSprintf, GlLink } from '@gitlab/ui';
import { n__, sprintf } from '~/locale';
import {
WARNING_ALERT_TITLE,
DANGER_ALERT_TITLE,
REACHED_LIMIT_UPGRADE_SUGGESTION_MESSAGE,
REACHED_LIMIT_VARIANT,
CLOSE_TO_LIMIT_MESSAGE,
CLOSE_TO_LIMIT_VARIANT,
} from '../constants';
export default {
name: 'UserLimitNotification',
components: { GlAlert, GlSprintf, GlLink },
inject: ['name'],
props: {
limitVariant: {
type: String,
required: true,
},
usersLimitDataset: {
type: Object,
required: true,
},
},
computed: {
limitAttributes() {
return {
[CLOSE_TO_LIMIT_VARIANT]: {
variant: 'warning',
title: this.title(WARNING_ALERT_TITLE, this.usersLimitDataset.remainingSeats),
message: CLOSE_TO_LIMIT_MESSAGE,
},
[REACHED_LIMIT_VARIANT]: {
variant: 'danger',
title: this.title(DANGER_ALERT_TITLE, this.usersLimitDataset.freeUsersLimit),
message: REACHED_LIMIT_UPGRADE_SUGGESTION_MESSAGE,
},
};
},
},
methods: {
title(titleTemplate, count) {
return sprintf(titleTemplate, {
count,
members: n__('member', 'members', count),
name: this.name,
});
},
},
};
</script>
<template>
<gl-alert
:variant="limitAttributes[limitVariant].variant"
:dismissible="false"
:title="limitAttributes[limitVariant].title"
>
<gl-sprintf :message="limitAttributes[limitVariant].message">
<template #trialLink="{ content }">
<gl-link
:href="usersLimitDataset.newTrialRegistrationPath"
class="gl-label-link"
data-track-action="click_link"
:data-track-label="`start_trial_user_limit_notification_${limitVariant}`"
data-testid="trial-link"
>
{{ content }}
</gl-link>
</template>
<template #upgradeLink="{ content }">
<gl-link
:href="usersLimitDataset.purchasePath"
class="gl-label-link"
data-track-action="click_link"
:data-track-label="`upgrade_user_limit_notification_${limitVariant}`"
data-testid="upgrade-link"
>
{{ content }}
</gl-link>
</template>
</gl-sprintf>
</gl-alert>
</template>
|