From adcaa85f85213ec3c6c85fa6c0b842487d7186d1 Mon Sep 17 00:00:00 2001 From: Rodrigo Nascimento Date: Thu, 3 Dec 2015 19:58:01 -0200 Subject: [PATCH 01/98] Allow packages to register files for theming --- packages/rocketchat-theme/server/server.coffee | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/rocketchat-theme/server/server.coffee b/packages/rocketchat-theme/server/server.coffee index 71f76a317fb2..1cb6a376e9e3 100644 --- a/packages/rocketchat-theme/server/server.coffee +++ b/packages/rocketchat-theme/server/server.coffee @@ -32,6 +32,7 @@ WebAppHashing.calculateClientHash = (manifest, includeFilter, runtimeConfigOverr RocketChat.theme = new class variables: {} + packageCallbacks: [] files: [ 'assets/stylesheets/global/_variables.less' 'assets/stylesheets/utils/_emojione.import.less' @@ -71,6 +72,11 @@ RocketChat.theme = new class content.push Assets.getText file for file in @files + for packageCallback in @packageCallbacks + result = packageCallback() + if _.isString result + content.push result + content = content.join '\n' options = @@ -120,5 +126,8 @@ RocketChat.theme = new class return items.join '\n' + addPackageAsset: (cb) -> + @packageCallbacks.push cb + getCss: -> return RocketChat.settings.get 'css' From 36bb64b00127874ac7630feff72ad23658fd7e09 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Fri, 4 Dec 2015 10:03:50 -0200 Subject: [PATCH 02/98] added livechat flex for more configuration options --- packages/rocketchat-livechat/client/ui.js | 43 +++++++++++------ .../client/views/sideNav/livechatFlex.html | 22 +++++++++ packages/rocketchat-livechat/package.js | 1 + .../side-nav/sideNav.coffee | 3 -- .../side-nav/sideNav.html | 2 +- packages/rocketchat-ui/lib/accountBox.coffee | 46 +++++++++++++------ 6 files changed, 85 insertions(+), 32 deletions(-) create mode 100644 packages/rocketchat-livechat/client/views/sideNav/livechatFlex.html diff --git a/packages/rocketchat-livechat/client/ui.js b/packages/rocketchat-livechat/client/ui.js index 920d8ca5c552..28591b5d046f 100644 --- a/packages/rocketchat-livechat/client/ui.js +++ b/packages/rocketchat-livechat/client/ui.js @@ -17,21 +17,36 @@ RocketChat.roomTypes.add('l', 5, { permissions: ['view-l-room'] }); +// 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: 'pageContainer', +// pageTitle: t('Livechat_Manager'), +// pageTemplate: 'livechatManager' +// }); +// } +// }, +// permissions: ['view-livechat-manager'] +// }); + 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: 'pageContainer', - pageTitle: t('Livechat_Manager'), - pageTemplate: 'livechatManager' - }); - } - }, - permissions: ['view-livechat-manager'] + href: 'livechat-manager', + permissions: ['view-livechat-manager'], +}); + +AccountBox.addRoute({ + name: 'livechat-manager', + path: '/livechat-manager', + sideNav: 'livechatFlex', + pageTitle: t('Livechat_Manager'), + pageTemplate: 'livechatManager' }); diff --git a/packages/rocketchat-livechat/client/views/sideNav/livechatFlex.html b/packages/rocketchat-livechat/client/views/sideNav/livechatFlex.html new file mode 100644 index 000000000000..815010b9fd6f --- /dev/null +++ b/packages/rocketchat-livechat/client/views/sideNav/livechatFlex.html @@ -0,0 +1,22 @@ + diff --git a/packages/rocketchat-livechat/package.js b/packages/rocketchat-livechat/package.js index 50bad731694d..6c2e212dc27b 100644 --- a/packages/rocketchat-livechat/package.js +++ b/packages/rocketchat-livechat/package.js @@ -40,6 +40,7 @@ Package.onUse(function(api) { api.addFiles('client/views/app/livechatManager.js', 'client'); api.addFiles('client/views/sideNav/livechat.html', 'client'); api.addFiles('client/views/sideNav/livechat.js', 'client'); + api.addFiles('client/views/sideNav/livechatFlex.html', 'client'); // methods api.addFiles('server/methods/addAgent.js', 'server'); diff --git a/packages/rocketchat-ui-sidenav/side-nav/sideNav.coffee b/packages/rocketchat-ui-sidenav/side-nav/sideNav.coffee index 227023ce43f8..0b377ed7aab4 100644 --- a/packages/rocketchat-ui-sidenav/side-nav/sideNav.coffee +++ b/packages/rocketchat-ui-sidenav/side-nav/sideNav.coffee @@ -38,9 +38,6 @@ Template.sideNav.helpers registeredMenus: -> return AccountBox.getItems() - itemPath: -> - FlowRouter.path @route.name - Template.sideNav.events 'click .close-flex': -> SideNav.closeFlex() diff --git a/packages/rocketchat-ui-sidenav/side-nav/sideNav.html b/packages/rocketchat-ui-sidenav/side-nav/sideNav.html index 888078c599c8..cb6d536bd679 100644 --- a/packages/rocketchat-ui-sidenav/side-nav/sideNav.html +++ b/packages/rocketchat-ui-sidenav/side-nav/sideNav.html @@ -21,7 +21,7 @@

{{username}}

{{_ "Invisible"}} {{#each registeredMenus}} - {{name}} + {{name}} {{/each}} {{#if showAdminOption }} diff --git a/packages/rocketchat-ui/lib/accountBox.coffee b/packages/rocketchat-ui/lib/accountBox.coffee index ee12f6afec5f..801e5ee9504f 100644 --- a/packages/rocketchat-ui/lib/accountBox.coffee +++ b/packages/rocketchat-ui/lib/accountBox.coffee @@ -28,16 +28,16 @@ self.box = $(".account-box") self.options = self.box.find(".options") - protectedAction = (item) -> - if not item.permissions? or RocketChat.authz.hasAllPermission item.permissions - return item.route.action + # protectedAction = (item) -> + # if not item.permissions? or RocketChat.authz.hasAllPermission 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' + # return -> + # BlazeLayout.render 'main', + # center: 'pageContainer' + # # @TODO text Not_authorized don't get the correct language + # pageTitle: t('Not_authorized') + # pageTemplate: 'notAuthorized' ### # @param newOption: @@ -52,22 +52,40 @@ actual.push newItem items.set actual - if newItem.route?.path? and newItem.route?.name? and newItem.route?.action? - FlowRouter.route newItem.route.path, - name: newItem.route.name - action: protectedAction newItem - getItems = -> return _.filter items.get(), (item) -> if not item.permissions? or RocketChat.authz.hasAllPermission item.permissions return true + addRoute = (newRoute) -> + + # @TODO check for mandatory fields + + FlowRouter.route newRoute.path, + name: newRoute.name + action: -> + + console.log 'accountBox -> action' + + Session.set 'openedRoom' + BlazeLayout.render 'main', + center: 'pageContainer' + pageTitle: newRoute.pageTitle + pageTemplate: newRoute.pageTemplate + + if newRoute.sideNav? + Tracker.afterFlush -> + SideNav.setFlex newRoute.sideNav + SideNav.openFlex() + + setStatus: setStatus toggle: toggle open: open close: close init: init + addRoute: addRoute addItem: addItem getItems: getItems )() From 9901d07994919599218ae8fc4ca0764c2f846433 Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Fri, 4 Dec 2015 17:02:40 -0200 Subject: [PATCH 03/98] moved accountBox HTML to new separated template --- packages/rocketchat-ui-sidenav/package.js | 2 + .../side-nav/accountBox.coffee | 62 +++++++++++++++++++ .../side-nav/accountBox.html | 32 ++++++++++ .../side-nav/sideNav.coffee | 55 ---------------- .../side-nav/sideNav.html | 31 +--------- 5 files changed, 97 insertions(+), 85 deletions(-) create mode 100644 packages/rocketchat-ui-sidenav/side-nav/accountBox.coffee create mode 100644 packages/rocketchat-ui-sidenav/side-nav/accountBox.html diff --git a/packages/rocketchat-ui-sidenav/package.js b/packages/rocketchat-ui-sidenav/package.js index 8c51ef517ef2..f0c3872b1463 100644 --- a/packages/rocketchat-ui-sidenav/package.js +++ b/packages/rocketchat-ui-sidenav/package.js @@ -21,6 +21,7 @@ Package.onUse(function(api) { 'rocketchat:lib@0.0.1' ]); + api.addFiles('side-nav/accountBox.html', 'client'); api.addFiles('side-nav/channels.html', 'client'); api.addFiles('side-nav/chatRoomItem.html', 'client'); api.addFiles('side-nav/createChannelFlex.html', 'client'); @@ -35,6 +36,7 @@ Package.onUse(function(api) { api.addFiles('side-nav/unreadRooms.html', 'client'); api.addFiles('side-nav/userStatus.html', 'client'); + api.addFiles('side-nav/accountBox.coffee', 'client'); api.addFiles('side-nav/channels.coffee', 'client'); api.addFiles('side-nav/chatRoomItem.coffee', 'client'); api.addFiles('side-nav/createChannelFlex.coffee', 'client'); diff --git a/packages/rocketchat-ui-sidenav/side-nav/accountBox.coffee b/packages/rocketchat-ui-sidenav/side-nav/accountBox.coffee new file mode 100644 index 000000000000..b5e470d32ded --- /dev/null +++ b/packages/rocketchat-ui-sidenav/side-nav/accountBox.coffee @@ -0,0 +1,62 @@ +Template.accountBox.helpers + myUserInfo: -> + visualStatus = "online" + username = Meteor.user()?.username + switch Session.get('user_' + username + '_status') + when "away" + visualStatus = t("away") + when "busy" + visualStatus = t("busy") + when "offline" + visualStatus = t("invisible") + return { + name: Session.get('user_' + username + '_name') + status: Session.get('user_' + username + '_status') + visualStatus: visualStatus + _id: Meteor.userId() + username: username + } + + showAdminOption: -> + return RocketChat.authz.hasAtLeastOnePermission( ['view-statistics', 'view-room-administration', 'view-user-administration', 'view-privileged-setting']) + + registeredMenus: -> + return AccountBox.getItems() + +Template.accountBox.events + 'click .options .status': (event) -> + event.preventDefault() + AccountBox.setStatus(event.currentTarget.dataset.status) + + 'click .account-box': (event) -> + AccountBox.toggle() + + 'click #logout': (event) -> + event.preventDefault() + user = Meteor.user() + Meteor.logout -> + FlowRouter.go 'home' + Meteor.call('logoutCleanUp', user) + + 'click #avatar': (event) -> + FlowRouter.go 'changeAvatar' + + 'click #account': (event) -> + SideNav.setFlex "accountFlex" + SideNav.openFlex() + FlowRouter.go 'account' + + 'click #admin': -> + SideNav.setFlex "adminFlex" + SideNav.openFlex() + + 'click .account-link': -> + menu.close() + + 'click .account-box-item': -> + if @sideNav? + SideNav.setFlex @sideNav + SideNav.openFlex() + +Template.accountBox.onRendered -> + AccountBox.init() diff --git a/packages/rocketchat-ui-sidenav/side-nav/accountBox.html b/packages/rocketchat-ui-sidenav/side-nav/accountBox.html new file mode 100644 index 000000000000..2530e8c3c67c --- /dev/null +++ b/packages/rocketchat-ui-sidenav/side-nav/accountBox.html @@ -0,0 +1,32 @@ + diff --git a/packages/rocketchat-ui-sidenav/side-nav/sideNav.coffee b/packages/rocketchat-ui-sidenav/side-nav/sideNav.coffee index 0b377ed7aab4..1f6f5958a07b 100644 --- a/packages/rocketchat-ui-sidenav/side-nav/sideNav.coffee +++ b/packages/rocketchat-ui-sidenav/side-nav/sideNav.coffee @@ -14,30 +14,6 @@ Template.sideNav.helpers return true if favoritesEnabled and hasFavoriteRoomOpened - myUserInfo: -> - visualStatus = "online" - username = Meteor.user()?.username - switch Session.get('user_' + username + '_status') - when "away" - visualStatus = t("away") - when "busy" - visualStatus = t("busy") - when "offline" - visualStatus = t("invisible") - return { - name: Session.get('user_' + username + '_name') - status: Session.get('user_' + username + '_status') - visualStatus: visualStatus - _id: Meteor.userId() - username: username - } - - showAdminOption: -> - return RocketChat.authz.hasAtLeastOnePermission( ['view-statistics', 'view-room-administration', 'view-user-administration', 'view-privileged-setting']) - - registeredMenus: -> - return AccountBox.getItems() - Template.sideNav.events 'click .close-flex': -> SideNav.closeFlex() @@ -54,35 +30,6 @@ Template.sideNav.events 'scroll .rooms-list': -> menu.updateUnreadBars() - 'click .options .status': (event) -> - event.preventDefault() - AccountBox.setStatus(event.currentTarget.dataset.status) - - 'click .account-box': (event) -> - AccountBox.toggle() - - 'click #logout': (event) -> - event.preventDefault() - user = Meteor.user() - Meteor.logout -> - FlowRouter.go 'home' - Meteor.call('logoutCleanUp', user) - - 'click #avatar': (event) -> - FlowRouter.go 'changeAvatar' - - 'click #account': (event) -> - SideNav.setFlex "accountFlex" - SideNav.openFlex() - FlowRouter.go 'account' - - 'click #admin': -> - SideNav.setFlex "adminFlex" - SideNav.openFlex() - - 'click .account-link': -> - menu.close() - Template.sideNav.onRendered -> SideNav.init() menu.init() @@ -90,8 +37,6 @@ Template.sideNav.onRendered -> Meteor.defer -> menu.updateUnreadBars() - AccountBox.init() - wrapper = $('.rooms-list .wrapper').get(0) lastLink = $('.rooms-list h3.history-div').get(0) diff --git a/packages/rocketchat-ui-sidenav/side-nav/sideNav.html b/packages/rocketchat-ui-sidenav/side-nav/sideNav.html index cb6d536bd679..80b0454af9cc 100644 --- a/packages/rocketchat-ui-sidenav/side-nav/sideNav.html +++ b/packages/rocketchat-ui-sidenav/side-nav/sideNav.html @@ -1,36 +1,7 @@