Vue migration - remove Vuew.set & this.$set; add vue-migrate script

Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
This commit is contained in:
Francesco Torchia
2024-10-23 17:00:48 +02:00
parent c983ed8384
commit ea12a81174
85 changed files with 938 additions and 256 deletions
@@ -77,7 +77,7 @@ export default {
watch: {
valuesContentJson: {
handler(neu) {
this.$set(this.value.spec, 'valuesContent', jsyaml.dump(neu));
this.value.spec['valuesContent'] = jsyaml.dump(neu);
},
deep: true,
immediate: true
@@ -191,7 +191,7 @@ export default {
watch: {
valuesContentJson: {
handler(neu) {
this.$set(this.value.spec, 'valuesContent', jsyaml.dump(neu));
this.value.spec['valuesContent'] = jsyaml.dump(neu);
},
deep: true,
immediate: true
@@ -80,7 +80,7 @@ export default {
watch: {
valuesContentJson: {
handler(neu) {
this.$set(this.value.spec, 'valuesContent', jsyaml.dump(neu));
this.value.spec['valuesContent'] = jsyaml.dump(neu);
},
deep: true,
immediate: true
@@ -108,7 +108,7 @@ export default {
const inStore = this.$store.getters['currentProduct'].inStore;
const defaultStorage = this.$store.getters[`${ inStore }/all`](STORAGE_CLASS).find( s => s.isDefault);
this.$set(this.valuesContent.pvcClaim, 'storageClassName', this.valuesContent?.pvcClaim?.storageClassName || defaultStorage?.metadata?.name || 'longhorn');
this.valuesContent.pvcClaim['storageClassName'] = this.valuesContent?.pvcClaim?.storageClassName || defaultStorage?.metadata?.name || 'longhorn';
this.update();
},
@@ -5,7 +5,7 @@ import { BadgeState } from '@components/BadgeState';
import { Banner } from '@components/Banner';
import { RadioGroup, RadioButton } from '@components/Form/Radio';
import HarvesterDisk from '../../mixins/harvester-disk';
import Tags from '../../components/DiskTags';
import DiskTags from '../../components/DiskTags';
import { HCI } from '../../types';
import { LONGHORN_SYSTEM } from './index';
@@ -17,7 +17,7 @@ export default {
Banner,
RadioGroup,
RadioButton,
Tags,
DiskTags,
},
mixins: [
@@ -171,7 +171,7 @@ export default {
<div v-if="!value.isNew">
<div class="row">
<div class="col span-12">
<Tags
<DiskTags
v-model="value.tags"
:label="t('harvester.host.disk.tags.label')"
:add-label="t('harvester.host.disk.tags.addLabel')"
@@ -92,7 +92,7 @@ export default {
methods: {
async saveKsmtuned() {
this.spec.mergeAcrossNodes = this.enableMergeAcrossNodes ? 1 : 0;
this.$set(this.ksmtuned, 'spec', this.spec);
this.ksmtuned['spec'] = this.spec;
await this.ksmtuned.save().catch((reason) => {
if (reason?.type === 'error') {
@@ -123,8 +123,8 @@ export default {
} else {
const [namespace, name] = value.split('/');
this.$set(this.value.spec.baseboardSpec.connection.authSecretRef, 'namespace', namespace);
this.$set(this.value.spec.baseboardSpec.connection.authSecretRef, 'name', name);
this.value.spec.baseboardSpec.connection.authSecretRef['namespace'] = namespace;
this.value.spec.baseboardSpec.connection.authSecretRef['name'] = name;
}
},
},
@@ -135,7 +135,7 @@ export default {
},
set(value) {
this.$set(this.secret.data, 'username', base64Encode(value));
this.secret.data['username'] = base64Encode(value);
}
},
@@ -145,7 +145,7 @@ export default {
},
set(value) {
this.$set(this.secret.data, 'password', base64Encode(value));
this.secret.data['password'] = base64Encode(value);
}
},
},
@@ -25,7 +25,7 @@ import { _EDIT } from '@shell/config/query-params';
import { sortBy } from '@shell/utils/sort';
import { Banner } from '@components/Banner';
import { HCI } from '../../types';
import Tags from '../../components/DiskTags';
import DiskTags from '../../components/DiskTags';
import HarvesterDisk from './HarvesterDisk';
import HarvesterSeeder from './HarvesterSeeder';
import HarvesterKsmtuned from './HarvesterKsmtuned';
@@ -46,7 +46,7 @@ export default {
ButtonDropdown,
KeyValue,
Banner,
Tags,
DiskTags,
Loading,
HarvesterSeeder,
MessageLink,
@@ -546,7 +546,7 @@ export default {
class="row mb-20"
>
<div class="col span-12">
<Tags
<DiskTags
v-model="longhornNode.spec.tags"
:label="t('harvester.host.tags.label')"
:add-label="t('harvester.host.tags.addLabel')"
@@ -49,10 +49,10 @@ export default {
}));
if (this.mode !== _VIEW) {
this.$set(this.value, 'spec', this.value.spec || {});
this.value['spec'] = this.value.spec || {};
providers.forEach((provider) => {
this.$set(this.value.spec, provider.name, this.value.spec[provider.name] || clone(provider.default));
this.value.spec[provider.name] = this.value.spec[provider.name] || clone(provider.default);
});
}
@@ -127,11 +127,11 @@ export default {
if (!isEmpty(bufferJson)) {
this.value.spec[this.selectedProvider].buffer = bufferJson;
} else {
this.$delete(this.value.spec[this.selectedProvider], 'buffer');
delete this.value.spec[this.selectedProvider]['buffer'];
}
if (this.loggingType === AUDIT_ONLY) {
this.$set(this.value.spec, 'loggingRef', 'harvester-kube-audit-log-ref');
this.value.spec['loggingRef'] = 'harvester-kube-audit-log-ref';
}
},
tabChanged({ tab }) {
@@ -52,9 +52,9 @@ export default {
if ( newCloudCred ) {
this.value.metadata.namespace = DEFAULT_WORKSPACE;
this.$set(this.value.metadata, 'name', '');
this.value.metadata['name'] = '';
this.$set(this.value, 'data', {});
this.value['data'] = {};
}
const secretTypes = [
@@ -77,7 +77,7 @@ export default {
});
if ( this.mode === _CREATE ) {
this.$set(this.value, '_type', TYPES.OPAQUE);
this.value['_type'] = TYPES.OPAQUE;
}
return {
@@ -212,7 +212,7 @@ export default {
selectCustomType(type) {
if (type !== 'custom') {
this.$set(this.value, '_type', type);
this.value['_type'] = type;
}
}
},
@@ -39,7 +39,7 @@ export default {
setting.canReset || !!this.value.default || this.value.canReset;
if (this.value.value === undefined) {
this.$set(this.value, 'value', null);
this.value['value'] = null;
}
this.value.value = this.value.value || this.value.default || '';
@@ -17,7 +17,7 @@ import { STORAGE_CLASS, LONGHORN } from '@shell/config/types';
import { allHash } from '@shell/utils/promise';
import { clone } from '@shell/utils/object';
import { CSI_DRIVER } from '../../types';
import Tags from '../../components/DiskTags';
import DiskTags from '../../components/DiskTags';
const LONGHORN_DRIVER = 'driver.longhorn.io';
@@ -34,7 +34,7 @@ export default {
Tab,
Tabbed,
Loading,
Tags,
DiskTags,
},
mixins: [CreateEditView],
@@ -72,11 +72,11 @@ export default {
const allowedTopologies = clone(this.value.allowedTopologies?.[0]?.matchLabelExpressions || []);
this.$set(this.value, 'parameters', this.value.parameters || {});
this.$set(this.value, 'provisioner', this.value.provisioner || LONGHORN_DRIVER);
this.$set(this.value, 'allowVolumeExpansion', this.value.allowVolumeExpansion || allowVolumeExpansionOptions[0].value);
this.$set(this.value, 'reclaimPolicy', this.value.reclaimPolicy || reclaimPolicyOptions[0].value);
this.$set(this.value, 'volumeBindingMode', this.value.volumeBindingMode || volumeBindingModeOptions[0].value);
this.value['parameters'] = this.value.parameters || {};
this.value['provisioner'] = this.value.provisioner || LONGHORN_DRIVER;
this.value['allowVolumeExpansion'] = this.value.allowVolumeExpansion || allowVolumeExpansionOptions[0].value;
this.value['reclaimPolicy'] = this.value.reclaimPolicy || reclaimPolicyOptions[0].value;
this.value['volumeBindingMode'] = this.value.volumeBindingMode || volumeBindingModeOptions[0].value;
return {
reclaimPolicyOptions,
@@ -141,7 +141,7 @@ export default {
watch: {
provisionerWatch() {
this.$set(this.value, 'parameters', {});
this.value['parameters'] = {};
}
},
@@ -159,8 +159,8 @@ export default {
},
updateProvisioner(provisioner) {
this.$set(this.value, 'provisioner', provisioner);
this.$set(this.value, 'allowVolumeExpansion', provisioner === LONGHORN_DRIVER);
this.value['provisioner'] = provisioner;
this.value['allowVolumeExpansion'] = provisioner === LONGHORN_DRIVER;
},
willSave() {
@@ -303,7 +303,7 @@ export default {
/>
</div>
<div class="col span-8 value">
<Tags
<DiskTags
v-model="scope.row.value.values"
:add-label="t('generic.add')"
:mode="modeOverride"
@@ -42,13 +42,13 @@ export default {
data() {
if (this.realMode === _CREATE) {
this.$set(this.value, 'parameters', {
this.value['parameters'] = {
numberOfReplicas: '3',
staleReplicaTimeout: '30',
diskSelector: null,
nodeSelector: null,
migratable: 'true',
});
migratable: 'true'
};
}
return {};
@@ -56,12 +56,12 @@ export default {
const defaultStorage = this.$store.getters[`${ inStore }/all`](STORAGE_CLASS).find(s => s.isDefault);
this.$set(this, 'storageClassName', this.storageClassName || defaultStorage?.metadata?.name || 'longhorn');
this['storageClassName'] = this.storageClassName || defaultStorage?.metadata?.name || 'longhorn';
},
data() {
if ( !this.value.spec ) {
this.$set(this.value, 'spec', { sourceType: DOWNLOAD });
this.value['spec'] = { sourceType: DOWNLOAD };
}
if (!this.value.metadata.name) {
@@ -130,7 +130,7 @@ export default {
},
'value.spec.sourceType'() {
this.$set(this, 'file', null);
this['file'] = null;
this.url = '';
if (this.$refs?.file?.value) {
@@ -175,10 +175,10 @@ export default {
this.value.cleanForNew();
this.customName = randomStr(10);
this.$set(this.value.metadata, 'annotations', {
this.value.metadata['annotations'] = {
...this.value.metadata.annotations,
[HCI_ANNOTATIONS.TEMPLATE_VERSION_CUSTOM_NAME]: this.customName
});
};
const name = this.templateValue.metadata.name || template.metadata.name;
const namespace = this.templateValue.metadata.namespace || template.metadata.namespace;
@@ -187,7 +187,7 @@ export default {
this.value.metadata.namespace = namespace;
}
this.$set(this.value.spec, 'templateId', `${ namespace }/${ name }`);
this.value.spec['templateId'] = `${ namespace }/${ name }`;
const res = await this.value.save();
await this.saveSecret(res);
@@ -59,7 +59,7 @@ export default {
const defaultStorage = this.$store.getters[`harvester/all`](STORAGE_CLASS).find( O => O.isDefault);
this.$set(this.value.spec, 'storageClassName', this.value?.spec?.storageClassName || defaultStorage?.metadata?.name || 'longhorn');
this.value.spec['storageClassName'] = this.value?.spec?.storageClassName || defaultStorage?.metadata?.name || 'longhorn';
},
data() {
@@ -247,7 +247,7 @@ export default {
this.value.setAnnotations(imageAnnotations);
this.$set(this.value, 'spec', spec);
this.value['spec'] = spec;
},
generateYaml() {
@@ -73,7 +73,7 @@ export default {
selectedUser(val, old) {
if ( val.includes(_NEW)) {
this.$set(this, 'selectedUser', old);
this['selectedUser'] = old;
this.update();
this.show();
}
@@ -49,7 +49,7 @@ export default {
},
updateUser(neu) {
this.$set(this.value, 'username', neu);
this.value['username'] = neu;
this.update();
},
@@ -40,12 +40,12 @@ export default {
},
updateUser(neu) {
this.$set(this.value, 'users', neu);
this.value['users'] = neu;
this.update();
},
updateSSH(neu) {
this.$set(this.value, 'sshkeys', neu);
this.value['sshkeys'] = neu;
this.update();
},
@@ -179,7 +179,7 @@ export default {
cancel() {
this.cloudTemplate = '';
this.cloudTemplateName = '';
this.$set(this, 'errors', []);
this['errors'] = [];
this.isOpen = false;
},
@@ -138,7 +138,7 @@ export default {
handler(neu) {
const hasManagementNetwork = !!neu.some(N => N.isPod);
this.$set(this, 'hasManagementNetwork', hasManagementNetwork);
this['hasManagementNetwork'] = hasManagementNetwork;
},
immediate: true,
deep: true
@@ -146,7 +146,7 @@ export default {
isSingle(neu) {
if (!neu) {
this.$set(this.value, 'macAddress', '');
this.value['macAddress'] = '';
this.update();
}
}
@@ -164,7 +164,7 @@ export default {
this.value.isPod = false;
}
this.$set(this, 'isMasquerade', this.value.isPod);
this['isMasquerade'] = this.value.isPod;
if (this.value.isPod) {
this.value.type = 'masquerade';
@@ -134,8 +134,8 @@ export default {
},
changeRows(filterRows, parentSriov) {
this.$set(this, 'filterRows', filterRows);
this.$set(this, 'parentSriov', parentSriov);
this['filterRows'] = filterRows;
this['parentSriov'] = parentSriov;
},
sortGenerationFn() {
@@ -126,7 +126,7 @@ export default {
checkedSsh(val, old) {
if ( val.includes(_NEW)) {
this.$set(this, 'checkedSsh', old);
this['checkedSsh'] = old;
this.update();
this.show();
}
@@ -89,8 +89,8 @@ export default {
methods: {
changeRows(filterRows, parentSriov) {
this.$set(this, 'filterRows', filterRows);
this.$set(this, 'parentSriov', parentSriov);
this['filterRows'] = filterRows;
this['parentSriov'] = parentSriov;
},
sortGenerationFn() {
@@ -149,7 +149,7 @@ export default {
return V;
});
this.$set(this, 'rows', rows);
this['rows'] = rows;
},
deep: true,
immediate: true,
@@ -32,7 +32,7 @@ export default {
watch: {
'value.type'(neu) {
if (neu === 'cd-rom') {
this.$set(this.value, 'bus', 'sata');
this.value['bus'] = 'sata';
this.update();
}
},
@@ -140,7 +140,7 @@ export default {
'value.type'(neu) {
if (neu === 'cd-rom') {
this.$set(this.value, 'bus', 'sata');
this.value['bus'] = 'sata';
this.update();
}
},
@@ -100,7 +100,7 @@ export default {
watch: {
'value.type'(neu) {
if (neu === 'cd-rom') {
this.$set(this.value, 'bus', 'sata');
this.value['bus'] = 'sata';
this.update();
}
},
@@ -143,11 +143,11 @@ export default {
if (this.idx === 0) {
if (/iso$/i.test(imageResource?.imageSuffix)) {
this.$set(this.value, 'type', 'cd-rom');
this.$set(this.value, 'bus', 'sata');
this.value['type'] = 'cd-rom';
this.value['bus'] = 'sata';
} else {
this.$set(this.value, 'type', 'disk');
this.$set(this.value, 'bus', 'virtio');
this.value['type'] = 'disk';
this.value['bus'] = 'virtio';
}
}
@@ -165,7 +165,7 @@ export default {
message: this.$store.getters['i18n/t']('harvester.vmTemplate.tips.notExistImage.message')
}, { root: true });
this.$set(this.value, 'image', '');
this.value['image'] = '';
}
}
}
@@ -87,7 +87,7 @@ export default {
watch: {
'value.type'(neu) {
if (neu === 'cd-rom') {
this.$set(this.value, 'bus', 'sata');
this.value['bus'] = 'sata';
this.update();
}
},
@@ -19,17 +19,17 @@ import KeyValue from '@shell/components/form/KeyValue';
import { clear } from '@shell/utils/array';
import { clone } from '@shell/utils/object';
import { HCI } from '../../types';
import { RunStrategys } from '../../config/harvester-map';
import { saferDump } from '@shell/utils/create-yaml';
import { exceptionToErrorsArray } from '@shell/utils/error';
import { HCI as HCI_ANNOTATIONS } from '@pkg/harvester/config/labels-annotations';
import { BEFORE_SAVE_HOOKS, AFTER_SAVE_HOOKS } from '@shell/mixins/child-hook';
import VM_MIXIN from '../../mixins/harvester-vm';
import CreateEditView from '@shell/mixins/create-edit-view';
import { parseVolumeClaimTemplates } from '@pkg/utils/vm';
import VM_MIXIN from '../../mixins/harvester-vm';
import { RunStrategys } from '../../config/harvester-map';
import { HCI } from '../../types';
import RestartVMDialog from '../../dialog/RestartVMDialog';
import VirtualMachineVGpuDevices from './VirtualMachineVGpuDevices/index';
import PciDevices from './VirtualMachinePciDevices/index';
@@ -218,7 +218,7 @@ export default {
this.getInitConfig({
value: cloneVersionVM, existUserData: true, fromTemplate: true
});
this.$set(this, 'hasCreateVolumes', []); // When using the template, all volume names need to be newly created
this['hasCreateVolumes'] = []; // When using the template, all volume names need to be newly created
}
},
@@ -261,7 +261,7 @@ export default {
const diskRows = this.getDiskRows(this.value);
this.$set(this, 'diskRows', diskRows);
this['diskRows'] = diskRows;
const templateId = this.$route.query.templateId;
const templateVersionId = this.$route.query.versionId;
@@ -317,13 +317,13 @@ export default {
const cloneSpec = clone(this.spec);
for (let i = 1; i <= this.count; i++) {
this.$set(this.value, 'spec', cloneValue.spec);
this.$set(this, 'spec', cloneSpec);
this.value['spec'] = cloneValue.spec;
this['spec'] = cloneSpec;
const suffix = i < 10 ? `0${ i }` : i;
this.value.cleanForNew();
this.value.metadata.name = `${ this.namePrefix }${ join }${ suffix }`;
this.$set(this.value.spec.template.spec, 'hostname', `${ baseHostname }${ join }${ suffix }`);
this.value.spec.template.spec['hostname'] = `${ baseHostname }${ join }${ suffix }`;
this.secretName = '';
await this.parseVM();
const basicValue = await this.$store.dispatch('harvester/clone', { resource: this.value });
@@ -380,7 +380,7 @@ export default {
updateBeforeSave() {
if (this.isSingle) {
if (!this.value.spec.template.spec.hostname) {
this.$set(this.value.spec.template.spec, 'hostname', this.value.metadata.name);
this.value.spec.template.spec['hostname'] = this.value.metadata.name;
}
}
@@ -395,7 +395,7 @@ export default {
validateCount(count) {
if (count > 10) {
this.$set(this, 'count', 10);
this['count'] = 10;
}
},
@@ -139,7 +139,7 @@ export default {
backendServerSelector[key] = (value[key] || '').split(',');
});
this.$set(this.value.spec, 'backendServerSelector', backendServerSelector);
this.value.spec['backendServerSelector'] = backendServerSelector;
},
},
@@ -36,8 +36,8 @@ export default {
this.canEditPSPBindings = !!pspBindingSchema;
},
data() {
this.$set(this.value, 'spec', this.value.spec || {});
this.$set(this.value.spec, 'podSecurityPolicyTemplateId', this.value.status?.podSecurityPolicyTemplateId || '');
this.value['spec'] = this.value.spec || {};
this.value.spec['podSecurityPolicyTemplateId'] = this.value.status?.podSecurityPolicyTemplateId || '';
return {
allPSPs: [],
@@ -134,9 +134,9 @@ export default {
}
},
created() {
this.$set(this.value.metadata, 'namespace', this.$store.getters['currentCluster'].id);
this.$set(this.value, 'spec', this.value.spec || {});
this.$set(this.value.spec, 'containerDefaultResourceLimit', this.value.spec.containerDefaultResourceLimit || {});
this.value.metadata['namespace'] = this.$store.getters['currentCluster'].id;
this.value['spec'] = this.value.spec || {};
this.value.spec['containerDefaultResourceLimit'] = this.value.spec.containerDefaultResourceLimit || {};
},
methods: {
async save(saveCb) {
@@ -178,11 +178,11 @@ export default {
},
onHasOwnerChanged(hasOwner) {
this.$set(this, 'membershipHasOwner', hasOwner);
this['membershipHasOwner'] = hasOwner;
},
onMembershipUpdate(update) {
this.$set(this, 'membershipUpdate', update);
this['membershipUpdate'] = update;
},
removeQuota(key) {