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
88
89
90
91
92
93
94
95
96
|
<script>
import { __, s__, sprintf } from '~/locale';
import { parseUserDeletionObstacles } from '~/vue_shared/components/user_deletion_obstacles/utils';
import ActionButtonGroup from './action_button_group.vue';
import LeaveButton from './leave_button.vue';
import RemoveMemberButton from './remove_member_button.vue';
export default {
name: 'UserActionButtons',
components: {
ActionButtonGroup,
RemoveMemberButton,
LeaveButton,
LdapOverrideButton: () =>
import('ee_component/members/components/ldap/ldap_override_button.vue'),
},
props: {
member: {
type: Object,
required: true,
},
isCurrentUser: {
type: Boolean,
required: true,
},
isInvitedUser: {
type: Boolean,
required: true,
},
permissions: {
type: Object,
required: true,
},
},
computed: {
message() {
const { user, source } = this.member;
if (user) {
return sprintf(
s__('Members|Are you sure you want to remove %{usersName} from "%{source}"?'),
{
usersName: user.name,
source: source.fullName,
},
false,
);
}
return sprintf(
s__('Members|Are you sure you want to remove this orphaned member from "%{source}"?'),
{
source: source.fullName,
},
);
},
userDeletionObstaclesUserData() {
return {
name: this.member.user?.name,
obstacles: parseUserDeletionObstacles(this.member.user),
};
},
removeMemberButtonText() {
return this.isInvitedUser ? null : __('Remove user');
},
removeMemberButtonIcon() {
return this.isInvitedUser ? 'remove' : '';
},
removeMemberButtonCategory() {
return this.isInvitedUser ? 'primary' : 'secondary';
},
},
};
</script>
<template>
<action-button-group>
<div v-if="permissions.canRemove" class="gl-px-1">
<leave-button v-if="isCurrentUser" :member="member" />
<remove-member-button
v-else
:member-id="member.id"
:member-type="member.type"
:user-deletion-obstacles="userDeletionObstaclesUserData"
:message="message"
:icon="removeMemberButtonIcon"
:button-text="removeMemberButtonText"
:button-category="removeMemberButtonCategory"
:title="s__('Member|Remove member')"
/>
</div>
<div v-else-if="permissions.canOverride && !member.isOverridden" class="gl-px-1">
<ldap-override-button :member="member" />
</div>
</action-button-group>
</template>
|