diff --git a/internal_packages/onboarding/lib/account-choose-page.cjsx b/internal_packages/onboarding/lib/account-choose-page.cjsx index a5bc673ac..22876ec2f 100644 --- a/internal_packages/onboarding/lib/account-choose-page.cjsx +++ b/internal_packages/onboarding/lib/account-choose-page.cjsx @@ -18,6 +18,12 @@ class AccountChoosePage extends React.Component componentWillUnmount: -> @_usub?() + componentDidMount: -> + if @props.pageData.provider + providerData = _.findWhere(Providers, name: @props.pageData.provider) + if providerData + @_onChooseProvider(providerData) + render: =>
OnboardingActions.closeWindow() }> diff --git a/spec/nylas-api-spec.coffee b/spec/nylas-api-spec.coffee index 1142dd25b..e71ab5801 100644 --- a/spec/nylas-api-spec.coffee +++ b/spec/nylas-api-spec.coffee @@ -51,14 +51,14 @@ describe "NylasAPI", -> spyOn(Actions, 'postNotification') NylasAPI._handleAuthenticationFailure('/threads/1234', 'token') expect(Actions.postNotification).toHaveBeenCalled() - expect(Actions.postNotification.mostRecentCall.args[0].message.trim()).toEqual("Nylas can no longer authenticate with your mail provider. You will not be able to send or receive mail. Please remove the account and sign in again.") + expect(Actions.postNotification.mostRecentCall.args[0].message.trim()).toEqual("Nylas N1 can no longer authenticate with your mail provider. You will not be able to send or receive mail. Please click here to reconnect your account.") it "should include the email address if possible", -> spyOn(AccountStore, 'tokenForAccountId').andReturn('token') spyOn(Actions, 'postNotification') NylasAPI._handleAuthenticationFailure('/threads/1234', 'token') expect(Actions.postNotification).toHaveBeenCalled() - expect(Actions.postNotification.mostRecentCall.args[0].message.trim()).toEqual("Nylas can no longer authenticate with #{AccountStore.accounts()[0].emailAddress}. You will not be able to send or receive mail. Please remove the account and sign in again.") + expect(Actions.postNotification.mostRecentCall.args[0].message.trim()).toEqual("Nylas N1 can no longer authenticate with #{AccountStore.accounts()[0].emailAddress}. You will not be able to send or receive mail. Please click here to reconnect your account.") describe "handleModelResponse", -> beforeEach -> diff --git a/src/browser/application.coffee b/src/browser/application.coffee index 29aae471a..b3488bbb6 100644 --- a/src/browser/application.coffee +++ b/src/browser/application.coffee @@ -271,7 +271,8 @@ class Application nylasWindow ?= @windowManager.focusedWindow() nylasWindow?.browserWindow.inspectElement(x, y) - @on 'application:add-account', => @windowManager.ensureOnboardingWindow() + @on 'application:add-account', (provider) => + @windowManager.ensureOnboardingWindow({provider}) @on 'application:new-message', => @windowManager.sendToMainWindow('new-message') @on 'application:view-help', => url = 'https://nylas.zendesk.com/hc/en-us/sections/203638587-N1' @@ -389,8 +390,8 @@ class Application win = BrowserWindow.fromWebContents(event.sender) @applicationMenu.update(win, template, keystrokesByCommand) - ipcMain.on 'command', (event, command) => - @emit(command) + ipcMain.on 'command', (event, command, args...) => + @emit(command, args...) ipcMain.on 'window-command', (event, command, args...) -> win = BrowserWindow.fromWebContents(event.sender) diff --git a/src/browser/window-manager.coffee b/src/browser/window-manager.coffee index ac4b3bc57..666cb0cd9 100644 --- a/src/browser/window-manager.coffee +++ b/src/browser/window-manager.coffee @@ -133,7 +133,7 @@ class WindowManager # Returns a new onboarding window # - ensureOnboardingWindow: ({welcome}={}) -> + ensureOnboardingWindow: ({welcome, provider}={}) -> existing = @onboardingWindow() if existing existing.focus() @@ -147,6 +147,7 @@ class WindowManager windowProps: page: 'account-choose' uniqueId: 'onboarding' + pageData: {provider} if welcome options.title = "Welcome to N1" diff --git a/src/flux/nylas-api.coffee b/src/flux/nylas-api.coffee index 1f5256bf1..32c3c40be 100644 --- a/src/flux/nylas-api.coffee +++ b/src/flux/nylas-api.coffee @@ -129,9 +129,9 @@ class NylasAPI if NylasEnv.isMainWindow() Actions.notificationActionTaken.listen ({notification, action}) -> - if action.id is '401:unlink' - Actions.switchPreferencesTab('Accounts') - Actions.openPreferences() + if action.id is '401:reconnect' + ipc = require('electron').ipcRenderer + ipc.send('command', 'application:add-account', action.provider) _onConfigChanged: => prev = {@AppID, @APIRoot, @APITokens} @@ -245,15 +245,16 @@ class NylasAPI type: 'error' tag: '401' sticky: true - message: "Nylas can no longer authenticate with #{email}. You - will not be able to send or receive mail. Please remove the - account and sign in again.", + message: "Nylas N1 can no longer authenticate with #{email}. You + will not be able to send or receive mail. Please click + here to reconnect your account.", icon: 'fa-sign-out' actions: [{ default: true dismisses: true - label: 'Unlink' - id: '401:unlink' + label: 'Reconnect' + provider: account?.provider ? "" + id: '401:reconnect' }] return Promise.resolve()