diff --git a/packages/app/client/src/ui/editor/appSettingsEditor/appSettingsEditor.tsx b/packages/app/client/src/ui/editor/appSettingsEditor/appSettingsEditor.tsx index 7e9c8ed60..e2d2d7a34 100644 --- a/packages/app/client/src/ui/editor/appSettingsEditor/appSettingsEditor.tsx +++ b/packages/app/client/src/ui/editor/appSettingsEditor/appSettingsEditor.tsx @@ -94,6 +94,9 @@ export class AppSettingsEditor extends React.Component @@ -167,7 +170,7 @@ export class AppSettingsEditor extends React.Component - Auth + User settings - Sign-in + + + + + + Application Updates - + ); } + private disableSaveButton(): boolean { + return this.state.useCustomId ? !this.state.userGUID : !this.state.dirty; + } + private onChangeCheckBox = (event: ChangeEvent) => { const { name, checked } = event.target; const change = { [name]: checked }; this.setState(change); this.updateDirtyFlag(change); + if (name === 'useCustomId' && checked === false) { + this.setState({ userGUID: null }); + } }; private onClickBrowse = async (): Promise => { diff --git a/packages/app/client/src/ui/editor/emulator/emulator.scss b/packages/app/client/src/ui/editor/emulator/emulator.scss index b8b30a27b..50a9b0559 100644 --- a/packages/app/client/src/ui/editor/emulator/emulator.scss +++ b/packages/app/client/src/ui/editor/emulator/emulator.scss @@ -82,6 +82,7 @@ } .restart-icon { + margin-left: 20px; &::before { -webkit-mask: url(../../media/ic_refresh.svg); } } .save-icon { diff --git a/packages/app/client/src/ui/editor/emulator/emulator.spec.tsx b/packages/app/client/src/ui/editor/emulator/emulator.spec.tsx index b970adf1e..b399e535c 100644 --- a/packages/app/client/src/ui/editor/emulator/emulator.spec.tsx +++ b/packages/app/client/src/ui/editor/emulator/emulator.spec.tsx @@ -288,8 +288,8 @@ describe('', () => { it('should export a transcript', () => { instance.onExportTranscriptClick(); - expect(mockRemoteCallsMade).toHaveLength(1); - expect(mockRemoteCallsMade[0].commandName).toBe(SharedConstants.Commands.Emulator.SaveTranscriptToFile); + expect(mockRemoteCallsMade).toHaveLength(3); + expect(mockRemoteCallsMade[2].commandName).toBe(SharedConstants.Commands.Emulator.SaveTranscriptToFile); expect(mockRemoteCallsMade[0].args).toEqual([16, 'convo1']); }); @@ -312,7 +312,7 @@ describe('', () => { }; await instance.startNewConversation(undefined, true, true); - expect(mockRemoteCallsMade).toHaveLength(1); + expect(mockRemoteCallsMade).toHaveLength(4); expect(initConversationSpy).toHaveBeenCalledWith(instance.props, options); }); @@ -349,9 +349,9 @@ describe('', () => { }; await instance.startNewConversation(undefined, false, true); - expect(mockRemoteCallsMade).toHaveLength(1); - expect(mockRemoteCallsMade[0].commandName).toBe(SharedConstants.Commands.Emulator.SetCurrentUser); - expect(mockRemoteCallsMade[0].args).toEqual([options.userId]); + expect(mockRemoteCallsMade).toHaveLength(4); + expect(mockRemoteCallsMade[3].commandName).toBe(SharedConstants.Commands.Emulator.SetCurrentUser); + expect(mockRemoteCallsMade[3].args).toEqual([options.userId]); expect(mockInitConversation).toHaveBeenCalledWith(instance.props, options); }); @@ -362,9 +362,9 @@ describe('', () => { expect(mockDispatch).toHaveBeenCalledWith(clearLog('doc1')); expect(mockDispatch).toHaveBeenCalledWith(setInspectorObjects('doc1', [])); - expect(mockRemoteCallsMade).toHaveLength(1); - expect(mockRemoteCallsMade[0].commandName).toBe(SharedConstants.Commands.Telemetry.TrackEvent); - expect(mockRemoteCallsMade[0].args).toEqual(['conversation_restart', { userId: 'new' }]); + expect(mockRemoteCallsMade).toHaveLength(3); + expect(mockRemoteCallsMade[2].commandName).toBe(SharedConstants.Commands.Telemetry.TrackEvent); + expect(mockRemoteCallsMade[2].args).toEqual(['conversation_restart', { userId: 'new' }]); expect(mockStartNewConversation).toHaveBeenCalledWith(undefined, true, true); }); @@ -375,9 +375,9 @@ describe('', () => { expect(mockDispatch).toHaveBeenCalledWith(clearLog('doc1')); expect(mockDispatch).toHaveBeenCalledWith(setInspectorObjects('doc1', [])); - expect(mockRemoteCallsMade).toHaveLength(1); - expect(mockRemoteCallsMade[0].commandName).toBe(SharedConstants.Commands.Telemetry.TrackEvent); - expect(mockRemoteCallsMade[0].args).toEqual(['conversation_restart', { userId: 'same' }]); + expect(mockRemoteCallsMade).toHaveLength(3); + expect(mockRemoteCallsMade[2].commandName).toBe(SharedConstants.Commands.Telemetry.TrackEvent); + expect(mockRemoteCallsMade[2].args).toEqual(['conversation_restart', { userId: 'same' }]); expect(mockStartNewConversation).toHaveBeenCalledWith(undefined, true, false); }); @@ -417,11 +417,11 @@ describe('', () => { await instance.startNewConversation(mockProps); - expect(mockRemoteCallsMade).toHaveLength(2); - expect(mockRemoteCallsMade[0].commandName).toBe(SharedConstants.Commands.Emulator.NewTranscript); - expect(mockRemoteCallsMade[0].args).toEqual(['someUniqueId|transcript']); - expect(mockRemoteCallsMade[1].commandName).toBe(SharedConstants.Commands.Emulator.FeedTranscriptFromMemory); - expect(mockRemoteCallsMade[1].args).toEqual(['someConvoId', 'someBotId', 'someUserId', []]); + expect(mockRemoteCallsMade).toHaveLength(6); + expect(mockRemoteCallsMade[4].commandName).toBe(SharedConstants.Commands.Emulator.NewTranscript); + expect(mockRemoteCallsMade[4].args).toEqual(['someUniqueId|transcript']); + expect(mockRemoteCallsMade[5].commandName).toBe(SharedConstants.Commands.Emulator.FeedTranscriptFromMemory); + expect(mockRemoteCallsMade[5].args).toEqual(['someConvoId', 'someBotId', 'someUserId', []]); }); it('should start a new conversation from transcript on disk', async () => { @@ -441,11 +441,11 @@ describe('', () => { await instance.startNewConversation(mockProps); - expect(mockRemoteCallsMade).toHaveLength(2); - expect(mockRemoteCallsMade[0].commandName).toBe(SharedConstants.Commands.Emulator.NewTranscript); - expect(mockRemoteCallsMade[0].args).toEqual(['someUniqueId|transcript']); - expect(mockRemoteCallsMade[1].commandName).toBe(SharedConstants.Commands.Emulator.FeedTranscriptFromDisk); - expect(mockRemoteCallsMade[1].args).toEqual(['someConvoId', 'someBotId', 'someUserId', 'someDocId']); + expect(mockRemoteCallsMade).toHaveLength(6); + expect(mockRemoteCallsMade[4].commandName).toBe(SharedConstants.Commands.Emulator.NewTranscript); + expect(mockRemoteCallsMade[4].args).toEqual(['someUniqueId|transcript']); + expect(mockRemoteCallsMade[5].commandName).toBe(SharedConstants.Commands.Emulator.FeedTranscriptFromDisk); + expect(mockRemoteCallsMade[5].args).toEqual(['someConvoId', 'someBotId', 'someUserId', 'someDocId']); expect(mockDispatch).toHaveBeenCalledWith(updateDocument('someDocId', { meta: 'some file info' })); }); }); diff --git a/packages/app/client/src/ui/editor/emulator/emulator.tsx b/packages/app/client/src/ui/editor/emulator/emulator.tsx index 17b774db6..fefbe9133 100644 --- a/packages/app/client/src/ui/editor/emulator/emulator.tsx +++ b/packages/app/client/src/ui/editor/emulator/emulator.tsx @@ -33,11 +33,18 @@ import { createDirectLine } from 'botframework-webchat'; import { uniqueId, uniqueIdv4 } from '@bfemulator/sdk-shared'; -import { SplitButton, Splitter } from '@bfemulator/ui-react'; +import { Splitter, SplitButton } from '@bfemulator/ui-react'; import base64Url from 'base64url'; import { IEndpointService } from 'botframework-config/lib/schema'; import * as React from 'react'; -import { DebugMode, newNotification, Notification, SharedConstants, ValueTypesMask } from '@bfemulator/app-shared'; +import { + DebugMode, + FrameworkSettings, + newNotification, + Notification, + SharedConstants, + ValueTypesMask, +} from '@bfemulator/app-shared'; import { Document } from '../../../data/reducer/editor'; import { CommandServiceImpl } from '../../../platform/commands/commandServiceImpl'; @@ -121,14 +128,11 @@ export class Emulator extends React.Component { const { document = {} } = props; const { document: nextDocument = {} } = nextProps; - const documentOrUserIdChanged = - (!nextDocument.directLine && document.documentId !== nextDocument.documentId) || - document.userId !== nextDocument.userId; + const documentIdChanged = !nextDocument.directLine && document.documentId !== nextDocument.documentId; - if (documentOrUserIdChanged) { + if (documentIdChanged) { startNewConversation(nextProps).catch(); } - const switchedDocuments = props.activeDocumentId !== nextProps.activeDocumentId; const switchedToThisDocument = nextProps.activeDocumentId === props.documentId; @@ -152,10 +156,13 @@ export class Emulator extends React.Component { ? `${uniqueId()}|${props.mode}` : props.document.conversationId || `${uniqueId()}|${props.mode}`; - const userId = requireNewUserId ? uniqueIdv4() : props.document.userId; - if (requireNewUserId) { - await CommandServiceImpl.remoteCall(SharedConstants.Commands.Emulator.SetCurrentUser, userId); - } + const framework: FrameworkSettings = await CommandServiceImpl.remoteCall( + SharedConstants.Commands.Settings.LoadAppSettings + ); + const stableId = framework.userGUID || props.document.userId; + const userId = requireNewUserId ? uniqueIdv4() : stableId; + + await CommandServiceImpl.remoteCall(SharedConstants.Commands.Emulator.SetCurrentUser, userId); const options = { conversationId, @@ -276,6 +283,7 @@ export class Emulator extends React.Component { onClick={this.onStartOverClick} /> )} +