diff --git a/i18n/translations/en.json b/i18n/translations/en.json index 02e14d34f6..70bece0b76 100644 --- a/i18n/translations/en.json +++ b/i18n/translations/en.json @@ -389,12 +389,8 @@ "form.discard.confirm": "Do you really want to discard all your changes?", "form.locked": "This content is disabled for you as it is currently edited by another user", "form.unsaved": "The current changes have not yet been saved", - "form.save.error": "Your changes could not be saved.", - "form.save.success": "Your changes have been saved", "form.preview": "Preview changes", "form.preview.draft": "Preview draft", - "form.publish.error": "Your changes could not be published.", - "form.publish.success": "Your changes have been published", "hide": "Hide", "hour": "Hour", diff --git a/panel/src/components/Views/ModelView.vue b/panel/src/components/Views/ModelView.vue index 15fe9557aa..b7854cb312 100644 --- a/panel/src/components/Views/ModelView.vue +++ b/panel/src/components/Views/ModelView.vue @@ -110,17 +110,21 @@ export default { }); }, async onSubmit() { - await this.$panel.content.publish(this.content, { - api: this.api, - language: this.$panel.language.code - }); + try { + await this.$panel.content.publish(this.content, { + api: this.api, + language: this.$panel.language.code + }); - this.$panel.notification.success(); - this.$events.emit("model.update"); + this.$panel.notification.success(); + this.$events.emit("model.update"); - // the view needs to be refreshed to get an updated set of props - // this will also rerender sections if needed - await this.$panel.view.refresh(); + // the view needs to be refreshed to get an updated set of props + // this will also rerender sections if needed + await this.$panel.view.refresh(); + } catch (error) { + this.$panel.notification.error(error); + } }, onViewSave(e) { e?.preventDefault?.(); diff --git a/panel/src/panel/content.js b/panel/src/panel/content.js index 71ac5f6fff..b167ef95dc 100644 --- a/panel/src/panel/content.js +++ b/panel/src/panel/content.js @@ -187,7 +187,7 @@ export default (panel) => { try { await this.request("publish", values, env); - // close the retry dialog if it is still open + // close the dialog if it is still open this.dialog?.close(); // update the props for the current view @@ -202,7 +202,7 @@ export default (panel) => { return this.lockDialog(error.details); } - this.retry("publish", error, [values, env]); + throw error; } finally { this.isProcessing = false; } @@ -225,50 +225,7 @@ export default (panel) => { options.silent = true; } - return await panel.api.post(api + "/changes/" + method, values, options); - }, - - /** - * Opens a dialog with the error message - * to retry the given method. - */ - retry(method, error, ...args) { - // log the error to the console to make it - // easier to debug the issue - console.error(error); - - // set the dialog instance - this.dialog = panel.dialog; - - // show a dialog to the user to try again - this.dialog.open({ - component: "k-text-dialog", - props: { - text: panel.t(`form.${method}.error`), - cancelButton: panel.t("close"), - submitButton: { - icon: "refresh", - text: panel.t("retry") - } - }, - on: { - close: () => { - this.dialog = null; - }, - submit: async () => { - this.dialog.isLoading = true; - - // try again with the latest state in the props - await this[method](...args); - - // make sure the dialog is closed if the request was successful - this.dialog?.close(); - - // give a more reassuring longer success notification - panel.notification.success(panel.t(`form.${method}.success`)); - } - } - }); + return panel.api.post(api + "/changes/" + method, values, options); }, /** @@ -287,7 +244,7 @@ export default (panel) => { this.isProcessing = false; - // close the retry dialog if it is still open + // close the dialog if it is still open this.dialog?.close(); // update the lock timestamp @@ -313,7 +270,7 @@ export default (panel) => { return this.lockDialog(error.details); } - this.retry("save", error, [values, env]); + throw error; } },