Skip to content

Commit

Permalink
Add cancelAction in VM create page
Browse files Browse the repository at this point in the history
  • Loading branch information
a110605 committed Sep 10, 2024
1 parent 1aaeaef commit ac9b556
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
23 changes: 23 additions & 0 deletions pkg/harvester/edit/kubevirt.io.virtualmachine/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ export default {
computed: {
...mapGetters({ t: 'i18n/t' }),
// doneLocationOverride() {
// const { fromPage } = this.$route?.query;
// const doneOverride = this.value.doneOverride;
// if (fromPage) {
// doneOverride.params.resource = fromPage;
// }
// console.log('doneOverride=', doneOverride);
// return doneOverride;
// },
machineTypeOptions() {
return [{
label: 'None',
Expand Down Expand Up @@ -270,6 +281,16 @@ export default {
},
methods: {
cancelAction() {
const { fromPage = HCI.VM } = this.$route?.query; // default back to VM list page
const cancelOverride = {
name: this.doneRoute,
params: { resource: fromPage }
};
// console.log('🚀 ~ cancelAction ~ cancelOverride:', cancelOverride);
this.$router.replace(cancelOverride);
},
saveVM(buttonCb) {
clear(this.errors);
Expand Down Expand Up @@ -434,12 +455,14 @@ export default {
id="vm"
:done-route="doneRoute"
:resource="value"
:cancelEvent="true"
:mode="mode"
:can-yaml="isSingle ? true : false"
:errors="errors"
:generate-yaml="generateYaml"
:apply-hooks="applyHooks"
@finish="saveVM"
@cancel="cancelAction"
>
<RadioGroup
v-if="isCreate"
Expand Down
4 changes: 2 additions & 2 deletions pkg/harvester/models/harvesterhci.io.virtualmachineimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default class HciVmImage extends HarvesterResource {
{
action: 'createFromImage',
enabled: canCreateVM,
icon: 'icon icon-fw icon-spinner',
icon: 'icon icon-circle-plus',
label: this.t('harvester.action.createVM'),
disabled: !this.isReady,
},
Expand All @@ -75,7 +75,7 @@ export default class HciVmImage extends HarvesterResource {
router.push({
name: `${ HARVESTER_PRODUCT }-c-cluster-resource-create`,
params: { resource: HCI.VM },
query: { image: this.id }
query: { image: this.id, fromPage: HCI.IMAGE }
});
}

Expand Down

0 comments on commit ac9b556

Please sign in to comment.