Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show confirmation before leaving room #2113

Merged
merged 2 commits into from
Feb 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@
"Has_more" : "Has more",
"Have_your_own_chat" : "Have your own web chat. Developed with Meteor.com, the Rocket.Chat is a great solution for developers looking forward to build and evolve their own chat platform.",
"Hide_room" : "Hide room",
"Hide_Room_Warning": "Are you sure you want to hide the room \"%s\"?",
"Hide_Group_Warning": "Are you sure you want to hide the group \"%s\"?",
"Hide_Private_Warning": "Are you sure you want to hide the discussion with \"%s\"?",
"History" : "History",
"hours" : "hours",
"Incorrect_Password" : "Incorrect Password",
Expand Down Expand Up @@ -256,6 +259,9 @@
"Layout_Sidenav_Footer" : "Side Navigation Footer",
"Layout_Sidenav_Footer_description" : "Footer size is 260 x 70px",
"Layout_Terms_of_Service" : "Terms of Service",
"Leave_Room_Warning": "Are you sure you want to leave the room \"%s\"?",
"Leave_Group_Warning": "Are you sure you want to leave the group \"%s\"?",
"Leave_Private_Warning": "Are you sure you want to leave the discussion with \"%s\"?",
"LDAP" : "LDAP",
"LDAP_Bind_Search" : "Bind Search",
"LDAP_Bind_Search_Description" : "A piece of JSON that governs bind and connection info and is of the form {\"filter\": \"(&(objectCategory=person)(objectclass=user)(memberOf=CN=ROCKET_ACCESS,CN=Users,DC=domain,DC=com)(sAMAccountName=#{username}))\", \"scope\": \"sub\", \"userDN\": \"[email protected]\", \"password\": \"urpass\"}",
Expand Down Expand Up @@ -611,6 +617,8 @@
"Yes" : "Yes",
"Yes_clear_all" : "Yes, clear all!",
"Yes_delete_it" : "Yes, delete it!",
"Yes_hide_it": "Yes, hide it!",
"Yes_leave_it": "Yes, leave it!",
"Yes_mute_user" : "Yes, mute user!",
"Yes_remove_user" : "Yes, remove user!",
"you_are_in_preview_mode_of" : "You are in preview mode of channel #<strong>__room_name__</strong>",
Expand Down
58 changes: 48 additions & 10 deletions packages/rocketchat-ui-sidenav/side-nav/chatRoomItem.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,56 @@ Template.chatRoomItem.events
e.stopPropagation()
e.preventDefault()

if FlowRouter.getRouteName() in ['channel', 'group', 'direct'] and Session.get('openedRoom') is this.rid
FlowRouter.go 'home'

Meteor.call 'hideRoom', this.rid
rid = this.rid
name = this.name

warnText = switch
when this.t == 'c' then 'Hide_Room_Warning'
when this.t == 'p' then 'Hide_Group_Warning'
when this.t == 'd' then 'Hide_Private_Warning'


swal {
title: t('Are_you_sure')
text: t(warnText, name)
type: 'warning'
showCancelButton: true
confirmButtonColor: '#DD6B55'
confirmButtonText: t('Yes_hide_it')
cancelButtonText: t('Cancel')
closeOnConfirm: true
html: false
}, ->
if FlowRouter.getRouteName() in ['channel', 'group', 'direct'] and Session.get('openedRoom') is rid
FlowRouter.go 'home'

Meteor.call 'hideRoom', rid

'click .leave-room': (e) ->
e.stopPropagation()
e.preventDefault()

if FlowRouter.getRouteName() in ['channel', 'group', 'direct'] and Session.get('openedRoom') is this.rid
FlowRouter.go 'home'

RoomManager.close this.rid

Meteor.call 'leaveRoom', this.rid
rid = this.rid
name = this.name

warnText = switch
when this.t == 'c' then 'Leave_Room_Warning'
when this.t == 'p' then 'Leave_Group_Warning'
when this.t == 'd' then 'Leave_Private_Warning'
swal {
title: t('Are_you_sure')
text: t(warnText, name)
type: 'warning'
showCancelButton: true
confirmButtonColor: '#DD6B55'
confirmButtonText: t('Yes_leave_it')
cancelButtonText: t('Cancel')
closeOnConfirm: true
html: false
}, ->
if FlowRouter.getRouteName() in ['channel', 'group', 'direct'] and Session.get('openedRoom') is rid
FlowRouter.go 'home'

RoomManager.close rid

Meteor.call 'leaveRoom', rid
14 changes: 8 additions & 6 deletions packages/rocketchat-ui-sidenav/side-nav/chatRoomItem.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
{{/if}}
<i class="{{roomIcon}} {{userStatus}}" aria-label=""></i>
<span class='name'>{{name}}</span>
<span class='opt'>
<i class="icon-eye-off hide-room" title="{{_ "Hide_room"}}" aria-label="{{_ "Hide_room"}}"></i>
{{#if canLeave}}
<i class="octicon octicon-sign-out leave-room" title="{{_ "Leave_room"}}" aria-label="{{_ "Leave_room"}}"></i>
{{/if}}
</span>
{{#if $not unread}}
<span class='opt'>
<i class="icon-eye-off hide-room" title="{{_ "Hide_room"}}" aria-label="{{_ "Hide_room"}}"></i>
{{#if canLeave}}
<i class="octicon octicon-sign-out leave-room" title="{{_ "Leave_room"}}" aria-label="{{_ "Leave_room"}}"></i>
{{/if}}
</span>
{{/if}}
</a>
</li>
</template>