• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Microsoft / BotFramework-Emulator / 389499

23 May 2024 02:16AM UTC coverage: 45.975% (-21.6%) from 67.547%
389499

Pull #2459

Azure DevOps

web-flow
Merge 88a7da94c into e554dc423
Pull Request #2459: Bumped webpack version from 4.32.2 to 5.91.0

1815 of 4567 branches covered (39.74%)

Branch coverage included in aggregate %.

4730 of 9669 relevant lines covered (48.92%)

5.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/packages/app/client/src/ui/dialogs/connectServicePromptDialog/connectServicePromptDialog.tsx
1
//
2
// Copyright (c) Microsoft. All rights reserved.
3
// Licensed under the MIT license.
4
//
5
// Microsoft Bot Framework: http://botframework.com
6
//
7
// Bot Framework Emulator Github:
8
// https://github.com/Microsoft/BotFramwork-Emulator
9
//
10
// Copyright (c) Microsoft Corporation
11
// All rights reserved.
12
//
13
// MIT License:
14
// Permission is hereby granted, free of charge, to any person obtaining
15
// a copy of this software and associated documentation files (the
16
// "Software"), to deal in the Software without restriction, including
17
// without limitation the rights to use, copy, modify, merge, publish,
18
// distribute, sublicense, and/or sell copies of the Software, and to
19
// permit persons to whom the Software is furnished to do so, subject to
20
// the following conditions:
21
//
22
// The above copyright notice and this permission notice shall be
23
// included in all copies or substantial portions of the Software.
24
//
25
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
26
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
29
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
30
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
31
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32
//
33
import { DefaultButton, Dialog, DialogFooter, LinkButton, PrimaryButton } from '@bfemulator/ui-react';
34
import { ServiceTypes } from 'botframework-config/lib/schema';
35
import * as React from 'react';
36
import { Component, ReactNode } from 'react';
37

38
import * as styles from '../dialogStyles.scss';
39

40
export interface ConnectServicePromptDialogProps {
41
  cancel: () => void;
42
  confirm: () => void;
43
  addServiceManually: () => void;
44
  onAnchorClick: (url: string) => void;
45
  serviceType?: ServiceTypes;
46
}
47

48
const titleMap = {
×
49
  [ServiceTypes.Luis]: 'Connect your bot to a LUIS application',
50
  [ServiceTypes.Dispatch]: 'Connect your bot to a Dispatch model',
51
  [ServiceTypes.QnA]: 'Connect your bot to a QnA Maker knowledge base',
52
  [ServiceTypes.AppInsights]: 'Connect to an Azure Application Insights resource',
53
  [ServiceTypes.BlobStorage]: 'Connect your bot to an Azure Storage account',
54
  [ServiceTypes.CosmosDB]: 'Connect your bot to an Azure Cosmos DB account',
55
};
56

57
export class ConnectServicePromptDialog extends Component<ConnectServicePromptDialogProps, Record<string, unknown>> {
58
  public render() {
59
    return (
×
60
      <Dialog className={styles.dialogMedium} cancel={this.props.cancel} title={titleMap[this.props.serviceType]}>
61
        <div tabIndex={0}>{this.dialogContent}</div>
62
        <DialogFooter>
63
          <DefaultButton text="Cancel" onClick={this.props.cancel} />
64
          <PrimaryButton text="Sign in with Azure" onClick={this.props.confirm} />
65
        </DialogFooter>
66
      </Dialog>
67
    );
68
  }
69

70
  private get dialogContent(): ReactNode {
71
    const { serviceType } = this.props;
×
72
    switch (serviceType) {
×
73
      case ServiceTypes.Luis:
74
        return this.luisContent;
×
75

76
      case ServiceTypes.QnA:
77
        return this.qnaContent;
×
78

79
      case ServiceTypes.Dispatch:
80
        return this.dispatchContent;
×
81

82
      case ServiceTypes.AppInsights:
83
        return this.appInsightsContent;
×
84

85
      case ServiceTypes.BlobStorage:
86
        return this.blobStorageContent;
×
87

88
      case ServiceTypes.CosmosDB:
89
        return this.cosmosDbContent;
×
90

91
      default:
92
        throw new TypeError(`${serviceType} is not a known service type`);
×
93
    }
94
  }
95

96
  private createAnchorClickHandler = url => () => this.props.onAnchorClick(url);
×
97

98
  private onAppInsightsClick = this.createAnchorClickHandler('https://aka.ms/bot-framework-emulator-appinsights-docs');
×
99

100
  private onAzureCosmosDbDocsClick = this.createAnchorClickHandler(
×
101
    'https://aka.ms/bot-framework-emulator-cosmosdb-docs'
102
  );
103

104
  private onAzureStorageDocsClick = this.createAnchorClickHandler('https://aka.ms/bot-framework-emulator-storage-docs');
×
105

106
  private onDispatchDocsClick = this.createAnchorClickHandler('https://aka.ms/bot-framework-emulator-create-dispatch');
×
107

108
  private onLuisDocsClick = this.createAnchorClickHandler('http://aka.ms/bot-framework-emulator-LUIS-docs-home');
×
109

110
  private onQnADocsClick = this.createAnchorClickHandler('http://aka.ms/bot-framework-emulator-qna-docs-home');
×
111

112
  private get luisContent(): ReactNode {
113
    return (
×
114
      <>
115
        <p role="presentation">
116
          {`Sign in to your Azure account to select the LUIS applications you'd like to associate with this bot. `}
117
          <LinkButton className={styles.dialogLink} linkRole={true} onClick={this.onLuisDocsClick}>
118
            Learn more about LUIS.
119
          </LinkButton>
120
        </p>
121
        <p role="presentation">
122
          {`Alternatively, you can `}
123
          <LinkButton className={styles.dialogLink} onClick={this.props.addServiceManually}>
124
            add a LUIS app manually
125
          </LinkButton>
126
          {` with the app ID, version, and authoring key.`}
127
        </p>
128
      </>
129
    );
130
  }
131

132
  private get qnaContent(): JSX.Element {
133
    return (
×
134
      <>
135
        <p role="presentation">
136
          {'Sign in to your Azure account to select the QnA ' +
137
            "Maker knowledge bases you'd like to associate with this bot. "}
138
          <LinkButton className={styles.dialogLink} linkRole={true} onClick={this.onQnADocsClick}>
139
            Learn more about QnA Maker.
140
          </LinkButton>
141
        </p>
142
        <p role="presentation">
143
          {`Alternatively, you can `}{' '}
144
          <LinkButton className={styles.dialogLink} onClick={this.props.addServiceManually}>
145
            connect to a QnA Maker knowledge base manually
146
          </LinkButton>
147
          {' with the app ID, version, and authoring key.'}
148
        </p>
149
      </>
150
    );
151
  }
152

153
  private get dispatchContent(): JSX.Element {
154
    return (
×
155
      <>
156
        <p role="presentation">
157
          {`Sign in to your Azure account to select the Dispatch model you'd like to associate with this bot. `}
158
          <LinkButton className={styles.dialogLink} linkRole={true} onClick={this.onDispatchDocsClick}>
159
            Learn more about Dispatch models.
160
          </LinkButton>
161
        </p>
162
        <p role="presentation">
163
          {`Alternatively, you can `}
164
          <LinkButton className={styles.dialogLink} onClick={this.props.addServiceManually}>
165
            connect to a Dispatch model manually
166
          </LinkButton>
167
          {` with the app ID, version, and authoring key.`}
168
        </p>
169
      </>
170
    );
171
  }
172

173
  private get appInsightsContent(): JSX.Element {
174
    return (
×
175
      <>
176
        <p role="presentation">
177
          {'Sign in to your Azure account to select the Azure Application ' +
178
            "Insights you'd like to associate with this bot. "}
179
          <LinkButton className={styles.dialogLink} linkRole={true} onClick={this.onAppInsightsClick}>
180
            Learn more about Azure Application Insights.
181
          </LinkButton>
182
        </p>
183
        <p role="presentation">
184
          {`Alternatively, you can `}
185
          <LinkButton className={styles.dialogLink} onClick={this.props.addServiceManually}>
186
            connect to a Azure Application Insights manually
187
          </LinkButton>
188
          {` with the app ID, version, and authoring key.`}
189
        </p>
190
      </>
191
    );
192
  }
193

194
  private get blobStorageContent(): ReactNode {
195
    return (
×
196
      <>
197
        <p role="presentation">
198
          {'Sign in to your Azure account to select the Azure Storage ' +
199
            "accounts you'd like to associate with this bot. "}
200
          <LinkButton className={styles.dialogLink} linkRole={true} onClick={this.onAzureStorageDocsClick}>
201
            Learn more about Azure Storage.
202
          </LinkButton>
203
        </p>
204
        <p role="presentation">
205
          {`Alternatively, you can `}
206
          <LinkButton className={styles.dialogLink} onClick={this.props.addServiceManually}>
207
            connect to a Azure Storage account manually.
208
          </LinkButton>
209
        </p>
210
      </>
211
    );
212
  }
213

214
  private get cosmosDbContent(): ReactNode {
215
    return (
×
216
      <>
217
        <p role="presentation">
218
          {'Sign in to your Azure account to select the Azure Cosmos DB ' +
219
            "accounts you'd like to associate with this bot. "}
220
          <LinkButton className={styles.dialogLink} linkRole={true} onClick={this.onAzureCosmosDbDocsClick}>
221
            Learn more about Azure Cosmos DB.
222
          </LinkButton>
223
        </p>
224
        <p role="presentation">
225
          {`Alternatively, you can `}
226
          <LinkButton className={styles.dialogLink} onClick={this.props.addServiceManually}>
227
            connect to a Azure Cosmos DB account manually.
228
          </LinkButton>
229
        </p>
230
      </>
231
    );
232
  }
233
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc