Commit 12560b80 authored by Juorder Gonzalez's avatar Juorder Gonzalez

Merge pull request #98 from ZBoxApp/issues_resolved_manager

add store functionality to companies, and show or hide if user is glo…
parents 1cb0e59a 2b316059
module.exports = {"main":{"js":"/263980bundle.js"}}
\ No newline at end of file
module.exports = {"main":{"js":"/699779bundle.js"}}
\ No newline at end of file
......@@ -11,6 +11,8 @@ import Panel from '../panel.jsx';
import CompaniesStore from '../../stores/company_store.jsx';
import ZimbraStore from '../../stores/zimbra_store.jsx';
import UserStore from '../../stores/user_store.jsx';
import DomainStore from '../../stores/domain_store.jsx';
import * as Client from '../../utils/client.jsx';
import * as Utils from '../../utils/utils.jsx';
......@@ -30,6 +32,8 @@ export default class Companies extends React.Component {
this.getDomains = this.getDomains.bind(this);
this.getPlans = this.getPlans.bind(this);
this.gotoCompany = this.gotoCompany.bind(this);
this.isGlobalAdmin = UserStore.isGlobalAdmin();
}
gotoCompany(e, company) {
......@@ -47,6 +51,9 @@ export default class Companies extends React.Component {
return GlobalActions.emitEndLoading();
}
const mydomain = UserStore.getCurrentUser().name.split('@').pop();
if (this.isGlobalAdmin) {
return Client.getAllCompanies().then((data) => {
const domains = data.map((company) => {
return self.getDomains(company);
......@@ -72,6 +79,39 @@ export default class Companies extends React.Component {
});
}
if (DomainStore.getDomains()) {
const domain = DomainStore.getDomainByName(mydomain);
Client.getCompany(domain.attrs.businessCategory, (company) => {
CompaniesStore.setCompanies(company);
}, (error) => {
self.setState({error: {
message: error,
type: messageTypes.ERROR
}});
});
} else {
Client.getDomain(mydomain, (dom) => {
Client.getCompany(dom.attrs.businessCategory, (company) => {
self.setState({
companies: company
});
}, (error) => {
self.setState({error: {
message: error,
type: messageTypes.ERROR
}});
});
}, (error) => {
self.setState({
error,
type: messageTypes.ERROR
});
});
}
return GlobalActions.emitEndLoading();
}
getDomains(company) {
const self = this;
return new Promise((resolve, reject) => {
......
......@@ -7,6 +7,8 @@ import DNSZoneForm from './multiform/dns_form.jsx';
import DomainStore from '../../stores/domain_store.jsx';
import EventStore from '../../stores/event_store.jsx';
import MessageBar from '../message_bar.jsx';
import UserStore from '../../stores/user_store.jsx';
import * as GlobalActions from '../../action_creators/global_actions.jsx';
export default class CreateDomain extends React.Component {
constructor(props) {
......@@ -15,6 +17,7 @@ export default class CreateDomain extends React.Component {
this.getNextStep = this.getNextStep.bind(this);
this.showMessage = this.showMessage.bind(this);
this.isGlobalAdmin = UserStore.isGlobalAdmin();
this.multiform = window.manager_config.multiFormDomain;
let total = 1;
......@@ -30,7 +33,8 @@ export default class CreateDomain extends React.Component {
this.state = {
step: 1,
total
total,
isGlobalAdmin: this.isGlobalAdmin
};
}
......@@ -56,6 +60,7 @@ export default class CreateDomain extends React.Component {
componentDidMount() {
DomainStore.addNextStepListener(this.getNextStep);
EventStore.addMessageListener(this.showMessage);
GlobalActions.emitEndLoading();
}
componentWillUnmount() {
......@@ -73,7 +78,9 @@ export default class CreateDomain extends React.Component {
width: `${width}%`
};
let error = null;
let actions = null;
if (this.state.isGlobalAdmin) {
if (this.state.error) {
error = (
<MessageBar
......@@ -111,7 +118,7 @@ export default class CreateDomain extends React.Component {
}
//onClick: (e) => Utils.handleLink(e, backUrl)
const actions = [
actions = [
{
label: 'Cancelar',
props: {
......@@ -132,8 +139,23 @@ export default class CreateDomain extends React.Component {
</div>
);
}
}
if (!this.state.isGlobalAdmin) {
form = (
<div className='text-center'>
<h4>
{'Lo sentimos pero usted no tiene permiso para crear dominios.'}
</h4>
</div>
);
}
return (
<div>
<div className='content animate-panel'>
<div className='row'>
<div className='col-md-12 panel-with-tabs'>
<Panel
title={'Agregar Dominio'}
classHeader={'forum-box'}
......@@ -143,6 +165,10 @@ export default class CreateDomain extends React.Component {
{progressForm}
{form}
</Panel>
</div>
</div>
</div>
</div>
);
}
}
......
......@@ -33,8 +33,10 @@ export default class SearchView extends React.Component {
loading: true
});
Client.search({
maxResults: window.manager_config.maxResultOnRequestZimbra,
query: `(|(mail=*${query}*)(cn=*${query}*)(sn=*${query}*)(gn=*${query}*)(displayName=*${query}*)(zimbraMailDeliveryAddress=*${query}*)(zimbraDomainName=*${query}*)(uid=*${query}*)(zimbraMailAlias=*${query}*)(uid=*${query}*)(zimbraDomainName=*${query}*)(cn=*${query}*))`,
types: 'accounts,distributionlists,domains'
types: 'accounts,distributionlists,domains',
attrs: 'objectClass'
}, (success) => {
const result = [];
......@@ -55,7 +57,8 @@ export default class SearchView extends React.Component {
return this.setState({
result,
loading: false
loading: false,
notfound: false
});
}, (error) => {
console.log(error); //eslint-disable-line no-console
......@@ -131,6 +134,7 @@ export default class SearchView extends React.Component {
<tr
key={id}
className={'mailbox-row'}
onClick={(e) => Utils.handleLink(e, url)}
>
<td className={'mailbox-name'}>
{tipo}
......@@ -166,7 +170,7 @@ export default class SearchView extends React.Component {
id='index-domains'
cellPadding='1'
cellSpacing='1'
className='table table-condensed table-striped vertical-align index-mailbox-table'
className='table table-condensed table-striped vertical-align index-mailbox-table table-search'
>
<thead>
<tr>
......
.margin-left {
margin-left: 5px;
}
.table-search {
.mailbox-row {
transition: background-color .5s;
&:hover {
background-color: $color-background;
cursor: pointer;
}
}
}
......@@ -18,6 +18,7 @@ class DomainStoreClass extends EventEmitter {
resetThisStore() {
this.current = null;
this.domains = null;
this.distributionListOwners = null;
this.distributionListMembers = null;
this.zoneDNS = null;
......@@ -39,6 +40,24 @@ class DomainStoreClass extends EventEmitter {
return null;
}
getDomainByName(name) {
if (this.domains) {
const data = this.domains.domain;
if (data) {
let length = data.length;
for (;length-- > 0;) {
if (data[length].name === name) {
return data[length];
}
}
}
}
return null;
}
getCurrent() {
return this.current;
}
......
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