The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Rocket.Chat/packages/rocketchat-ui/client/lib/accountBox.js

94 lines
1.8 KiB

import _ from 'underscore';
this.AccountBox = (function() {
let status = 0;
const items = new ReactiveVar([]);
function setStatus(status) {
return Meteor.call('UserPresence:setDefaultStatus', status);
}
function open() {
if (SideNav.flexStatus()) {
SideNav.closeFlex();
return;
}
status = 1;
}
function close() {
status = 0;
}
function toggle() {
if (status) {
return close();
} else {
return open();
}
}
function openFlex() {
status = 0;
}
/*
* @param newOption:
* name: Button label
* icon: Button icon
* class: Class of the item
* permissions: Which permissions a user should have (all of them) to see this item
*/
function addItem(newItem) {
return Tracker.nonreactive(function() {
const actual = items.get();
actual.push(newItem);
return items.set(actual);
});
}
function checkCondition(item) {
return (item.condition == null) || item.condition();
}
function getItems() {
return _.filter(items.get(), function(item) {
if (checkCondition(item)) {
return true;
}
});
}
function addRoute(newRoute, router) {
if (router == null) {
router = FlowRouter;
}
const routeConfig = {
center: 'pageContainer',
pageTemplate: newRoute.pageTemplate
};
if (newRoute.i18nPageTitle != null) {
routeConfig.i18nPageTitle = newRoute.i18nPageTitle;
}
if (newRoute.pageTitle != null) {
routeConfig.pageTitle = newRoute.pageTitle;
}
return router.route(newRoute.path, {
name: newRoute.name,
action() {
Session.set('openedRoom');
return BlazeLayout.render('main', routeConfig);
},
triggersEnter: [
function() {
if (newRoute.sideNav != null) {
SideNav.setFlex(newRoute.sideNav);
return SideNav.openFlex();
}
}
]
});
}
return {
setStatus,
toggle,
open,
close,
openFlex,
addRoute,
addItem,
getItems
};
}());