Skip to content

Commit

Permalink
fix Restore New / Restore Existing action route
Browse files Browse the repository at this point in the history
Signed-off-by: andy.lee <andy.lee@suse.com>
(cherry picked from commit eabd943)

# Conflicts:
#	pkg/harvester/config/labels-annotations.js
  • Loading branch information
a110605 authored and mergify[bot] committed Sep 27, 2024
1 parent cfab55d commit 6eecd47
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 140 deletions.
2 changes: 1 addition & 1 deletion pkg/harvester/components/FilterVMSchedule.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default {
</template>

<v-popover
trigger="click"
:trigger="scheduleOptions.length ? 'click' : 'manual'"
placement="bottom-end"
>
<slot name="header">
Expand Down
6 changes: 6 additions & 0 deletions pkg/harvester/config/labels-annotations.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,11 @@ export const HCI = {
PARENT_SRIOV_GPU: 'harvesterhci.io/parentSRIOVGPUDevice',
VM_MAINTENANCE_MODE_STRATEGY: 'harvesterhci.io/maintain-mode-strategy',
NODE_CPU_MANAGER_UPDATE_STATUS: 'harvesterhci.io/cpu-manager-update-status',
<<<<<<< HEAD
CPU_MANAGER: 'cpumanager'
=======
CPU_MANAGER: 'cpumanager',
VM_DEVICE_ALLOCATION_DETAILS: 'harvesterhci.io/deviceAllocationDetails',
SVM_BACKUP_ID: 'harvesterhci.io/svmbackupId',
>>>>>>> eabd94355 (fix Restore New / Restore Existing action route)
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { STATE, NAME, AGE } from '@shell/config/table-headers';
import { allSettled } from '../../utils/promise';
import { BACKUP_TYPE } from '../../config/types';
import { HCI } from '../../types';
import { HCI as HCI_ANNOTATIONS } from '@pkg/harvester/config/labels-annotations';
export default {
name: 'BackupList',
Expand Down Expand Up @@ -90,7 +91,7 @@ export default {
let r = this.rows.filter(row => row.spec?.type === BACKUP_TYPE.BACKUP);
if (this.id) {
r = r.filter(backup => backup.metadata.annotations?.['harvesterhci.io/svmbackupId'] === this.id);
r = r.filter(backup => backup.metadata.annotations?.[HCI_ANNOTATIONS.SVM_BACKUP_ID] === this.id);
}
return r;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import ResourceTable from '@shell/components/ResourceTable';
import { STATE, NAME, AGE } from '@shell/config/table-headers';
import { allSettled } from '../../utils/promise';
import { BACKUP_TYPE } from '../../config/types';
import { HCI as HCI_ANNOTATIONS } from '@pkg/harvester/config/labels-annotations';
import { HCI } from '../../types';
import { schema } from '../../list/harvesterhci.io.vmsnapshot';
Expand Down Expand Up @@ -58,7 +59,7 @@ export default {
let r = this.rows.filter(row => row.spec?.type === BACKUP_TYPE.SNAPSHOT);
if (this.id) {
r = r.filter(row => row.metadata.annotations?.['harvesterhci.io/svmbackupId'] === this.id);
r = r.filter(row => row.metadata.annotations?.[HCI_ANNOTATIONS.SVM_BACKUP_ID] === this.id);
}
return r;
Expand Down
129 changes: 0 additions & 129 deletions pkg/harvester/dialog/HarvesterScheduleModal.vue

This file was deleted.

6 changes: 5 additions & 1 deletion pkg/harvester/edit/harvesterhci.io.virtualmachinebackup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ export default {
},
methods: {
cancelAction() {
this.$router.go(-1);
},
async saveRestore(buttonCb) {
this.update();
Expand Down Expand Up @@ -261,7 +265,7 @@ export default {
/>
</div>
<Footer mode="create" class="footer" :errors="errors" @save="saveRestore" @done="done" />
<Footer mode="create" class="footer" :errors="errors" @save="saveRestore" @done="cancelAction" />
</div>
</template>
Expand Down
5 changes: 4 additions & 1 deletion pkg/harvester/edit/harvesterhci.io.vmsnapshot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ export default {
},
methods: {
cancelAction() {
this.$router.go(-1);
},
async saveRestore(buttonCb) {
this.update();
Expand Down Expand Up @@ -241,7 +244,7 @@ export default {
<LabeledSelect v-if="!restoreNewVm" v-model="deletionPolicy" :label="t('harvester.backup.restore.deletePreviousVolumes')" :options="deletionPolicyOption" />
</div>
<Footer mode="create" class="footer" :errors="errors" @save="saveRestore" @done="done" />
<Footer mode="create" class="footer" :errors="errors" @save="saveRestore" @done="cancelAction" />
</div>
</template>
Expand Down
20 changes: 14 additions & 6 deletions pkg/harvester/models/harvesterhci.io.virtualmachinebackup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { HCI } from '../types';
import { get, clone } from '@shell/utils/object';
import { findBy } from '@shell/utils/array';
import { colorForState } from '@shell/plugins/dashboard-store/resource-class';
import { HCI as HCI_ANNOTATIONS } from '@pkg/harvester/config/labels-annotations';
import { _CREATE } from '@shell/config/query-params';
import HarvesterResource from './harvester';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../config/harvester';
Expand Down Expand Up @@ -81,22 +82,29 @@ export default class HciVmBackup extends HarvesterResource {

restoreExistingVM(resource = this) {
const router = this.currentRouter();
const targetResource = resource.spec.type === BACKUP_TYPE.BACKUP ? HCI.BACKUP : HCI.VM_SNAPSHOT;

router.push({
name: `${ HARVESTER_PRODUCT }-c-cluster-resource-create`,
params: { resource: HCI.BACKUP },
query: { restoreMode: 'existing', resourceName: resource.name }
params: { resource: targetResource },
query: {
restoreMode: 'existing',
resourceName: resource.name,
}
});
}

restoreNewVM(resource = this) {
// const route = this.currentRoute();
const router = this.currentRouter();
const targetResource = resource.spec.type === BACKUP_TYPE.BACKUP ? HCI.BACKUP : HCI.VM_SNAPSHOT;

router.push({
name: `${ HARVESTER_PRODUCT }-c-cluster-resource-create`,
params: { resource: HCI.BACKUP },
query: { restoreMode: 'new', resourceName: resource.name }
params: { resource: targetResource },
query: {
restoreMode: 'new',
resourceName: resource.name,
}
});
}

Expand Down Expand Up @@ -124,7 +132,7 @@ export default class HciVmBackup extends HarvesterResource {
}

get sourceSchedule() {
return this.metadata?.annotations['harvesterhci.io/svmbackupId'];
return this.metadata?.annotations[HCI_ANNOTATIONS.SVM_BACKUP_ID];
}

get attachVM() {
Expand Down

0 comments on commit 6eecd47

Please sign in to comment.