From 8e9d7ff73e88034f05addc7c6b92a51b3a0358df Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Mon, 14 Mar 2016 17:04:40 -0700 Subject: [PATCH] fix(signatures): Adds default signature, convert to ES6 --- build/config/eslint.json | 3 +- .../composer-signature/lib/main.es6 | 6 +- .../lib/preferences-signatures.cjsx | 118 ----------------- .../lib/preferences-signatures.jsx | 122 ++++++++++++++++++ .../lib/signature-actions.es6 | 12 ++ .../lib/signature-composer-extension.es6 | 5 +- .../lib/signature-store.es6 | 44 +++++-- .../signature-composer-extension-spec.es6 | 35 ++++- 8 files changed, 207 insertions(+), 138 deletions(-) delete mode 100644 internal_packages/composer-signature/lib/preferences-signatures.cjsx create mode 100644 internal_packages/composer-signature/lib/preferences-signatures.jsx create mode 100644 internal_packages/composer-signature/lib/signature-actions.es6 diff --git a/build/config/eslint.json b/build/config/eslint.json index 0065fbe02..ee23d4ebf 100644 --- a/build/config/eslint.json +++ b/build/config/eslint.json @@ -4,7 +4,8 @@ "NylasEnv": false, "$n": false, "waitsForPromise": false, - "advanceClock": false + "advanceClock": false, + "TEST_ACCOUNT_ID": false }, "env": { "browser": true, diff --git a/internal_packages/composer-signature/lib/main.es6 b/internal_packages/composer-signature/lib/main.es6 index f8b9b876f..5aaa35a7e 100644 --- a/internal_packages/composer-signature/lib/main.es6 +++ b/internal_packages/composer-signature/lib/main.es6 @@ -13,15 +13,13 @@ export function activate() { ExtensionRegistry.Composer.register(SignatureComposerExtension); PreferencesUIStore.registerPreferencesTab(this.preferencesTab); - - this.signatureStore = new SignatureStore(); - this.signatureStore.activate(); + SignatureStore.activate(); } export function deactivate() { ExtensionRegistry.Composer.unregister(SignatureComposerExtension); PreferencesUIStore.unregisterPreferencesTab(this.preferencesTab.sectionId); - this.signatureStore.deactivate(); + SignatureStore.deactivate(); } export function serialize() { diff --git a/internal_packages/composer-signature/lib/preferences-signatures.cjsx b/internal_packages/composer-signature/lib/preferences-signatures.cjsx deleted file mode 100644 index 78f84cda1..000000000 --- a/internal_packages/composer-signature/lib/preferences-signatures.cjsx +++ /dev/null @@ -1,118 +0,0 @@ -React = require 'react' -_ = require 'underscore' -{Contenteditable, RetinaImg, Flexbox} = require 'nylas-component-kit' -{AccountStore, Utils} = require 'nylas-exports' - -class PreferencesSignatures extends React.Component - @displayName: 'PreferencesSignatures' - - constructor: (@props) -> - @_signatureSaveQueue = {} - - # TODO check initally selected account - selectedAccountId = AccountStore.accounts()[0].id - if selectedAccountId - key = @_configKey(selectedAccountId) - initialSig = @props.config.get(key) - else - initialSig = "" - - @state = - editAsHTML: false - accounts: AccountStore.accounts() - currentSignature: initialSig - selectedAccountId: selectedAccountId - - componentDidMount: -> - @usub = AccountStore.listen @_onChange - - componentWillUnmount: -> - @usub() - @_saveSignatureNow(@state.selectedAccountId, @state.currentSignature) - - _saveSignatureNow: (accountId, value) => - key = @_configKey(accountId) - @props.config.set(key, value) - - _saveSignatureSoon: (accountId, value) => - @_signatureSaveQueue[accountId] = value - @_saveSignaturesFromCache() - - __saveSignaturesFromCache: => - for accountId, value of @_signatureSaveQueue - @_saveSignatureNow(accountId, value) - - @_signatureSaveQueue = {} - - _saveSignaturesFromCache: _.debounce(PreferencesSignatures::__saveSignaturesFromCache, 500) - - _onChange: => - @setState @_getStateFromStores() - - _getStateFromStores: -> - accounts = AccountStore.accounts() - selectedAccountId = @state.selectedAccountId - currentSignature = @state.currentSignature - if not @state.selectedAccountId in _.pluck(accounts, "id") - selectedAccountId = null - currentSignature = "" - return {accounts, selectedAccountId, currentSignature} - - _renderAccountPicker: -> - options = @state.accounts.map (account) -> - - - - - _renderEditableSignature: -> - - - _renderHTMLSignature: -> -