-
Notifications
You must be signed in to change notification settings - Fork 748
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
923 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/app/client/src/ui/dialogs/updateAvailableDialog/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
93 changes: 93 additions & 0 deletions
93
packages/app/client/src/ui/dialogs/updateAvailableDialog/updateAvailableDialog.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); | ||
}); | ||
}); |
76 changes: 76 additions & 0 deletions
76
packages/app/client/src/ui/dialogs/updateAvailableDialog/updateAvailableDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
packages/app/client/src/ui/dialogs/updateAvailableDialog/updateAvailableDialogContainer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
34 changes: 34 additions & 0 deletions
34
packages/app/client/src/ui/dialogs/updateUnavailableDialog/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
Oops, something went wrong.