Commit a967c17e authored by Juorder Gonzalez's avatar Juorder Gonzalez Committed by GitHub

Merge pull request #207 from ZBoxApp/issues_resolved_manager

create a domain, that check if the returned length og DL is equal to …
parents c1cdb9c4 d51b3e9f
module.exports = {"main":{"js":"/430297bundle.js"}} module.exports = {"main":{"js":"/012994bundle.js"}}
\ No newline at end of file \ No newline at end of file
...@@ -35,7 +35,7 @@ export default class AddDistributionListModal extends React.Component { ...@@ -35,7 +35,7 @@ export default class AddDistributionListModal extends React.Component {
if (this.isStoreEnabled) { if (this.isStoreEnabled) {
DomainStore.addDistributionList(data); DomainStore.addDistributionList(data);
} else { } else {
DomainStore.emitDistributionListsChange(); DomainStore.emitDistributionListsChange('add');
} }
GlobalActions.emitEndLoading(); GlobalActions.emitEndLoading();
this.props.onHide(); this.props.onHide();
......
...@@ -39,19 +39,45 @@ export default class DomainDistributionList extends React.Component { ...@@ -39,19 +39,45 @@ export default class DomainDistributionList extends React.Component {
return lists; return lists;
} }
getLists() { getLists(label) {
const tag = label || null;
const domain = this.props.domain; const domain = this.props.domain;
let condition;
setTimeout(() => { setTimeout(() => {
domain.getAllDistributionLists( domain.getAllDistributionLists(
(err, lists) => { (err, lists) => {
if (this.isStoreEnabled) { if (this.isStoreEnabled) {
DomainStore.setDistibutionLists(domain, lists); DomainStore.setDistibutionLists(domain, lists);
} }
if (tag === 'add') {
condition = this.state.length + 1;
}
if (tag === 'remove') {
condition = this.state.length - 1;
}
this.listscache = lists; this.listscache = lists;
this.setState({lists}); const length = lists.length;
if (!tag) {
return this.setState({
lists,
length
});
}
if (condition === lists.length) {
return this.setState({
lists,
length
});
} else {
this.getLists(tag);
}
} }
); );
}, 1000); }, 100);
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
const page = parseInt(nextProps.location.query.page, 10) || 1; const page = parseInt(nextProps.location.query.page, 10) || 1;
...@@ -60,10 +86,10 @@ export default class DomainDistributionList extends React.Component { ...@@ -60,10 +86,10 @@ export default class DomainDistributionList extends React.Component {
offset: ((page - 1) * defaultLimit) offset: ((page - 1) * defaultLimit)
}); });
} }
onListsChange() { onListsChange(label) {
const lists = this.isStoreEnabled ? DomainStore.getDistributionLists(this.props.domain) : null; const lists = this.isStoreEnabled ? DomainStore.getDistributionLists(this.props.domain) : null;
if (!lists) { if (!lists) {
return this.getLists(); return this.getLists(label);
} }
return this.setState({lists}); return this.setState({lists});
...@@ -93,7 +119,7 @@ export default class DomainDistributionList extends React.Component { ...@@ -93,7 +119,7 @@ export default class DomainDistributionList extends React.Component {
if (this.isStoreEnabled) { if (this.isStoreEnabled) {
DomainStore.removeDistributionList(list.id); DomainStore.removeDistributionList(list.id);
} else { } else {
DomainStore.emitDistributionListsChange(); DomainStore.emitDistributionListsChange('remove');
} }
return sweetAlert(response); return sweetAlert(response);
......
...@@ -116,7 +116,7 @@ export default class BlockGeneralInfoMailbox extends React.Component { ...@@ -116,7 +116,7 @@ export default class BlockGeneralInfoMailbox extends React.Component {
<Button <Button
btnAttrs={{ btnAttrs={{
onClick: (e) => { onClick: (e) => {
this.handleWatchDomain(e, `domains/${this.state.domainData.id}`, this.props.location); this.handleWatchDomain(e, `/domains/${this.state.domainData.id}`, this.props.location);
} }
}} }}
> >
......
...@@ -317,8 +317,8 @@ class DomainStoreClass extends EventEmitter { ...@@ -317,8 +317,8 @@ class DomainStoreClass extends EventEmitter {
this.removeListener(eventTypes.ZONE_DNS_CHANGE_EVENT, zone); this.removeListener(eventTypes.ZONE_DNS_CHANGE_EVENT, zone);
} }
emitDistributionListsChange() { emitDistributionListsChange(params) {
this.emit(eventTypes.DOMAIN_DLS_CHANGE_EVENT); this.emit(eventTypes.DOMAIN_DLS_CHANGE_EVENT, params);
} }
addDistributionListsChangeListener(callback) { addDistributionListsChangeListener(callback) {
......
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