Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1906] Fixed bugs within connected service editor. #2000

Merged
merged 1 commit into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [1993](https://github.com/microsoft/BotFramework-Emulator/pull/1993)
- [1994](https://github.com/microsoft/BotFramework-Emulator/pull/1994)
- [1997](https://github.com/microsoft/BotFramework-Emulator/pull/1997)
- [2000](https://github.com/microsoft/BotFramework-Emulator/pull/2000)

- [main] Increased ngrok spawn timeout to 15 seconds to be more forgiving to slower networks in PR [1998](https://github.com/microsoft/BotFramework-Emulator/pull/1998)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,21 @@ describe('The ConnectedServiceEditor component should render the correct content
const instance = node.instance();
expect(instance.learnMoreLinkButton).not.toBeFalsy();
expect(instance.editableFields).toEqual(['name', 'appId', 'authoringKey', 'version', 'region', 'subscriptionKey']);
expect(instance.headerContent).toEqual(instance.luisAndDispatchHeader);
expect(JSON.stringify(instance.headerContent)).toEqual(JSON.stringify(instance.luisAndDispatchHeader));
});

it('ServiceTypes.Dispatch', () => {
const instance = node.instance();
expect(instance.learnMoreLinkButton).not.toBeFalsy();
expect(instance.editableFields).toEqual(['name', 'appId', 'authoringKey', 'version', 'region', 'subscriptionKey']);
expect(instance.headerContent).toEqual(instance.luisAndDispatchHeader);
expect(JSON.stringify(instance.headerContent)).toEqual(JSON.stringify(instance.luisAndDispatchHeader));
});

it('ServiceTypes.QnA', () => {
const instance = node.instance();
expect(instance.learnMoreLinkButton).not.toBeFalsy();
expect(instance.editableFields).toEqual(['name', 'kbId', 'hostname', 'subscriptionKey', 'endpointKey']);
expect(instance.headerContent).toEqual(instance.qnaHeader);
expect(JSON.stringify(instance.headerContent)).toEqual(JSON.stringify(instance.qnaHeader));
});

it('ServiceTypes.AppInsights', () => {
Expand All @@ -236,7 +236,7 @@ describe('The ConnectedServiceEditor component should render the correct content
'instrumentationKey',
'applicationId',
]);
expect(instance.headerContent).toEqual(instance.appInsightsAndBlobStorageHeader);
expect(JSON.stringify(instance.headerContent)).toEqual(JSON.stringify(instance.appInsightsAndBlobStorageHeader));
});

it('ServiceTypes.Blob', () => {
Expand All @@ -251,7 +251,7 @@ describe('The ConnectedServiceEditor component should render the correct content
'connectionString',
'container',
]);
expect(instance.headerContent).toEqual(instance.appInsightsAndBlobStorageHeader);
expect(JSON.stringify(instance.headerContent)).toEqual(JSON.stringify(instance.appInsightsAndBlobStorageHeader));
});

it('ServiceTypes.CosmosDB', () => {
Expand All @@ -267,13 +267,13 @@ describe('The ConnectedServiceEditor component should render the correct content
'database',
'collection',
]);
expect(instance.headerContent).toEqual(instance.cosmosDbHeader);
expect(JSON.stringify(instance.headerContent)).toEqual(JSON.stringify(instance.cosmosDbHeader));
});

it('ServiceTypes.Generic', () => {
const instance = node.instance();
expect(instance.editableFields).toEqual(['name', 'url']);

expect(instance.headerContent).toEqual(instance.genericHeader);
expect(JSON.stringify(instance.headerContent)).toEqual(JSON.stringify(instance.genericHeader));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import { DefaultButton, Dialog, DialogFooter, LinkButton, PrimaryButton, TextField } from '@bfemulator/ui-react';
import { BotConfigurationBase } from 'botframework-config/lib/botConfigurationBase';
import { ConnectedService } from 'botframework-config/lib/models';
import { IConnectedService, IGenericService, ServiceTypes } from 'botframework-config/lib/schema';
import { IConnectedService, IGenericService, ServiceTypes, IQnAService } from 'botframework-config/lib/schema';
import * as React from 'react';
import { ChangeEvent, Component, ReactNode } from 'react';

Expand Down Expand Up @@ -100,13 +100,17 @@ const portalMap = {
export class ConnectedServiceEditor extends Component<ConnectedServiceEditorProps, ConnectedServiceEditorState> {
constructor(props: ConnectedServiceEditorProps, state: ConnectedServiceEditorState) {
super(props, state);
const connectedService = props.connectedService || {
type: props.serviceType,
name: '',
};
// if qnamaker, initialize with sample hostname so that botframework-config doesn't throw
if (props.serviceType === ServiceTypes.QnA) {
(connectedService as IQnAService).hostname =
(connectedService as IQnAService).hostname || 'https://myqna.azurewebsites.net';
}
this.state = {
connectedServiceCopy: BotConfigurationBase.serviceFromJSON(
props.connectedService || {
type: props.serviceType,
name: '',
}
),
connectedServiceCopy: BotConfigurationBase.serviceFromJSON(connectedService),
};
}

Expand Down Expand Up @@ -228,13 +232,10 @@ export class ConnectedServiceEditor extends Component<ConnectedServiceEditorProp

private get luisAndDispatchHeader(): ReactNode {
const { serviceType } = this.props;
const textString = 'Learn more about keys in ' + labelMap[serviceType].toString();
return (
<p>
{`You can find your LUIS app ID and subscription key in ${portalMap[serviceType]}. `}
<LinkButton className={styles.link} linkRole={true} onClick={this.learnMoreLinkButton}>
{textString}
</LinkButton>
{this.learnMoreLinkButton}
</p>
);
}
Expand Down Expand Up @@ -301,7 +302,7 @@ export class ConnectedServiceEditor extends Component<ConnectedServiceEditorProp
}
};

private learnMoreLinkButton = (): ReactNode => {
private get learnMoreLinkButton(): ReactNode {
const { serviceType } = this.props;

switch (serviceType) {
Expand Down Expand Up @@ -387,7 +388,7 @@ export class ConnectedServiceEditor extends Component<ConnectedServiceEditorProp
default:
return '';
}
};
}

private onAzurePortalClick = this.createAnchorClickHandler('https://portal.azure.com');

Expand Down