Skip to content

Commit

Permalink
Merge pull request #12253 from rak-phillip/bugfix/12241-vue-set
Browse files Browse the repository at this point in the history
Replace remaining instances of `$set` and `$delete`
  • Loading branch information
rak-phillip authored Oct 15, 2024
2 parents b574979 + 468685b commit 86cde1f
Show file tree
Hide file tree
Showing 13 changed files with 35 additions and 80 deletions.
2 changes: 1 addition & 1 deletion pkg/aks/components/CruAks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,7 @@ export default defineComponent({
:mode="mode"
:label="t('aks.sshPublicKey.readFromFile')"
class="role-tertiary mt-10"
@selected="e=>$set(config, 'sshPublicKey', e)"
@selected="e => config.sshPublicKey = e"
/>
</div>
</div>
Expand Down
24 changes: 4 additions & 20 deletions shell/chart/monitoring/alerting/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,27 +81,15 @@ export default {
watch: {
filteredSecrets(newValue) {
if (isEmpty(newValue)) {
this.$set(
this.value.alertmanager.alertmanagerSpec,
'useExistingSecret',
false
);
this.value.alertmanager.alertmanagerSpec.useExistingSecret = false;
}
const { existingSecret } = this;
if (existingSecret) {
this.$nextTick(() => {
this.$set(
this.value.alertmanager.alertmanagerSpec,
'useExistingSecret',
true
);
this.$set(
this.value.alertmanager.alertmanagerSpec,
'configSecret',
existingSecret.metadata.name
);
this.value.alertmanager.alertmanagerSpec.useExistingSecret = true;
this.value.alertmanager.alertmanagerSpec.configSecret = existingSecret.metadata.name;
});
}
},
Expand All @@ -110,11 +98,7 @@ export default {
if (useExistingSecret) {
if (existingSecret?.metadata?.name) {
this.$set(
this.value.alertmanager.alertmanagerSpec,
'configSecret',
existingSecret.metadata.name
);
this.value.alertmanager.alertmanagerSpec.configSecret = existingSecret.metadata.name;
}
} else {
this.value.alertmanager.alertmanagerSpec['configSecret'] = '';
Expand Down
6 changes: 3 additions & 3 deletions shell/chart/monitoring/grafana/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export default {
:mode="mode"
:options="pvcs"
:label="t('monitoring.grafana.storage.existingClaim')"
@updateName="(name) => $set(value.grafana.persistence, 'existingClaim', name)"
@updateName="(name) => value.grafana.persistence.existingClaim = name"
/>
</div>
</div>
Expand All @@ -271,7 +271,7 @@ export default {
:mode="mode"
:options="storageClasses"
:label="t('monitoring.prometheus.storage.className')"
@updateName="(name) => $set(value.grafana.persistence, 'storageClassName', name)"
@updateName="(name) => value.grafana.persistence.storageClassName = name"
/>
</div>
</div>
Expand Down Expand Up @@ -338,7 +338,7 @@ export default {
:mode="mode"
:options="storageClasses"
:label="t('monitoring.prometheus.storage.className')"
@updateName="(name) => $set(value.grafana.persistence, 'storageClassName', name)"
@updateName="(name) => value.grafana.persistence.storageClassName = name"
/>
</div>
</div>
Expand Down
21 changes: 7 additions & 14 deletions shell/chart/monitoring/prometheus/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,14 @@ export default {
watch: {
enablePersistentStorage(enabled) {
if (!!enabled) {
this.$set(
this.value.prometheus.prometheusSpec.storageSpec,
'volumeClaimTemplate',
{
spec: {
accessModes: ['ReadWriteOnce'],
resources: { requests: { storage: '50Gi' } },
}
this.value.prometheus.prometheusSpec.storageSpec.volumeClaimTemplate = {
spec: {
accessModes: ['ReadWriteOnce'],
resources: { requests: { storage: '50Gi' } },
}
);
};
} else {
this.$delete(
this.value.prometheus.prometheusSpec.storageSpec,
'volumeClaimTemplate'
);
delete this.value.prometheus.prometheusSpec.storageSpec['volumeClaimTemplate'];
}
},
},
Expand Down Expand Up @@ -328,7 +321,7 @@ export default {
:options="storageClasses"
:value="value.prometheus.prometheusSpec.storageSpec.volumeClaimTemplate.spec.storageClassName"
:label="t('monitoring.prometheus.storage.className')"
@updateName="(name) => $set(value.prometheus.prometheusSpec.storageSpec.volumeClaimTemplate.spec, 'storageClassName', name)"
@updateName="(name) => value.prometheus.prometheusSpec.storageSpec.volumeClaimTemplate.spec.storageClassName = name"
/>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion shell/components/form/PodAffinity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ export default {
:value="props.row.value._anti ?t('workload.scheduling.affinity.antiAffinityOption') :t('workload.scheduling.affinity.affinityOption') "
:label="t('workload.scheduling.affinity.type')"
:data-testid="`pod-affinity-type-index${props.i}`"
@update:value="$set(props.row.value, '_anti',!props.row.value._anti)"
@update:value="props.row.value._anti = !props.row.value._anti"
/>
</div>
<div class="col span-6">
Expand Down
4 changes: 2 additions & 2 deletions shell/edit/auth/googleoauth.vue
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export default {
class="role-tertiary add mt-5"
:label="t('generic.readFromFile')"
:mode="mode"
@selected="$set(model, 'oauthCredential', $event)"
@selected="model.oauthCredential = $event"
/>
</div>
</div>
Expand Down Expand Up @@ -231,7 +231,7 @@ export default {
class="role-tertiary add mt-5"
:label="t('generic.readFromFile')"
:mode="mode"
@selected="$set(model, 'serviceAccountCredential', $event)"
@selected="model.serviceAccountCredential = $event"
/>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions shell/edit/auth/ldap/config.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default {
:step="1"
:mode="mode"
:label="t('authConfig.ldap.port')"
@update:value="e=>$set(model, 'port', e.replace(/[^0-9]*/g, ''))"
@update:value="e=> model.port = e.replace(/[^0-9]*/g, '')"
/>
</div>

Expand Down Expand Up @@ -158,7 +158,7 @@ export default {
class="role-tertiary add mt-5"
:label="t('generic.readFromFile')"
:mode="mode"
@selected="$set(model, 'certificate', $event)"
@selected="model.certificate = $event"
/>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions shell/edit/auth/oidc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ export default {
class="role-tertiary add mt-5"
:label="t('generic.readFromFile')"
:mode="mode"
@selected="$set(model, 'privateKey', $event)"
@selected="model.privateKey = $event"
/>
</div>
<div class="col span-6">
Expand All @@ -248,7 +248,7 @@ export default {
class="role-tertiary add mt-5"
:label="t('generic.readFromFile')"
:mode="mode"
@selected="$set(model, 'certificate', $event)"
@selected="model.certificate = $event"
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,29 +84,28 @@ export default {
watch: {
'value.type'(neuType, oldType) {
const { $set } = this;
let resourceSpec, podSpec, objectSpec, externalSpec;
switch (neuType) {
case 'External':
externalSpec = this.initExternalSpec();
$set(this.value, 'external', externalSpec);
this.value.external = externalSpec;
break;
case 'Object':
objectSpec = this.initObjectSpec();
$set(this.value, 'object', objectSpec);
this.value.object = objectSpec;
break;
case 'Pods':
podSpec = this.initPodsSpec();
$set(this.value, 'pods', podSpec);
this.value.pods = podSpec;
break;
case 'Resource':
resourceSpec = this.initResourceSpec();
$set(this.value, 'resource', resourceSpec.resource);
this.value.resource = resourceSpec.resource;
break;
default:
break;
Expand Down
6 changes: 1 addition & 5 deletions shell/edit/monitoring.coreos.com.alertmanagerconfig/auth.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ export default {
initializeType(authOptions, type) {
authOptions.forEach((authOption) => {
if (authOption.value === type && type !== 'none') {
this.$set(
this.value,
authOption.value,
this.value[authOption.value] || authOption.default
);
this.value.authOption.value = this.value[authOption.value] || authOption.default;
} else if (typeof this.value[authOption.value] !== 'undefined') {
delete this.value[authOption.value];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ export default {
this.value['sendResolved'] = this.value.sendResolved || false;
if (this.mode === _CREATE) {
this.$set(
this.value,
'text',
this.value.text || '{{ template "slack.rancher.text" . }}'
);
this.value.text = this.value.text || '{{ template "slack.rancher.text" . }}';
}
return {
Expand Down
6 changes: 1 addition & 5 deletions shell/edit/monitoring.coreos.com.receiver/types/slack.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ export default {
this.value['send_resolved'] = this.value.send_resolved || false;
if (this.mode === _CREATE) {
this.$set(
this.value,
'text',
this.value.text || '{{ template "slack.rancher.text" . }}'
);
this.value.text = this.value.text || '{{ template "slack.rancher.text" . }}';
}
return {};
Expand Down
21 changes: 6 additions & 15 deletions shell/edit/service.vue
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,7 @@ export default {
this.value.spec.sessionAffinityConfig = { clientIP: { timeoutSeconds: null } };
// set it null and then set it with vue to make reactive.
this.$set(
this.value.spec.sessionAffinityConfig.clientIP,
'timeoutSeconds',
SESSION_STICKY_TIME_DEFAULT
);
this.value.spec.sessionAffinityConfig.clientIP.timeoutSeconds = SESSION_STICKY_TIME_DEFAULT;
} else if (
this.value?.spec?.sessionAffinityConfig?.clientIP?.timeoutSeconds
) {
Expand Down Expand Up @@ -425,7 +421,7 @@ export default {
:mode="mode"
:initial-empty-row="true"
:protip="false"
@update:value="(e) => $set(value.spec, 'selector', e)"
@update:value="(e) => value.spec.selector = e"
/>
</div>
</div>
Expand All @@ -448,7 +444,7 @@ export default {
:tooltip-key="
hasClusterIp ? 'servicesPage.ips.clusterIpHelpText' : null
"
@update:value="(e) => $set(value.spec, 'clusterIP', e)"
@update:value="(e) => value.spec.clusterIP = e"
/>
</div>
</div>
Expand All @@ -465,7 +461,7 @@ export default {
:tooltip-key="
hasClusterIp ? 'servicesPage.ips.loadBalancerIp.helpText' : null
"
@update:value="(e) => $set(value.spec, 'loadBalancerIP', e)"
@update:value="(e) => value.spec.loadBalancerIP = e"
/>
</div>
</div>
Expand All @@ -478,7 +474,7 @@ export default {
:value-placeholder="t('servicesPage.ips.external.placeholder')"
:mode="mode"
:protip="false"
@update:value="(e) => $set(value.spec, 'externalIPs', e)"
@update:value="(e) => value.spec.externalIPs = e"
/>
</div>
</div>
Expand Down Expand Up @@ -527,12 +523,7 @@ export default {
:label="t('servicesPage.affinity.timeout.label')"
:placeholder="t('servicesPage.affinity.timeout.placeholder')"
@input="
(e) =>
$set(
value.spec.sessionAffinityConfig.clientIP,
'timeoutSeconds',
e
)
(e) => value.spec.sessionAffinityConfig.clientIP.timeoutSeconds = e
"
/>
</div>
Expand Down

0 comments on commit 86cde1f

Please sign in to comment.