Add pkg/harvester components + shell portings - 1

Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
This commit is contained in:
Francesco Torchia
2024-10-23 17:00:46 +02:00
parent f8408469f7
commit 4f2688f6ab
265 changed files with 42316 additions and 82 deletions
@@ -0,0 +1,70 @@
import { clone } from '@shell/utils/object';
import { HCI } from '../../types';
import HarvesterResource from '../harvester';
import { PRODUCT_NAME as HARVESTER_PRODUCT } from '../../config/harvester';
import { PVC } from '@shell/config/types';
export default class HciSnapshot extends HarvesterResource {
get availableActions() {
return [
{
action: 'restoreSnapshot',
enabled: this.hasAction('restore'),
icon: 'icon icon-refresh',
label: this.t('harvester.action.restore'),
},
...super._availableActions
];
}
get canClone() {
return false;
}
restoreSnapshot(resources = this) {
this.$dispatch('promptModal', {
resources,
component: 'RestoreSnapshotDialog'
});
}
get detailLocation() {
const detailLocation = clone(this._detailLocation);
detailLocation.params.resource = HCI.SNAPSHOT;
return detailLocation;
}
get doneOverride() {
const detailLocation = clone(this._detailLocation);
delete detailLocation.params.namespace;
delete detailLocation.params.id;
detailLocation.params.resource = HCI.SNAPSHOT;
detailLocation.name = `${ HARVESTER_PRODUCT }-c-cluster-resource`;
return detailLocation;
}
get parentNameOverride() {
return this.$rootGetters['i18n/t'](`typeLabel."${ HCI.SNAPSHOT }"`, { count: 1 })?.trim();
}
get parentLocationOverride() {
return this.doneOverride;
}
get volume() {
const inStore = this.$rootGetters['currentProduct'].inStore;
const namespace = this?.metadata?.namespace;
const pvc = this?.spec?.source?.persistentVolumeClaimName;
const volume = this.$rootGetters[`${ inStore }/byId`](
PVC,
`${ namespace }/${ pvc }`
);
return volume;
}
}