fix delete VM modal not dismiss

This commit is contained in:
andy.lee 2024-11-04 18:24:37 +08:00 committed by Francesco Torchia
parent e150c7f550
commit 9eec2ed557
No known key found for this signature in database
GPG Key ID: E6D011B7415D4393

View File

@ -26,6 +26,14 @@ export default {
type: { type: {
type: String, type: String,
required: true required: true
},
close: {
type: Function,
required: true
},
doneLocation: {
type: Object,
default: () => {}
} }
}, },
@ -84,13 +92,11 @@ export default {
methods: { methods: {
resourceNames, resourceNames,
remove() { remove() {
const parentComponent = this.$parent.$parent.$parent;
let goTo; let goTo;
if (parentComponent.doneLocation) { if (this.doneLocation) {
// doneLocation will recompute to undefined when delete request completes // doneLocation will recompute to undefined when delete request completes
goTo = { ...parentComponent.doneLocation }; goTo = { ...this.doneLocation };
} }
Promise.all(this.value.map((resource) => { Promise.all(this.value.map((resource) => {
@ -118,13 +124,13 @@ export default {
const parsed = Parse(resource.links.self); const parsed = Parse(resource.links.self);
resource.remove({ url: `${ parsed.pathname }?${ removedDisks }propagationPolicy=Foreground` }); resource.remove({ url: `${ parsed.pathname }?${ removedDisks }propagationPolicy=Foreground` });
})).then((results) => { })).then((_results) => {
if ( goTo && !isEmpty(goTo) ) { if ( goTo && !isEmpty(goTo) ) {
parentComponent.currentRouter.push(goTo); this.value?.[0]?.currentRouter().push(goTo)
} }
parentComponent.close(); this.close();
}).catch((err) => { }).catch((err) => {
parentComponent.error = err; this.$emit('errors', err);
}); });
} }
} }