Skip to content

Commit

Permalink
Merge pull request #6848 from getkirby/v5/fix/remove-retry-dialog
Browse files Browse the repository at this point in the history
Remove retry dialog
  • Loading branch information
bastianallgeier authored Dec 8, 2024
2 parents 4b8e371 + 2cd56bd commit 3ce4161
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 61 deletions.
4 changes: 0 additions & 4 deletions i18n/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,8 @@
"form.discard.confirm": "Do you really want to <strong>discard all your changes</strong>?",
"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",
Expand Down
22 changes: 13 additions & 9 deletions panel/src/components/Views/ModelView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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?.();
Expand Down
53 changes: 5 additions & 48 deletions panel/src/panel/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -202,7 +202,7 @@ export default (panel) => {
return this.lockDialog(error.details);
}

this.retry("publish", error, [values, env]);
throw error;
} finally {
this.isProcessing = false;
}
Expand All @@ -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);
},

/**
Expand All @@ -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
Expand All @@ -313,7 +270,7 @@ export default (panel) => {
return this.lockDialog(error.details);
}

this.retry("save", error, [values, env]);
throw error;
}
},

Expand Down

0 comments on commit 3ce4161

Please sign in to comment.