Commit 052536de authored by Patricio Bruna's avatar Patricio Bruna

Merge pull request #119 from ZBoxApp/fix_count_accounts_for_domain

Fix count accounts for domain admin
parents a1df6d64 5330aafa
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
"consistent-this": [2, "self"], "consistent-this": [2, "self"],
"func-names": 2, "func-names": 2,
"func-style": [2, "declaration"], "func-style": [2, "declaration"],
"indent": [2, 4, {"SwitchCase": 0}], # "indent": [2, 2, {"SwitchCase": 0}],
"jsx-quotes": [2, "prefer-single"], "jsx-quotes": [2, "prefer-single"],
"key-spacing": [2, {"beforeColon": false, "afterColon": true}], "key-spacing": [2, {"beforeColon": false, "afterColon": true}],
"linebreak-style": 2, "linebreak-style": 2,
......
{
"esnext": true,
"node": true,
"predef": [ "describe", "it", "beforeEach", "afterEach" ]
}
module.exports = {"main":{"js":"/950474bundle.js"}}
\ No newline at end of file
...@@ -8,6 +8,7 @@ import ZimbraAdminApi from 'zimbra-admin-api-js'; ...@@ -8,6 +8,7 @@ import ZimbraAdminApi from 'zimbra-admin-api-js';
import Powerdns from 'js-powerdns'; import Powerdns from 'js-powerdns';
import ZimbraStore from '../stores/zimbra_store.jsx'; import ZimbraStore from '../stores/zimbra_store.jsx';
import ResetStores from '../stores/reset_stores.jsx'; import ResetStores from '../stores/reset_stores.jsx';
import UserStore from '../stores/user_store.jsx';
import * as GlobalActions from '../action_creators/global_actions.jsx'; import * as GlobalActions from '../action_creators/global_actions.jsx';
import * as Utils from './utils.jsx'; import * as Utils from './utils.jsx';
...@@ -588,24 +589,33 @@ export function batchRequest(requestArray, success, error) { ...@@ -588,24 +589,33 @@ export function batchRequest(requestArray, success, error) {
export function getAllCos(success, error) { export function getAllCos(success, error) {
initZimbra().then( initZimbra().then(
(zimbra) => { (zimbra) => {
if (UserStore.isGlobalAdmin()) {
zimbra.getAllCos((err, data) => { zimbra.getAllCos((err, data) => {
if (err) { if (err) {
const e = handleError('getAllCos', err); return error(handleError('getAllCos', err));
if (error) {
return error(e);
}
} }
return success(data); return success(data);
}); });
} else {
const batchRequests = [];
const planNames = Object.keys(window.manager_config.plans);
planNames.forEach((plan) => {
batchRequests.push(zimbra.getCos(plan));
});
zimbra.makeBatchRequest(batchRequests, (err, data) => {
if (err) {
return error(handleError('getCos', err));
}
const allCos = data.GetCosResponse.map((r) => {
return r.cos[0];
});
return success(allCos);
});
}
}, },
(err) => { (err) => {
const e = handleError('getAllCos', err); return error(handleError('getAllCos', err));
if (error) {
return error(e);
}
return null;
} }
); );
} }
......
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