Commit graph

834 commits

Author SHA1 Message Date
Ben Gotow 1d19533fd8 fix(focus): Minor changes to composer focus logic to focus new drafts
Summary:
Remove FocusTrackingRegion—all CommandRegions should be focusable, and nesting the two creates varying behavior based on which is the parent

Calling focus() on an injected / unsafe component should always do /something/. Try the inner React method, inner DOM method, or call on ourselves

Rename contentEditable._focusEditor to "focus" since it intends to replace default focus behavior

In ComposerView, always change focus via setState, never by calling focus() directly. Rather than tracking `_lastFocusedField`, just focus whenever the activeElement isnt within the focusedField. Make body initial focus when draft is pristine...

...(ensures new drafts are focused)

Test Plan: Run tests

Reviewers: evan, juan

Reviewed By: evan, juan

Differential Revision: https://phab.nylas.com/D2406
2016-01-05 11:34:26 -08:00
Colin King 8794686688 Moved all quick actions within flexbox from injectable component
Fixed linting issues

Moved away from ComponentRegistry towards InjectComponentSet children
2016-01-04 20:25:59 -05:00
Ben Gotow 0e41c53efb fix(spec): Participant tests breaking on Travis 2015-12-30 18:09:16 -08:00
Juan Tejada 72ae4228c0 fix(specs): Fix extension test 2015-12-30 18:08:33 -05:00
Evan Morikawa 116d375ff7 feat(extension): async extensions
Summary:
WIP:

This is a quick patch for Drew to make extensions async

We'll need to think through the upgrade/deprecation plan to roll out async
extensions across all of our APIs.

Test Plan: TODO

Reviewers: drew, evan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2392
2015-12-30 18:04:52 -05:00
Juan Tejada 27cc46ed1f feat(column-width): Store column width state in the app
Summary:
- Fixes #833
- Allows column widths to be persisted between sessions

Test Plan: - Manual

Reviewers: evan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2401
2015-12-30 15:18:38 -05:00
Juan Tejada cd1ee3f672 fix(extension-adapter): Update adapter to support all versions of extension api we've used
Summary:
- Rewrites composer extension adpater to support all versions of the
  ComposerExtension API we've ever declared. This will allow old plugins (or
  plugins that haven't been reinstalled after update) to keep functioning
  without breaking N1
- Adds specs

Test Plan: - Unit tests

Reviewers: evan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2399
2015-12-30 15:11:37 -05:00
Drew Regitsky b94122b0b2 fix(signatures-tests): actually fix the signatures tests 2015-12-29 18:31:10 -08:00
Juan Tejada 56258991fb fix(composer-focus): Fix focus behavior + update InjectedComponent props
Summary:
- Fixes bug with Composer focus caused by injected component. The composer body
  was being focused, but the cursor remained at the beginning of the content
  instead of at the end. This was caused because the focus method was being
  called before the content had actually been rendered to the dom.
  - Adds a callback to check when injected comp was actually rendered, and uses
    that to focus the body at the correct time.
  - Updates specs
- Updates behavior of focusing composer body when selecting threads in split
  mode --  resolves #T3444
  - It will focus the body when a thread is selcted via a click
  - It wont focus the body when a thread is selected via arrow keys
  - It will focus the body when a new inline reply is created
  - Updates specs

Test Plan: - Unit tests

Reviewers: evan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2393
2015-12-29 21:28:15 -05:00
Drew Regitsky 93e0ba06d4 fix(signatures-tests): update tests for new signatures code 2015-12-29 18:00:18 -08:00
Drew Regitsky 4528734a33 fix(signatures): Wrap signature in a nylas-n1-signature div to allow easy detection
Summary:
Changes the internal signatures plugin to wrap the signature in a
`<div class="nylas-n1-signature">` block, to make it easier to detect and handle
signatures from within other plugins.

Also:
- Fixes the QuickSchedule plugin to place the scheduling block above the signature.
- Fixes a small syntax error in Translate plugin

Test Plan: manual

Reviewers: evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2383
2015-12-29 15:33:49 -08:00
Ben Gotow a2781be17c lint(mail-rules): Fix build failure from linter issue 2015-12-29 14:41:30 -08:00
Ben Gotow 55b2d588bc fix(uploads): Don't allow dragging of uploading images (Fixes #366) 2015-12-29 14:21:42 -08:00
Ben Gotow 0a5c66f4cc fix(regex): Chop leading '/" off emails if they are wrapped in quotes 2015-12-28 18:39:06 -08:00
Ben Gotow d911793bef fix(mail-rules): Catch and disable mail rules building bad actions 2015-12-28 18:39:06 -08:00
Ben Gotow 6da6bb5246 fix(autoload-images): Watch for images declared in more attrs
Fixes #739
2015-12-28 14:59:07 -08:00
Ben Gotow 608060ed6d fix(search): Switching accounts while searching no longer breaks app
Fixes #850
2015-12-28 12:16:56 -08:00
Juan Tejada 3aa77a3d05 fix(styles): Fix border styles for subject input in composer
- Fixes #825
2015-12-23 22:05:43 -08:00
Ben Gotow 606909e256 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 02:19:32 -05:00
Juan Tejada 5675f24407 fix(prefs): Prevent main key commands from being fired to thread list while on prefs page
Summary:
- When the preferences sheet is open, any commands triggered through key presses were being received by the thread-list, producing unexpected
(and unseen) results
- This is a partial/temporary solution and should go away when we do the Keymap/Commands/Menu refactor

Test Plan: - Manaul

Reviewers: evan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2380
2015-12-22 09:38:56 -08:00
Juan Tejada 69e1ec1442 refactor(tray): Update main file for tray package 2015-12-21 20:18:17 -08:00
Evan Morikawa 2aae075126 refactor(contenteditable): new ContenteditableExtension API
Summary:
This provides a new API for `ContenteditableExtension`s. Instead of
manually manipulating the raw DOM and `Selection` objects, there's a new
`Editor` interface that encapsulates it and provides helper methods.

You can now do:

      editor.select(someNode).createLink("foo").collapseToEnd()

Now raw methods like `execCommand` ONLY show up in the `Editor` interface
as well as most of the raw `Selection` APIs.

There are also more integration tests :)

Another major goal was cleaning up the contenteditable file itself. To
that end:

1. The DOMNormalizer got pulled out into its own extension
1. The TabManager is now its own extension
1. Url wrangling got moved into the FloatingToolbar control
1. There is now the concept of a `ContenteditableService`, which are
tightly-couple blocks of code separated out into logical units. These are
dependent on the core state, innerState, and props and are not full
extensions.
1. `MouseService` now handles all the click event logic
1. `ClipboardService` was modified to the new service architecture

Test Plan: script/grunt run-integration-tests

Reviewers: drew, juan, bengotow

Reviewed By: juan, bengotow

Differential Revision: https://phab.nylas.com/D2367
2015-12-21 19:58:01 -08:00
Juan Tejada de1f8d24d0 update(tray): Show 'Open Inbox' tray menu option and option to disable
tray  on Mac and Linux

- Resolves #673
- Resolves #762
- Resolves #594
2015-12-20 21:32:59 -08:00
Juan Tejada b559d41bed feat(editor-region): Add support to register components as editors
Summary:
- The main purpose of this is to be able to properly register the editor for the markdown plugin (and any other plugins to come)

- Refactors ComposerView and Contenteditable ->
  - Replaces Contenteditable with an InjectedComponent for a new region role:
    "Composer:Editor"
  - Creates a new component called ComposerEditor, which is the one that is
    being registered by default as "Composer:Editor"
  - I used this class to try to standardize the props that should be
    passed to any would be editor Component:
    - Renamed a bunch of the props which (I think) had a bit of
      confusing names
    - Added a bunch of docs for these in the source file, although
      I feel like those docs should live elsewhere, like in the
      ComponentRegion docs.
  - In the process, I ended up pulling some stuff out of ComposerView and
    some stuff out of the Contenteditable, namely:
    - The scrolling logic to ensure that the composer is visible while
      typing was moved outside of the Contenteditable -- this feels more
      like the ComposerEditor's responsibility, especially since the
      Contenteditable is meant to be used in other contexts as well.
    - The ComposerExtensions state; it feels less awkward for me if this
      is inside the ComposerEditor because 1) ComposerView does less
      things, 2) these are actually just being passed to the
      Contenteditable, 3) I feel like other plugins shouldn't need to
      mess around with ComposerExtensions, so we shouldn't pass them to the
      editor. If you register an editor different from our default one,
      any other ComposerExtension callbacks will be disabled, which
      I feel is expected behavior.
  - I think there is still some more refactoring to be done, and I left some TODOS
    here and there, but I think this diff is already big enough and its a minimal
    set of changes to get the markdown editor working in a not so duck
    tapish way.
- New props for InjectedComponent:
  - `requiredMethods`: allows you to define a collection of methods that
    should be implemented by any Component that registers for your
    desired region.
    - It will throw an error if these are not implemented
    - It will automatically pass calls made on the InjectedComponent to these methods
      down to the instance of the actual registered component
    - Would love some comments on this approach and impl
  - `fallback`: allows you to define a default component to use if none were
    registered through the ComponentRegistry
- Misc:
  - Added a new test case for the QuotedHTMLTransformer
- Tests:
  - They were minimally updated so that they don't break, but a big TODO
    is to properly refactor them. I plan to do that in an upcoming
    diff.

Test Plan: - Unit tests

Reviewers: bengotow, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2372
2015-12-18 11:06:44 -08:00
Ben Gotow a14a5212ac feat(transactions): Explicit (and faster) database transactions
Summary:
Until now, we've been hiding transactions beneath the surface. When you call persistModel, you're implicitly creating a transaction.
You could explicitly create them with `atomically`..., but there were several critical problems that are fixed in this diff:

- Calling persistModel / unpersistModel within a transaction could cause the DatabaseStore to trigger. This could result in other parts of the app making queries /during/
  the transaction, potentially before the COMMIT occurred and saved the changes. The new, explicit inTransaction syntax holds all changes until after COMMIT and then triggers.

- Calling atomically and then calling persistModel inside that resulted in us having to check whether a transaction was present and was gross.

- Many parts of the code ran extensive logic inside a promise chained within `atomically`:

  BAD:

```
  DatabaseStore.atomically =>
   DatabaseStore.persistModel(draft) =>
     GoMakeANetworkRequestThatReturnsAPromise
```

OVERWHELMINGLY BETTER:

```
  DatabaseStore.inTransaction (t) =>
     t.persistModel(draft)
  .then =>
    GoMakeANetworkRequestThatReturnsAPromise
```

Having explicit transactions also puts us on equal footing with Sequelize and other ORMs. Note that you /have/ to call DatabaseStore.inTransaction (t) =>. There is no other way to access the methods that let you alter the database. :-)

Other changes:
- This diff removes Message.labels and the Message-Labels table. We weren't using Message-level labels anywhere, and the table could grow very large.
- This diff changes the page size during initial sync from 250 => 200 in an effort to make transactions a bit faster.

Test Plan: Run tests!

Reviewers: juan, evan

Reviewed By: juan, evan

Differential Revision: https://phab.nylas.com/D2353
2015-12-17 11:46:05 -08:00
Ben Gotow a6c69e2775 Merge pull request #728 from francois2metz/fix_unused_require
Harmonize require and remove unused ones.
2015-12-17 11:19:09 -08:00
François de Metz 6108798c53 Harmonize require and remove unused ones. 2015-12-17 00:02:37 +01:00
Ben Gotow 71bd96f978 fix(aliases): Add note that aliases may need to be setup 2015-12-15 11:56:31 -08:00
Juan Tejada f575a2dabc feat(theme-selector): Add theme selector to preferences page
Summary:
- Adds a couple of helper methods to theme manager and updates how
a theme package is enabled to be consistent with how we actually want to
activate themes.
- Adds small select component to choose a theme or install a new one.

Test Plan: - Manual

Reviewers: evan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2355
2015-12-15 10:29:58 -08:00
Juan Tejada 26a907c0c0 feat(default-alias): Add functionality to select a default alias
Summary:
- Update Account model witha default alias and DraftStore methods that
construct new messages to use default alias if available.
- Update AccountDetails page and add selector to select default alias

Test Plan: - Unit tests

Reviewers: evan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2352
2015-12-14 14:35:26 -08:00
Juan Tejada 9d77d6399d fix(editable-list): Prevent empty selection on esc pressed + other fixes
- When prop specified to not allow empty selection it should also
prevent it from being cleared when pressing Esc while focusing the list
- Adds a default value to the edit item input
- Updates specs
- Updates styles
2015-12-14 14:29:45 -08:00
Juan Tejada aed9b77207 fix(shortcuts): Fix shortcut handlers for marking as read/unread
- Marking as read/unread did not work when selecting multiple threads
2015-12-14 10:32:45 -08:00
Juan Tejada aa57ab3990 fix(specs): Fix composer view specs for enabling 'from:' field based on
aliases

- Will show from field when account has at least one alias
2015-12-14 00:02:30 -08:00
Ben Gotow d8b3a09599 fix(aliases): Show from field whenever aliases are present 2015-12-11 19:04:14 -08:00
Ben Gotow 9eb3eb3297 fix(thread-list): Initialize database view immediately 2015-12-11 12:15:38 -08:00
Juan Tejada 80be13410d fix(docs): Update ES6 comment docs to use JSDoc 3 format 2015-12-11 10:01:13 -08:00
Juan Tejada 14f0086a02 fix(warning): Remove implicit return from event handler to remove react
warning
2015-12-10 18:19:13 -08:00
Juan Tejada 0073f21982 add(docs):Add documentation to EditableList and PreferencesAccountDetails 2015-12-10 17:59:16 -08:00
Juan Tejada 281e458d39 feat(account-prefs): Adds new page for Account in preferences
Summary:
Adds the new Account preferences page. This consists of two major React components,
PreferencesAccountList and PreferencesAccountDetails, both of which use EditableList.

I added a bunch of fixes and updated the API for EditableList, plus a bit of
refactoring for PreferencesAccount component, and a bunch of CSS so its a big diff.

The detailed changelog:

Updates to EditableList:
  - Fix bug updating selection state when arrows pressed to move selection
  - Add new props:
    - allowEmptySelection to allow the list to have no selection
    - createInputProps to pass aditional props to the createInput
  - Add scroll region for list items
  - Update styles and refactor render methods

Other Updates:
- Updates Account model to hold aliases and a label
  - Adds getter for label to default to email
- Update accountswitcher to display label, update styles and spec

- Refactor PreferencesAccounts component:
  - Splits it into smaller components,
  - Removes unused code
- Splits preferences styelsheets into smaller separate stylesheet for
  account page. Adds some updates and fixes (scroll-region padding)
- Update AccountStore to be able to perform updates on an account.
- Adds new Action to update account, and an action to remove account to
  be consistent with Action usage
- Adds components for Account list and Aliases list using EditableList

Test Plan: - All specs pass, but need to write new tests!

Reviewers: bengotow, evan

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2332
2015-12-10 15:27:29 -08:00
Evan Morikawa 35e45032ec fix(composer): focus on text box when clicking in margins 2015-12-10 16:52:18 -05:00
Ben Gotow 03908fbd84 fix(drafts): Refresh view when draft becomes message 2015-12-10 13:43:27 -08:00
sriraman 74a7e09066 Update README.md
Fix typo
2015-12-10 12:33:10 +05:30
Evan Morikawa 9af40833ac fix(spellcheck): check for existing languages and add tests 2015-12-09 18:10:55 -05:00
Ben Gotow e19a69c4a8 polish(quick-schedule): Use calendar icon in the composer 2015-12-09 10:55:08 -08:00
Ben Gotow ee78090ce0 fix(composer): Change state.focusedField when clicking fields—see details
Clicking participant fields to type in them did not cause state.focusedField to change, because no onFocus events were bound to the ParticipantTextFields. Since setState was not called, the focus would appear to change but revert as soon as you touched state.

This diff also renames `onChangeEnabledFields` to `onAdjustEnabledFields` making it more clear that unlike the other handlers, it does not take a new value, it takes a set of changes. I also noticed that we /always/ focus fields when showing them, so I removed the separate focus param from it and made it adjust focus at the composer-view level only.

I also consolidated everywhere that touches `state.focusedField` so that we can keep the `_lastFocusedParticipantField` value in sync with it more easily.
2015-12-08 17:44:20 -08:00
Ben Gotow 1bc10cfbbb fix(auth): Log first account creation 2015-12-08 17:05:59 -08:00
Ben Gotow 5ca28a340d fix(auth): Track authentication success / failure rates by provider 2015-12-08 16:39:38 -08:00
Juan Tejada 17e9cc8921 fix(composer): Pass in onFocus handler correctly to contenteditable
- Fixes issue where body lost focus when typing and focus switched to to
field
- Now passes the onFocus handler as part of a `ContenteditableExtension`
2015-12-08 11:00:33 -08:00
Ben Gotow 0af5fea3dc fix(expand-all): Fixes for dark theme, don't show expand when one message 2015-12-07 18:01:06 -08:00
Ben Gotow 30c58e90a6 feat(observables): Implementation of observables to replace some stores
Summary:
Add concept of "final" to Query, clean up internals

Tiny bug fixes

RxJs Observables!

WIP

Test Plan: Run tests

Reviewers: evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D2319
2015-12-07 16:52:46 -08:00