From 0d493ca81df426f4d387d9f4971c032ab7b4097d Mon Sep 17 00:00:00 2001 From: Petr Jasek Date: Tue, 14 Nov 2023 16:38:21 +0100 Subject: [PATCH 1/2] show error message on delete --- scripts/core/helpers/crud-manager-http.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/core/helpers/crud-manager-http.tsx b/scripts/core/helpers/crud-manager-http.tsx index e1863e180a..b3e1dde267 100644 --- a/scripts/core/helpers/crud-manager-http.tsx +++ b/scripts/core/helpers/crud-manager-http.tsx @@ -97,6 +97,14 @@ export function connectCrudManagerHttp this.refresh()) .then(() => { notify.success(gettext('The item has been deleted.')); + }) + .catch((reason) => { + if (reason != null && reason.message != null) { + notify.error(reason.message); + return; + } + + return Promise.reject(reason); }); } From 14feab98ba631d85b4b852870e50925eda3791ff Mon Sep 17 00:00:00 2001 From: Petr Jasek Date: Wed, 15 Nov 2023 09:35:48 +0100 Subject: [PATCH 2/2] shorten code --- scripts/core/helpers/crud-manager-http.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/core/helpers/crud-manager-http.tsx b/scripts/core/helpers/crud-manager-http.tsx index b3e1dde267..5e444c99b6 100644 --- a/scripts/core/helpers/crud-manager-http.tsx +++ b/scripts/core/helpers/crud-manager-http.tsx @@ -99,7 +99,7 @@ export function connectCrudManagerHttp { - if (reason != null && reason.message != null) { + if (reason?.message != null) { notify.error(reason.message); return; }