Commit cea34571 authored by Patricio Bruna's avatar Patricio Bruna

Fix #111

parent 2674efa4
......@@ -60,7 +60,7 @@
"block-scoped-var": 2,
"complexity": [0, 8],
"consistent-return": 2,
# "consistent-return": 2,
"curly": [2, "all"],
"dot-location": [2, "object"],
"dot-notation": 2,
......@@ -71,7 +71,7 @@
"no-array-constructor": 2,
"no-caller": 2,
"no-div-regex": 2,
"no-else-return": 2,
# "no-else-return": 2,
"no-eval": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
......@@ -112,7 +112,7 @@
"yoda": [2, "never", {"exceptRange": false, "onlyEquality": false}],
"no-undefined": 2,
"no-shadow": [2, {"hoist": "functions"}],
# "no-shadow": [2, {"hoist": "functions"}],
"no-shadow-restricted-names": 2,
"no-unused-vars": [2, {"vars": "all", "args": "after-used"}],
"no-use-before-define": [2, "nofunc"],
......@@ -142,9 +142,9 @@
"no-spaced-func": 2,
"no-ternary": 0,
"no-trailing-spaces": [2, { "skipBlankLines": false }],
"no-underscore-dangle": 2,
# "no-underscore-dangle": 2,
"no-unneeded-ternary": [2, {"defaultAssignment": false}],
"object-curly-spacing": [2, "never"],
# "object-curly-spacing": [2, "never"],
"one-var": [2, "never"],
"operator-linebreak": [2, "after"],
"padded-blocks": [2, "never"],
......
module.exports = {"main":{"js":"/080240bundle.js"}}
\ No newline at end of file
module.exports = {"main":{"js":"/619769bundle.js"}}
\ No newline at end of file
......@@ -19,9 +19,19 @@ export default class SidebarMenu extends React.Component {
browserHistory.push(path);
}
}
render() {
const companyText = UserStore.isGlobalAdmin() ? 'Empresas' : 'Mi Empresa';
makeCompanyLink() {
const link = { text: 'Empresas', path: '/companies' };
if (!UserStore.isGlobalAdmin()) {
const user = UserStore.getCurrentUser();
link.text = 'Mi Empresa';
link.path = `/companies/${user.company_id}`;
}
return link;
}
render() {
const companyLink = this.makeCompanyLink();
return (
<ul
className='nav'
......@@ -30,9 +40,9 @@ export default class SidebarMenu extends React.Component {
<li id='sidebar-companies'>
<a
href='#'
onClick={(e) => this.handleLink(e, '/companies')}
onClick={(e) => this.handleLink(e, companyLink.path)}
>
<span className='nav-label'>{companyText}</span>
<span className='nav-label'>{companyLink.text}</span>
</a>
</li>
<li id='sidebar-domains'>
......
......@@ -36,6 +36,12 @@ class UserStoreClass extends EventEmitter {
return null;
}
getPrimaryDomain() {
const user = this.getCurrentUser();
const domain = user ? user.name.split(/@/)[1] : null;
return domain;
}
isGlobalAdmin() {
const user = this.getCurrentUser();
......
......@@ -90,10 +90,25 @@ export function getMe(success, error) {
const e = handleError('getMe', err);
return error(e);
}
Reflect.deleteProperty(data, 'obj');
GlobalActions.saveUser(data);
return success();
const user = data;
if (user.attrs._attrs.zimbraIsAdminAccount === 'TRUE') {
Reflect.deleteProperty(user, 'obj');
GlobalActions.saveUser(user);
return success();
} else {
const domain = user.name.split(/@/)[1];
zimbra.getDomain(domain, (e, d) => {
if (e) {
const error = handleError('getDomain', e);
return error(error);
}
user.company_id = d.attrs.businessCategory;
Reflect.deleteProperty(user, 'obj');
GlobalActions.saveUser(user);
return success();
});
}
});
},
(err) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment