Merge pull request #1799 from RocketChat/add-livechat-as-default

Add livechat package as default
pull/1803/merge
Gabriel Engel 10 years ago
commit e1f9c72ce6
  1. 2
      .meteor/packages
  2. 1
      .meteor/versions
  3. 9
      client/startup/defaultRoomTypes.coffee
  4. 20
      packages/rocketchat-lib/README.md
  5. 26
      packages/rocketchat-lib/client/lib/roomTypes.coffee
  6. 8
      packages/rocketchat-livechat/client/ui.js
  7. 2
      packages/rocketchat-livechat/config.js
  8. 10
      packages/rocketchat-livechat/server/models/LivechatDepartmentAgents.js
  9. 10
      packages/rocketchat-livechat/server/models/Users.js
  10. 16
      packages/rocketchat-ui-sidenav/side-nav/sideNav.coffee
  11. 6
      packages/rocketchat-ui-sidenav/side-nav/sideNav.html
  12. 5
      packages/rocketchat-ui/lib/accountBox.coffee

@ -83,7 +83,7 @@ rocketchat:wordpress
#rocketchat:chatops
#rocketchat:hubot
#rocketchat:irc
#rocketchat:livechat
rocketchat:livechat
konecty:change-case
konecty:delayed-task

@ -138,6 +138,7 @@ rocketchat:highlight@0.0.1
rocketchat:integrations@0.0.1
rocketchat:ldap@0.0.1
rocketchat:lib@0.0.1
rocketchat:livechat@0.0.1
rocketchat:logger@0.0.1
rocketchat:mailer@0.0.1
rocketchat:markdown@0.0.1

@ -14,7 +14,8 @@ RocketChat.roomTypes.add 'c', 10,
RocketChat.TabBar.showGroup 'channel'
link: (sub) ->
return { name: sub.name }
permissions: [ 'view-c-room' ]
condition: ->
return RocketChat.authz.hasAllPermission 'view-c-room'
RocketChat.roomTypes.add 'd', 20,
template: 'directMessages'
@ -28,7 +29,8 @@ RocketChat.roomTypes.add 'd', 20,
RocketChat.TabBar.showGroup 'directmessage'
link: (sub) ->
return { username: sub.name }
permissions: [ 'view-d-room' ]
condition: ->
return RocketChat.authz.hasAllPermission 'view-d-room'
RocketChat.roomTypes.add 'p', 30,
template: 'privateGroups'
@ -42,4 +44,5 @@ RocketChat.roomTypes.add 'p', 30,
RocketChat.TabBar.showGroup 'privategroup'
link: (sub) ->
return { name: sub.name }
permissions: [ 'view-p-room' ]
condition: ->
return RocketChat.authz.hasAllPermission 'view-p-room'

@ -66,7 +66,9 @@ RocketChat.roomTypes.add('l', 5, {
return { name: sub.name }
}
},
permissions: [ 'view-l-room' ]
condition: () => {
return RocketChat.authz.hasAllPermission('view-l-room');
}
});
```
@ -95,19 +97,9 @@ AccountBox.addItem({
name: 'Livechat',
icon: 'icon-chat-empty',
class: 'livechat-manager',
route: {
name: 'livechat-manager',
path: '/livechat-manager',
action(params, queryParams) {
Session.set('openedRoom');
BlazeLayout.render('main', {
center: 'page-container',
pageTitle: 'Live Chat Manager',
pageTemplate: 'livechat-manager'
});
}
},
permissions: ['view-livechat-manager']
condition: () => {
return RocketChat.authz.hasAllPermission('view-livechat-manager');
}
});
```

@ -3,23 +3,11 @@ RocketChat.roomTypes = new class
roomTypes = {}
mainOrder = 1
protectedAction = (item) ->
# if not item.permissions? or RocketChat.authz.hasAtLeastOnePermission item.permissions
return item.route.action
# return ->
# BlazeLayout.render 'main',
# center: 'pageContainer'
# # @TODO text Not_authorized don't get the correct language
# pageTitle: t('Not_authorized')
# pageTemplate: 'notAuthorized'
### Adds a room type to app
@param identifier An identifier to the room type. If a real room, MUST BE the same of `db.rocketchat_room.t` field, if not, can be null
@param order Order number of the type
@param config
template: template name to render on sideNav
permissions: list of permissions to see the sideNav template
icon: icon class
route:
name: route name
@ -45,7 +33,7 @@ RocketChat.roomTypes = new class
if config.route?.path? and config.route?.name? and config.route?.action?
FlowRouter.route config.route.path,
name: config.route.name
action: protectedAction config
action: config.route.action
triggersExit: [roomExit]
###
@ -58,14 +46,16 @@ RocketChat.roomTypes = new class
return FlowRouter.path roomTypes[roomType].route.name, roomTypes[roomType].route.link(subData)
checkCondition = (roomType) ->
return not roomType.condition? or roomType.condition()
getAllTypes = ->
typesPermitted = []
orderedTypes = []
_.sortBy(roomTypesOrder, 'order').forEach (type) ->
if not roomTypes[type.identifier].permissions? or RocketChat.authz.hasAtLeastOnePermission roomTypes[type.identifier].permissions
typesPermitted.push roomTypes[type.identifier]
orderedTypes.push roomTypes[type.identifier]
return typesPermitted
return orderedTypes
getIcon = (roomType) ->
return roomTypes[roomType]?.icon
@ -85,4 +75,6 @@ RocketChat.roomTypes = new class
# setRoute: setRoute
getRouteLink: getRouteLink
checkCondition: checkCondition
add: add

@ -14,7 +14,9 @@ RocketChat.roomTypes.add('l', 5, {
}
}
},
permissions: ['view-l-room']
condition: () => {
return RocketChat.settings.get('Livechat_enabled') && RocketChat.authz.hasAllPermission('view-l-room');
}
});
AccountBox.addItem({
@ -22,5 +24,7 @@ AccountBox.addItem({
icon: 'icon-chat-empty',
href: 'livechat-users',
sideNav: 'livechatFlex',
permissions: ['view-livechat-manager'],
condition: () => {
return RocketChat.settings.get('Livechat_enabled') && RocketChat.authz.hasAllPermission('view-livechat-manager');
},
});

@ -2,6 +2,6 @@ Meteor.startup(function() {
RocketChat.settings.addGroup('Livechat');
RocketChat.settings.add('Livechat_title' , 'Rocket.Chat', { type: 'string', group: 'Livechat', public: true });
RocketChat.settings.add('Livechat_title_color' , '#C1272D', { type: 'string', group: 'Livechat', public: true });
RocketChat.settings.add('Livechat_enabled' , true, { type: 'boolean', group: 'Livechat', public: true });
RocketChat.settings.add('Livechat_enabled' , false, { type: 'boolean', group: 'Livechat', public: true });
RocketChat.settings.add('Livechat_registration_form' , true, { type: 'boolean', group: 'Livechat', public: true, i18nLabel: 'Show_preregistration_form' });
});

@ -64,7 +64,15 @@ class LivechatDepartmentAgents extends RocketChat.models._Base {
var collectionObj = this.model.rawCollection();
var findAndModify = Meteor.wrapAsync(collectionObj.findAndModify, collectionObj);
return findAndModify(query, sort, update);
var agent = findAndModify(query, sort, update);
if (agent) {
return {
agentId: agent.agentId,
username: agent.username
}
} else {
return null;
}
}
}

@ -69,7 +69,15 @@ RocketChat.models.Users.getNextAgent = function() {
}
};
return findAndModify(query, sort, update);
var user = findAndModify(query, sort, update);
if (user) {
return {
agentId: user._id,
username: user.username
}
} else {
return null;
}
};
/**

@ -14,6 +14,15 @@ Template.sideNav.helpers
return true if favoritesEnabled and hasFavoriteRoomOpened
roomType: ->
return RocketChat.roomTypes.getTypes()
canShowRoomType: ->
return RocketChat.roomTypes.checkCondition(@)
templateName: ->
return @template
Template.sideNav.events
'click .close-flex': ->
SideNav.closeFlex()
@ -36,10 +45,3 @@ Template.sideNav.onRendered ->
Meteor.defer ->
menu.updateUnreadBars()
wrapper = $('.rooms-list .wrapper').get(0)
lastLink = $('.rooms-list h3.history-div').get(0)
RocketChat.roomTypes.getTypes().forEach (roomType) ->
if Template[roomType.template]?
Blaze.render Template[roomType.template], wrapper, lastLink

@ -11,6 +11,12 @@
<div class="wrapper">
{{ > unreadRooms }}
{{#each roomType}}
{{#if canShowRoomType}}
{{> Template.dynamic template=templateName }}
{{/if}}
{{/each}}
<h3 class="history-div">
<a href="{{pathFor 'privateHistory'}}">{{_ "History"}}</a>
</h3>

@ -41,9 +41,12 @@
actual.push newItem
items.set actual
checkCondition = (item) ->
return not item.condition? or item.condition()
getItems = ->
return _.filter items.get(), (item) ->
if not item.permissions? or RocketChat.authz.hasAllPermission item.permissions
if checkCondition(item)
return true
addRoute = (newRoute, router = FlowRouter) ->

Loading…
Cancel
Save