forked from bluerobotics/BlueOS
/
AddressDeletionDialog.vue
92 lines (86 loc) · 2.11 KB
/
AddressDeletionDialog.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
<template>
<v-dialog
width="350"
:value="show"
@input="resolve"
>
<v-card>
<v-card-title>{{ title }}</v-card-title>
<v-card-subtitle class="text-center mb-3 mt-3">
{{ message }}
</v-card-subtitle>
<v-card-text class="d-flex flex-row justify-space-around">
<v-btn
color="grey"
class="ma-2 elevation-2"
text
@click="resolve(false)"
>
Abort
</v-btn>
<v-btn
color="primary"
class="ma-2 elevation-2"
text
@click="resolve(true)"
>
Confirm
</v-btn>
</v-card-text>
</v-card>
</v-dialog>
</template>
<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
name: 'AddressDeletionDialog',
model: {
prop: 'show',
event: 'change',
},
props: {
show: {
type: Boolean,
default: false,
},
dialogType: {
type: String,
default: '',
validator: (value: string) => ['', 'last-ip-address', 'ip-being-used'].includes(value),
},
},
data() {
return {
resolveCallback: undefined as ((state: boolean) => void) | undefined,
}
},
computed: {
title() {
if (this.dialogType === 'last-ip-address') {
return 'Last IP address'
}
if (this.dialogType === 'ip-being-used') {
return 'IP address in use'
}
return 'IP Deletion'
},
message() {
if (this.dialogType === 'last-ip-address') {
return 'This is the last IP address on this interface.'
+ ' Deleting it could prevent you from accessing your vehicle. Are you sure you want to proceed?'
}
if (this.dialogType === 'ip-being-used') {
return 'The IP address is currently being used to access BlueOS.'
+ ' Deleting it could prevent you from accessing your vehicle. Are you sure you want to proceed?'
}
return 'Are you sure you want to delete this IP address?'
},
},
methods: {
resolve(state: boolean) {
this.resolveCallback?.(state)
this.$emit('change', false)
},
},
})
</script>