Mailspring/internal_packages
Evan Morikawa 8b895068e2 feat(metadata): add cloudState that sync with Metadata service
Summary:
Now all plugins get passed a `cloudState` object to their `activate`
method.

The `cloudState` object is an instance of `CloudState` and acts like a
key-value store backed by the yet-to-be-implemented Metadata service.

It has a `get`, `getAll`, and `observe` method. The `observe` method
returns a new `Rx.Observable` for the given key.

It has a `set`, and `unset` method that doesn't actually mutate state, but
rather dispatches new `Task`s to Create, Update, and Delete `Metadata`
objects.

The whole object is backed by `Metadata` objects. Since these are standard
Database Objects that will appear on the delta sync streaming API, any
updates from the server will automatically propagate down to listening
views via the `Rx.Observable`s.

Additionally, there is a new `N1-Send-Later` stub plugin that demonstrates
how to use the `cloudState`.

There are few other minor refactors included in this diff:

**Generic CUD Tasks**: There is now a generic `CreateModelTask`,
`UpdateModelTask`, and `DestroyModelTask`. These can either be used as-is
or trivially overridden to easily update simple objects. Hopefully all of
the boilerplate rollback, error handling, and undo logic won't have to be
re-duplicated on every task. There are also tests for these tasks. We use
them to perform mutating actions on `Metadata` objects.

**New `boundProps` for `InjectedComponents`**: When making the
`N1-Send_later` plugin, I realized that the injected component needed to
get the `cloudState` somehow. Traditionally components would require
Stores and load data that way, but these are setup at `require`-time. Now
that `cloudState` only is available on `activate` we needed a way to get
the data to the components. There's now the concept of `boundProps` which
will be props added to the Component when it gets injected. This required
changing the return signature of `findComponentMatching`, which got
renamed to `findComponentDataMatching`.

**Failing on Promise Rejects**: Turns out that if a Promise rejected
due to an error or `Promise.reject` we were ignoring it and letting tests
pass. Now, tests will Fail if any unhandled promise rejects. This
uncovered a variety of errors throughout the test suite that had to be
fixed. The most significant one was during the `theme-manager` tests when
all packages (and their stores with async DB requests) was loaded. Long
after the `theme-manager` specs finished, those DB requests were
(somtimes) silently failing.

**Globally stub `DatabaseStore._query`**: All tests shouldn't actually
make queries on the database. Furthremore, the `inTransaction` block
doesn't resolve at all unless `_query` is stubbed. Instead of manually
remembering to do this in every test that touches the DB, it's now mocked
in `spec_helper`. This broke a handful of tests that needed to be manually
fixed.

**ESLint Fixes**: Some minor fixes to the linter config to prevent
yelling about minor ES6 things and ensuring we have the correct parser.

Test Plan: new tests

Reviewers: drew, bengotow, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D2419
2016-02-02 15:28:06 -05:00
..
account-sidebar fix(sidebar):Correctly update sidebar by listening to FocusedPerspective 2016-02-02 10:59:44 -08:00
attachments fix(uploads): Consolidate logic, use Promisify, path.join 2016-01-29 14:45:53 -08:00
category-picker fix(message-list): Spec fixes, all stubs need accountId 2016-01-28 11:14:04 -08:00
composer 💄(composer): Account dropdown aliases styling 2016-02-02 11:33:08 -08:00
composer-signature refactor(rip-current-account): Rips out AccountStore.current 2016-01-08 14:22:13 -08:00
composer-spellcheck fix(electron): Update api usage to require('electron') 2016-01-29 14:24:33 -08:00
composer-templates feat(metadata): add cloudState that sync with Metadata service 2016-02-02 15:28:06 -05:00
composer-translate fix(examples): examples => packages, move away from installing them 2016-01-07 14:56:34 -08:00
events Merge branch 'master' into unified-inbox 2016-01-12 08:20:55 -08:00
feedback rm(intercom): Point feedback to support.nylas, shrink button 2016-01-20 11:26:14 -08:00
github-contact-card fix(examples): examples => packages, move away from installing them 2016-01-07 14:56:34 -08:00
message-autoload-images fix(config): observe fires immediately, causing re-renders 2016-01-29 00:31:10 -08:00
message-list fix(contact): Converge on displayName(), don't show account label in ThreadList. Fixes #1157 2016-02-01 19:12:06 -08:00
message-view-on-github fix(examples): examples => packages, move away from installing them 2016-01-07 14:56:34 -08:00
mode-switch fix(license): GPLv3 => GPL-3.0 2015-12-07 10:50:47 -08:00
notification-mailto fix(license): GPLv3 => GPL-3.0 2015-12-07 10:50:47 -08:00
notification-update-available fix(license): GPLv3 => GPL-3.0 2015-12-07 10:50:47 -08:00
notifications Merge branch 'master' into unified-inbox 2016-01-12 08:20:55 -08:00
onboarding feat(startup): new option to launch on system start 2016-01-28 12:02:08 -08:00
personal-level-indicators fix(indicators): Remove duplicate description key 2016-01-12 10:28:34 -08:00
phishing-detection fix(phishing): set the package name to the correct value 2016-01-14 22:43:40 -05:00
plugins fix(packages): Default icon for third-party packages 2016-01-12 13:52:01 -08:00
preferences fix(lint): Fix new eslint rule introduced with babel-eslint upgrade. 2016-02-01 20:07:36 -08:00
print refactor(rip-current-account): Rips out AccountStore.current 2016-01-08 14:22:13 -08:00
quick-schedule fix(electron): Update api usage to require('electron') 2016-01-29 14:24:33 -08:00
screenshot-mode feat(screenshot-mode): Minor fix to unmount method 2016-01-29 16:59:51 -08:00
search-bar Fix for search bar issue with threads not appearing 2016-01-25 13:47:41 -08:00
send-and-archive fix(send-and-archive): Was disabling signatures due to name collision 2016-02-01 17:33:18 -08:00
sidebar-fullcontact feat(transactions): Explicit (and faster) database transactions 2015-12-17 11:46:05 -08:00
system-tray fix(tray): Order of operations causing exception 2016-02-02 12:24:59 -08:00
thread-list 💄(thread-list): Correct top border on selected threads. Fixes #1189 2016-02-02 11:12:28 -08:00
ui-dark feat(theme-selector): Add theme selector to preferences page 2015-12-15 10:29:58 -08:00
ui-light feat(theme-selector): Add theme selector to preferences page 2015-12-15 10:29:58 -08:00
undo-redo TaskFactory now returns N tasks for performing standard actions, undo uses arrays 2016-01-21 13:46:04 -08:00
unread-notifications Revert "fix(sidebar): Correctly update sidebar when a notif is selected" 2016-02-02 10:58:24 -08:00
worker-sync fix(activity): "Long Polling" => "Delta Streaming" because we don't really poll. 2016-01-29 16:06:33 -08:00
worker-ui fix(activity): "Long Polling" => "Delta Streaming" because we don't really poll. 2016-01-29 16:06:33 -08:00