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

do not redirect to deleted work package

ulfertscb1416bfd9ca
diff --git a/app/helpers/work_packages_helper.rb b/app/helpers/work_packages_helper.rb
index ffebdca6d24..ecf8f8bbf31 100644
--- a/app/helpers/work_packages_helper.rb
+++ b/app/helpers/work_packages_helper.rb
@@ -207,6 +207,11 @@ module WorkPackagesHelper
ret
end
+ def back_url_is_wp_show?
+ route = Rails.application.routes.recognize_path(params[:back_url] || request.env['HTTP_REFERER'])
+ route[:controller] == 'work_packages' && route[:action] == 'index' && route[:state]&.match?(/^\d+/)
+ end
+
private
def truncated_work_package_description(work_package, lines = 3)
diff --git a/app/views/work_packages/bulk/destroy.html.erb b/app/views/work_packages/bulk/destroy.html.erb
index 6c111d19966..3d0ffe3aef8 100644
--- a/app/views/work_packages/bulk/destroy.html.erb
+++ b/app/views/work_packages/bulk/destroy.html.erb
@@ -29,31 +29,31 @@ See docs/COPYRIGHT.rdoc for more details.
<%= error_messages_for work_packages.first %>
<%= styled_form_tag work_packages_bulk_path, method: :delete, class: 'form danger-zone' do %>
- <%= back_url_hidden_field_tag %>
+ <%= back_url_hidden_field_tag unless back_url_is_wp_show? %>
<% work_packages.each do |work_package| %>
<%= hidden_field_tag 'ids[]', work_package.id %>
<% end %>
<section class="form--section">
<h3 class="form--section-title">
- <%= l('work_package.destroy.title') %>
+ <%= t('work_package.destroy.title') %>
</h3>
<%= work_package_associations_to_address(associated) %>
<p>
- <strong><%= l(:text_destroy_what_to_do) %></strong>
+ <strong><%= t(:text_destroy_what_to_do) %></strong>
</p>
<%= fields_for :to_do do |f| %>
<div class="form--field -trailing-label">
- <%= styled_label_tag :to_do_action_destroy, l(:text_destroy) %>
+ <%= styled_label_tag :to_do_action_destroy, t(:text_destroy) %>
<div class="form--field-container">
<%= styled_radio_button_tag 'to_do[action]', 'destroy' %>
</div>
</div>
<div class="form--field -trailing-label">
- <%=styled_label_tag 'to_do_action_nullify', l(:text_assign_to_project) %>
+ <%=styled_label_tag 'to_do_action_nullify', t(:text_assign_to_project) %>
<div class="form--field-container">
<%= styled_radio_button_tag 'to_do[action]' , 'nullify' %>
</div>
@@ -61,7 +61,7 @@ See docs/COPYRIGHT.rdoc for more details.
<div class="grid-block">
<div class="grid-block small-3">
<div class="form--field -trailing-label">
- <%= styled_label_tag 'to_do_action_reassign', l(:text_reassign) %>
+ <%= styled_label_tag 'to_do_action_reassign', t(:text_reassign) %>
<div class="form--field-container">
<%= styled_radio_button_tag 'to_do[action]', 'reassign' %>
<% csp_onclick('if(jQuery("#to_do_action_reassign").prop("checked")) { jQuery("#to_do_reassign_to_id").focus(); }',
@@ -72,7 +72,7 @@ See docs/COPYRIGHT.rdoc for more details.
<div class="grid-block">
<div class="form--field">
<div class="form--text-field-container -xslim">
- <%= styled_label_tag 'to_do_reassign_to_id', l(:text_reassign), class: 'form--label hidden-for-sighted' %>
+ <%= styled_label_tag 'to_do_reassign_to_id', t(:text_reassign), class: 'form--label hidden-for-sighted' %>
<%= f.text_field 'reassign_to_id', placeholder: WorkPackage.human_attribute_name(:id), value: params[:reassign_to_id], size: 6, onfocus: 'jQuery("#to_do_action_reassign").prop("checked", true);' %>
</div>
</div>
@@ -80,13 +80,13 @@ See docs/COPYRIGHT.rdoc for more details.
</div>
<% end %>
<div class="danger-zone--verification">
- <%= styled_button_tag title: l(:button_delete), class: '-highlight' do
+ <%= styled_button_tag title: t(:button_delete), class: '-highlight' do
concat content_tag :i, '', class: 'button--icon icon-delete'
- concat content_tag :span, l(:button_delete), class: 'button--text'
+ concat content_tag :span, t(:button_delete), class: 'button--text'
end %>
- <%= link_to_function l(:button_cancel),
+ <%= link_to_function t(:button_cancel),
"history.back()",
- title: l(:button_cancel),
+ title: t(:button_cancel),
class: 'button -with-icon icon-cancel'%>
</section>
diff --git a/modules/costs/spec/features/destroy_work_package_with_cost_entries_spec.rb b/modules/costs/spec/features/destroy_work_package_with_cost_entries_spec.rb
index acf2a908eca..a2247c21ff3 100644
--- a/modules/costs/spec/features/destroy_work_package_with_cost_entries_spec.rb
+++ b/modules/costs/spec/features/destroy_work_package_with_cost_entries_spec.rb
@@ -28,7 +28,7 @@
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
-describe 'Only see your own rates', type: :feature, js: true do
+describe 'Deleting time entries', type: :feature, js: true do
let(:project) { work_package.project }
let(:user) do
FactoryBot.create :user,
@@ -65,7 +65,7 @@ describe 'Only see your own rates', type: :feature, js: true do
end
it 'allows to move the time entry to a different work package' do
- allow(User).to receive(:current).and_return(user)
+ login_as(user)
work_package
other_work_package
@@ -87,6 +87,9 @@ describe 'Only see your own rates', type: :feature, js: true do
click_button(I18n.t('button_delete'))
+ table = Pages::WorkPackagesTable.new(project)
+ table.expect_current_path
+
other_wp_page = Pages::FullWorkPackage.new(other_work_package)
other_wp_page.visit!