Skip to content

Commit

Permalink
Merge 2c4ca36 into 014fa59
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Wilaby committed Apr 24, 2019
2 parents 014fa59 + 2c4ca36 commit bc26e40
Show file tree
Hide file tree
Showing 35 changed files with 175 additions and 109 deletions.
13 changes: 9 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions packages/app/client/src/commands/uiCommands.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ import {
SecretPromptDialogContainer,
} from '../ui/dialogs';
import { CommandServiceImpl } from '../platform/commands/commandServiceImpl';
import { BotActionType } from '../data/action/botActions';
import { ExplorerActions } from '../data/action/explorerActions';
import { SWITCH_DEBUG_MODE } from '../data/action/debugModeAction';
import { ActiveBotHelper } from '../ui/helpers/activeBotHelper';

import { registerCommands } from './uiCommands';

Expand Down Expand Up @@ -156,9 +156,11 @@ describe('the uiCommands', () => {
dispatchedActions.push(action);
return action;
};
registry.getCommand(Commands.SwitchDebugMode).handler(DebugMode.Sidecar);
expect(dispatchedActions.length).toBe(3);
[BotActionType.close, ExplorerActions.Show, SWITCH_DEBUG_MODE].forEach((type, index) =>
const closeActiveBotSpy = jest.spyOn(ActiveBotHelper, 'closeActiveBot').mockResolvedValueOnce(true);
await registry.getCommand(Commands.SwitchDebugMode).handler(DebugMode.Sidecar);
expect(dispatchedActions.length).toBe(2);
expect(closeActiveBotSpy).toHaveBeenCalled();
[ExplorerActions.Show, SWITCH_DEBUG_MODE].forEach((type, index) =>
expect(type).toEqual(dispatchedActions[index].type)
);
});
Expand Down
6 changes: 3 additions & 3 deletions packages/app/client/src/commands/uiCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import { ServiceTypes } from 'botframework-config/lib/schema';

import * as Constants from '../constants';
import { azureArmTokenDataChanged, beginAzureAuthWorkflow, invalidateArmToken } from '../data/action/azureAuthActions';
import { closeBot } from '../data/action/botActions';
import { switchDebugMode } from '../data/action/debugModeAction';
import * as EditorActions from '../data/action/editorActions';
import * as NavBarActions from '../data/action/navBarActions';
Expand All @@ -63,6 +62,7 @@ import {
import * as ExplorerActions from '../data/action/explorerActions';
import { closeConversation } from '../data/action/chatActions';
import { close } from '../data/action/editorActions';
import { ActiveBotHelper } from '../ui/helpers/activeBotHelper';

/** Register UI commands (toggling UI) */
export function registerCommands(commandRegistry: CommandRegistry) {
Expand Down Expand Up @@ -135,12 +135,12 @@ export function registerCommands(commandRegistry: CommandRegistry) {

// ---------------------------------------------------------------------------
// Debug mode from main
commandRegistry.registerCommand(UI.SwitchDebugMode, (debugMode: DebugMode) => {
commandRegistry.registerCommand(UI.SwitchDebugMode, async (debugMode: DebugMode) => {
const {
editor: { editors, activeEditor },
} = store.getState();
const { documents } = editors[activeEditor];
store.dispatch(closeBot());
await ActiveBotHelper.closeActiveBot();
store.dispatch(ExplorerActions.showExplorer(debugMode !== DebugMode.Sidecar));
store.dispatch(switchDebugMode(debugMode));
// Close all active conversations - this is a clean wipe of all active conversations
Expand Down
3 changes: 2 additions & 1 deletion packages/app/client/src/data/sagas/azureAuthSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
import { SharedConstants } from '@bfemulator/app-shared';
import { call, ForkEffect, put, select, takeEvery } from 'redux-saga/effects';

import { CommandServiceImpl } from '../../platform/commands/commandServiceImpl';
import { DialogService } from '../../ui/dialogs';
Expand All @@ -44,6 +43,8 @@ import {
import { AzureAuthState } from '../reducer/azureAuthReducer';
import { RootState } from '../store';

import { call, ForkEffect, put, select, takeEvery } from 'redux-saga/effects';

const getArmTokenFromState = (state: RootState) => state.azureAuth;

export function* getArmToken(action: AzureAuthAction<AzureAuthWorkflow>): IterableIterator<any> {
Expand Down
3 changes: 2 additions & 1 deletion packages/app/client/src/data/sagas/botSagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import { newNotification, SharedConstants } from '@bfemulator/app-shared';
import { BotConfigWithPath, ConversationService } from '@bfemulator/sdk-shared';
import { call, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

import { ActiveBotHelper } from '../../ui/helpers/activeBotHelper';
import {
Expand All @@ -49,6 +48,8 @@ import { generateHash } from '../botHelpers';
import { botSagas, browseForBot, generateHashForActiveBot, openBotViaFilePath, openBotViaUrl } from './botSagas';
import { refreshConversationMenu } from './sharedSagas';

import { call, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

jest.mock('../../ui/dialogs', () => ({}));

jest.mock('../store', () => ({
Expand Down
3 changes: 2 additions & 1 deletion packages/app/client/src/data/sagas/botSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import { newNotification, UserSettings } from '@bfemulator/app-shared';
import { ConversationService, StartConversationParams } from '@bfemulator/sdk-shared';
import { call, ForkEffect, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

import { ActiveBotHelper } from '../../ui/helpers/activeBotHelper';
import { BotAction, BotActionType, BotConfigWithPathPayload, botHashGenerated } from '../action/botActions';
Expand All @@ -43,6 +42,8 @@ import { RootState } from '../store';

import { refreshConversationMenu } from './sharedSagas';

import { call, ForkEffect, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

/** Opens up native open file dialog to browse for a .bot file */
export function* browseForBot(): IterableIterator<any> {
yield call([ActiveBotHelper, ActiveBotHelper.confirmAndOpenBotFromFile]);
Expand Down
3 changes: 2 additions & 1 deletion packages/app/client/src/data/sagas/chatSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import { diff } from 'deep-diff';
import { IEndpointService } from 'botframework-config/lib/schema';
import { createCognitiveServicesBingSpeechPonyfillFactory } from 'botframework-webchat';
import { createStore as createWebChatStore } from 'botframework-webchat-core';
import { call, ForkEffect, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

import {
ChatAction,
Expand All @@ -57,6 +56,8 @@ import { CommandServiceImpl } from '../../platform/commands/commandServiceImpl';
import { RootState } from '../store';
import { isSpeechEnabled } from '../../utils';

import { call, ForkEffect, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

const getConversationIdFromDocumentId = (state: RootState, documentId: string) => {
return (state.chat.chats[documentId] || {}).conversationId;
};
Expand Down
3 changes: 2 additions & 1 deletion packages/app/client/src/data/sagas/editorSagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@
//

import { SharedConstants } from '@bfemulator/app-shared';
import { call, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

import { EditorActions, removeDocPendingChange } from '../action/editorActions';

import { checkActiveDocForPendingChanges, editorSagas, promptUserToReloadDocument } from './editorSagas';
import { refreshConversationMenu, editorSelector } from './sharedSagas';

import { call, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

jest.mock('../store', () => ({
get store() {
return {};
Expand Down
3 changes: 2 additions & 1 deletion packages/app/client/src/data/sagas/editorSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@
//

import { isChatFile, isTranscriptFile, SharedConstants } from '@bfemulator/app-shared';
import { call, ForkEffect, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

import { CommandServiceImpl } from '../../platform/commands/commandServiceImpl';
import { EditorActions, removeDocPendingChange } from '../action/editorActions';

import { editorSelector, refreshConversationMenu } from './sharedSagas';

import { call, ForkEffect, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

export function* promptUserToReloadDocument(filename: string): IterableIterator<any> {
const { Commands } = SharedConstants;
const options = {
Expand Down
3 changes: 2 additions & 1 deletion packages/app/client/src/data/sagas/endpointSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import { SharedConstants } from '@bfemulator/app-shared';
import { IBotService, IEndpointService, ServiceTypes } from 'botframework-config/lib/schema';
import { ComponentClass } from 'react';
import { call, ForkEffect, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

import { CommandServiceImpl } from '../../platform/commands/commandServiceImpl';
import { DialogService } from '../../ui/dialogs/service';
Expand All @@ -49,6 +48,8 @@ import {
} from '../action/endpointServiceActions';
import { RootState } from '../store';

import { call, ForkEffect, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

const getConnectedAbs = (state: RootState, endpointAppId: string) => {
return (state.bot.activeBot.services || []).find(service => {
return service.type === ServiceTypes.Bot && (service as IBotService).appId === endpointAppId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import { SharedConstants, newNotification } from '@bfemulator/app-shared';
import { applyMiddleware, combineReducers, createStore } from 'redux';
import sagaMiddlewareFactory from 'redux-saga';
import { call, put, takeEvery, select } from 'redux-saga/effects';

import { CONTENT_TYPE_APP_SETTINGS, DOCUMENT_ID_APP_SETTINGS } from '../../constants';
import * as EditorActions from '../action/editorActions';
Expand All @@ -59,6 +58,8 @@ import {
saveFrameworkSettings,
} from './frameworkSettingsSagas';

import { call, put, takeEvery, select } from 'redux-saga/effects';

jest.mock(
'../../ui/dialogs/',
() =>
Expand Down
3 changes: 2 additions & 1 deletion packages/app/client/src/data/sagas/frameworkSettingsSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
import { frameworkDefault, FrameworkSettings, newNotification, SharedConstants } from '@bfemulator/app-shared';
import { call, ForkEffect, put, select, takeEvery } from 'redux-saga/effects';

import { CommandServiceImpl } from '../../platform/commands/commandServiceImpl';
import * as EditorActions from '../action/editorActions';
Expand All @@ -47,6 +46,8 @@ import { generateHash } from '../botHelpers';
import { Document } from '../reducer/editor';
import { RootState } from '../store';

import { call, ForkEffect, put, select, takeEvery } from 'redux-saga/effects';

export const normalizeSettingsData = async (settings: FrameworkSettings): Promise<FrameworkSettings> => {
// trim keys that do not belong and generate a hash
const keys = Object.keys(frameworkDefault).sort();
Expand Down
4 changes: 2 additions & 2 deletions packages/app/client/src/data/sagas/navBarSagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import { put } from 'redux-saga/effects';

import { select } from '../action/navBarActions';
import * as Constants from '../../constants';
import { markAllAsRead } from '../action/notificationActions';

import { markNotificationsAsRead } from './navBarSagas';

import { put } from 'redux-saga/effects';

jest.mock('../../ui/dialogs', () => ({
AzureLoginPromptDialogContainer: function mock() {
return undefined;
Expand Down
4 changes: 2 additions & 2 deletions packages/app/client/src/data/sagas/navBarSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import { ForkEffect, put, takeEvery } from 'redux-saga/effects';

import * as Constants from '../../constants';
import { NavBarActions, SelectNavBarAction } from '../action/navBarActions';
import { markAllAsRead } from '../action/notificationActions';

import { ForkEffect, put, takeEvery } from 'redux-saga/effects';

/** Marks all notifications as read if the notifications pane is opened */
export function* markNotificationsAsRead(action: SelectNavBarAction): IterableIterator<any> {
const navBarSelection = action.payload.selection;
Expand Down
3 changes: 2 additions & 1 deletion packages/app/client/src/data/sagas/notificationSagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@
//

import { newNotification, NotificationType } from '@bfemulator/app-shared';
import { put } from 'redux-saga/effects';

import { NotificationManager } from '../../notificationManager';
import { beginAdd, finishAdd, finishClear, beginRemove, finishRemove } from '../action/notificationActions';

import { addNotification, clearNotifications, removeNotification, markAllAsRead } from './notificationSagas';

import { put } from 'redux-saga/effects';

describe('Notification sagas', () => {
test('addNotification()', () => {
const notification = newNotification('someMessage', NotificationType.Info);
Expand Down
4 changes: 2 additions & 2 deletions packages/app/client/src/data/sagas/notificationSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import { ForkEffect, put, takeEvery } from 'redux-saga/effects';

import { NotificationManager } from '../../notificationManager';
import {
BeginAddNotificationAction,
Expand All @@ -43,6 +41,8 @@ import {
NotificationActions,
} from '../action/notificationActions';

import { ForkEffect, put, takeEvery } from 'redux-saga/effects';

/** Adds a notification to the notification manager then
* adds it to the state store
*/
Expand Down
3 changes: 2 additions & 1 deletion packages/app/client/src/data/sagas/resourcesSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import { BotInfo, isChatFile, isTranscriptFile, NotificationType, SharedConstant
import { newNotification } from '@bfemulator/app-shared/built';
import { IFileService } from 'botframework-config/lib/schema';
import { ComponentClass } from 'react';
import { ForkEffect, put, takeEvery } from 'redux-saga/effects';

import { CommandServiceImpl } from '../../platform/commands/commandServiceImpl';
import { DialogService } from '../../ui/dialogs/service';
Expand All @@ -48,6 +47,8 @@ import {
ResourcesAction,
} from '../action/resourcesAction';

import { ForkEffect, put, takeEvery } from 'redux-saga/effects';

function* openContextMenuForResource(action: ResourcesAction<IFileService>): IterableIterator<any> {
const menuItems = [{ label: 'Open file location', id: 0 }, { label: 'Rename', id: 1 }, { label: 'Delete', id: 2 }];

Expand Down
3 changes: 2 additions & 1 deletion packages/app/client/src/data/sagas/servicesExplorerSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import {
IQnAService,
ServiceTypes,
} from 'botframework-config/lib/schema';
import { ForkEffect, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

import { CommandServiceImpl } from '../../platform/commands/commandServiceImpl';
import { DialogService } from '../../ui/dialogs/service';
Expand All @@ -65,6 +64,8 @@ import { RootState } from '../store';

import { getArmToken } from './azureAuthSaga';

import { ForkEffect, put, select, takeEvery, takeLatest } from 'redux-saga/effects';

declare interface ServicesPayload {
services: IConnectedService[];
code: ServiceCodes;
Expand Down
3 changes: 2 additions & 1 deletion packages/app/client/src/data/sagas/sharedSagas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@
//

import { SharedConstants } from '@bfemulator/app-shared';
import { select } from 'redux-saga/effects';

import { RootState } from '../store';

import { editorSelector, refreshConversationMenu } from './sharedSagas';

import { select } from 'redux-saga/effects';

let mockRemoteCommandsCalled = [];
jest.mock('../../platform/commands/commandServiceImpl', () => ({
CommandServiceImpl: {
Expand Down
3 changes: 2 additions & 1 deletion packages/app/client/src/data/sagas/sharedSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@
//

import { SharedConstants } from '@bfemulator/app-shared';
import { select } from 'redux-saga/effects';

import { CommandServiceImpl } from '../../platform/commands/commandServiceImpl';
import { RootState } from '../store';

import { select } from 'redux-saga/effects';

export function editorSelector(state: RootState) {
return state.editor;
}
Expand Down
3 changes: 2 additions & 1 deletion packages/app/client/src/data/sagas/welcomePageSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
import { BotInfo, newNotification, SharedConstants } from '@bfemulator/app-shared';
import { ForkEffect, put, takeEvery } from 'redux-saga/effects';

import { CommandServiceImpl } from '../../platform/commands/commandServiceImpl';
import { beginAdd } from '../action/notificationActions';
import { OPEN_CONTEXT_MENU_FOR_BOT, WelcomePageAction } from '../action/welcomePageActions';

import { ForkEffect, put, takeEvery } from 'redux-saga/effects';

function* openContextMenuForBot(action: WelcomePageAction<BotInfo>): IterableIterator<any> {
const menuItems = [
{ label: 'Move...', id: 0 },
Expand Down

0 comments on commit bc26e40

Please sign in to comment.