Commit bce5a14e authored by Patricio Bruna's avatar Patricio Bruna

Merge pull request #123 from ZBoxApp/fix_my_company_link

Fix #111
parents 2674efa4 cea34571
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
"block-scoped-var": 2, "block-scoped-var": 2,
"complexity": [0, 8], "complexity": [0, 8],
"consistent-return": 2, # "consistent-return": 2,
"curly": [2, "all"], "curly": [2, "all"],
"dot-location": [2, "object"], "dot-location": [2, "object"],
"dot-notation": 2, "dot-notation": 2,
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
"no-array-constructor": 2, "no-array-constructor": 2,
"no-caller": 2, "no-caller": 2,
"no-div-regex": 2, "no-div-regex": 2,
"no-else-return": 2, # "no-else-return": 2,
"no-eval": 2, "no-eval": 2,
"no-extend-native": 2, "no-extend-native": 2,
"no-extra-bind": 2, "no-extra-bind": 2,
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
"yoda": [2, "never", {"exceptRange": false, "onlyEquality": false}], "yoda": [2, "never", {"exceptRange": false, "onlyEquality": false}],
"no-undefined": 2, "no-undefined": 2,
"no-shadow": [2, {"hoist": "functions"}], # "no-shadow": [2, {"hoist": "functions"}],
"no-shadow-restricted-names": 2, "no-shadow-restricted-names": 2,
"no-unused-vars": [2, {"vars": "all", "args": "after-used"}], "no-unused-vars": [2, {"vars": "all", "args": "after-used"}],
"no-use-before-define": [2, "nofunc"], "no-use-before-define": [2, "nofunc"],
...@@ -142,9 +142,9 @@ ...@@ -142,9 +142,9 @@
"no-spaced-func": 2, "no-spaced-func": 2,
"no-ternary": 0, "no-ternary": 0,
"no-trailing-spaces": [2, { "skipBlankLines": false }], "no-trailing-spaces": [2, { "skipBlankLines": false }],
"no-underscore-dangle": 2, # "no-underscore-dangle": 2,
"no-unneeded-ternary": [2, {"defaultAssignment": false}], "no-unneeded-ternary": [2, {"defaultAssignment": false}],
"object-curly-spacing": [2, "never"], # "object-curly-spacing": [2, "never"],
"one-var": [2, "never"], "one-var": [2, "never"],
"operator-linebreak": [2, "after"], "operator-linebreak": [2, "after"],
"padded-blocks": [2, "never"], "padded-blocks": [2, "never"],
......
module.exports = {"main":{"js":"/080240bundle.js"}} module.exports = {"main":{"js":"/619769bundle.js"}}
\ No newline at end of file \ No newline at end of file
...@@ -19,9 +19,19 @@ export default class SidebarMenu extends React.Component { ...@@ -19,9 +19,19 @@ export default class SidebarMenu extends React.Component {
browserHistory.push(path); 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 ( return (
<ul <ul
className='nav' className='nav'
...@@ -30,9 +40,9 @@ export default class SidebarMenu extends React.Component { ...@@ -30,9 +40,9 @@ export default class SidebarMenu extends React.Component {
<li id='sidebar-companies'> <li id='sidebar-companies'>
<a <a
href='#' 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> </a>
</li> </li>
<li id='sidebar-domains'> <li id='sidebar-domains'>
......
...@@ -36,6 +36,12 @@ class UserStoreClass extends EventEmitter { ...@@ -36,6 +36,12 @@ class UserStoreClass extends EventEmitter {
return null; return null;
} }
getPrimaryDomain() {
const user = this.getCurrentUser();
const domain = user ? user.name.split(/@/)[1] : null;
return domain;
}
isGlobalAdmin() { isGlobalAdmin() {
const user = this.getCurrentUser(); const user = this.getCurrentUser();
......
...@@ -90,10 +90,25 @@ export function getMe(success, error) { ...@@ -90,10 +90,25 @@ export function getMe(success, error) {
const e = handleError('getMe', err); const e = handleError('getMe', err);
return error(e); return error(e);
} }
const user = data;
Reflect.deleteProperty(data, 'obj');
GlobalActions.saveUser(data); if (user.attrs._attrs.zimbraIsAdminAccount === 'TRUE') {
return success(); 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) => { (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