]> source.dussan.org Git - redmine.git/commitdiff
Add edit button to Wiki sidebar (#32629).
authorGo MAEDA <maeda@farend.jp>
Fri, 26 Mar 2021 02:19:02 +0000 (02:19 +0000)
committerGo MAEDA <maeda@farend.jp>
Fri, 26 Mar 2021 02:19:02 +0000 (02:19 +0000)
Patch by Takenori TAKAKI.

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

app/views/wiki/_sidebar.html.erb
test/functional/wiki_controller_test.rb

index 16e8be167c16631fcce66444d8f2e4e5eeef1e8a..e849919c485b23d96fc8226aca0ad7b559fefcbb 100644 (file)
@@ -1,3 +1,11 @@
+<% if User.current.allowed_to?(:edit_wiki_pages, @project) &&
+      (@wiki && @wiki.find_or_new_page('Sidebar').editable_by?(User.current)) %>
+  <div class="contextual">
+    <%= link_to l(:button_edit), edit_project_wiki_page_path(@project, 'sidebar'),
+                :class => 'icon icon-edit' %>
+  </div>
+<% end -%>
+
 <% if @wiki && @wiki.sidebar -%>
   <div class="wiki">
     <%= textilizable @wiki.sidebar.content, :text %>
index 8ae7ad509690d53f3ec2e210b97b51e2162998ce..73b1e3658a5bc75793a3c2de88d1c0290eefa8ad 100644 (file)
@@ -46,6 +46,14 @@ class WikiControllerTest < Redmine::ControllerTest
     assert_select 'a[href=?]', '/projects/ecookbook/wiki/CookBook_documentation.txt'
   end
 
+  def test_edit_sidebar_link
+    Role.anonymous.add_permission! :edit_wiki_pages
+    Role.anonymous.add_permission! :protect_wiki_pages
+    get :show, :params => {:project_id => 'ecookbook'}
+    assert_response :success
+    assert_select 'a[href=?]', '/projects/ecookbook/wiki/sidebar/edit'
+  end
+
   def test_show_page_with_name
     get :show, :params => {:project_id => 1, :id => 'Another_page'}
     assert_response :success