2016-04-01 06:52:03 +08:00
|
|
|
import _ from 'underscore';
|
|
|
|
import React from 'react';
|
|
|
|
import {AccountStore} from 'nylas-exports';
|
|
|
|
import ConfigSchemaItem from './config-schema-item';
|
|
|
|
|
|
|
|
|
|
|
|
class SendingSection extends React.Component {
|
|
|
|
|
|
|
|
static displayName = 'SendingSection';
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
config: React.PropTypes.object,
|
|
|
|
configSchema: React.PropTypes.object,
|
|
|
|
}
|
|
|
|
|
|
|
|
_getExtendedSchema(configSchema) {
|
|
|
|
const accounts = AccountStore.accounts();
|
|
|
|
|
2016-05-07 07:23:48 +08:00
|
|
|
let values = accounts.map(acc => acc.id);
|
|
|
|
let labels = accounts.map(acc => acc.me().toString());
|
2016-04-01 06:52:03 +08:00
|
|
|
|
|
|
|
values = ['selected-mailbox'].concat(values);
|
|
|
|
labels = ['Account of selected mailbox'].concat(labels);
|
|
|
|
|
|
|
|
_.extend(configSchema.properties.sending.properties, {
|
|
|
|
defaultAccountIdForSend: {
|
2016-05-07 07:23:48 +08:00
|
|
|
'type': 'string',
|
|
|
|
'title': 'Send new messages from',
|
|
|
|
'default': 'selected-mailbox',
|
|
|
|
'enum': values,
|
|
|
|
'enumLabels': labels,
|
2016-04-01 06:52:03 +08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
return configSchema.properties.sending;
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const sendingSchema = this._getExtendedSchema(this.props.configSchema);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ConfigSchemaItem
|
|
|
|
config={this.props.config}
|
|
|
|
configSchema={sendingSchema}
|
|
|
|
keyName="Sending"
|
2016-05-07 07:23:48 +08:00
|
|
|
keyPath="core.sending"
|
|
|
|
/>
|
2016-04-01 06:52:03 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SendingSection;
|