mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-07-01 22:32:20 +00:00
feat: clear selected VM after doing bulk action (#929)
* feat: clear selected VM rows after click bulk action Signed-off-by: Andy Lee <andy.lee@suse.com> * refactor: await altStopVM action Signed-off-by: Andy Lee <andy.lee@suse.com> * refactor: multiple VM start actions Signed-off-by: Andy Lee <andy.lee@suse.com> * refactor: modify altRestartVM() Signed-off-by: Andy Lee <andy.lee@suse.com> --------- Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
parent
f115261889
commit
5e3f12de35
@ -98,9 +98,9 @@ export default {
|
||||
methods: {
|
||||
escapeHtml,
|
||||
|
||||
close() {
|
||||
close(data) {
|
||||
this.errors = [];
|
||||
this.$emit('close');
|
||||
this.$emit('close', data);
|
||||
},
|
||||
|
||||
async apply(buttonDone) {
|
||||
@ -109,7 +109,7 @@ export default {
|
||||
await resource.doActionGrowl(this.modalData.action, {});
|
||||
}
|
||||
buttonDone(true);
|
||||
this.close();
|
||||
this.close({ performCallback: true, clearTableSelection: true });
|
||||
} catch (e) {
|
||||
this.errors = exceptionToErrorsArray(e);
|
||||
buttonDone(false);
|
||||
|
||||
@ -117,10 +117,10 @@ export default {
|
||||
},
|
||||
|
||||
methods: {
|
||||
close() {
|
||||
close(data) {
|
||||
this.nodeName = '';
|
||||
this.errors = [];
|
||||
this.$emit('close');
|
||||
this.$emit('close', data);
|
||||
},
|
||||
|
||||
async apply(buttonDone) {
|
||||
@ -166,7 +166,7 @@ export default {
|
||||
}
|
||||
|
||||
buttonDone(true);
|
||||
this.close();
|
||||
this.close({ performCallback: true, clearTableSelection: true });
|
||||
} catch (err) {
|
||||
const error = err?.data || err;
|
||||
const message = exceptionToErrorsArray(error);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
import ResourceTable from '@shell/components/ResourceTable';
|
||||
import { STATE, AGE, NAME, NAMESPACE } from '@shell/config/table-headers';
|
||||
import {
|
||||
@ -116,6 +117,8 @@ export default {
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapGetters({ actionCb: 'action-menu/performCallbackData' }),
|
||||
|
||||
headers() {
|
||||
const restoreCol = {
|
||||
name: 'restoreProgress',
|
||||
@ -182,6 +185,13 @@ export default {
|
||||
},
|
||||
|
||||
watch: {
|
||||
actionCb(neu) {
|
||||
if (neu?.clearTableSelection) {
|
||||
this.$refs.resourceTable.clearSelection();
|
||||
this.$store.dispatch('action-menu/clearCallbackData');
|
||||
}
|
||||
},
|
||||
|
||||
vmRestartRequiredNames(vmNames) {
|
||||
const count = vmNames.length;
|
||||
|
||||
@ -220,6 +230,7 @@ export default {
|
||||
<Loading v-if="$fetchState.pending" />
|
||||
<div v-else>
|
||||
<ResourceTable
|
||||
ref="resourceTable"
|
||||
v-bind="$attrs"
|
||||
:headers="headers"
|
||||
default-sort-by="age"
|
||||
|
||||
@ -184,11 +184,12 @@ export default class VirtVm extends HarvesterResource {
|
||||
label: this.t('harvester.action.softreboot')
|
||||
},
|
||||
{
|
||||
action: 'startVM',
|
||||
enabled: !!this.actions?.start,
|
||||
icon: 'icon icon-play',
|
||||
label: this.t('harvester.action.start'),
|
||||
bulkable: true
|
||||
action: 'startVM',
|
||||
enabled: !!this.actions?.start,
|
||||
icon: 'icon icon-play',
|
||||
label: this.t('harvester.action.start'),
|
||||
bulkable: true,
|
||||
bulkAction: 'startVM'
|
||||
},
|
||||
{
|
||||
action: 'backupVM',
|
||||
@ -378,10 +379,6 @@ export default class VirtVm extends HarvesterResource {
|
||||
this.metadata.annotations[HCI_ANNOTATIONS.VOLUME_CLAIM_TEMPLATE] = JSON.stringify(deleteDataSource);
|
||||
}
|
||||
|
||||
altRestartVM() {
|
||||
this.doActionGrowl('restart', {});
|
||||
}
|
||||
|
||||
restartVM(resources = this) {
|
||||
this.$dispatch('promptModal', {
|
||||
resources,
|
||||
@ -553,16 +550,38 @@ export default class VirtVm extends HarvesterResource {
|
||||
});
|
||||
}
|
||||
|
||||
altStopVM() {
|
||||
this.doActionGrowl('stop', {});
|
||||
async altRestartVM() {
|
||||
await this.doActionGrowl('restart', {});
|
||||
this.$dispatch('promptModal', { performCallback: true, clearTableSelection: true });
|
||||
}
|
||||
|
||||
forceStop() {
|
||||
this.doActionGrowl('forceStop', {});
|
||||
async altStopVM() {
|
||||
await this.doActionGrowl('stop', {});
|
||||
this.$dispatch('promptModal', { performCallback: true, clearTableSelection: true });
|
||||
}
|
||||
|
||||
startVM() {
|
||||
this.doActionGrowl('start', {});
|
||||
async forceStop() {
|
||||
await this.doActionGrowl('forceStop', {});
|
||||
this.$dispatch('promptModal', { performCallback: true, clearTableSelection: true });
|
||||
}
|
||||
|
||||
async startVM(resources = this) {
|
||||
const list = Array.isArray(resources) ? resources : [resources];
|
||||
|
||||
for (const r of list) {
|
||||
await r.doActionGrowl('start', {});
|
||||
}
|
||||
this.$dispatch('promptModal', { performCallback: true, clearTableSelection: true });
|
||||
}
|
||||
|
||||
async download() {
|
||||
await super.download();
|
||||
this.$dispatch('promptModal', { performCallback: true, clearTableSelection: true });
|
||||
}
|
||||
|
||||
async downloadBulk(items) {
|
||||
await super.downloadBulk(items);
|
||||
this.$dispatch('promptModal', { performCallback: true, clearTableSelection: true });
|
||||
}
|
||||
|
||||
migrateVM(resources = this) {
|
||||
|
||||
@ -123,6 +123,7 @@ export default {
|
||||
this.value?.[0]?.currentRouter().push(goTo);
|
||||
}
|
||||
this.close();
|
||||
this.$store.commit('action-menu/togglePromptModal', { performCallback: true, clearTableSelection: true });
|
||||
}).catch((err) => {
|
||||
this.$emit('errors', err);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user