Skip to content

Commit

Permalink
Fixed some left-over legacy / mismatched commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyanziano committed Jul 16, 2018
1 parent 60bbceb commit 890c55d
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 22 deletions.
7 changes: 4 additions & 3 deletions packages/app/client/src/data/sagas/editorSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ import { isChatFile, isTranscriptFile } from '../../utils';
import { SharedConstants } from '@bfemulator/app-shared';

export function* promptUserToReloadDocument(filename: string): IterableIterator<any> {
const { Commands } = SharedConstants;
const options = {
buttons: ['Cancel', 'Reload'],
title: 'File change detected',
message: 'We have detected a change in this file on disk. Would you like to reload it in the Emulator?'
};
const confirmation = yield CommandServiceImpl.remoteCall('shell:showMessageBox', options);
const confirmation = yield CommandServiceImpl.remoteCall(Commands.Electron.ShowMessageBox, options);

// clear the doc of pending changes
yield put(removeDocPendingChange(filename));
Expand All @@ -53,9 +54,9 @@ export function* promptUserToReloadDocument(filename: string): IterableIterator<
if (confirmation) {
if (isChatFile(filename)) {
const reload = true;
yield CommandServiceImpl.call(SharedConstants.Commands.Emulator.OpenChatFile, filename, reload);
yield CommandServiceImpl.call(Commands.Emulator.OpenChatFile, filename, reload);
} else if (isTranscriptFile(filename)) {
yield CommandServiceImpl.call(SharedConstants.Commands.Emulator.ReloadTranscript, filename);
yield CommandServiceImpl.call(Commands.Emulator.ReloadTranscript, filename);
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions packages/app/client/src/hyperlinkHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,17 @@ export function navigate(url: string) {
}

function navigateEmulatedOAuthUrl(oauthParam: string) {
const { Commands } = SharedConstants;
let parts = oauthParam.split('&&&');
CommandServiceImpl
.remoteCall(SharedConstants.Commands.OAuth.SendTokenResponse, parts[0], parts[1], 'emulatedToken_' + uniqueId())
.remoteCall(Commands.OAuth.SendTokenResponse, parts[0], parts[1], 'emulatedToken_' + uniqueId())
.catch();
}

function navigateOAuthUrl(oauthParam: string) {
const { Commands } = SharedConstants;
let parts = oauthParam.split('&&&');
CommandServiceImpl.remoteCall('oauth:create-oauth-window', parts[0], parts[1]).catch();
CommandServiceImpl.remoteCall(Commands.OAuth.CreateOAuthWindow, parts[0], parts[1]).catch();
}

// import * as URL from 'url';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ import { EndpointService } from 'msbot/bin/models';
import { IEndpointService, ServiceType } from 'msbot/bin/schema';
import * as React from 'react';
import * as styles from './botCreationDialog.scss';

import { CommandServiceImpl } from '../../../platform/commands/commandServiceImpl';
import { ActiveBotHelper } from '../../helpers/activeBotHelper';
import { DialogService } from '../service';
import { SharedConstants } from '@bfemulator/app-shared';

export interface BotCreationDialogState {
bot: BotConfigWithPath;
Expand Down Expand Up @@ -237,8 +237,9 @@ export class BotCreationDialog extends React.Component<{}, BotCreationDialogStat
}

private showBotSaveDialog = async (): Promise<any> => {
const { Commands } = SharedConstants;
// get a safe bot file name
const botFileName = await CommandServiceImpl.remoteCall('file:sanitize-string', this.state.bot.name);
const botFileName = await CommandServiceImpl.remoteCall(Commands.File.SanitizeString, this.state.bot.name);
// TODO - Localization
const dialogOptions = {
filters: [
Expand All @@ -253,7 +254,7 @@ export class BotCreationDialog extends React.Component<{}, BotCreationDialogStat
buttonLabel: 'Save'
};

return CommandServiceImpl.remoteCall('shell:showSaveDialog', dialogOptions);
return CommandServiceImpl.remoteCall(Commands.Electron.ShowSaveDialog, dialogOptions);
}

private onChangeSecret = (secret) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import {
SmallHeader,
TextField
} from '@bfemulator/ui-react';
import { FrameworkSettings } from '@bfemulator/app-shared';
import { FrameworkSettings, SharedConstants } from '@bfemulator/app-shared';
import { CommandServiceImpl } from '../../../platform/commands/commandServiceImpl';
import * as EditorActions from '../../../data/action/editorActions';
import * as Constants from '../../../constants';
Expand Down Expand Up @@ -103,8 +103,9 @@ export class AppSettingsEditor extends React.Component<AppSettingsEditorProps, A
}

componentWillMount(): void {
const { Commands } = SharedConstants;
// load settings from main and populate form
CommandServiceImpl.remoteCall('app:settings:load')
CommandServiceImpl.remoteCall(Commands.Settings.LoadAppSettings)
.then(settings => {
this.setState(() => ({
committed: settings,
Expand Down Expand Up @@ -144,13 +145,14 @@ export class AppSettingsEditor extends React.Component<AppSettingsEditorProps, A
}

onClickBrowse(): void {
const { Commands } = SharedConstants;
const dialogOptions = {
title: 'Browse for ngrok',
buttonLabel: 'Select ngrok',
properties: ['openFile']
};

CommandServiceImpl.remoteCall('shell:showOpenDialog', dialogOptions)
CommandServiceImpl.remoteCall(Commands.Electron.ShowOpenDialog, dialogOptions)
.then(ngrokPath => this.setUncommittedState({ ngrokPath }))
.catch(err => console.log('User cancelled browsing for ngrok: ', err));
}
Expand All @@ -160,6 +162,7 @@ export class AppSettingsEditor extends React.Component<AppSettingsEditorProps, A
}

onClickSave(): void {
const { Commands } = SharedConstants;
const { uncommitted } = this.state;
const settings: FrameworkSettings = {
ngrokPath: uncommitted.ngrokPath.trim(),
Expand All @@ -171,7 +174,7 @@ export class AppSettingsEditor extends React.Component<AppSettingsEditorProps, A
locale: uncommitted.locale.trim()
};

CommandServiceImpl.remoteCall('app:settings:save', settings)
CommandServiceImpl.remoteCall(Commands.Settings.SaveAppSettings, settings)
.then(() => this.commit(settings))
.catch(err => console.error('Error while saving emulator settings: ', err));
}
Expand Down
5 changes: 3 additions & 2 deletions packages/app/client/src/ui/editor/emulator/parts/log/log.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import * as ChatActions from '../../../../../data/action/chatActions';
import * as styles from './log.scss';
import store from '../../../../../data/store';
import { ExtensionManager, InspectorAPI } from '../../../../../extensions';
import { LogEntry, LogItem, LogLevel } from '@bfemulator/app-shared';
import { LogEntry, LogItem, LogLevel, SharedConstants } from '@bfemulator/app-shared';
import { CommandServiceImpl } from '../../../../../platform/commands/commandServiceImpl';

function number2(n: number) {
Expand Down Expand Up @@ -196,9 +196,10 @@ class LogEntryComponent extends React.Component<LogEntryProps> {
}

renderAppSettingsItem(text: string, key: string) {
const { Commands } = SharedConstants;
return (
<span key={ key } className={ styles.spaced }>
<a onClick={ () => CommandServiceImpl.call('shell:show-app-settings') }>{ text }</a>
<a onClick={ () => CommandServiceImpl.call(Commands.UI.ShowAppSettings) }>{ text }</a>
</span>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

import * as React from 'react';
import { connect } from 'react-redux';
import { FileInfo } from '@bfemulator/app-shared';
import { FileInfo, SharedConstants } from '@bfemulator/app-shared';
import { TreeView, TreeViewProps } from '@fuselab/ui-fabric/lib';
import { ExpandCollapse, ExpandCollapseContent } from '@bfemulator/ui-react';
import { FileTreeState } from '../../../../data/reducer/files';
Expand Down Expand Up @@ -63,11 +63,13 @@ class FileExplorerComponent extends React.Component<FileExplorerProps> {
}

private handleTranscriptClick(filename: string) {
CommandServiceImpl.call('transcript:open', filename);
const { Commands } = SharedConstants;
CommandServiceImpl.call(Commands.Emulator.OpenTranscript, filename);
}

private handleChatClick(filename: string) {
CommandServiceImpl.call('chat:open', filename);
const { Commands } = SharedConstants;
CommandServiceImpl.call(Commands.Emulator.OpenChatFile, filename);
}

private renderFileTree(): JSX.Element {
Expand Down
6 changes: 5 additions & 1 deletion packages/app/client/src/ui/shell/navBar/navBarContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as NavBarActions from '../../../data/action/navBarActions';
import { RootState } from '../../../data/store';
import * as ExplorerActions from '../../../data/action/explorerActions';
import * as EditorActions from '../../../data/action/editorActions';
import { SharedConstants } from '@bfemulator/app-shared';

const mapStateToProps = (state: RootState): NavBarProps => ({
activeBot: state.bot.activeBot
Expand All @@ -14,7 +15,10 @@ const mapStateToProps = (state: RootState): NavBarProps => ({
const mapDispatchToProps = (dispatch, ownProps: NavBarProps): NavBarProps => ({
showBotExplorer: show => dispatch(ExplorerActions.show(show)),
navBarSelectionChanged: newSelection => dispatch(NavBarActions.select(newSelection)),
openBotSettings: () => CommandServiceImpl.call('bot-settings:open', ownProps.activeBot),
openBotSettings: () => {
const { Commands } = SharedConstants;
CommandServiceImpl.call(Commands.Bot.OpenSettings, ownProps.activeBot);
},
openEmulatorSettings: () => {
const { CONTENT_TYPE_APP_SETTINGS, DOCUMENT_ID_APP_SETTINGS } = Constants;
dispatch(EditorActions.open(CONTENT_TYPE_APP_SETTINGS, DOCUMENT_ID_APP_SETTINGS, true, null));
Expand Down
2 changes: 1 addition & 1 deletion packages/app/main/src/commands/clientInitCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export function registerCommands(commandRegistry: CommandRegistryImpl) {
// some extra info to differentiate it from a transcript on disk
mainWindow.commandService.remoteCall(Commands.Emulator.OpenTranscript, 'deepLinkedTranscript', {
activities: conversationActivities,
deepLink: true
inMemory: true
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/app/main/src/commands/oauthCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function registerCommands(commandRegistry: CommandRegistryImpl) {

// ---------------------------------------------------------------------------
// Opens an OAuth login window
commandRegistry.registerCommand(Commands.GetStoreOAuthWindow, async (url: string, conversationId: string) => {
commandRegistry.registerCommand(Commands.CreateOAuthWindow, async (url: string, conversationId: string) => {
const convo = emulator.framework.server.botEmulator.facilities.conversations.conversationById(conversationId);
windowManager.createOAuthWindow(url, convo.codeVerifier);
});
Expand Down
2 changes: 1 addition & 1 deletion packages/app/main/src/protocolHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export const ProtocolHandler = new class ProtocolHandlerImpl implements Protocol
// extra info to differentiate it from a transcript on disk
mainWindow.commandService.remoteCall(
SharedConstants.Commands.Emulator.OpenTranscript, 'deepLinkedTranscript',
{ activities: conversationActivities, deepLink: true, fileName }
{ activities: conversationActivities, inMemory: true, fileName }
);
} catch (e) {
throw new Error(`Error occured while reading downloaded transcript: ${e}`);
Expand Down
2 changes: 1 addition & 1 deletion packages/app/shared/src/constants/sharedConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export namespace SharedConstants {

export namespace OAuth {
export const SendTokenResponse: string = 'oauth:send-token-response';
export const GetStoreOAuthWindow: string = 'oauth:get-store-oauth-window';
export const CreateOAuthWindow: string = 'oauth:create-oauth-window';
}

export namespace Settings {
Expand Down

0 comments on commit 890c55d

Please sign in to comment.