Skip to content

Commit

Permalink
Add simple delete link (without function)
Browse files Browse the repository at this point in the history
  • Loading branch information
kfischer-okarin committed Nov 21, 2020
1 parent 3c2b6eb commit d6f5a00
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/controllers/wiki_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def show
@content.current_version? &&
Redmine::WikiFormatting.supports_section_edit?

@redirects_to_self = WikiRedirect.where(:redirects_to => @page.title, :redirects_to_wiki_id => @page.wiki_id)
respond_to do |format|
format.html
format.api
Expand Down
4 changes: 3 additions & 1 deletion app/views/wiki/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
<%= link_to_if_authorized(l(:button_lock), {:action => 'protect', :id => @page.title, :protected => 1}, :method => :post, :class => 'icon icon-lock') if !@page.protected? %>
<%= link_to_if_authorized(l(:button_unlock), {:action => 'protect', :id => @page.title, :protected => 0}, :method => :post, :class => 'icon icon-unlock') if @page.protected? %>
<%= link_to_if_authorized(l(:button_rename), {:action => 'rename', :id => @page.title}, :class => 'icon icon-move') %>
<%= link_to('Delete redirect from CookBook_documentation', {} , :class => 'icon icon-link-break') %>
<% @redirects_to_self.map { |redirect| %>
<%= link_to("Delete redirect from #{WikiPage.pretty_title(redirect.title)}", {} , :class => 'icon icon-link-break') %>
<% } %>
<%= link_to_if_authorized(l(:button_delete), {:action => 'destroy', :id => @page.title}, :method => :delete, :data => {:confirm => l(:text_are_you_sure)}, :class => 'icon icon-del') %>
<% else %>
<%= link_to_if_authorized(l(:button_rollback), {:action => 'edit', :id => @page.title, :version => @content.version }, :class => 'icon icon-cancel') %>
Expand Down
7 changes: 6 additions & 1 deletion test/functional/wiki_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,19 @@ def test_show_delete_redirect_links
@request.session[:user_id] = 2

wiki_page = WikiPage.find_by(title: 'CookBook_documentation')
second_title = 'Old_Cookbook'
wiki_page.title = second_title
wiki_page.save

new_title = 'New_Cookbook'
wiki_page.title = new_title
wiki_page.save

get :show, :params => {:project_id => 1, :id => new_title}

assert_select '.drdn-items' do
assert_select 'a.icon-link-break', text: 'Delete redirect from CookBook_documentation'
assert_select 'a.icon-link-break', text: 'Delete redirect from CookBook documentation'
assert_select 'a.icon-link-break', text: 'Delete redirect from Old Cookbook'
end
end

Expand Down

0 comments on commit d6f5a00

Please sign in to comment.