Skip to content

Commit

Permalink
Merge branch 'corinagum/1096' of https://github.com/Microsoft/BotFram…
Browse files Browse the repository at this point in the history
…ework-Emulator into corinagum/1096
  • Loading branch information
Corina committed Nov 19, 2018
2 parents 659f329 + e519776 commit e4fad8d
Show file tree
Hide file tree
Showing 21 changed files with 936 additions and 122 deletions.
25 changes: 24 additions & 1 deletion packages/app/client/src/commands/uiCommands.ts
Expand Up @@ -39,7 +39,10 @@ import {
BotCreationDialog,
DialogService,
PostMigrationDialogContainer,
SecretPromptDialogContainer
SecretPromptDialogContainer,
UpdateAvailableDialogContainer,
UpdateUnavailableDialogContainer,
ProgressIndicatorContainer
} from '../ui/dialogs';
import { store } from '../data/store';
import * as EditorActions from '../data/action/editorActions';
Expand Down Expand Up @@ -129,7 +132,27 @@ export function registerCommands(commandRegistry: CommandRegistry) {
DialogService.showDialog(PostMigrationDialogContainer);
});

// ---------------------------------------------------------------------------
// Shows the progress indicator component
commandRegistry.registerCommand(UI.ShowProgressIndicator, async (props?: ProgressIndicatorPayload) => {
return await DialogService.showDialog(ProgressIndicatorContainer, props).catch(e => console.error(e));
});

// ---------------------------------------------------------------------------
// Updates the progress of the progress indicator component
commandRegistry.registerCommand(UI.UpdateProgressIndicator, (value: ProgressIndicatorPayload) => {
store.dispatch(updateProgressIndicator(value));
});

// ---------------------------------------------------------------------------
// Shows the dialog telling the user that an update is available
commandRegistry.registerCommand(UI.ShowUpdateAvailableDialog, async (version: string = '') => {
return await DialogService.showDialog(UpdateAvailableDialogContainer, { version }).catch(e => console.error(e));
});

// ---------------------------------------------------------------------------
// Shows the dialog telling the user that an update is unavailable
commandRegistry.registerCommand(UI.ShowUpdateUnavailableDialog, async () => {
return await DialogService.showDialog(UpdateUnavailableDialogContainer).catch(e => console.error(e));
});
}
Expand Up @@ -11,12 +11,14 @@
}

.multi-input-row {
width: 420px;
justify-content: space-between;
}

.small-input input {
width: 200px;
.input-container {
width: 100%;
& + div {
margin-left: 8px;
}
}

.bot-create-form {
Expand Down Expand Up @@ -53,21 +55,20 @@
.key {
width: 175px;
margin: 16px 145px 0 32px;
> label[aria-disabled] {
color: initial;
}
}

.encrypt-key-check-box {
margin-top: 30px;

span {
width: auto;
}
}

.actions-list {
list-style: none;
position: absolute;
right: 106px; // when re-enabling 'Generate new secret' link, original value: 0;
bottom: 3px;
bottom: 12.5px;
padding: 0;
margin: 0;

Expand Down
@@ -1,7 +1,7 @@
// This is a generated file. Changes are likely to result in being overwritten
export const main: string;
export const multiInputRow: string;
export const smallInput: string;
export const inputContainer: string;
export const botCreateForm: string;
export const checkboxAnchorContainer: string;
export const link: string;
Expand Down
Expand Up @@ -120,14 +120,14 @@ export class BotCreationDialog extends React.Component<{}, BotCreationDialogStat
{ endpointWarning && <span className={ styles.endpointWarning }>{ endpointWarning }</span> }
<Row className={ styles.multiInputRow }>
<TextField
className={ styles.smallInput }
inputContainerClassName={ styles.inputContainer }
data-prop="appId"
label="Microsoft App ID"
onChange={ this.onInputChange }
placeholder="Optional"
value={ endpoint.appId }/>
<TextField
className={ styles.smallInput }
inputContainerClassName={ styles.inputContainer }
label="Microsoft App password"
data-prop="appPassword"
onChange={ this.onInputChange }
Expand All @@ -150,7 +150,7 @@ export class BotCreationDialog extends React.Component<{}, BotCreationDialogStat
</Row>

<TextField
className={ styles.key }
inputContainerClassName={ styles.key }
label="Secret "
value={ secret }
placeholder="Your keys are not encrypted"
Expand Down
3 changes: 3 additions & 0 deletions packages/app/client/src/ui/dialogs/index.ts
Expand Up @@ -30,6 +30,7 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

export * from './botCreationDialog/botCreationDialog';
export * from './host/host';
export * from './secretPromptDialog/secretPromptDialogContainer';
Expand All @@ -44,3 +45,5 @@ export * from './postMigrationDialog/postMigrationDialogContainer';
export * from './progressIndicator/progressIndicatorContainer';
export * from './botSettingsEditor/botSettingsEditorContainer';
export * from './resourcesSettings/resourcesSettingsContainer';
export * from './updateAvailableDialog';
export * from './updateUnavailableDialog';
34 changes: 34 additions & 0 deletions packages/app/client/src/ui/dialogs/updateAvailableDialog/index.ts
@@ -0,0 +1,34 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license.
//
// Microsoft Bot Framework: http://botframework.com
//
// Bot Framework Emulator Github:
// https://github.com/Microsoft/BotFramwork-Emulator
//
// Copyright (c) Microsoft Corporation
// All rights reserved.
//
// MIT License:
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

export * from './updateAvailableDialogContainer';
@@ -0,0 +1,93 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license.
//
// Microsoft Bot Framework: http://botframework.com
//
// Bot Framework Emulator Github:
// https://github.com/Microsoft/BotFramwork-Emulator
//
// Copyright (c) Microsoft Corporation
// All rights reserved.
//
// MIT License:
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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 { UpdateAvailableDialog } from './updateAvailableDialog';
import { UpdateAvailableDialogContainer } from './updateAvailableDialogContainer';
import { createStore } from 'redux';
import { Provider } from 'react-redux';
import { navBar } from '../../../data/reducer/navBar';
import * as React from 'react';
import { mount } from 'enzyme';

let mockHideDialog;
jest.mock('../service', () => ({
DialogService: {
get hideDialog() { return mockHideDialog; }
}
}));

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

describe('UpdateAvailableDialog', () => {
let wrapper;
let node;
let instance;

beforeEach(() => {
wrapper = mount(
<Provider store={ createStore(navBar) } >
<UpdateAvailableDialogContainer/>
</Provider>
);

node = wrapper.find(UpdateAvailableDialog);
instance = node.instance();
mockHideDialog = jest.fn(_ => null);
});

it('should render deeply', () => {
expect(wrapper.find(UpdateAvailableDialogContainer)).not.toBe(null);
expect(node.find(UpdateAvailableDialog)).not.toBe(null);
});

it('should change state when the install after download checkbox is toggled', () => {
instance.setState({ installAfterDownload: false });

instance.onChangeInstallAfterDownload();

const state = instance.state;
expect(state.installAfterDownload).toBe(true);
});

it('should close properly', () => {
instance.props.onCloseClick();

expect(mockHideDialog).toHaveBeenCalledWith(null);
});

it('should close and return the passed in value when "Download" is clicked', () => {
instance.props.onDownloadClick(true);

expect(mockHideDialog).toHaveBeenCalledWith({ installAfterDownload: true });
});
});
@@ -0,0 +1,76 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license.
//
// Microsoft Bot Framework: http://botframework.com
//
// Bot Framework Emulator Github:
// https://github.com/Microsoft/BotFramwork-Emulator
//
// Copyright (c) Microsoft Corporation
// All rights reserved.
//
// MIT License:
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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 React from 'react';
import { Dialog, DialogFooter, PrimaryButton, DefaultButton, Checkbox } from '@bfemulator/ui-react';

export interface UpdateAvailableDialogProps {
onCloseClick?: () => any;
onDownloadClick?: (installAfterDownload: boolean) => any;
version?: string;
}

export interface UpdateAvailableDialogState {
installAfterDownload: boolean;
}

export class UpdateAvailableDialog extends React.Component<UpdateAvailableDialogProps, UpdateAvailableDialogState> {
constructor(props: UpdateAvailableDialogProps) {
super(props);

this.state = { installAfterDownload: false };
}

public render(): JSX.Element {
const { onCloseClick, onDownloadClick, version } = this.props;
const { installAfterDownload } = this.state;
const { onChangeInstallAfterDownload } = this;

return (
<Dialog cancel={ onCloseClick } title="Update available">
<p>Bot Framework Emulator { version } is available. Would you like to download the new version?</p>
<Checkbox label="Restart the emulator and install update after download"
checked={ installAfterDownload }
onChange={ onChangeInstallAfterDownload }/>
<DialogFooter>
<DefaultButton text="Cancel" onClick={ onCloseClick }/>
<PrimaryButton text="Download" onClick={ () => onDownloadClick(this.state.installAfterDownload) }/>
</DialogFooter>
</Dialog>
);
}

private onChangeInstallAfterDownload = (): void => {
this.setState({ installAfterDownload: !this.state.installAfterDownload });
}
}
@@ -0,0 +1,47 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license.
//
// Microsoft Bot Framework: http://botframework.com
//
// Bot Framework Emulator Github:
// https://github.com/Microsoft/BotFramwork-Emulator
//
// Copyright (c) Microsoft Corporation
// All rights reserved.
//
// MIT License:
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// 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 { UpdateAvailableDialog, UpdateAvailableDialogProps } from './updateAvailableDialog';
import { connect } from 'react-redux';
import { DialogService } from '../service';

function mapDispatchToProps(_dispatch: any): UpdateAvailableDialogProps {
return {
onCloseClick: () => DialogService.hideDialog(null),
onDownloadClick: (installAfterDownload: boolean) => {
DialogService.hideDialog({ installAfterDownload });
}
};
}

export const UpdateAvailableDialogContainer = connect(null, mapDispatchToProps)(UpdateAvailableDialog);

0 comments on commit e4fad8d

Please sign in to comment.