From 130fee41f80ba6b7ac5d91513b8a72a7575e9c9c Mon Sep 17 00:00:00 2001 From: Justin Wilaby Date: Thu, 7 Mar 2019 14:14:34 -0800 Subject: [PATCH 1/4] Fixes #1283 - opening a bot that has moved should show a message --- packages/app/main/src/commands/botCommands.ts | 9 ++----- .../app/main/src/commands/electronCommands.ts | 15 ++++++----- packages/app/main/src/main.ts | 25 ++++++++----------- 3 files changed, 19 insertions(+), 30 deletions(-) diff --git a/packages/app/main/src/commands/botCommands.ts b/packages/app/main/src/commands/botCommands.ts index 884a981b0..538295995 100644 --- a/packages/app/main/src/commands/botCommands.ts +++ b/packages/app/main/src/commands/botCommands.ts @@ -32,7 +32,7 @@ // import * as path from 'path'; - +import { dialog } from 'electron'; import { BotInfo, getBotDisplayName, SharedConstants } from '@bfemulator/app-shared'; import { BotConfigWithPath, CommandRegistryImpl, mergeEndpoints, uniqueId } from '@bfemulator/sdk-shared'; import { BotConfigurationBase } from 'botframework-config/lib'; @@ -132,12 +132,7 @@ export function registerCommands(commandRegistry: CommandRegistryImpl) { try { bot = await loadBotWithRetry(botPath, secret); } catch (e) { - const errMessage = `Failed to open the bot with error: ${e.message}`; - await Electron.dialog.showMessageBox(mainWindow.browserWindow, { - type: 'error', - message: errMessage, - }); - throw new Error(errMessage); + await dialog.showErrorBox('Failed to open the bot', e.message); } if (!bot) { // user couldn't provide correct secret, abort diff --git a/packages/app/main/src/commands/electronCommands.ts b/packages/app/main/src/commands/electronCommands.ts index 75ea7503d..37dd75c87 100644 --- a/packages/app/main/src/commands/electronCommands.ts +++ b/packages/app/main/src/commands/electronCommands.ts @@ -1,4 +1,9 @@ // +import { SharedConstants } from '@bfemulator/app-shared'; +import { CommandRegistryImpl } from '@bfemulator/sdk-shared'; +import * as Electron from 'electron'; +import { app, dialog, Menu, MessageBoxOptions } from 'electron'; +import * as fs from 'fs-extra'; // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // @@ -32,18 +37,12 @@ // import * as path from 'path'; -import { SharedConstants } from '@bfemulator/app-shared'; -import { CommandRegistryImpl } from '@bfemulator/sdk-shared'; -import * as Electron from 'electron'; -import { app, Menu, MessageBoxOptions } from 'electron'; -import * as fs from 'fs-extra'; - import { AppMenuBuilder } from '../appMenuBuilder'; import { getStore } from '../botData/store'; import { mainWindow } from '../main'; import { ContextMenuService } from '../services/contextMenuService'; -import { showOpenDialog, showSaveDialog } from '../utils'; import { TelemetryService } from '../telemetry'; +import { showOpenDialog, showSaveDialog } from '../utils'; const { shell } = Electron; @@ -62,7 +61,7 @@ export function registerCommands(commandRegistry: CommandRegistryImpl) { ...options, }; const args = modal ? [mainWindow.browserWindow, options] : [options]; - return Electron.dialog.showMessageBox.apply(Electron.dialog, args); + return dialog.showMessageBox.apply(dialog, args); }); // --------------------------------------------------------------------------- diff --git a/packages/app/main/src/main.ts b/packages/app/main/src/main.ts index 45ad67471..ba0ec1eeb 100644 --- a/packages/app/main/src/main.ts +++ b/packages/app/main/src/main.ts @@ -1,4 +1,9 @@ // +import { newNotification, Notification, PersistentSettings, Settings, SharedConstants } from '@bfemulator/app-shared'; +import { Users } from '@bfemulator/emulator-core'; +import { ProgressInfo } from 'builder-util-runtime'; +import { app, dialog, systemPreferences } from 'electron'; +import { UpdateInfo } from 'electron-updater'; // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // @@ -31,23 +36,17 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // import * as path from 'path'; +import { Store } from 'redux'; import { setTimeout } from 'timers'; import * as url from 'url'; -import { newNotification, Notification, PersistentSettings, Settings, SharedConstants } from '@bfemulator/app-shared'; -import { Users } from '@bfemulator/emulator-core'; -import { ProgressInfo } from 'builder-util-runtime'; -import * as Electron from 'electron'; -import { app, systemPreferences } from 'electron'; -import { UpdateInfo } from 'electron-updater'; -import { Store } from 'redux'; - import { appendCustomUserAgent } from './appendCustomUserAgent'; import { AppMenuBuilder } from './appMenuBuilder'; import { AppUpdater } from './appUpdater'; import { getStore } from './botData/store'; import * as commandLine from './commandLine'; import { CommandRegistry, registerAllCommands } from './commands'; +import { Protocol } from './constants'; import { Emulator, emulator } from './emulator'; import './fetchProxy'; import { ngrokEmitter } from './ngrok'; @@ -55,12 +54,11 @@ import { Window } from './platform/window'; import { azureLoggedInUserChanged } from './settingsData/actions/azureAuthActions'; import { rememberBounds, rememberTheme } from './settingsData/actions/windowStateActions'; import { dispatch, getSettings, getStore as getSettingsStore } from './settingsData/store'; -import { botListsAreDifferent, ensureStoragePath, saveSettings, writeFile, isMac } from './utils'; +import { TelemetryService } from './telemetry'; +import { botListsAreDifferent, ensureStoragePath, isMac, saveSettings, writeFile } from './utils'; import { openFileFromCommandLine } from './utils/openFileFromCommandLine'; import { sendNotificationToClient } from './utils/sendNotificationToClient'; import { WindowManager } from './windowManager'; -import { Protocol } from './constants'; -import { TelemetryService } from './telemetry'; export let mainWindow: Window; export let windowManager: WindowManager; @@ -341,10 +339,7 @@ const createMainWindow = async () => { windowManager = new WindowManager(); AppMenuBuilder.initAppMenu().catch(err => { - Electron.dialog.showErrorBox( - 'Bot Framework Emulator', - `An error occurred while initializing the application menu: ${err}` - ); + dialog.showErrorBox('Bot Framework Emulator', `An error occurred while initializing the application menu: ${err}`); }); const rememberCurrentBounds = () => { From 622d11ba1148e40e9243a949698633e1f8c32955 Mon Sep 17 00:00:00 2001 From: Justin Wilaby Date: Thu, 7 Mar 2019 14:24:51 -0800 Subject: [PATCH 2/4] Linting fix --- packages/app/main/src/commands/botCommands.ts | 1 + packages/app/main/src/commands/electronCommands.ts | 3 ++- packages/app/main/src/main.ts | 7 ++++--- packages/emulator/core/src/utils/oauthLinkEncoder.ts | 5 +++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/app/main/src/commands/botCommands.ts b/packages/app/main/src/commands/botCommands.ts index 538295995..7a5fe0f62 100644 --- a/packages/app/main/src/commands/botCommands.ts +++ b/packages/app/main/src/commands/botCommands.ts @@ -32,6 +32,7 @@ // import * as path from 'path'; + import { dialog } from 'electron'; import { BotInfo, getBotDisplayName, SharedConstants } from '@bfemulator/app-shared'; import { BotConfigWithPath, CommandRegistryImpl, mergeEndpoints, uniqueId } from '@bfemulator/sdk-shared'; diff --git a/packages/app/main/src/commands/electronCommands.ts b/packages/app/main/src/commands/electronCommands.ts index 37dd75c87..0c6e0d1a6 100644 --- a/packages/app/main/src/commands/electronCommands.ts +++ b/packages/app/main/src/commands/electronCommands.ts @@ -1,4 +1,6 @@ // +import * as path from 'path'; + import { SharedConstants } from '@bfemulator/app-shared'; import { CommandRegistryImpl } from '@bfemulator/sdk-shared'; import * as Electron from 'electron'; @@ -35,7 +37,6 @@ import * as fs from 'fs-extra'; // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -import * as path from 'path'; import { AppMenuBuilder } from '../appMenuBuilder'; import { getStore } from '../botData/store'; diff --git a/packages/app/main/src/main.ts b/packages/app/main/src/main.ts index ba0ec1eeb..bb5186f74 100644 --- a/packages/app/main/src/main.ts +++ b/packages/app/main/src/main.ts @@ -1,4 +1,8 @@ // +import * as path from 'path'; +import { setTimeout } from 'timers'; +import * as url from 'url'; + import { newNotification, Notification, PersistentSettings, Settings, SharedConstants } from '@bfemulator/app-shared'; import { Users } from '@bfemulator/emulator-core'; import { ProgressInfo } from 'builder-util-runtime'; @@ -35,10 +39,7 @@ import { UpdateInfo } from 'electron-updater'; // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -import * as path from 'path'; import { Store } from 'redux'; -import { setTimeout } from 'timers'; -import * as url from 'url'; import { appendCustomUserAgent } from './appendCustomUserAgent'; import { AppMenuBuilder } from './appMenuBuilder'; diff --git a/packages/emulator/core/src/utils/oauthLinkEncoder.ts b/packages/emulator/core/src/utils/oauthLinkEncoder.ts index 86f205b8b..28e98a28d 100644 --- a/packages/emulator/core/src/utils/oauthLinkEncoder.ts +++ b/packages/emulator/core/src/utils/oauthLinkEncoder.ts @@ -31,12 +31,13 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +import * as crypto from 'crypto'; + import { Attachment, AttachmentContentTypes, GenericActivity, OAuthCard } from '@bfemulator/sdk-shared'; import { BotEmulator } from '../botEmulator'; -import uniqueId from './uniqueId'; -import * as crypto from 'crypto'; +import uniqueId from './uniqueId'; export default class OAuthLinkEncoder { public static OAuthUrlProtocol: string = 'oauthlink:'; From 14cca9ef9e05f3d150e3930b5e0f6671f2f681cc Mon Sep 17 00:00:00 2001 From: Justin Wilaby Date: Fri, 8 Mar 2019 16:03:00 -0800 Subject: [PATCH 3/4] Moved imports back to proper location --- .../app/main/src/commands/electronCommands.ts | 14 +++++++------- packages/app/main/src/main.ts | 19 ++++++++++--------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/packages/app/main/src/commands/electronCommands.ts b/packages/app/main/src/commands/electronCommands.ts index 0c6e0d1a6..ac0c336ae 100644 --- a/packages/app/main/src/commands/electronCommands.ts +++ b/packages/app/main/src/commands/electronCommands.ts @@ -1,11 +1,4 @@ // -import * as path from 'path'; - -import { SharedConstants } from '@bfemulator/app-shared'; -import { CommandRegistryImpl } from '@bfemulator/sdk-shared'; -import * as Electron from 'electron'; -import { app, dialog, Menu, MessageBoxOptions } from 'electron'; -import * as fs from 'fs-extra'; // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // @@ -37,6 +30,13 @@ import * as fs from 'fs-extra'; // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +import * as path from 'path'; + +import { SharedConstants } from '@bfemulator/app-shared'; +import { CommandRegistryImpl } from '@bfemulator/sdk-shared'; +import * as Electron from 'electron'; +import { app, dialog, Menu, MessageBoxOptions } from 'electron'; +import * as fs from 'fs-extra'; import { AppMenuBuilder } from '../appMenuBuilder'; import { getStore } from '../botData/store'; diff --git a/packages/app/main/src/main.ts b/packages/app/main/src/main.ts index bb5186f74..b66330b21 100644 --- a/packages/app/main/src/main.ts +++ b/packages/app/main/src/main.ts @@ -1,13 +1,4 @@ // -import * as path from 'path'; -import { setTimeout } from 'timers'; -import * as url from 'url'; - -import { newNotification, Notification, PersistentSettings, Settings, SharedConstants } from '@bfemulator/app-shared'; -import { Users } from '@bfemulator/emulator-core'; -import { ProgressInfo } from 'builder-util-runtime'; -import { app, dialog, systemPreferences } from 'electron'; -import { UpdateInfo } from 'electron-updater'; // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. // @@ -39,6 +30,16 @@ import { UpdateInfo } from 'electron-updater'; // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // +import * as path from 'path'; +import { setTimeout } from 'timers'; +import * as url from 'url'; + +import { newNotification, Notification, PersistentSettings, Settings, SharedConstants } from '@bfemulator/app-shared'; +import { Users } from '@bfemulator/emulator-core'; +import { ProgressInfo } from 'builder-util-runtime'; +import { app, dialog, systemPreferences } from 'electron'; +import { UpdateInfo } from 'electron-updater'; + import { Store } from 'redux'; import { appendCustomUserAgent } from './appendCustomUserAgent'; From ca4db39e5ecb29a1096619f7a7f72198ba572b44 Mon Sep 17 00:00:00 2001 From: Justin Wilaby Date: Mon, 11 Mar 2019 07:23:44 -0700 Subject: [PATCH 4/4] Lint --- packages/app/main/src/main.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/app/main/src/main.ts b/packages/app/main/src/main.ts index b66330b21..4bffb8e2f 100644 --- a/packages/app/main/src/main.ts +++ b/packages/app/main/src/main.ts @@ -39,7 +39,6 @@ import { Users } from '@bfemulator/emulator-core'; import { ProgressInfo } from 'builder-util-runtime'; import { app, dialog, systemPreferences } from 'electron'; import { UpdateInfo } from 'electron-updater'; - import { Store } from 'redux'; import { appendCustomUserAgent } from './appendCustomUserAgent';