-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Side-nav CoffeeScript to JavaScript II (#6266)
* convert sidenav Coffeescript to Javascript * fix no unused vars
- Loading branch information
1 parent
4b56894
commit 2ffad6d
Showing
9 changed files
with
527 additions
and
393 deletions.
There are no files selected for viewing
122 changes: 0 additions & 122 deletions
122
packages/rocketchat-ui-sidenav/client/chatRoomItem.coffee
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
/* globals KonchatNotification, menu */ | ||
|
||
Template.chatRoomItem.helpers({ | ||
|
||
alert() { | ||
if ((FlowRouter.getParam('_id') !== this.rid) || !document.hasFocus()) { | ||
return this.alert; | ||
} | ||
}, | ||
|
||
unread() { | ||
if (((FlowRouter.getParam('_id') !== this.rid) || !document.hasFocus()) && (this.unread > 0)) { | ||
return this.unread; | ||
} | ||
}, | ||
|
||
userStatus() { | ||
const userStatus = RocketChat.roomTypes.getUserStatus(this.t, this.rid); | ||
return `status-${userStatus || 'offline'}`; | ||
}, | ||
|
||
name() { | ||
return this.name; | ||
}, | ||
|
||
roomIcon() { | ||
return RocketChat.roomTypes.getIcon(this.t); | ||
}, | ||
|
||
active() { | ||
if (Session.get('openedRoom') === this.rid) { | ||
return 'active'; | ||
} | ||
}, | ||
|
||
canLeave() { | ||
const roomData = Session.get('roomData' + this.rid); | ||
|
||
if (!roomData) { return false; } | ||
|
||
if (((roomData.cl != null) && !roomData.cl) || (roomData.t === 'd')) { | ||
return false; | ||
} else { | ||
return true; | ||
} | ||
}, | ||
|
||
route() { | ||
return RocketChat.roomTypes.getRouteLink(this.t, this); | ||
}, | ||
|
||
archived() { | ||
return this.archived ? 'archived' : undefined; | ||
} | ||
}); | ||
|
||
Template.chatRoomItem.rendered = function() { | ||
if (!(FlowRouter.getParam('_id') && (FlowRouter.getParam('_id') === this.data.rid)) && !this.data.ls && (this.data.alert === true)) { | ||
return KonchatNotification.newRoom(this.data.rid); | ||
} | ||
}; | ||
|
||
Template.chatRoomItem.events({ | ||
|
||
'click .open-room'() { | ||
return menu.close(); | ||
}, | ||
|
||
'click .hide-room'(e) { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
|
||
const { rid } = this; | ||
const { name } = this; | ||
|
||
const warnText = (() => { | ||
switch (this.t) { | ||
case 'c': return 'Hide_Room_Warning'; | ||
case 'p': return 'Hide_Group_Warning'; | ||
case 'd': return 'Hide_Private_Warning'; | ||
} | ||
})(); | ||
|
||
return swal({ | ||
title: t('Are_you_sure'), | ||
text: warnText ? t(warnText, name) : '', | ||
type: 'warning', | ||
showCancelButton: true, | ||
confirmButtonColor: '#DD6B55', | ||
confirmButtonText: t('Yes_hide_it'), | ||
cancelButtonText: t('Cancel'), | ||
closeOnConfirm: true, | ||
html: false | ||
}, function() { | ||
if (['channel', 'group', 'direct'].includes(FlowRouter.getRouteName()) && (Session.get('openedRoom') === rid)) { | ||
FlowRouter.go('home'); | ||
} | ||
|
||
return Meteor.call('hideRoom', rid, function(err) { | ||
if (err) { | ||
return handleError(err); | ||
} else if (rid === Session.get('openedRoom')) { | ||
return Session.delete('openedRoom'); | ||
} | ||
}); | ||
}); | ||
}, | ||
|
||
'click .leave-room'(e) { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
|
||
const { rid } = this; | ||
const { name } = this; | ||
|
||
const warnText = (() => { | ||
switch (false) { | ||
case this.t !== 'c': return 'Leave_Room_Warning'; | ||
case this.t !== 'p': return 'Leave_Group_Warning'; | ||
case this.t !== 'd': return 'Leave_Private_Warning'; | ||
} | ||
})(); | ||
return 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: false, | ||
html: false | ||
}, function(isConfirm) { | ||
if (isConfirm) { | ||
return Meteor.call('leaveRoom', rid, function(err) { | ||
if (err) { | ||
return swal({ | ||
title: t('Warning'), | ||
text: handleError(err, false), | ||
type: 'warning', | ||
html: false | ||
}); | ||
|
||
} else { | ||
swal.close(); | ||
if (['channel', 'group', 'direct'].includes(FlowRouter.getRouteName()) && (Session.get('openedRoom') === rid)) { | ||
FlowRouter.go('home'); | ||
} | ||
|
||
return RoomManager.close(rid); | ||
} | ||
}); | ||
} else { | ||
return swal.close(); | ||
} | ||
}); | ||
} | ||
}); |
95 changes: 0 additions & 95 deletions
95
packages/rocketchat-ui-sidenav/client/listChannelsFlex.coffee
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.