Skip to content

Commit

Permalink
Merge 3e47fa9 into 368e1dc
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Wilaby committed Nov 21, 2018
2 parents 368e1dc + 3e47fa9 commit c7fa6a5
Show file tree
Hide file tree
Showing 10 changed files with 476 additions and 108 deletions.
4 changes: 3 additions & 1 deletion packages/app/client/src/data/sagas/servicesExplorerSagas.ts
Expand Up @@ -224,7 +224,9 @@ function* openAddConnectedServiceContextMenu(action: ConnectedServiceAction<Conn
{ label: 'Add QnA Maker', id: ServiceTypes.QnA },
{ label: 'Add Dispatch', id: ServiceTypes.Dispatch },
{ type: 'separator' },
{ label: 'Add Azure Application Insights', id: ServiceTypes.AppInsights}
{ label: 'Add Azure Cosmos DB account', id: ServiceTypes.CosmosDB},
{ label: 'Add Azure Storage account', id: ServiceTypes.BlobStorage},
{ label: 'Add Azure Application Insights', id: ServiceTypes.AppInsights},
];

const response = yield CommandServiceImpl.remoteCall(SharedConstants.Commands.Electron.DisplayContextMenu, menuItems);
Expand Down
Expand Up @@ -15,7 +15,9 @@ const titleMap = {
[ServiceTypes.Luis]: 'Connect your bot to a LUIS application',
[ServiceTypes.Dispatch]: 'Connect your bot to a Dispatch model',
[ServiceTypes.QnA]: 'Connect your bot to a QnA Maker knowledge base',
[ServiceTypes.AppInsights]: 'Connect to an Azure Application Insights resource'
[ServiceTypes.AppInsights]: 'Connect to an Azure Application Insights resource',
[ServiceTypes.BlobStorage]: 'Connect your bot to an Azure Storage account',
[ServiceTypes.CosmosDB]: 'Connect your bot to an Azure Cosmos DB account'
};

export class ConnectServicePromptDialog extends Component<ConnectServicePromptDialogProps, {}> {
Expand Down Expand Up @@ -50,6 +52,12 @@ export class ConnectServicePromptDialog extends Component<ConnectServicePromptDi
case ServiceTypes.AppInsights:
return this.appInsightsContent;

case ServiceTypes.BlobStorage:
return this.blobStorageContent;

case ServiceTypes.CosmosDB:
return this.cosmosDbContent;

default:
throw new TypeError(`${serviceType} is not a known service type`);
}
Expand Down Expand Up @@ -123,11 +131,51 @@ export class ConnectServicePromptDialog extends Component<ConnectServicePromptDi
<p>
{ `Alternatively, you can ` }
<a href="javascript:void(0);" onClick={ this.props.addServiceManually }>
connect to a azure Application Insights manually
connect to a Azure Application Insights manually
</a>
{ ` with the app ID, version, and authoring key.` }
</p>
</>
);
}

private get blobStorageContent(): ReactNode {
return (
<>
<p>
{ 'Sign in to your Azure account to select the Azure Storage ' +
'accounts you\'d like to associate with this bot. ' }
<a href="https://aka.ms/bot-framework-emulator-storage-docs">
Learn more about Azure Storage.
</a>
</p>
<p>
{ `Alternatively, you can ` }
<a href="javascript:void(0);" onClick={ this.props.addServiceManually }>
connect to a Azure Storage account manually.
</a>
</p>
</>
);
}

private get cosmosDbContent(): ReactNode {
return (
<>
<p>
{ 'Sign in to your Azure account to select the Azure Cosmos DB ' +
'accounts you\'d like to associate with this bot. ' }
<a href="https://aka.ms/bot-framework-emulator-cosmosdb-docs">
Learn more about Azure Cosmos DB.
</a>
</p>
<p>
{ `Alternatively, you can ` }
<a href="javascript:void(0);" onClick={ this.props.addServiceManually }>
connect to a Azure Cosmos DB account manually.
</a>
</p>
</>
);
}
}
@@ -1,14 +1,14 @@
import { PrimaryButton } from '@bfemulator/ui-react';
import { ServiceTypes } from 'botframework-config';
import { LuisService } from 'botframework-config/lib/models';
import { mount } from 'enzyme';
import * as React from 'react';
import { Provider } from 'react-redux';
import { combineReducers, createStore } from 'redux';
import { azureAuth } from '../../../../../data/reducer/azureAuthReducer';
import { DialogService } from '../../../../dialogs/service';
import { ConnectedServiceEditor, getLearnMoreLink } from './connectedServiceEditor';
import { ConnectedServiceEditor } from './connectedServiceEditor';
import { ConnectedServiceEditorContainer } from './connectedServiceEditorContainer';
import { ServiceTypes } from 'botframework-config/lib/schema';

jest.mock('../../../../dialogs/service', () => ({
DialogService: {
Expand Down Expand Up @@ -43,7 +43,7 @@ describe('The ConnectedServiceEditor component ', () => {
"subscriptionKey": "emoji"
}`);
parent = mount(<Provider store={ createStore(combineReducers({ azureAuth })) }>
<ConnectedServiceEditorContainer connectedService={ mockService }/>
<ConnectedServiceEditorContainer connectedService={ mockService } serviceType={ mockService.type }/>
</Provider>);
node = parent.find(ConnectedServiceEditor);
});
Expand Down Expand Up @@ -101,18 +101,99 @@ describe('The ConnectedServiceEditor component ', () => {
const submitBtn = node.find(PrimaryButton);
expect(submitBtn.props.disabled).toBeFalsy();
});
});

describe('The ConnectedServiceEditor component\'s should render the correct content when the service type is', () => {
let parent;
let node;
let mockService = JSON.parse(`{
"id": "b5af3f67-7ec8-444a-ae91-c4f02883c8f4",
"name": "It's mathmatical!",
"version": "0.1",
"appId": "121221",
"authoringKey": "poo",
"subscriptionKey": "emoji"
}`);
const services = [
ServiceTypes.Luis,
ServiceTypes.Dispatch,
ServiceTypes.QnA,
ServiceTypes.AppInsights,
ServiceTypes.BlobStorage,
ServiceTypes.CosmosDB];

beforeEach(() => {
mockService.type = services.shift();
parent = mount(<Provider store={ createStore(combineReducers({ azureAuth })) }>
<ConnectedServiceEditorContainer connectedService={ mockService } serviceType={ mockService.type }/>
</Provider>);
node = parent.find(ConnectedServiceEditor);
});

it('should return the correct url according to service type.', () => {
let serviceType = ServiceTypes.QnA;
let returnedHref = getLearnMoreLink(serviceType);
expect(returnedHref).toBe('http://aka.ms/bot-framework-emulator-qna-keys');

serviceType = ServiceTypes.Luis;
returnedHref = getLearnMoreLink(serviceType);
expect(returnedHref).toBe('http://aka.ms/bot-framework-emulator-LUIS-docs-home');

serviceType = ServiceTypes.Dispatch;
returnedHref = getLearnMoreLink(serviceType);
expect(returnedHref).toBe('https://aka.ms/bot-framework-emulator-create-dispatch');
it('ServiceTypes.Luis', () => {
const instance = node.instance();
expect(instance.learnMoreLink).toBe('http://aka.ms/bot-framework-emulator-LUIS-docs-home');
expect(instance.editableFields).toEqual(['name', 'appId', 'authoringKey', 'version', 'subscriptionKey']);
expect(instance.headerContent).toEqual(instance.luisAndDispatchHeader);
});

it('ServiceTypes.Dispatch', () => {
const instance = node.instance();
expect(instance.learnMoreLink).toBe('https://aka.ms/bot-framework-emulator-create-dispatch');
expect(instance.editableFields).toEqual(['name', 'appId', 'authoringKey', 'version', 'subscriptionKey']);
expect(instance.headerContent).toEqual(instance.luisAndDispatchHeader);
});

it('ServiceTypes.QnA', () => {
const instance = node.instance();
expect(instance.learnMoreLink).toBe('http://aka.ms/bot-framework-emulator-qna-keys');
expect(instance.editableFields).toEqual(['name', 'kbId', 'hostname', 'subscriptionKey', 'endpointKey']);
expect(instance.headerContent).toEqual(instance.qnaHeader);
});

it('ServiceTypes.AppInsights', () => {
const instance = node.instance();
expect(instance.learnMoreLink).toBe('https://aka.ms/bot-framework-emulator-appinsights-keys');
expect(instance.editableFields).toEqual([
'name',
'tenantId',
'subscriptionKey',
'resourceGroup',
'serviceName',
'instrumentationKey',
'applicationId'
]);
expect(instance.headerContent).toEqual(instance.appInsightsAndBlobStorageHeader);
});

it('ServiceTypes.Blob', () => {
const instance = node.instance();
expect(instance.learnMoreLink).toBe('https://aka.ms/bot-framework-emulator-storage-keys');
expect(instance.editableFields).toEqual([
'name',
'tenantId',
'subscriptionKey',
'resourceGroup',
'serviceName',
'connectionString',
'container'
]);
expect(instance.headerContent).toEqual(instance.appInsightsAndBlobStorageHeader);
});

it('ServiceTypes.CosmosDB', () => {
const instance = node.instance();
expect(instance.learnMoreLink).toBe('https://aka.ms/bot-framework-emulator-cosmosdb-keys');
expect(instance.editableFields).toEqual([
'name',
'tenantId',
'subscriptionKey',
'resourceGroup',
'serviceName',
'endpoint',
'database',
'collection'
]);
expect(instance.headerContent).toEqual(instance.cosmosDbHeader);
});
});

0 comments on commit c7fa6a5

Please sign in to comment.