Commit 9bd61b6d authored by Juorder Gonzalez's avatar Juorder Gonzalez Committed by GitHub

Merge pull request #264 from ZBoxApp/manager_performance

add resend account of mailbox from admin domain and make visible dele…
parents ee87137b 2384b73a
module.exports = {"main":{"js":"/975145bundle.js"}}
\ No newline at end of file
module.exports = {"main":{"js":"/222915bundle.js"}}
\ No newline at end of file
......@@ -19,6 +19,7 @@ import ToggleModalButton from '../toggle_modal_button.jsx';
import MessageBar from '../message_bar.jsx';
import Promise from 'bluebird';
import MailboxStore from '../../stores/mailbox_store.jsx';
import ResendForm from './reenvios_form.jsx';
import * as Client from '../../utils/client.jsx';
import * as Utils from '../../utils/utils.jsx';
......@@ -343,7 +344,7 @@ export default class MailboxDetails extends React.Component {
/>
);
const tab2 = (
const tabAlias = (
<Panel
title='Casillas'
hasHeader={false}
......@@ -352,12 +353,17 @@ export default class MailboxDetails extends React.Component {
/>
);
const reenvios = (
<ResendForm mailbox={this.state.data}/>
);
panelTabs = (
<PanelTab
tabNames={['Resp Vacaciones', 'Alias']}
tabNames={['Resp Vacaciones', 'Alias', 'Reenvios']}
tabs={{
resp_vacaciones: tabAdmin,
alias: tab2
alias: tabAlias,
reenvios
}}
location={this.props.location}
/>
......
import React from 'react';
import * as Client from '../../utils/client.jsx';
import EventStore from '../../stores/event_store.jsx';
import Constants from '../../utils/constants.jsx';
const messageType = Constants.MessageType;
export default class ResendForm extends React.Component {
constructor(props) {
super(props);
this.onUpdateAttrs = this.onUpdateAttrs.bind(this);
const {attrs} = this.props.mailbox;
this.state = {
zimbraPrefMailForwardingAddress: attrs.zimbraPrefMailForwardingAddress || '',
zimbraMailForwardingAddress: attrs.zimbraMailForwardingAddress || ''
};
}
onUpdateAttrs(e) {
e.preventDefault();
const {mailbox} = this.props;
const attrs = {};
let zimbraMailForwardingAddressTextarea = this.refs.zimbraMailForwardingAddress.value.trim();
let zimbraPrefMailForwardingAddressInput = this.refs.zimbraPrefMailForwardingAddress.value.trim();
let hasError = false;
const pattern = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (zimbraMailForwardingAddressTextarea !== '') {
const arrayMailboxes = zimbraMailForwardingAddressTextarea.split(/\r?\n/gi);
zimbraMailForwardingAddressTextarea = [];
if (arrayMailboxes && arrayMailboxes.length > 0) {
arrayMailboxes.forEach((mailbox) => {
if (mailbox !== '') {
const cleanEmail = mailbox.trim();
const isNotRightEmail = !pattern.test(cleanEmail);
if (isNotRightEmail) {
hasError = true;
} else {
zimbraMailForwardingAddressTextarea.push(mailbox);
}
}
});
}
}
if (zimbraPrefMailForwardingAddressInput !== '') {
if (!pattern.test(zimbraPrefMailForwardingAddressInput)) {
hasError = true;
}
}
if (hasError) {
return EventStore.emitToast({
body: 'Algunas de las cuentas de correo, no tiene el formato de un correo electrónico, verifique por favor.',
title: 'Reenvios',
type: messageType.ERROR.toLowerCase()
});
}
attrs.zimbraMailForwardingAddress = zimbraMailForwardingAddressTextarea;
attrs.zimbraPrefMailForwardingAddress = zimbraPrefMailForwardingAddressInput;
Client.modifyAccount(mailbox.id, attrs, () => {
//MailboxStore.updateMailbox(data.id, mailbox, this.domain_id);
EventStore.emitToast({
title: 'Reenvios',
body: 'Se han modificado los correos de reenvio éxitosamente.',
type: messageType.SUCCESS.toLowerCase()
});
this.setState(attrs);
}, (error) => {
EventStore.emitToast({
title: 'Reenvios',
body: error.message,
type: messageType.ERROR.toLowerCase()
});
});
}
renderMailbox(mailboxes) {
const accounts = mailboxes.constructor.name === 'Array' ? mailboxes.join('\r\n') : mailboxes;
return accounts;
}
render() {
const {zimbraPrefMailForwardingAddress, zimbraMailForwardingAddress} = this.state;
return (
<div>
<div className='row margin-bottom'>
<div className='col-xs-12'>
<blockquote className='custom-blockquote'>
<p>
<i>
{'Direcciones de reenvío especificadas por el usuario'}
</i>
</p>
</blockquote>
</div>
<div className='col-xs-8'>
<input
type='text'
ref='zimbraPrefMailForwardingAddress'
className='form-control'
id='forwardingAddress'
defaultValue={this.renderMailbox(zimbraPrefMailForwardingAddress)}
/>
</div>
</div>
<div className='row margin-bottom'>
<div className='col-xs-12'>
<blockquote className='custom-blockquote'>
<p>
<i>
{'Direcciones de reenvío ocultas para el usuario'}
</i>
</p>
<p>
<i>
<small>
{'Separe las cuentas de correo con una nueva linea (Tecla Enter)'}
</small>
</i>
</p>
</blockquote>
</div>
<div className='col-xs-12'>
<textarea
ref='zimbraMailForwardingAddress'
id='forwardingAddressHidden'
rows='10'
className='form-control noresize'
defaultValue={this.renderMailbox(zimbraMailForwardingAddress)}
>
</textarea>
</div>
</div>
<div className='row'>
<div className='col-xs-12 text-right'>
<button
className='btn btn-info'
onClick={this.onUpdateAttrs}
>
{'Guardar'}
</button>
</div>
</div>
</div>
);
}
}
ResendForm.propTypes = {
mailbox: React.PropTypes.object
};
......@@ -5,6 +5,7 @@ import * as GlobalActions from '../../action_creators/global_actions.jsx';
import * as Utils from '../../utils/utils.jsx';
import ErrorStore from '../../stores/error_store.jsx';
import UserStore from '../../stores/user_store.jsx';
import PageInfo from '../page_info.jsx';
import Panel from '../panel.jsx';
......@@ -39,8 +40,13 @@ export default class MassiveDelete extends React.Component {
}
}
componentWillReceiveProps() {
GlobalActions.emitEndLoading();
}
componentDidMount() {
this.handleCommands();
GlobalActions.emitEndLoading();
}
handleDelete(e) {
......@@ -55,13 +61,13 @@ export default class MassiveDelete extends React.Component {
}
const preMailboxes = consoleText.split(/\r?\n/gi);
const pattern = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
const getAccountByBatch = [];
const deleteAccountByBatch = [];
const wrongEmails = [];
const emailsNotFound = [];
preMailboxes.forEach((email) => {
const pattern = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
const cleanEmail = email.trim();
const condition = pattern.test(cleanEmail) && cleanEmail !== '';
......@@ -246,7 +252,24 @@ export default class MassiveDelete extends React.Component {
}
render() {
const consoleText = (
let buttons = null;
let consoleText = null;
if (!UserStore.isGlobalAdmin()) {
consoleText = (
<div
className='text-center'
key='notAllowed'
>
<h3 className='page-header'>
{'Usted no tiene permisos para ingresar a esta area'}
</h3>
</div>
);
}
if (UserStore.isGlobalAdmin()) {
consoleText = (
<div
className='row'
key='deleteConsole'
......@@ -278,7 +301,7 @@ export default class MassiveDelete extends React.Component {
</div>
);
const buttons = (
buttons = (
<div
key={'btn-actions'}
className='row'
......@@ -293,6 +316,7 @@ export default class MassiveDelete extends React.Component {
</div>
</div>
);
}
return (
<div>
......
......@@ -13,6 +13,7 @@ export default class SidebarMenu extends React.Component {
this.handleLink = this.handleLink.bind(this);
this.openSupportModal = this.openSupportModal.bind(this);
}
handleLink(e, path) {
e.preventDefault();
if (`/${this.props.location.pathname}` !== path) {
......@@ -93,6 +94,17 @@ export default class SidebarMenu extends React.Component {
{'Soporte'}
</a>
</li>
{UserStore.isGlobalAdmin() && (
<li>
<a
className='nav-label'
href='#'
onClick={(e) => this.handleLink(e, '/deleteMassive')}
>
{'Borrado Masivo'}
</a>
</li>
)}
<li>
<Link
to='/logout'
......
......@@ -25,6 +25,7 @@ import EditDistributionList from './components/distribution/edit_distribution_li
import SearchView from './components/search/search.jsx';
import SalesForm from './components/sales/sales.jsx';
import TemplateError from './components/404/404.jsx';
import DeleteMassive from './components/massive/masive_delete.jsx';
import * as Client from './utils/client.jsx';
import * as Utils from './utils/utils.jsx';
......@@ -216,6 +217,11 @@ function renderRootComponent() {
path='sales/:domainId/mailboxes'
component={SalesForm}
/>
<Route
path='/deleteMassive'
component={DeleteMassive}
/>
</Route>
<Route component={NotLoggedIn}>
<IndexRedirect to='login'/>
......
......@@ -1855,6 +1855,14 @@ label {
}
}
.noresize {
resize: none;
}
.margin-bottom {
margin-bottom: 20px;
}
// Error Page
// scss-lint:enable all
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