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

Only redirect to a query when it is still visibil

Klaus Zanders8a450a4c3231
diff --git a/app/controllers/projects/queries_controller.rb b/app/controllers/projects/queries_controller.rb
index 11940de5509..cc37266a0b0 100644
--- a/app/controllers/projects/queries_controller.rb
+++ b/app/controllers/projects/queries_controller.rb
@@ -91,17 +91,19 @@ class Projects::QueriesController < ApplicationController
private
- def render_result(service_call, success_i18n_key:, error_i18n_key:)
+ def render_result(service_call, success_i18n_key:, error_i18n_key:) # rubocop:disable Metrics/AbcSize
+ modified_query = service_call.result
+
if service_call.success?
flash[:notice] = I18n.t(success_i18n_key)
- redirect_to projects_path(query_id: service_call.result.id)
+ redirect_to modified_query.visible? ? projects_path(query_id: modified_query.id) : projects_path
else
flash[:error] = I18n.t(error_i18n_key, errors: service_call.errors.full_messages.join("\n"))
render template: "/projects/index",
layout: "global",
- locals: { query: service_call.result, state: :edit }
+ locals: { query: modified_query, state: :edit }
end
end