Summary:
Adds two new functions in NylasAPI to allow auth and unauth of
plugin backends. The `authPlugin` function should be called within
plugins before taking any action that requires offline account access
from the plugin's backend server. The `unauthPlugin` function will be
used by N1 internally to revoke offline account access for plugins.
Test Plan: manual for now
Reviewers: bengotow, evan, juan
Reviewed By: evan, juan
Differential Revision: https://phab.nylas.com/D2440
Summary:
This is a refactor of the toolbar in the contenteditable. Goals of this
are:
1. Allow developers to add new buttons to the toolbar
2. Allow developers to add other component types to the floating toolbar (like the LinkEditor)
3. Make the toolbar declaratively defined instead of imperatively set
4. Separate out logical units of the toolbar into individual sections
5. Clean up `innerState` of the Contenteditable
The Floating Toolbar used to be an imperative mess. Doing simple
functionality additions required re-understanding a very complex set of
logic to hide and show the toolbar and delecately manage focus states.
There also was no real capacity for any developer to extend the toolbar.
It also used to be completely outside of our `atomicEdit` system and was a
legacy of having raw access to contenteditable controls (since it all used
to be directly inside of the contenteditable)
Finally it was difficult to declaratively define things because the
`innerState` of the Contenteditable was inconsistently used and its
lifecycle not properly thought through. This fixed several lifecycle bugs
with that.
Along the way several of the DOMUtils methods were also subtly not
functional and fixed.
The Toolbar is now broken apart into separate logical units.
There are now `ContentedtiableExtension`s that declare what should be
displayed in the toolbar at any given moment.
They define a method called `toolbarComponentData`. This is a pure
function of the state of the `Contenteditable`. If selection and content
conditions look correct, then that method will return a component to
render. This is how we declaratively define whether a toolbar should be
visible or not instead of manually setting `hide` & `show` bits.
There is also a `toolbarButtons` method that declaratively defines buttons
that can go in the new `<ToolbarButtons>` component.
The `ToolbarButtonManager` takes care of extracting these and binding the
correct editorAPI context.
Now the `<LinkEditor>` is a separate component from the `<ToolbarButtons>`
instead of being smashed together.
The `LinkManager` takes care of declaring when the `LinkEditor` should be
displayed and has properly bound methods to update the `contenteditable`
through the standard `atomicEdit` interface.
If users have additional contenteditable popup plugins (like displaying
extra info on a name or some content in the composer), they can now
implement the `toolbarComponentData` api and declaratively define that
information based on the state of the contenteditable.
Test Plan: TODO
Reviewers: bengotow, juan
Reviewed By: bengotow
Differential Revision: https://phab.nylas.com/D2442
- Account switcher can now switch between all accounts and each account
- Updates FocusedPerspectiveStore and Actions.focusDefaultMailboxPerspectiveForAccounts
to focus a perspective for accountIds instead of for a single account,
and updates methods
- Adds helpers to CategoryStore and MailboxPerspective
- Updates key commands to allow switch to unified inbox
- Refactors some of the old code which was 💩
- Makes SidbarSection a factory for different types of items for the
OutlineView
- Decided not to create a OutlineViewItem.Model class since the only
purpose it would serve would be to validate getters for props or for
documentation, both of which are already done via React.PropTypes.
- Adds sections when looking at unified inbox and integrates with new
mailbox perspecitve interface
- Updates OutlineViewItem a bit + styles
- Tests missing
- Creates OutlineView generic component and uses that instead of custom
code
- Refactors AccountSidebarStore:
- Split the generation of the state tree into smaller functions
- Adds different types of account sidebar items and sections, which contain
logic and props necessary to be rendered as OutlineViewItems, and
removes that logic from the store
- Removes WorkspaceStore.SidebarItem and removes the ability to register
new sidebar items. If people want to add something to the sidebar they
can just register a Component via the component registry and use the
OutlineView component
- Removes the DraftListSidebarItem, which was basically duplicated code
for an item but with a different data source. This is now handled
generically by the account sidebar by rendering OutlineViewItems with
different props and handlers
- Clean ups here and there:
- TODO
- Add AccountSwitcher
- Revisit calculation and generation of the state tree. Should the
parent store contain and update the entire state all the time.
Should separate items inside the tree have their own data sources?
- This would avoid having the AccountSidebarStore listen to a bunch of
different other stores, and the specific logic wold be contained
inside each item type.
Summary:
1. **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.
1. **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.
1. **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.
1. **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: bengotow, juan, drew
Differential Revision: https://phab.nylas.com/D2419
Remove cloudState and N1-Send-Later