Skip to content

Commit 27a1886

Browse files
committed
Changes delete conversation button tooltip to 'hide' or 'delete'
1 parent 5d44fa7 commit 27a1886

4 files changed

Lines changed: 39 additions & 12 deletions

File tree

app/controllers/conversation_visibilities_controller.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,13 @@ def destroy
1010
@vis = ConversationVisibility.where(:person_id => current_user.person.id,
1111
:conversation_id => params[:conversation_id]).first
1212
if @vis
13+
participants = @vis.conversation.participants.count
1314
if @vis.destroy
14-
flash[:notice] = I18n.t('conversations.destroy.success')
15+
if participants == 1
16+
flash[:notice] = I18n.t('conversations.destroy.delete_success')
17+
else
18+
flash[:notice] = I18n.t('conversations.destroy.hide_success')
19+
end
1520
end
1621
end
1722
redirect_to conversations_path

app/views/conversations/_show.haml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@
33
-# the COPYRIGHT file.
44
55
.conversation_participants
6-
= link_to(content_tag(:div, nil, :class => 'icons-deletelabel'),
7-
conversation_visibility_path(conversation),
8-
:method => 'delete',
9-
:data => { :confirm => "#{t('.delete')}?" },
10-
:title => t('.delete'),
11-
:class => 'close_conversation')
12-
6+
- if conversation.participants.count > 1
7+
= link_to(content_tag(:div, nil, :class => 'icons-deletelabel'),
8+
conversation_visibility_path(conversation),
9+
:method => 'delete',
10+
:data => { :confirm => "#{t('.hide')}?" },
11+
:title => t('.hide'),
12+
:class => 'close_conversation')
13+
- else
14+
= link_to(content_tag(:div, nil, :class => 'icons-deletelabel'),
15+
conversation_visibility_path(conversation),
16+
:method => 'delete',
17+
:data => { :confirm => "#{t('.delete')}?" },
18+
:title => t('.delete'),
19+
:class => 'close_conversation')
20+
1321
%h3{ :class => direction_for(conversation.subject) }
1422
= conversation.subject
1523

config/locales/diaspora/en.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ en:
358358
show:
359359
reply: "reply"
360360
replying: "Replying..."
361-
delete: "delete and block conversation"
361+
hide: "hide and mute conversation"
362+
delete: "delete conversation"
362363
new:
363364
to: "to"
364365
subject: "subject"
@@ -377,8 +378,8 @@ en:
377378
new_conversation:
378379
fail: "Invalid message"
379380
destroy:
380-
success: "Conversation successfully removed"
381-
381+
delete_success: "Conversation successfully deleted"
382+
hide_success: "Conversation successfully hidden"
382383
date:
383384
formats:
384385
fullmonth_day: "%B %d"

spec/controllers/conversation_visibilities_controller_spec.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,18 @@
3333
delete :destroy, :conversation_id => @conversation.id
3434
}.not_to change(ConversationVisibility, :count)
3535
end
36+
37+
it 'returns "hidden"' do
38+
get :destroy, :conversation_id => @conversation.id
39+
expect(flash.notice).to include("hidden")
40+
end
41+
42+
it 'returns "deleted" when last participant' do
43+
get :destroy, :conversation_id => @conversation.id
44+
sign_out :user
45+
sign_in :user, bob
46+
get :destroy, :conversation_id => @conversation.id
47+
expect(flash.notice).to include("deleted")
48+
end
3649
end
37-
end
50+
end

0 commit comments

Comments
 (0)