This repository was archived by the owner on Jul 9, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 375
feat: Settings page #4456
Merged
liweitian
merged 50 commits into
microsoft:feature/bot-projects
from
liweitian:settingsPage
Nov 16, 2020
Merged
feat: Settings page #4456
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
3d02e7c
setting page UX
liweitian 2d0490c
update UX
liweitian 0107f93
refine css
liweitian b054272
update url
liweitian 4be7091
update css and fix localStorage bug
liweitian 0f9a9f4
refactor and refine css
liweitian e0d6ecb
add custom error style and fix bugs of language settings
liweitian 4f8b6d2
localstorage migration
liweitian 38548a8
fix delete button hidden bug
liweitian 96aae47
update css
liweitian a88b04e
update Composer Setting page
liweitian 2a63a98
save tmp code about the callout switching active language in design …
liweitian 9d22999
changing locale button on Header
liweitian 66f088b
lint fix
liweitian f314687
lint fix
liweitian e5d43ce
handle comments
liweitian 63edadc
save tmp code
liweitian 40a6518
handle comments
liweitian 216e5d5
save tmp code
liweitian ef214b4
add test case
liweitian 525a67e
Merge branch 'settingsPage' of https://github.com/liweitian/BotFramew…
liweitian 900b8fd
add test cases
liweitian 74151ea
add test cases
liweitian 36a87f2
fix bugs and update router component
liweitian 99076f5
handle comments
liweitian d652f0f
handle comments
liweitian 22bfe5d
Merge branch 'feature/bot-projects' into settingsPage
liweitian 349885d
handle comments
liweitian cae512a
update qna end point key after update qna subscription key
liweitian 70a8033
code style
liweitian 82be07a
Merge https://github.com/microsoft/BotFramework-Composer into setting…
liweitian 89e4837
Merge branch 'feature/bot-projects' into settingsPage
liweitian ccf0c90
Merge branch 'settingsPage' of https://github.com/liweitian/BotFramew…
liweitian 4b67c42
set defaultLanguage as active language if active language is deleted
liweitian 6e28c87
Merge branch 'settingsPage' of https://github.com/liweitian/BotFramew…
liweitian b21339f
fix UT
liweitian ba0bc82
remove useless files
liweitian 3f82c3c
Merge branch 'feature/bot-projects' into settingsPage
liweitian c88f2da
save tmp code
liweitian 50a059b
sync on root key
liweitian 242eb36
fix bug
liweitian be44e0a
code refine
liweitian 2a40001
Merge branch 'feature/bot-projects' into settingsPage
liweitian e7b357b
fix UT
liweitian 1438303
fix bug
liweitian 4243c9a
Merge branch 'feature/bot-projects' into settingsPage
srinaath a2798f9
Refactoring function calls
bbd7e70
Merge branch 'settingsPage' of https://github.com/liweitian/BotFramew…
f38c27b
Merge branch 'feature/bot-projects' into settingsPage
liweitian dd64a34
lint fix
liweitian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
Composer/packages/client/__tests__/pages/botProjectsSettings/AppIdAndPassword.test.tsx
This file contains hidden or 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,73 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import React from 'react'; | ||
| import { act, fireEvent } from '@botframework-composer/test-utils'; | ||
|
|
||
| import { AppIdAndPassword } from '../../../src/pages/botProject/AppIdAndPassword'; | ||
| import { renderWithRecoilAndCustomDispatchers } from '../../testUtils'; | ||
| import { dispatcherState } from '../../../src/recoilModel'; | ||
| import { settingsState, currentProjectIdState } from '../../../src/recoilModel'; | ||
|
|
||
| const state = { | ||
| projectId: 'test', | ||
| settings: { | ||
| defaultLanguage: 'en-us', | ||
| languages: ['en-us', 'fr-fr'], | ||
| }, | ||
| }; | ||
|
|
||
| describe('App Id and Password', () => { | ||
| it('should submit settings', async () => { | ||
| const setSettingsMock = jest.fn(); | ||
| const initRecoilState = ({ set }) => { | ||
| set(currentProjectIdState, state.projectId); | ||
| set(settingsState(state.projectId), state.settings); | ||
| set(dispatcherState, { | ||
| setSettings: setSettingsMock, | ||
| }); | ||
| }; | ||
| const { getByTestId } = renderWithRecoilAndCustomDispatchers( | ||
| <AppIdAndPassword projectId={state.projectId} />, | ||
| initRecoilState | ||
| ); | ||
| const textField1 = getByTestId('MicrosoftAppId'); | ||
| await act(async () => { | ||
| await fireEvent.change(textField1, { | ||
| target: { value: 'myMicrosoftAppId' }, | ||
| }); | ||
| await fireEvent.blur(textField1); | ||
| }); | ||
| expect(setSettingsMock).toBeCalledWith('test', { | ||
| defaultLanguage: 'en-us', | ||
| languages: ['en-us', 'fr-fr'], | ||
| luis: { | ||
| authoringKey: '', | ||
| authoringRegion: '', | ||
| }, | ||
| qna: { | ||
| subscriptionKey: '', | ||
| }, | ||
| MicrosoftAppId: 'myMicrosoftAppId', | ||
| }); | ||
| const textField2 = getByTestId('MicrosoftPassword'); | ||
| await act(async () => { | ||
| await fireEvent.change(textField2, { | ||
| target: { value: 'myMicrosoftPassword' }, | ||
| }); | ||
| await fireEvent.blur(textField2); | ||
| }); | ||
| expect(setSettingsMock).toBeCalledWith('test', { | ||
| defaultLanguage: 'en-us', | ||
| languages: ['en-us', 'fr-fr'], | ||
| luis: { | ||
| authoringKey: '', | ||
| authoringRegion: '', | ||
| }, | ||
| qna: { | ||
| subscriptionKey: '', | ||
| }, | ||
| MicrosoftAppPassword: 'myMicrosoftPassword', | ||
| }); | ||
| }); | ||
| }); | ||
51 changes: 51 additions & 0 deletions
51
Composer/packages/client/__tests__/pages/botProjectsSettings/BotLanguage.test.tsx
This file contains hidden or 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,51 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import React from 'react'; | ||
| import { act, fireEvent, within } from '@botframework-composer/test-utils'; | ||
|
|
||
| import { BotLanguage } from '../../../src/pages/botProject/BotLanguage'; | ||
| import { renderWithRecoilAndCustomDispatchers } from '../../testUtils'; | ||
| import { dispatcherState } from '../../../src/recoilModel'; | ||
| import { settingsState, currentProjectIdState } from '../../../src/recoilModel'; | ||
|
|
||
| const state = { | ||
| projectId: 'test', | ||
| settings: { | ||
| defaultLanguage: 'en-us', | ||
| languages: ['en-us', 'fr-fr'], | ||
| }, | ||
| }; | ||
|
|
||
| describe('Bot Language', () => { | ||
| it('should submit settings', () => { | ||
| const setSettingsMock = jest.fn(); | ||
| const setLocaleMock = jest.fn(); | ||
| const deleteLanguages = jest.fn(); | ||
| const initRecoilState = ({ set }) => { | ||
| set(currentProjectIdState, state.projectId); | ||
| set(settingsState(state.projectId), state.settings); | ||
| set(dispatcherState, { | ||
| setSettings: setSettingsMock, | ||
| setLocale: setLocaleMock, | ||
| deleteLanguages: deleteLanguages, | ||
| }); | ||
| }; | ||
| const { getByTestId } = renderWithRecoilAndCustomDispatchers( | ||
| <BotLanguage projectId={state.projectId} />, | ||
| initRecoilState | ||
| ); | ||
| const defaultLanguageContainer = getByTestId('defaultLanguage'); | ||
| expect(within(defaultLanguageContainer).getByText('English (United States)')).toBeInTheDocument(); | ||
| const setDefaultLanguage = getByTestId('setDefaultLanguage'); | ||
| act(() => { | ||
| fireEvent.click(setDefaultLanguage); | ||
| }); | ||
| expect(setLocaleMock).toBeCalledWith('fr-fr', 'test'); | ||
| const remove = getByTestId('remove'); | ||
| act(() => { | ||
| fireEvent.click(remove); | ||
| }); | ||
| expect(deleteLanguages).toBeCalledWith({ languages: ['fr-fr'], projectId: 'test' }); | ||
| }); | ||
| }); |
24 changes: 24 additions & 0 deletions
24
Composer/packages/client/__tests__/pages/botProjectsSettings/DeleteBotButton.test.tsx
This file contains hidden or 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,24 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
| /* eslint-disable react-hooks/rules-of-hooks */ | ||
|
|
||
| import React from 'react'; | ||
| import { act, fireEvent } from '@botframework-composer/test-utils'; | ||
|
|
||
| import { DeleteBotButton } from '../../../src/pages/botProject/DeleteBotButton'; | ||
| import { renderWithRecoil } from '../../testUtils'; | ||
|
|
||
| const state = { | ||
| projectId: 'test', | ||
| }; | ||
|
|
||
| describe('Delete Bot Button', () => { | ||
| it('should render Delete Bot Button', () => { | ||
| const { getByText } = renderWithRecoil(<DeleteBotButton projectId={state.projectId} />); | ||
| const deleteButton = getByText('Delete'); | ||
| act(() => { | ||
| fireEvent.click(deleteButton); | ||
| }); | ||
| expect(getByText('Delete Bot')).toBeInTheDocument(); | ||
| }); | ||
| }); |
37 changes: 37 additions & 0 deletions
37
Composer/packages/client/__tests__/pages/botProjectsSettings/PublishTarget.test.tsx
This file contains hidden or 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,37 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
| /* eslint-disable react-hooks/rules-of-hooks */ | ||
|
|
||
| import React from 'react'; | ||
| import { act, fireEvent } from '@botframework-composer/test-utils'; | ||
|
|
||
| import { PublishTargets } from '../../../src/pages/botProject/PublishTargets'; | ||
| import { renderWithRecoilAndCustomDispatchers } from '../../testUtils'; | ||
| import { dispatcherState, publishTypesState } from '../../../src/recoilModel'; | ||
| const state = { | ||
| projectId: 'test', | ||
| publishTypes: [{ name: 'azureFunctionsPublish', description: 'Publish bot to Azure Functions (Preview)' }], | ||
| }; | ||
| describe('Publish Target', () => { | ||
| const setPublishTargetsMock = jest.fn(); | ||
| const initRecoilState = ({ set }) => { | ||
| set(dispatcherState, { | ||
| setPublishTargets: setPublishTargetsMock, | ||
| getPublishTargetTypes: () => {}, | ||
| }); | ||
| set(publishTypesState(state.projectId), [ | ||
| { name: 'azureFunctionsPublish', description: 'Publish bot to Azure Functions (Preview)' }, | ||
| ]); | ||
| }; | ||
| it('should add new publish profile', () => { | ||
| const { getByTestId, getByText } = renderWithRecoilAndCustomDispatchers( | ||
| <PublishTargets projectId={state.projectId} />, | ||
| initRecoilState | ||
| ); | ||
| const addNewPublishProfile = getByTestId('addNewPublishProfile'); | ||
| act(() => { | ||
| fireEvent.click(addNewPublishProfile); | ||
| }); | ||
| expect(getByText('Add a publish profile')).toBeInTheDocument(); | ||
| }); | ||
| }); |
128 changes: 128 additions & 0 deletions
128
Composer/packages/client/__tests__/pages/botProjectsSettings/RootBotExternalService.test.tsx
This file contains hidden or 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,128 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import React from 'react'; | ||
| import { act, fireEvent } from '@botframework-composer/test-utils'; | ||
|
|
||
| import { RootBotExternalService } from '../../../src/pages/botProject/RootBotExternalService'; | ||
| import { renderWithRecoilAndCustomDispatchers } from '../../testUtils'; | ||
| import { dispatcherState } from '../../../src/recoilModel'; | ||
| import { | ||
| settingsState, | ||
| currentProjectIdState, | ||
| projectMetaDataState, | ||
| botProjectIdsState, | ||
| dialogState, | ||
| luFilesState, | ||
| } from '../../../src/recoilModel'; | ||
|
|
||
| const state = { | ||
| dialogs: [ | ||
| { | ||
| content: { | ||
| recognizer: '', | ||
| }, | ||
| id: 'dialog1', | ||
| }, | ||
| { | ||
| content: { | ||
| recognizer: '', | ||
| }, | ||
| id: 'dialog2', | ||
| }, | ||
| ], | ||
| qnaFiles: [ | ||
| { | ||
| content: '', | ||
| empty: true, | ||
| id: 'dialog1.en-us', | ||
| }, | ||
| ], | ||
| luFiles: [ | ||
| { | ||
| content: '', | ||
| empty: true, | ||
| id: 'dialog1.en-us', | ||
| }, | ||
| ], | ||
| projectId: 'test', | ||
| settings: {}, | ||
| projectMetaDataState: { | ||
| isRootBot: true, | ||
| isRemote: false, | ||
| }, | ||
| botProjectIdsState: ['test'], | ||
| }; | ||
|
|
||
| describe('Root Bot External Service', () => { | ||
| it('should submit settings', async () => { | ||
| const setSettingsMock = jest.fn(); | ||
| const setQnASettingsMock = jest.fn(); | ||
| const initRecoilState = ({ set }) => { | ||
| set(currentProjectIdState, state.projectId); | ||
| set(dialogState({ projectId: state.projectId, dialogId: state.dialogs[0].id }), state.dialogs[0]); | ||
| set(dialogState({ projectId: state.projectId, dialogId: state.dialogs[1].id }), state.dialogs[1]); | ||
| set(botProjectIdsState, state.botProjectIdsState); | ||
| set(luFilesState(state.projectId), state.luFiles); | ||
| set(projectMetaDataState(state.projectId), state.projectMetaDataState); | ||
| set(settingsState(state.projectId), state.settings); | ||
| set(dispatcherState, { | ||
| setSettings: setSettingsMock, | ||
| setQnASettings: setQnASettingsMock, | ||
| }); | ||
| }; | ||
| const { getByTestId } = renderWithRecoilAndCustomDispatchers( | ||
| <RootBotExternalService projectId={state.projectId} />, | ||
| initRecoilState | ||
| ); | ||
| const textField1 = getByTestId('rootLUISKey'); | ||
| await act(async () => { | ||
| await fireEvent.change(textField1, { | ||
| target: { value: 'myRootLUISKey' }, | ||
| }); | ||
| await fireEvent.blur(textField1); | ||
| }); | ||
| expect(setSettingsMock).toBeCalledWith('test', { | ||
| luis: { | ||
| authoringKey: 'myRootLUISKey', | ||
| authoringRegion: '', | ||
| }, | ||
| qna: { | ||
| subscriptionKey: '', | ||
| }, | ||
| }); | ||
| const textField2 = getByTestId('rootLUISRegion'); | ||
| await act(async () => { | ||
| await fireEvent.change(textField2, { | ||
| target: { value: 'myRootLUISRegion' }, | ||
| }); | ||
| await fireEvent.blur(textField2); | ||
| }); | ||
| expect(setSettingsMock).toBeCalledWith('test', { | ||
| luis: { | ||
| authoringKey: '', | ||
| authoringRegion: 'myRootLUISRegion', | ||
| }, | ||
| qna: { | ||
| subscriptionKey: '', | ||
| }, | ||
| }); | ||
| const textField3 = getByTestId('QnASubscriptionKey'); | ||
| await act(async () => { | ||
| await fireEvent.change(textField3, { | ||
| target: { value: 'myQnASubscriptionKey' }, | ||
| }); | ||
| await fireEvent.blur(textField3); | ||
| }); | ||
| expect(setSettingsMock).toBeCalledWith('test', { | ||
| luis: { | ||
| authoringKey: '', | ||
| authoringRegion: '', | ||
| }, | ||
| qna: { | ||
| subscriptionKey: 'myQnASubscriptionKey', | ||
| }, | ||
| }); | ||
| expect(setQnASettingsMock).toBeCalledWith('test', 'myQnASubscriptionKey'); | ||
| }); | ||
| }); |
54 changes: 54 additions & 0 deletions
54
Composer/packages/client/__tests__/pages/botProjectsSettings/SkillHostEndPoint.test.tsx
This file contains hidden or 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,54 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import React from 'react'; | ||
| import { act, fireEvent } from '@botframework-composer/test-utils'; | ||
|
|
||
| import { SkillHostEndPoint } from '../../../src/pages/botProject/SkillHostEndPoint'; | ||
| import { renderWithRecoilAndCustomDispatchers } from '../../testUtils'; | ||
| import { dispatcherState } from '../../../src/recoilModel'; | ||
| import { settingsState, currentProjectIdState } from '../../../src/recoilModel'; | ||
|
|
||
| const state = { | ||
| projectId: 'test', | ||
| settings: { | ||
| defaultLanguage: 'en-us', | ||
| languages: ['en-us', 'fr-fr'], | ||
| }, | ||
| }; | ||
|
|
||
| describe('SkillHostEndPoint', () => { | ||
| it('should submit settings', async () => { | ||
| const setSettingsMock = jest.fn(); | ||
| const initRecoilState = ({ set }) => { | ||
| set(currentProjectIdState, state.projectId); | ||
| set(settingsState(state.projectId), state.settings); | ||
| set(dispatcherState, { | ||
| setSettings: setSettingsMock, | ||
| }); | ||
| }; | ||
| const { getByTestId } = renderWithRecoilAndCustomDispatchers( | ||
| <SkillHostEndPoint projectId={state.projectId} />, | ||
| initRecoilState | ||
| ); | ||
| const textField = getByTestId('SkillHostEndPointTextField'); | ||
| await act(async () => { | ||
| await fireEvent.change(textField, { | ||
| target: { value: 'mySkillHostEndPoint' }, | ||
| }); | ||
| await fireEvent.blur(textField); | ||
| }); | ||
| expect(setSettingsMock).toBeCalledWith('test', { | ||
| defaultLanguage: 'en-us', | ||
| languages: ['en-us', 'fr-fr'], | ||
| skillHostEndpoint: 'mySkillHostEndPoint', | ||
| luis: { | ||
| authoringKey: '', | ||
| authoringRegion: '', | ||
| }, | ||
| qna: { | ||
| subscriptionKey: '', | ||
| }, | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.