-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDelete.vue
More file actions
85 lines (72 loc) · 1.91 KB
/
Copy pathDelete.vue
File metadata and controls
85 lines (72 loc) · 1.91 KB
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
<template>
<div class="card mb-4 border-danger">
<div class="card-body">
<h3 class="card-title mb-3">
Delete Workspace
</h3>
<b-alert
v-if="!isLead"
variant="info"
show
class="mb-3"
>
<app-icon variant="info" />
Only workspace owners can delete the workspace.
</b-alert>
<p>
Deleting a workspace is permanent. This action will not remove any
TDEI datasets outside of Workspaces.
</p>
<button
class="btn btn-danger mb-3"
:disabled="!isLead || accepted"
@click="acceptDelete"
>
I understand, and I want to delete this workspace
</button>
<template v-if="accepted">
<label class="d-block mb-3">
<strong>To confirm, please type "delete" in the box below:</strong>
<input
ref="input"
v-model.trim="attestation"
class="form-control border-danger"
>
</label>
<button
class="btn btn-danger"
:disabled="!isLead || attestation !== 'delete'"
@click="submitDelete"
>
Delete this workspace
</button>
</template>
</div>
<!-- .card-body -->
</div>
<!-- .card -->
</template>
<script setup lang="ts">
import { workspacesClient } from '~/services/index';
import type { Workspace } from '~/types/workspaces';
const workspace = inject<Workspace>('workspace')!;
const { isLead } = useWorkspaceRole();
const accepted = ref(false);
const attestation = ref('');
const input = useTemplateRef<HTMLInputElement>('input');
async function acceptDelete() {
if (!isLead.value) {
return;
}
accepted.value = true;
await nextTick();
input.value!.focus();
}
async function submitDelete() {
if (!isLead.value) {
return;
}
await workspacesClient.deleteWorkspace(workspace.id);
navigateTo('/dashboard');
}
</script>