mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 06:56:38 +00:00
P1 bugs for copilot (#1689)
* P1 bugs for copilot * P1 bugs for copilot * P1 bugs for copilot * Update branding and AFEC * Update branding and AFEC * add timeout for ARM calls * increase test timeout * fix formatting * fix formatting * fix formatting * fix formatting * don't call ARM when connectionstring login
This commit is contained in:
parent
0e124f4881
commit
40b8127a6f
@ -1385,11 +1385,15 @@ export default class Explorer {
|
||||
}
|
||||
|
||||
public async configureCopilot(): Promise<void> {
|
||||
if (userContext.apiType !== "SQL") {
|
||||
if (userContext.apiType !== "SQL" || !userContext.subscriptionId) {
|
||||
return;
|
||||
}
|
||||
const copilotEnabled = await getCopilotEnabled();
|
||||
const copilotUserDBEnabled = await isCopilotFeatureRegistered(userContext.subscriptionId);
|
||||
const copilotEnabledPromise = getCopilotEnabled();
|
||||
const copilotUserDBEnabledPromise = isCopilotFeatureRegistered(userContext.subscriptionId);
|
||||
const [copilotEnabled, copilotUserDBEnabled] = await Promise.all([
|
||||
copilotEnabledPromise,
|
||||
copilotUserDBEnabledPromise,
|
||||
]);
|
||||
useQueryCopilot.getState().setCopilotEnabled(copilotEnabled);
|
||||
useQueryCopilot.getState().setCopilotUserDBEnabled(copilotUserDBEnabled);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Checkbox, ChoiceGroup, DefaultButton, IconButton, PrimaryButton, TextField } from "@fluentui/react";
|
||||
import { Checkbox, DefaultButton, IconButton, PrimaryButton, TextField } from "@fluentui/react";
|
||||
import Explorer from "Explorer/Explorer";
|
||||
import { QueryCopilotFeedbackModal } from "Explorer/QueryCopilot/Modal/QueryCopilotFeedbackModal";
|
||||
import { useCopilotStore } from "Explorer/QueryCopilot/QueryCopilotContext";
|
||||
@ -83,42 +83,6 @@ describe("Query Copilot Feedback Modal snapshot test", () => {
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should record user contact choice no", () => {
|
||||
const wrapper = shallow(
|
||||
<QueryCopilotFeedbackModal
|
||||
explorer={new Explorer()}
|
||||
databaseId="CopilotUserDb"
|
||||
containerId="CopilotUserContainer"
|
||||
mode="User"
|
||||
/>,
|
||||
);
|
||||
const contactAllowed = wrapper.find(ChoiceGroup);
|
||||
|
||||
contactAllowed.simulate("change", {}, { key: "no" });
|
||||
|
||||
expect(getUserEmail).toHaveBeenCalledTimes(3);
|
||||
expect(wrapper.find(ChoiceGroup).props().selectedKey).toEqual("no");
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should record user contact choice yes", () => {
|
||||
const wrapper = shallow(
|
||||
<QueryCopilotFeedbackModal
|
||||
explorer={new Explorer()}
|
||||
databaseId="CopilotUserDb"
|
||||
containerId="CopilotUserContainer"
|
||||
mode="User"
|
||||
/>,
|
||||
);
|
||||
const contactAllowed = wrapper.find(ChoiceGroup);
|
||||
|
||||
contactAllowed.simulate("change", {}, { key: "yes" });
|
||||
|
||||
expect(getUserEmail).toHaveBeenCalledTimes(4);
|
||||
expect(wrapper.find(ChoiceGroup).props().selectedKey).toEqual("yes");
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should not render dont show again button", () => {
|
||||
const wrapper = shallow(
|
||||
<QueryCopilotFeedbackModal
|
||||
@ -219,7 +183,6 @@ describe("Query Copilot Feedback Modal snapshot test", () => {
|
||||
generatedQuery: "test query",
|
||||
userPrompt: "test prompt",
|
||||
description: "",
|
||||
contact: getUserEmail(),
|
||||
},
|
||||
explorer: explorer,
|
||||
});
|
||||
|
@ -1,6 +1,5 @@
|
||||
import {
|
||||
Checkbox,
|
||||
ChoiceGroup,
|
||||
DefaultButton,
|
||||
IconButton,
|
||||
Link,
|
||||
@ -14,7 +13,6 @@ import Explorer from "Explorer/Explorer";
|
||||
import { useCopilotStore } from "Explorer/QueryCopilot/QueryCopilotContext";
|
||||
import { SubmitFeedback } from "Explorer/QueryCopilot/Shared/QueryCopilotClient";
|
||||
import React from "react";
|
||||
import { getUserEmail } from "../../../Utils/UserUtils";
|
||||
|
||||
export const QueryCopilotFeedbackModal = ({
|
||||
explorer,
|
||||
@ -35,16 +33,14 @@ export const QueryCopilotFeedbackModal = ({
|
||||
closeFeedbackModal,
|
||||
setHideFeedbackModalForLikedQueries,
|
||||
} = useCopilotStore();
|
||||
const [isContactAllowed, setIsContactAllowed] = React.useState<boolean>(false);
|
||||
const [description, setDescription] = React.useState<string>("");
|
||||
const [doNotShowAgainChecked, setDoNotShowAgainChecked] = React.useState<boolean>(false);
|
||||
const [contact, setContact] = React.useState<string>(getUserEmail());
|
||||
|
||||
const handleSubmit = () => {
|
||||
closeFeedbackModal();
|
||||
setHideFeedbackModalForLikedQueries(doNotShowAgainChecked);
|
||||
SubmitFeedback({
|
||||
params: { generatedQuery, likeQuery, description, userPrompt, contact },
|
||||
params: { generatedQuery, likeQuery, description, userPrompt },
|
||||
explorer,
|
||||
databaseId,
|
||||
containerId,
|
||||
@ -77,30 +73,6 @@ export const QueryCopilotFeedbackModal = ({
|
||||
defaultValue={generatedQuery}
|
||||
readOnly
|
||||
/>
|
||||
<ChoiceGroup
|
||||
styles={{
|
||||
root: {
|
||||
marginBottom: 14,
|
||||
},
|
||||
flexContainer: {
|
||||
selectors: {
|
||||
".ms-ChoiceField-field::before": { marginTop: 4 },
|
||||
".ms-ChoiceField-field::after": { marginTop: 4 },
|
||||
".ms-ChoiceFieldLabel": { paddingLeft: 6 },
|
||||
},
|
||||
},
|
||||
}}
|
||||
label="May we contact you about your feedback?"
|
||||
options={[
|
||||
{ key: "yes", text: "Yes, you may contact me." },
|
||||
{ key: "no", text: "No, do not contact me." },
|
||||
]}
|
||||
selectedKey={isContactAllowed ? "yes" : "no"}
|
||||
onChange={(_, option) => {
|
||||
setIsContactAllowed(option.key === "yes");
|
||||
setContact(option.key === "yes" ? getUserEmail() : "");
|
||||
}}
|
||||
></ChoiceGroup>
|
||||
<Text style={{ fontSize: 12, marginBottom: 14 }}>
|
||||
By pressing submit, your feedback will be used to improve Microsoft products and services. Please see the{" "}
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
.modalContentPadding {
|
||||
padding-top: 15px;
|
||||
width: 513px;
|
||||
height: 638px;
|
||||
}
|
||||
|
||||
.exitPadding {
|
||||
@ -39,7 +38,7 @@
|
||||
}
|
||||
|
||||
.buttonPadding {
|
||||
padding: 15px 0px 0px 0px;
|
||||
padding: 15px 0px 15px 0px;
|
||||
}
|
||||
|
||||
.tryButton {
|
||||
|
@ -23,7 +23,7 @@ export const WelcomeModal = ({ visible }: { visible: boolean }): JSX.Element =>
|
||||
isBlocking={false}
|
||||
styles={{
|
||||
main: {
|
||||
maxHeight: 530,
|
||||
maxHeight: 600,
|
||||
borderRadius: 10,
|
||||
overflow: "hidden",
|
||||
},
|
||||
@ -53,7 +53,7 @@ export const WelcomeModal = ({ visible }: { visible: boolean }): JSX.Element =>
|
||||
</Stack>
|
||||
<Stack horizontalAlign="center">
|
||||
<Stack.Item align="center" style={{ textAlign: "center" }}>
|
||||
<Text className="title bold">Welcome to Copilot in Azure Cosmos DB</Text>
|
||||
<Text className="title bold">Welcome to Microsoft Copilot for Azure in Cosmos DB (preview)</Text>
|
||||
</Stack.Item>
|
||||
<Stack.Item align="center" className="text">
|
||||
<Stack horizontal>
|
||||
|
@ -76,43 +76,6 @@ exports[`Query Copilot Feedback Modal snapshot test shoud render and match snaps
|
||||
}
|
||||
}
|
||||
/>
|
||||
<StyledChoiceGroup
|
||||
label="May we contact you about your feedback?"
|
||||
onChange={[Function]}
|
||||
options={
|
||||
Array [
|
||||
Object {
|
||||
"key": "yes",
|
||||
"text": "Yes, you may contact me.",
|
||||
},
|
||||
Object {
|
||||
"key": "no",
|
||||
"text": "No, do not contact me.",
|
||||
},
|
||||
]
|
||||
}
|
||||
selectedKey="no"
|
||||
styles={
|
||||
Object {
|
||||
"flexContainer": Object {
|
||||
"selectors": Object {
|
||||
".ms-ChoiceField-field::after": Object {
|
||||
"marginTop": 4,
|
||||
},
|
||||
".ms-ChoiceField-field::before": Object {
|
||||
"marginTop": 4,
|
||||
},
|
||||
".ms-ChoiceFieldLabel": Object {
|
||||
"paddingLeft": 6,
|
||||
},
|
||||
},
|
||||
},
|
||||
"root": Object {
|
||||
"marginBottom": 14,
|
||||
},
|
||||
}
|
||||
}
|
||||
/>
|
||||
<Text
|
||||
style={
|
||||
Object {
|
||||
@ -235,43 +198,6 @@ exports[`Query Copilot Feedback Modal snapshot test should cancel submission 1`]
|
||||
}
|
||||
}
|
||||
/>
|
||||
<StyledChoiceGroup
|
||||
label="May we contact you about your feedback?"
|
||||
onChange={[Function]}
|
||||
options={
|
||||
Array [
|
||||
Object {
|
||||
"key": "yes",
|
||||
"text": "Yes, you may contact me.",
|
||||
},
|
||||
Object {
|
||||
"key": "no",
|
||||
"text": "No, do not contact me.",
|
||||
},
|
||||
]
|
||||
}
|
||||
selectedKey="no"
|
||||
styles={
|
||||
Object {
|
||||
"flexContainer": Object {
|
||||
"selectors": Object {
|
||||
".ms-ChoiceField-field::after": Object {
|
||||
"marginTop": 4,
|
||||
},
|
||||
".ms-ChoiceField-field::before": Object {
|
||||
"marginTop": 4,
|
||||
},
|
||||
".ms-ChoiceFieldLabel": Object {
|
||||
"paddingLeft": 6,
|
||||
},
|
||||
},
|
||||
},
|
||||
"root": Object {
|
||||
"marginBottom": 14,
|
||||
},
|
||||
}
|
||||
}
|
||||
/>
|
||||
<Text
|
||||
style={
|
||||
Object {
|
||||
@ -394,43 +320,6 @@ exports[`Query Copilot Feedback Modal snapshot test should close on cancel click
|
||||
}
|
||||
}
|
||||
/>
|
||||
<StyledChoiceGroup
|
||||
label="May we contact you about your feedback?"
|
||||
onChange={[Function]}
|
||||
options={
|
||||
Array [
|
||||
Object {
|
||||
"key": "yes",
|
||||
"text": "Yes, you may contact me.",
|
||||
},
|
||||
Object {
|
||||
"key": "no",
|
||||
"text": "No, do not contact me.",
|
||||
},
|
||||
]
|
||||
}
|
||||
selectedKey="no"
|
||||
styles={
|
||||
Object {
|
||||
"flexContainer": Object {
|
||||
"selectors": Object {
|
||||
".ms-ChoiceField-field::after": Object {
|
||||
"marginTop": 4,
|
||||
},
|
||||
".ms-ChoiceField-field::before": Object {
|
||||
"marginTop": 4,
|
||||
},
|
||||
".ms-ChoiceFieldLabel": Object {
|
||||
"paddingLeft": 6,
|
||||
},
|
||||
},
|
||||
},
|
||||
"root": Object {
|
||||
"marginBottom": 14,
|
||||
},
|
||||
}
|
||||
}
|
||||
/>
|
||||
<Text
|
||||
style={
|
||||
Object {
|
||||
@ -553,43 +442,6 @@ exports[`Query Copilot Feedback Modal snapshot test should get user unput 1`] =
|
||||
}
|
||||
}
|
||||
/>
|
||||
<StyledChoiceGroup
|
||||
label="May we contact you about your feedback?"
|
||||
onChange={[Function]}
|
||||
options={
|
||||
Array [
|
||||
Object {
|
||||
"key": "yes",
|
||||
"text": "Yes, you may contact me.",
|
||||
},
|
||||
Object {
|
||||
"key": "no",
|
||||
"text": "No, do not contact me.",
|
||||
},
|
||||
]
|
||||
}
|
||||
selectedKey="no"
|
||||
styles={
|
||||
Object {
|
||||
"flexContainer": Object {
|
||||
"selectors": Object {
|
||||
".ms-ChoiceField-field::after": Object {
|
||||
"marginTop": 4,
|
||||
},
|
||||
".ms-ChoiceField-field::before": Object {
|
||||
"marginTop": 4,
|
||||
},
|
||||
".ms-ChoiceFieldLabel": Object {
|
||||
"paddingLeft": 6,
|
||||
},
|
||||
},
|
||||
},
|
||||
"root": Object {
|
||||
"marginBottom": 14,
|
||||
},
|
||||
}
|
||||
}
|
||||
/>
|
||||
<Text
|
||||
style={
|
||||
Object {
|
||||
@ -712,361 +564,6 @@ exports[`Query Copilot Feedback Modal snapshot test should not render dont show
|
||||
}
|
||||
}
|
||||
/>
|
||||
<StyledChoiceGroup
|
||||
label="May we contact you about your feedback?"
|
||||
onChange={[Function]}
|
||||
options={
|
||||
Array [
|
||||
Object {
|
||||
"key": "yes",
|
||||
"text": "Yes, you may contact me.",
|
||||
},
|
||||
Object {
|
||||
"key": "no",
|
||||
"text": "No, do not contact me.",
|
||||
},
|
||||
]
|
||||
}
|
||||
selectedKey="no"
|
||||
styles={
|
||||
Object {
|
||||
"flexContainer": Object {
|
||||
"selectors": Object {
|
||||
".ms-ChoiceField-field::after": Object {
|
||||
"marginTop": 4,
|
||||
},
|
||||
".ms-ChoiceField-field::before": Object {
|
||||
"marginTop": 4,
|
||||
},
|
||||
".ms-ChoiceFieldLabel": Object {
|
||||
"paddingLeft": 6,
|
||||
},
|
||||
},
|
||||
},
|
||||
"root": Object {
|
||||
"marginBottom": 14,
|
||||
},
|
||||
}
|
||||
}
|
||||
/>
|
||||
<Text
|
||||
style={
|
||||
Object {
|
||||
"fontSize": 12,
|
||||
"marginBottom": 14,
|
||||
}
|
||||
}
|
||||
>
|
||||
By pressing submit, your feedback will be used to improve Microsoft products and services. Please see the
|
||||
|
||||
<StyledLinkBase
|
||||
href="https://privacy.microsoft.com/privacystatement"
|
||||
target="_blank"
|
||||
>
|
||||
Privacy statement
|
||||
</StyledLinkBase>
|
||||
|
||||
for more information.
|
||||
</Text>
|
||||
<Stack
|
||||
horizontal={true}
|
||||
horizontalAlign="end"
|
||||
>
|
||||
<CustomizedPrimaryButton
|
||||
styles={
|
||||
Object {
|
||||
"root": Object {
|
||||
"marginRight": 8,
|
||||
},
|
||||
}
|
||||
}
|
||||
type="submit"
|
||||
>
|
||||
Submit
|
||||
</CustomizedPrimaryButton>
|
||||
<CustomizedDefaultButton
|
||||
onClick={[Function]}
|
||||
>
|
||||
Cancel
|
||||
</CustomizedDefaultButton>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</form>
|
||||
</Modal>
|
||||
`;
|
||||
|
||||
exports[`Query Copilot Feedback Modal snapshot test should record user contact choice no 1`] = `
|
||||
<Modal
|
||||
isOpen={false}
|
||||
>
|
||||
<form
|
||||
onSubmit={[Function]}
|
||||
>
|
||||
<Stack
|
||||
style={
|
||||
Object {
|
||||
"padding": 24,
|
||||
}
|
||||
}
|
||||
>
|
||||
<Stack
|
||||
horizontal={true}
|
||||
horizontalAlign="space-between"
|
||||
>
|
||||
<Text
|
||||
style={
|
||||
Object {
|
||||
"fontSize": 20,
|
||||
"fontWeight": 600,
|
||||
"marginBottom": 20,
|
||||
}
|
||||
}
|
||||
>
|
||||
Send feedback to Microsoft
|
||||
</Text>
|
||||
<CustomizedIconButton
|
||||
iconProps={
|
||||
Object {
|
||||
"iconName": "Cancel",
|
||||
}
|
||||
}
|
||||
onClick={[Function]}
|
||||
/>
|
||||
</Stack>
|
||||
<Text
|
||||
style={
|
||||
Object {
|
||||
"fontSize": 14,
|
||||
"marginBottom": 14,
|
||||
}
|
||||
}
|
||||
>
|
||||
Your feedback will help improve the experience.
|
||||
</Text>
|
||||
<StyledTextFieldBase
|
||||
label="Description"
|
||||
multiline={true}
|
||||
onChange={[Function]}
|
||||
placeholder="Provide more details"
|
||||
required={true}
|
||||
rows={3}
|
||||
styles={
|
||||
Object {
|
||||
"root": Object {
|
||||
"marginBottom": 14,
|
||||
},
|
||||
}
|
||||
}
|
||||
value=""
|
||||
/>
|
||||
<StyledTextFieldBase
|
||||
defaultValue="test query"
|
||||
label="Query generated"
|
||||
readOnly={true}
|
||||
styles={
|
||||
Object {
|
||||
"root": Object {
|
||||
"marginBottom": 14,
|
||||
},
|
||||
}
|
||||
}
|
||||
/>
|
||||
<StyledChoiceGroup
|
||||
label="May we contact you about your feedback?"
|
||||
onChange={[Function]}
|
||||
options={
|
||||
Array [
|
||||
Object {
|
||||
"key": "yes",
|
||||
"text": "Yes, you may contact me.",
|
||||
},
|
||||
Object {
|
||||
"key": "no",
|
||||
"text": "No, do not contact me.",
|
||||
},
|
||||
]
|
||||
}
|
||||
selectedKey="no"
|
||||
styles={
|
||||
Object {
|
||||
"flexContainer": Object {
|
||||
"selectors": Object {
|
||||
".ms-ChoiceField-field::after": Object {
|
||||
"marginTop": 4,
|
||||
},
|
||||
".ms-ChoiceField-field::before": Object {
|
||||
"marginTop": 4,
|
||||
},
|
||||
".ms-ChoiceFieldLabel": Object {
|
||||
"paddingLeft": 6,
|
||||
},
|
||||
},
|
||||
},
|
||||
"root": Object {
|
||||
"marginBottom": 14,
|
||||
},
|
||||
}
|
||||
}
|
||||
/>
|
||||
<Text
|
||||
style={
|
||||
Object {
|
||||
"fontSize": 12,
|
||||
"marginBottom": 14,
|
||||
}
|
||||
}
|
||||
>
|
||||
By pressing submit, your feedback will be used to improve Microsoft products and services. Please see the
|
||||
|
||||
<StyledLinkBase
|
||||
href="https://privacy.microsoft.com/privacystatement"
|
||||
target="_blank"
|
||||
>
|
||||
Privacy statement
|
||||
</StyledLinkBase>
|
||||
|
||||
for more information.
|
||||
</Text>
|
||||
<Stack
|
||||
horizontal={true}
|
||||
horizontalAlign="end"
|
||||
>
|
||||
<CustomizedPrimaryButton
|
||||
styles={
|
||||
Object {
|
||||
"root": Object {
|
||||
"marginRight": 8,
|
||||
},
|
||||
}
|
||||
}
|
||||
type="submit"
|
||||
>
|
||||
Submit
|
||||
</CustomizedPrimaryButton>
|
||||
<CustomizedDefaultButton
|
||||
onClick={[Function]}
|
||||
>
|
||||
Cancel
|
||||
</CustomizedDefaultButton>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</form>
|
||||
</Modal>
|
||||
`;
|
||||
|
||||
exports[`Query Copilot Feedback Modal snapshot test should record user contact choice yes 1`] = `
|
||||
<Modal
|
||||
isOpen={false}
|
||||
>
|
||||
<form
|
||||
onSubmit={[Function]}
|
||||
>
|
||||
<Stack
|
||||
style={
|
||||
Object {
|
||||
"padding": 24,
|
||||
}
|
||||
}
|
||||
>
|
||||
<Stack
|
||||
horizontal={true}
|
||||
horizontalAlign="space-between"
|
||||
>
|
||||
<Text
|
||||
style={
|
||||
Object {
|
||||
"fontSize": 20,
|
||||
"fontWeight": 600,
|
||||
"marginBottom": 20,
|
||||
}
|
||||
}
|
||||
>
|
||||
Send feedback to Microsoft
|
||||
</Text>
|
||||
<CustomizedIconButton
|
||||
iconProps={
|
||||
Object {
|
||||
"iconName": "Cancel",
|
||||
}
|
||||
}
|
||||
onClick={[Function]}
|
||||
/>
|
||||
</Stack>
|
||||
<Text
|
||||
style={
|
||||
Object {
|
||||
"fontSize": 14,
|
||||
"marginBottom": 14,
|
||||
}
|
||||
}
|
||||
>
|
||||
Your feedback will help improve the experience.
|
||||
</Text>
|
||||
<StyledTextFieldBase
|
||||
label="Description"
|
||||
multiline={true}
|
||||
onChange={[Function]}
|
||||
placeholder="Provide more details"
|
||||
required={true}
|
||||
rows={3}
|
||||
styles={
|
||||
Object {
|
||||
"root": Object {
|
||||
"marginBottom": 14,
|
||||
},
|
||||
}
|
||||
}
|
||||
value=""
|
||||
/>
|
||||
<StyledTextFieldBase
|
||||
defaultValue="test query"
|
||||
label="Query generated"
|
||||
readOnly={true}
|
||||
styles={
|
||||
Object {
|
||||
"root": Object {
|
||||
"marginBottom": 14,
|
||||
},
|
||||
}
|
||||
}
|
||||
/>
|
||||
<StyledChoiceGroup
|
||||
label="May we contact you about your feedback?"
|
||||
onChange={[Function]}
|
||||
options={
|
||||
Array [
|
||||
Object {
|
||||
"key": "yes",
|
||||
"text": "Yes, you may contact me.",
|
||||
},
|
||||
Object {
|
||||
"key": "no",
|
||||
"text": "No, do not contact me.",
|
||||
},
|
||||
]
|
||||
}
|
||||
selectedKey="yes"
|
||||
styles={
|
||||
Object {
|
||||
"flexContainer": Object {
|
||||
"selectors": Object {
|
||||
".ms-ChoiceField-field::after": Object {
|
||||
"marginTop": 4,
|
||||
},
|
||||
".ms-ChoiceField-field::before": Object {
|
||||
"marginTop": 4,
|
||||
},
|
||||
".ms-ChoiceFieldLabel": Object {
|
||||
"paddingLeft": 6,
|
||||
},
|
||||
},
|
||||
},
|
||||
"root": Object {
|
||||
"marginBottom": 14,
|
||||
},
|
||||
}
|
||||
}
|
||||
/>
|
||||
<Text
|
||||
style={
|
||||
Object {
|
||||
@ -1189,43 +686,6 @@ exports[`Query Copilot Feedback Modal snapshot test should render dont show agai
|
||||
}
|
||||
}
|
||||
/>
|
||||
<StyledChoiceGroup
|
||||
label="May we contact you about your feedback?"
|
||||
onChange={[Function]}
|
||||
options={
|
||||
Array [
|
||||
Object {
|
||||
"key": "yes",
|
||||
"text": "Yes, you may contact me.",
|
||||
},
|
||||
Object {
|
||||
"key": "no",
|
||||
"text": "No, do not contact me.",
|
||||
},
|
||||
]
|
||||
}
|
||||
selectedKey="no"
|
||||
styles={
|
||||
Object {
|
||||
"flexContainer": Object {
|
||||
"selectors": Object {
|
||||
".ms-ChoiceField-field::after": Object {
|
||||
"marginTop": 4,
|
||||
},
|
||||
".ms-ChoiceField-field::before": Object {
|
||||
"marginTop": 4,
|
||||
},
|
||||
".ms-ChoiceFieldLabel": Object {
|
||||
"paddingLeft": 6,
|
||||
},
|
||||
},
|
||||
},
|
||||
"root": Object {
|
||||
"marginBottom": 14,
|
||||
},
|
||||
}
|
||||
}
|
||||
/>
|
||||
<Text
|
||||
style={
|
||||
Object {
|
||||
@ -1363,43 +823,6 @@ exports[`Query Copilot Feedback Modal snapshot test should submit submission 1`]
|
||||
}
|
||||
}
|
||||
/>
|
||||
<StyledChoiceGroup
|
||||
label="May we contact you about your feedback?"
|
||||
onChange={[Function]}
|
||||
options={
|
||||
Array [
|
||||
Object {
|
||||
"key": "yes",
|
||||
"text": "Yes, you may contact me.",
|
||||
},
|
||||
Object {
|
||||
"key": "no",
|
||||
"text": "No, do not contact me.",
|
||||
},
|
||||
]
|
||||
}
|
||||
selectedKey="no"
|
||||
styles={
|
||||
Object {
|
||||
"flexContainer": Object {
|
||||
"selectors": Object {
|
||||
".ms-ChoiceField-field::after": Object {
|
||||
"marginTop": 4,
|
||||
},
|
||||
".ms-ChoiceField-field::before": Object {
|
||||
"marginTop": 4,
|
||||
},
|
||||
".ms-ChoiceFieldLabel": Object {
|
||||
"paddingLeft": 6,
|
||||
},
|
||||
},
|
||||
},
|
||||
"root": Object {
|
||||
"marginBottom": 14,
|
||||
},
|
||||
}
|
||||
}
|
||||
/>
|
||||
<Text
|
||||
style={
|
||||
Object {
|
||||
|
@ -10,7 +10,7 @@ exports[`Query Copilot Welcome Modal snapshot test should render when isOpen is
|
||||
Object {
|
||||
"main": Object {
|
||||
"borderRadius": 10,
|
||||
"maxHeight": 530,
|
||||
"maxHeight": 600,
|
||||
"overflow": "hidden",
|
||||
},
|
||||
}
|
||||
@ -78,7 +78,7 @@ exports[`Query Copilot Welcome Modal snapshot test should render when isOpen is
|
||||
<Text
|
||||
className="title bold"
|
||||
>
|
||||
Welcome to Copilot in Azure Cosmos DB
|
||||
Welcome to Microsoft Copilot for Azure in Cosmos DB (preview)
|
||||
</Text>
|
||||
</StackItem>
|
||||
<StackItem
|
||||
|
@ -19,6 +19,7 @@ import {
|
||||
TextField,
|
||||
} from "@fluentui/react";
|
||||
import { useBoolean } from "@fluentui/react-hooks";
|
||||
import { HttpStatusCodes } from "Common/Constants";
|
||||
import { handleError } from "Common/ErrorHandlingUtils";
|
||||
import { createUri } from "Common/UrlUtility";
|
||||
import { WelcomeModal } from "Explorer/QueryCopilot/Modal/WelcomeModal";
|
||||
@ -53,7 +54,15 @@ type QueryCopilotPromptProps = QueryCopilotProps & {
|
||||
|
||||
const promptStyles: IButtonStyles = {
|
||||
root: { border: 0, selectors: { ":hover": { outline: "1px dashed #605e5c" } } },
|
||||
label: { fontWeight: 400, textAlign: "left", paddingLeft: 8 },
|
||||
label: {
|
||||
fontWeight: 400,
|
||||
textAlign: "left",
|
||||
paddingLeft: 8,
|
||||
overflow: "hidden",
|
||||
whiteSpace: "nowrap",
|
||||
textOverflow: "ellipsis",
|
||||
},
|
||||
textContainer: { overflow: "hidden" },
|
||||
};
|
||||
|
||||
export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
|
||||
@ -98,6 +107,7 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
|
||||
setGeneratedQueryComments,
|
||||
setQueryResults,
|
||||
setErrorMessage,
|
||||
errorMessage,
|
||||
} = useCopilotStore();
|
||||
|
||||
const sampleProps: SamplePromptsProps = {
|
||||
@ -230,6 +240,16 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
|
||||
responseCode: response.status,
|
||||
});
|
||||
}
|
||||
} else if (response?.status === HttpStatusCodes.TooManyRequests) {
|
||||
handleError(JSON.stringify(generateSQLQueryResponse), "copilotTooManyRequestError");
|
||||
useTabs.getState().setIsQueryErrorThrown(true);
|
||||
setShowErrorMessageBar(true);
|
||||
setErrorMessage("Ratelimit exceeded 5 per 1 minute. Please try again after sometime");
|
||||
TelemetryProcessor.traceFailure(Action.QueryGenerationFromCopilotPrompt, {
|
||||
databaseName: databaseId,
|
||||
collectionId: containerId,
|
||||
responseCode: response.status,
|
||||
});
|
||||
} else {
|
||||
handleError(JSON.stringify(generateSQLQueryResponse), "copilotInternalServerError");
|
||||
useTabs.getState().setIsQueryErrorThrown(true);
|
||||
@ -361,7 +381,7 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
|
||||
{isGeneratingQuery && <Spinner style={{ marginLeft: 8 }} />}
|
||||
{showSamplePrompts && (
|
||||
<Callout
|
||||
styles={{ root: { minWidth: 400 } }}
|
||||
styles={{ root: { minWidth: 400, maxWidth: "70vw" } }}
|
||||
target="#naturalLanguageInput"
|
||||
isBeakVisible={false}
|
||||
onDismiss={() => setShowSamplePrompts(false)}
|
||||
@ -393,7 +413,7 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
|
||||
setShowSamplePrompts(false);
|
||||
inputEdited.current = true;
|
||||
}}
|
||||
onRenderIcon={() => <Image src={RecentIcon} />}
|
||||
onRenderIcon={() => <Image src={RecentIcon} styles={{ root: { overflow: "unset" } }} />}
|
||||
styles={promptStyles}
|
||||
>
|
||||
{history}
|
||||
@ -469,7 +489,7 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
|
||||
</Link>
|
||||
{showErrorMessageBar && (
|
||||
<MessageBar messageBarType={MessageBarType.error}>
|
||||
We ran into an error and were not able to execute query.
|
||||
{errorMessage ? errorMessage : "We ran into an error and were not able to execute query."}
|
||||
</MessageBar>
|
||||
)}
|
||||
{showInvalidQueryMessageBar && (
|
||||
|
@ -35,18 +35,38 @@ import { QueryCopilotState, useQueryCopilot } from "hooks/useQueryCopilot";
|
||||
import { useTabs } from "hooks/useTabs";
|
||||
import * as StringUtility from "../../../Shared/StringUtility";
|
||||
|
||||
async function fetchWithTimeout(
|
||||
url: string,
|
||||
headers: {
|
||||
[x: string]: string;
|
||||
},
|
||||
) {
|
||||
const timeout = 10000;
|
||||
const options = { timeout };
|
||||
|
||||
const controller = new AbortController();
|
||||
const id = setTimeout(() => controller.abort(), timeout);
|
||||
|
||||
const response = await window.fetch(url, {
|
||||
headers,
|
||||
...options,
|
||||
signal: controller.signal,
|
||||
});
|
||||
clearTimeout(id);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
export const isCopilotFeatureRegistered = async (subscriptionId: string): Promise<boolean> => {
|
||||
const api_version = "2021-07-01";
|
||||
const url = `${configContext.ARM_ENDPOINT}/subscriptions/${subscriptionId}/providers/Microsoft.Features/featureProviders/Microsoft.DocumentDB/subscriptionFeatureRegistrations/CopilotInAzureCDB?api-version=${api_version}`;
|
||||
const url = `${configContext.ARM_ENDPOINT}/subscriptions/${subscriptionId}/providers/Microsoft.Features/featureProviders/Microsoft.DocumentDB/subscriptionFeatureRegistrations/MicrosoftCopilotForAzureInCDB?api-version=${api_version}`;
|
||||
const authorizationHeader: AuthorizationTokenHeaderMetadata = getAuthorizationHeader();
|
||||
const headers = { [authorizationHeader.header]: authorizationHeader.token };
|
||||
|
||||
let response;
|
||||
|
||||
try {
|
||||
response = await window.fetch(url, {
|
||||
headers,
|
||||
});
|
||||
response = await fetchWithTimeout(url, headers);
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
@ -67,9 +87,7 @@ export const getCopilotEnabled = async (): Promise<boolean> => {
|
||||
let response;
|
||||
|
||||
try {
|
||||
response = await window.fetch(url, {
|
||||
headers,
|
||||
});
|
||||
response = await fetchWithTimeout(url, headers);
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
|
@ -443,7 +443,7 @@ export default class QueryTabComponent extends React.Component<IQueryTabComponen
|
||||
onCommandClick: () => {
|
||||
this._toggleCopilot(!this.state.copilotActive);
|
||||
},
|
||||
commandButtonLabel: "Copilot",
|
||||
commandButtonLabel: this.state.copilotActive ? "Disable Copilot" : "Enable Copilot",
|
||||
ariaLabel: "Copilot",
|
||||
hasPopup: false,
|
||||
};
|
||||
|
@ -58,19 +58,21 @@ export function useKnockoutExplorer(platform: Platform): Explorer {
|
||||
userContext.features.phoenixNotebooks = true;
|
||||
userContext.features.phoenixFeatures = true;
|
||||
}
|
||||
let explorer: Explorer;
|
||||
if (platform === Platform.Hosted) {
|
||||
const explorer = await configureHosted();
|
||||
setExplorer(explorer);
|
||||
explorer = await configureHosted();
|
||||
} else if (platform === Platform.Emulator) {
|
||||
const explorer = configureEmulator();
|
||||
setExplorer(explorer);
|
||||
explorer = configureEmulator();
|
||||
} else if (platform === Platform.Portal) {
|
||||
const explorer = await configurePortal();
|
||||
setExplorer(explorer);
|
||||
explorer = await configurePortal();
|
||||
} else if (platform === Platform.Fabric) {
|
||||
const explorer = await configureFabric();
|
||||
setExplorer(explorer);
|
||||
explorer = await configureFabric();
|
||||
}
|
||||
if (explorer && userContext.features.enableCopilot) {
|
||||
await updateContextForCopilot(explorer);
|
||||
await updateContextForSampleData(explorer);
|
||||
}
|
||||
setExplorer(explorer);
|
||||
}
|
||||
};
|
||||
effect();
|
||||
@ -79,9 +81,6 @@ export function useKnockoutExplorer(platform: Platform): Explorer {
|
||||
useEffect(() => {
|
||||
if (explorer) {
|
||||
applyExplorerBindings(explorer);
|
||||
if (userContext.features.enableCopilot) {
|
||||
updateContextForCopilot(explorer).then(() => updateContextForSampleData(explorer));
|
||||
}
|
||||
}
|
||||
}, [explorer]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user