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
|
<script>
import { GlBadge, GlTab } from '@gitlab/ui';
import { s__ } from '~/locale';
import { getUserFollowing } from '~/rest_api';
import { createAlert } from '~/alert';
import { parseIntPagination, normalizeHeaders } from '~/lib/utils/common_utils';
import Follow from './follow.vue';
export default {
i18n: {
title: s__('UserProfile|Following'),
errorMessage: s__(
'UserProfile|An error occurred loading the following. Please refresh the page to try again.',
),
currentUserEmptyStateTitle: s__('UserProfile|You are not following other users'),
visitorEmptyStateTitle: s__("UserProfile|This user isn't following other users"),
},
components: {
GlBadge,
GlTab,
Follow,
},
inject: ['followeesCount', 'userId'],
data() {
return {
following: [],
loading: true,
totalItems: 0,
page: 1,
};
},
watch: {
page: {
async handler() {
this.loading = true;
try {
const { data: following, headers } = await getUserFollowing(this.userId, {
page: this.page,
});
const { total } = parseIntPagination(normalizeHeaders(headers));
this.following = following;
this.totalItems = total;
} catch (error) {
createAlert({ message: this.$options.i18n.errorMessage, error, captureError: true });
} finally {
this.loading = false;
}
},
immediate: true,
},
},
methods: {
onPaginationInput(page) {
this.page = page;
},
},
};
</script>
<template>
<gl-tab>
<template #title>
<span>{{ $options.i18n.title }}</span>
<gl-badge size="sm" class="gl-ml-2">{{ followeesCount }}</gl-badge>
</template>
<follow
:users="following"
:loading="loading"
:page="page"
:total-items="totalItems"
:current-user-empty-state-title="$options.i18n.currentUserEmptyStateTitle"
:visitor-empty-state-title="$options.i18n.visitorEmptyStateTitle"
@pagination-input="onPaginationInput"
/>
</gl-tab>
</template>
|