Skip to content

Commit

Permalink
Merge 77e65f6 into 7c868b1
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyanziano committed Nov 19, 2018
2 parents 7c868b1 + 77e65f6 commit 79186d7
Show file tree
Hide file tree
Showing 18 changed files with 923 additions and 110 deletions.
25 changes: 24 additions & 1 deletion packages/app/client/src/commands/uiCommands.ts
Original file line number Diff line number Diff line change
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));
});
}
3 changes: 3 additions & 0 deletions packages/app/client/src/ui/dialogs/index.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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 });
});
});
Original file line number Diff line number Diff line change
@@ -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 });
}
}
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
@@ -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 './updateUnavailableDialogContainer';

0 comments on commit 79186d7

Please sign in to comment.