2015-12-10 04:35:40 +08:00
|
|
|
import React, {Component, PropTypes} from 'react';
|
|
|
|
import {RetinaImg, Flexbox, EditableList} from 'nylas-component-kit';
|
|
|
|
|
|
|
|
class PreferencesAccountList extends Component {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
accounts: PropTypes.array,
|
feat(mail-rules): Per-account mail rules filter incoming, existing mail
Summary:
Originally, this was going to be a totally independent package, but
I wasn't able to isolate the functionality and get it tied in to
the delta-stream consumption. Here's how it currently works:
- The preferences package has a new tab which allows you to edit
mail filters. Filters are saved in a new core store, and a new
stock component (ScenarioEditor) renders the editor. The editor
takes a set of templates that define a value space, and outputs
a valid set of values.
- A new MailFilterProcessor takes messages and creates tasks to
apply the actions from the MailFiltersStore.
- The worker-sync package now uses the MailFilterProcessor to
apply filters /before/ it calls didPassivelyReceiveNewModels,
so filtrs are applied before any notifications are created.
- A new task, ReprocessMailFiltersTask allows you to run filters
on all of your existing mail. It leverages the existing TaskQueue
architecture to: a) resume where it left off if you quit midway,
b) be queryable (for status) from all windows and c) cancelable.
The TaskQueue is a bit strange because it runs performLocal and
performRemote very differently, and I had to use `performRemote`.
(todo refactor soon.)
This diff also changes the EditableList a bit to behave like a
controlled component and render focused / unfocused states.
Test Plan: Run tests, only for actual filter processing atm.
Reviewers: juan, evan
Reviewed By: evan
Differential Revision: https://phab.nylas.com/D2379
2015-12-23 15:19:32 +08:00
|
|
|
selected: PropTypes.object,
|
2015-12-10 04:35:40 +08:00
|
|
|
onAddAccount: PropTypes.func.isRequired,
|
2016-02-02 06:06:54 +08:00
|
|
|
onReorderAccount: PropTypes.func.isRequired,
|
feat(mail-rules): Per-account mail rules filter incoming, existing mail
Summary:
Originally, this was going to be a totally independent package, but
I wasn't able to isolate the functionality and get it tied in to
the delta-stream consumption. Here's how it currently works:
- The preferences package has a new tab which allows you to edit
mail filters. Filters are saved in a new core store, and a new
stock component (ScenarioEditor) renders the editor. The editor
takes a set of templates that define a value space, and outputs
a valid set of values.
- A new MailFilterProcessor takes messages and creates tasks to
apply the actions from the MailFiltersStore.
- The worker-sync package now uses the MailFilterProcessor to
apply filters /before/ it calls didPassivelyReceiveNewModels,
so filtrs are applied before any notifications are created.
- A new task, ReprocessMailFiltersTask allows you to run filters
on all of your existing mail. It leverages the existing TaskQueue
architecture to: a) resume where it left off if you quit midway,
b) be queryable (for status) from all windows and c) cancelable.
The TaskQueue is a bit strange because it runs performLocal and
performRemote very differently, and I had to use `performRemote`.
(todo refactor soon.)
This diff also changes the EditableList a bit to behave like a
controlled component and render focused / unfocused states.
Test Plan: Run tests, only for actual filter processing atm.
Reviewers: juan, evan
Reviewed By: evan
Differential Revision: https://phab.nylas.com/D2379
2015-12-23 15:19:32 +08:00
|
|
|
onSelectAccount: PropTypes.func.isRequired,
|
2015-12-10 04:35:40 +08:00
|
|
|
onRemoveAccount: PropTypes.func.isRequired,
|
2016-02-02 12:06:29 +08:00
|
|
|
};
|
2015-12-10 04:35:40 +08:00
|
|
|
|
|
|
|
_renderAccount = (account)=> {
|
|
|
|
const label = account.label;
|
|
|
|
const accountSub = `${account.name || 'No name provided'} <${account.emailAddress}>`;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className="account"
|
|
|
|
key={account.id} >
|
|
|
|
<Flexbox direction="row" style={{alignItems: 'middle'}}>
|
|
|
|
<div style={{textAlign: 'center'}}>
|
|
|
|
<RetinaImg
|
|
|
|
name={`ic-settings-account-${account.provider}.png`}
|
|
|
|
fallback="ic-settings-account-imap.png"
|
|
|
|
mode={RetinaImg.Mode.ContentPreserve} />
|
|
|
|
</div>
|
|
|
|
<div style={{flex: 1, marginLeft: 10}}>
|
|
|
|
<div className="account-name">{label}</div>
|
|
|
|
<div className="account-subtext">{accountSub} ({account.displayProvider()})</div>
|
|
|
|
</div>
|
|
|
|
</Flexbox>
|
|
|
|
</div>
|
|
|
|
);
|
2016-02-02 12:06:29 +08:00
|
|
|
};
|
2015-12-10 04:35:40 +08:00
|
|
|
|
|
|
|
render() {
|
|
|
|
if (!this.props.accounts) {
|
|
|
|
return <div className="account-list"></div>;
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<div className="account-list">
|
|
|
|
<EditableList
|
feat(mail-rules): Per-account mail rules filter incoming, existing mail
Summary:
Originally, this was going to be a totally independent package, but
I wasn't able to isolate the functionality and get it tied in to
the delta-stream consumption. Here's how it currently works:
- The preferences package has a new tab which allows you to edit
mail filters. Filters are saved in a new core store, and a new
stock component (ScenarioEditor) renders the editor. The editor
takes a set of templates that define a value space, and outputs
a valid set of values.
- A new MailFilterProcessor takes messages and creates tasks to
apply the actions from the MailFiltersStore.
- The worker-sync package now uses the MailFilterProcessor to
apply filters /before/ it calls didPassivelyReceiveNewModels,
so filtrs are applied before any notifications are created.
- A new task, ReprocessMailFiltersTask allows you to run filters
on all of your existing mail. It leverages the existing TaskQueue
architecture to: a) resume where it left off if you quit midway,
b) be queryable (for status) from all windows and c) cancelable.
The TaskQueue is a bit strange because it runs performLocal and
performRemote very differently, and I had to use `performRemote`.
(todo refactor soon.)
This diff also changes the EditableList a bit to behave like a
controlled component and render focused / unfocused states.
Test Plan: Run tests, only for actual filter processing atm.
Reviewers: juan, evan
Reviewed By: evan
Differential Revision: https://phab.nylas.com/D2379
2015-12-23 15:19:32 +08:00
|
|
|
items={this.props.accounts}
|
|
|
|
itemContent={this._renderAccount}
|
|
|
|
selected={this.props.selected}
|
2016-02-02 06:06:54 +08:00
|
|
|
onReorderItem={this.props.onReorderAccount}
|
2015-12-10 04:35:40 +08:00
|
|
|
onCreateItem={this.props.onAddAccount}
|
feat(mail-rules): Per-account mail rules filter incoming, existing mail
Summary:
Originally, this was going to be a totally independent package, but
I wasn't able to isolate the functionality and get it tied in to
the delta-stream consumption. Here's how it currently works:
- The preferences package has a new tab which allows you to edit
mail filters. Filters are saved in a new core store, and a new
stock component (ScenarioEditor) renders the editor. The editor
takes a set of templates that define a value space, and outputs
a valid set of values.
- A new MailFilterProcessor takes messages and creates tasks to
apply the actions from the MailFiltersStore.
- The worker-sync package now uses the MailFilterProcessor to
apply filters /before/ it calls didPassivelyReceiveNewModels,
so filtrs are applied before any notifications are created.
- A new task, ReprocessMailFiltersTask allows you to run filters
on all of your existing mail. It leverages the existing TaskQueue
architecture to: a) resume where it left off if you quit midway,
b) be queryable (for status) from all windows and c) cancelable.
The TaskQueue is a bit strange because it runs performLocal and
performRemote very differently, and I had to use `performRemote`.
(todo refactor soon.)
This diff also changes the EditableList a bit to behave like a
controlled component and render focused / unfocused states.
Test Plan: Run tests, only for actual filter processing atm.
Reviewers: juan, evan
Reviewed By: evan
Differential Revision: https://phab.nylas.com/D2379
2015-12-23 15:19:32 +08:00
|
|
|
onSelectItem={this.props.onSelectAccount}
|
|
|
|
onDeleteItem={this.props.onRemoveAccount} />
|
2015-12-10 04:35:40 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
export default PreferencesAccountList;
|