Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: frontend: Add checks prior to delete IPs
* Add a check layer prior to deleting IPs on interfaces avoiding to delete the last IP or curently being useed IP by mistake
- Loading branch information
1 parent
8f5e935
commit 62f21ea
Showing
2 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
core/frontend/src/components/ethernet/AddressDeletionDialog.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<template> | ||
<v-dialog | ||
width="350" | ||
:value="show" | ||
@input="resolve" | ||
> | ||
<v-card> | ||
<v-card-title>{{ title }}</v-card-title> | ||
|
||
<v-card-subtitle class="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 the interface. Are you sure you want to proceed?' | ||
} | ||
if (this.dialogType === 'ip-being-used') { | ||
return 'The IP address is currently being used to access BlueOS. 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters