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

Use turbo_power instead of handrolled method

Klaus Zandersa5473703298b
diff --git a/app/controllers/concerns/op_turbo/component_stream.rb b/app/controllers/concerns/op_turbo/component_stream.rb
index 02ef101b420..4c1836f9f4e 100644
--- a/app/controllers/concerns/op_turbo/component_stream.rb
+++ b/app/controllers/concerns/op_turbo/component_stream.rb
@@ -53,10 +53,6 @@ module OpTurbo
modify_via_turbo_stream(component:, action: :remove, status:)
end
- def modify_history_via_turbo_stream(method:, url:)
- turbo_streams << helpers.turbo_stream_action_tag(:history, method:, url:)
- end
-
def modify_via_turbo_stream(component:, action:, status:)
@turbo_status = status
turbo_streams << component.render_as_turbo_stream(
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 051598a4870..caac34fd138 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -65,16 +65,13 @@ class ProjectsController < ApplicationController
end
format.turbo_stream do
- current_url = url_for(params.permit(:conroller, :action, :query_id, :filters, :columns, :sortBy))
- modify_history_via_turbo_stream(method: :push, url: current_url)
-
replace_via_turbo_stream(
component: Projects::IndexPageHeaderComponent.new(query: @query, current_user:, state: :show, params:)
)
+ replace_via_turbo_stream(component: Projects::TableComponent.new(query: @query, current_user:, params:))
- replace_via_turbo_stream(
- component: Projects::TableComponent.new(query: @query, current_user:, params:)
- )
+ current_url = url_for(params.permit(:conroller, :action, :query_id, :filters, :columns, :sortBy))
+ turbo_streams << turbo_stream.push_state(current_url)
render turbo_stream: turbo_streams
end
diff --git a/frontend/src/turbo/history-action.ts b/frontend/src/turbo/history-action.ts
deleted file mode 100644
index 2eae55e35f2..00000000000
--- a/frontend/src/turbo/history-action.ts
+++ /dev/null
@@ -1,19 +0,0 @@
-import { StreamActions, StreamElement } from '@hotwired/turbo';
-
-export function registerHistoryAction() {
- StreamActions.history = function historyStreamAction(this:StreamElement) {
- const url = this.getAttribute('url');
- const method = this.getAttribute('method');
-
- switch (method) {
- case 'replace':
- window.history.replaceState({ href: url }, '', url);
- break;
- case 'push':
- window.history.pushState({ href: url }, '', url);
- break;
- default:
- throw new Error(`Unknown history method: ${method}`);
- }
- };
-}
diff --git a/frontend/src/turbo/setup.ts b/frontend/src/turbo/setup.ts
index 283c221917e..e961b198b00 100644
--- a/frontend/src/turbo/setup.ts
+++ b/frontend/src/turbo/setup.ts
@@ -2,7 +2,6 @@ import '../typings/shims.d.ts';
import * as Turbo from '@hotwired/turbo';
import TurboPower from 'turbo_power';
import { registerDialogStreamAction } from './dialog-stream-action';
-import { registerHistoryAction } from './history-action';
import { addTurboEventListeners } from './turbo-event-listeners';
// Disable default turbo-drive for now as we don't need it for now AND it breaks angular routing
@@ -13,7 +12,6 @@ Turbo.start();
// Register our own actions
addTurboEventListeners();
registerDialogStreamAction();
-registerHistoryAction();
// Register turbo power actions
TurboPower.initialize(Turbo.StreamActions);