Skip to content

Commit

Permalink
Send edit request only if settings change
Browse files Browse the repository at this point in the history
Signed-off-by: Francesco Torchia <francesco.torchia@suse.com>
  • Loading branch information
torchiaf committed Sep 8, 2023
1 parent 538c244 commit 8ef9806
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions dashboard/pkg/epinio/edit/services.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default Vue.extend<Data, EpinioCompRecord, EpinioCompRecord, EpinioCompRe
errors: [],
failedWaitingForServiceInstance: false,
selectedApps: this.value.boundapps || [],
chartValues: this.value.settings || {},
chartValues: objValuesToString(this.value.settings) || {},
validChartValues: {}
};
},
Expand Down Expand Up @@ -134,6 +134,13 @@ export default Vue.extend<Data, EpinioCompRecord, EpinioCompRecord, EpinioCompRe
methods: {
async save(saveCb: (success: boolean) => void) {
this.errors = [];
const newSettings = !isEqual(objValuesToString(this.chartValues), objValuesToString(this.value.settings));
if (newSettings) {
this.value.settings = objValuesToString(this.chartValues);
}
try {
if (this.isCreate) {
await this.value.create();
Expand All @@ -144,7 +151,9 @@ export default Vue.extend<Data, EpinioCompRecord, EpinioCompRecord, EpinioCompRe
}
if (this.isEdit) {
await this.value.update();
if (newSettings) {
await this.value.update();
}
await this.updateServiceInstanceAppBindings(this.value);
await this.value.forceFetch();
}
Expand All @@ -165,7 +174,6 @@ export default Vue.extend<Data, EpinioCompRecord, EpinioCompRecord, EpinioCompRe
},
resetChartValues() {
this.chartValues = {};
this.value.settings = null;
this.validChartValues = {};
}
},
Expand All @@ -174,12 +182,6 @@ export default Vue.extend<Data, EpinioCompRecord, EpinioCompRecord, EpinioCompRe
'value.meta.namespace'() {
Vue.set(this, 'selectedApps', []);
},
chartValues: {
handler(neu) {
this.value.settings = objValuesToString(neu);
},
deep: true
}
}
});
Expand Down

0 comments on commit 8ef9806

Please sign in to comment.