mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-10-04 13:16:05 +08:00
feat: add warning message when disabling a device that have not been detached in the backend (#675)
* feat: add wanring message when disabling a device that haven not been detached in the backend Signed-off-by: Jack Yu <jack.yu@suse.com> * fix: remove unused en-us key Signed-off-by: Jack Yu <jack.yu@suse.com> --------- Signed-off-by: Jack Yu <jack.yu@suse.com>
This commit is contained in:
@@ -133,6 +133,12 @@ export default class USBDevice extends SteveModel {
|
||||
// 'disable' passthrough deletes claim
|
||||
// backend should return error if device is in use
|
||||
async disablePassthrough() {
|
||||
if (!this.allowDisable) {
|
||||
this.showDetachWarning();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!this.claimedByMe) {
|
||||
throw new Error(this.$rootGetters['i18n/t']('harvester.usb.cantUnclaim', { name: escapeHtml(this.metadata.name) }));
|
||||
@@ -158,4 +164,20 @@ export default class USBDevice extends SteveModel {
|
||||
get groupByDevice() {
|
||||
return this.status?.description;
|
||||
}
|
||||
|
||||
showDetachWarning() {
|
||||
this.$dispatch('growl/warning', {
|
||||
title: this.$rootGetters['i18n/t']('harvester.usb.detachWarning.title'),
|
||||
message: this.$rootGetters['i18n/t']('harvester.usb.detachWarning.message'),
|
||||
timeout: 5000
|
||||
}, { root: true });
|
||||
}
|
||||
|
||||
get allowDisable() {
|
||||
return this._allowDisable;
|
||||
}
|
||||
|
||||
set allowDisable(value) {
|
||||
this._allowDisable = value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user