/
RemoveProjectMemberDialog.vue
154 lines (136 loc) · 4.97 KB
/
RemoveProjectMemberDialog.vue
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// Copyright (C) 2023 Storj Labs, Inc.
// See LICENSE for copying information.
<template>
<v-dialog
v-model="model"
width="410px"
transition="fade-transition"
:persistent="isLoading"
>
<v-card rounded="xlg">
<v-card-item class="pa-5 pl-7">
<template #prepend>
<v-sheet
class="border-sm d-flex justify-center align-center"
width="40"
height="40"
rounded="lg"
>
<img src="@/assets/icon-remove-member.svg" alt="member icon">
</v-sheet>
</template>
<v-card-title class="font-weight-bold">Remove member</v-card-title>
<template #append>
<v-btn
icon="$close"
variant="text"
size="small"
color="default"
:disabled="isLoading"
@click="model = false"
/>
</template>
</v-card-item>
<v-card-item class="px-7 py-0">
<v-divider />
<p class="py-4">The following team members will be removed.</p>
<v-divider />
</v-card-item>
<v-card-item class="px-7 pt-4 pb-1">
<v-chip
v-for="email in firstThreeSelected"
:key="email"
rounded
class="mb-3 mr-1"
>
<template #default>
<div class="max-width">
<p :title="email" class="text-truncate">{{ email }}</p>
</div>
</template>
</v-chip>
<v-chip v-if="props.emails.length > 3" rounded class="mb-3 mr-1">
+ {{ props.emails.length - 3 }} more
</v-chip>
</v-card-item>
<v-card-item class="px-7 py-0">
<v-alert variant="tonal" class="mb-4 pa-4" color="warning" border="start">
<template #text>
<strong>Important:</strong> Any access keys created could still provide data access to removed members. If necessary, please revoke these access keys to ensure the security of your data.
</template>
</v-alert>
<v-divider />
</v-card-item>
<v-card-actions class="pa-7">
<v-row>
<v-col>
<v-btn variant="outlined" color="default" block :disabled="isLoading" @click="model = false">
Cancel
</v-btn>
</v-col>
<v-col>
<v-btn color="error" variant="flat" block :loading="isLoading" @click="onDelete">
Remove
</v-btn>
</v-col>
</v-row>
</v-card-actions>
</v-card>
</v-dialog>
</template>
<script setup lang="ts">
import { computed } from 'vue';
import {
VAlert,
VDialog,
VCard,
VCardItem,
VSheet,
VCardTitle,
VDivider,
VCardActions,
VRow,
VCol,
VBtn,
VChip,
} from 'vuetify/components';
import { useProjectsStore } from '@/store/modules/projectsStore';
import { useConfigStore } from '@/store/modules/configStore';
import { useAnalyticsStore } from '@/store/modules/analyticsStore';
import { useLoading } from '@/composables/useLoading';
import { useNotify } from '@/utils/hooks';
import { useProjectMembersStore } from '@/store/modules/projectMembersStore';
import { AnalyticsErrorEventSource } from '@/utils/constants/analyticsEventNames';
const props = defineProps<{
emails: string[],
}>();
const model = defineModel<boolean>({ required: true });
const emit = defineEmits<{
(event: 'deleted'): void;
}>();
const analyticsStore = useAnalyticsStore();
const configStore = useConfigStore();
const projectsStore = useProjectsStore();
const pmStore = useProjectMembersStore();
const { isLoading, withLoading } = useLoading();
const notify = useNotify();
const firstThreeSelected = computed<string[]>(() => props.emails.slice(0, 3));
async function onDelete(): Promise<void> {
await withLoading(async () => {
try {
await pmStore.deleteProjectMembers(projectsStore.state.selectedProject.id, props.emails);
notify.success('Members were successfully removed from the project');
emit('deleted');
model.value = false;
} catch (error) {
error.message = `Error removing project members. ${error.message}`;
notify.notifyError(error, AnalyticsErrorEventSource.PROJECT_MEMBERS_HEADER);
}
});
}
</script>
<style scoped lang="scss">
.max-width {
max-width: 320px;
}
</style>