Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Handle non-turbo responses in async-dialog controller

Jan Sandbrink0935d11e92a7
diff --git a/frontend/src/stimulus/controllers/async-dialog.controller.ts b/frontend/src/stimulus/controllers/async-dialog.controller.ts
index 9b4197abf7b..66b02f2c434 100644
--- a/frontend/src/stimulus/controllers/async-dialog.controller.ts
+++ b/frontend/src/stimulus/controllers/async-dialog.controller.ts
@@ -49,13 +49,20 @@ export default class AsyncDialogController extends ApplicationController {
Accept: 'text/vnd.turbo-stream.html',
'X-Authentication-Scheme': 'Session',
},
- }).then((r) => r.text())
- .then((html) => {
- renderStreamMessage(html);
- })
- .finally(() => {
- TurboHelpers.hideProgressBar();
- });
+ }).then((response) => {
+ const contentType = response.headers.get('Content-Type') || '';
+ const isTurboStream = contentType.includes('text/vnd.turbo-stream.html');
+
+ if (!isTurboStream) {
+ return Promise.reject();
+ }
+
+ return response.text();
+ }).then((html) => {
+ renderStreamMessage(html);
+ }).finally(() => {
+ TurboHelpers.hideProgressBar();
+ });
}
get href() {