]> source.dussan.org Git - redmine.git/commitdiff
"Copy link" feature for issues list (#34932).
authorGo MAEDA <maeda@farend.jp>
Tue, 13 Apr 2021 07:20:47 +0000 (07:20 +0000)
committerGo MAEDA <maeda@farend.jp>
Tue, 13 Apr 2021 07:20:47 +0000 (07:20 +0000)
Patch by Mizuki ISHIKAWA.

git-svn-id: http://svn.redmine.org/redmine/trunk@20939 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/routes_helper.rb
app/views/context_menus/issues.html.erb
test/functional/context_menus_controller_test.rb
test/helpers/routes_helper_test.rb

index 8a799b17b159fbaa94e5c24f45f4d3182bca81c7..94c68c0a46524843d5264da6a0dbae3554695834 100644 (file)
@@ -29,6 +29,14 @@ module RoutesHelper
     end
   end
 
+  def _project_issues_url(project, *args)
+    if project
+      project_issues_url(project, *args)
+    else
+      issues_url(*args)
+    end
+  end
+
   def _project_news_path(project, *args)
     if project
       project_news_index_path(project, *args)
index 3a8e19cdd6e1e2169060b0b3a7d34eb3f0fa82c9..cf402f1205f7de68d75f87186cae9bd2803607e6 100644 (file)
   <li><%= context_menu_link l(:button_add_subtask), url_for_new_subtask(@issue),
           :class => 'icon icon-add' %></li>
   <% end %>
+  <li><%= copy_object_url_link(issue_url(@issue)) %></li>
   <li><%= context_menu_link l(:button_copy), project_copy_issue_path(@project, @issue),
           :class => 'icon icon-copy', :disabled => !@can[:copy] %></li>
 <% else %>
+  <li><%= copy_object_url_link(_project_issues_url(@project, set_filter: 1, status_id: '*', issue_id: @issue_ids.join(','))) %></li>
   <li><%= context_menu_link l(:button_copy), bulk_edit_issues_path(:ids => @issue_ids, :copy => '1'),
                           :class => 'icon icon-copy', :disabled => !@can[:copy] %></li>
 <% end %>
index a2fbd3f78553bdbaf44d622fac1d50f7c4a8ae44..5178ca61b2accb3801d357d3769dfb6ae5e86e6f 100644 (file)
@@ -47,6 +47,7 @@ class ContextMenusControllerTest < Redmine::ControllerTest
     assert_response :success
 
     assert_select 'a.icon-edit[href=?]', '/issues/1/edit', :text => 'Edit'
+    assert_select 'a.icon-copy-link[data-clipboard-text=?]', 'http://test.host/issues/1', :text => 'Copy link'
     assert_select 'a.icon-copy[href=?]', '/projects/ecookbook/issues/1/copy', :text => 'Copy'
     assert_select 'a.icon-del[href=?]', '/issues?ids%5B%5D=1', :text => 'Delete'
 
@@ -89,6 +90,8 @@ class ContextMenusControllerTest < Redmine::ControllerTest
     ids = [1, 2].map {|i| "ids%5B%5D=#{i}"}.join('&')
 
     assert_select 'a.icon-edit[href=?]', "/issues/bulk_edit?#{ids}", :text => 'Edit'
+    # issue_id: '1,2', set_filter: 1, status_id: '*'
+    assert_select 'a.icon-copy-link[data-clipboard-text=?]', "http://test.host/projects/ecookbook/issues?issue_id=1%2C2&set_filter=1&status_id=%2A", :text => 'Copy link'
     assert_select 'a.icon-copy[href=?]', "/issues/bulk_edit?copy=1&#{ids}", :text => 'Copy'
     assert_select 'a.icon-del[href=?]', "/issues?#{ids}", :text => 'Delete'
 
@@ -110,6 +113,8 @@ class ContextMenusControllerTest < Redmine::ControllerTest
     ids = [1, 2, 6].map {|i| "ids%5B%5D=#{i}"}.join('&')
 
     assert_select 'a.icon-edit[href=?]', "/issues/bulk_edit?#{ids}", :text => 'Edit'
+    # issue_id: '1,2,6', set_filter: 1, status_id: '*'
+    assert_select 'a.icon-copy-link[data-clipboard-text=?]', "http://test.host/issues?issue_id=1%2C2%2C6&set_filter=1&status_id=%2A", :text => 'Copy link'
     assert_select 'a.icon-del[href=?]', "/issues?#{ids}", :text => 'Delete'
 
     assert_select 'a[href=?]', "/issues/bulk_update?#{ids}&issue%5Bstatus_id%5D=5", :text => 'Closed'
index 653c8f2e3763552d0f04ad369a72d1c0cb3d7849..9f1ac7280b424bbff45983d8109075ca339296c1 100644 (file)
@@ -40,4 +40,11 @@ class RoutesHelperTest < Redmine::HelperTest
     assert_equal '/issues/1/time_entries/new', _new_time_entry_path(nil, Issue.find(1))
     assert_equal '/time_entries/new', _new_time_entry_path(nil, nil)
   end
+
+  def test_project_issues_url
+    assert_equal 'http://test.host/projects/ecookbook/issues', _project_issues_url(Project.find(1))
+    assert_equal 'http://test.host/issues', _project_issues_url(nil)
+    assert_equal 'http://test.host/projects/ecookbook/issues?set_filter=1', _project_issues_url(Project.find(1), set_filter: 1)
+    assert_equal 'http://test.host/issues?set_filter=1', _project_issues_url(nil, set_filter: 1)
+  end
 end