Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove retry dialog #6848

Merged
merged 1 commit into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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