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> {
|
public async configureCopilot(): Promise<void> {
|
||||||
if (userContext.apiType !== "SQL") {
|
if (userContext.apiType !== "SQL" || !userContext.subscriptionId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const copilotEnabled = await getCopilotEnabled();
|
const copilotEnabledPromise = getCopilotEnabled();
|
||||||
const copilotUserDBEnabled = await isCopilotFeatureRegistered(userContext.subscriptionId);
|
const copilotUserDBEnabledPromise = isCopilotFeatureRegistered(userContext.subscriptionId);
|
||||||
|
const [copilotEnabled, copilotUserDBEnabled] = await Promise.all([
|
||||||
|
copilotEnabledPromise,
|
||||||
|
copilotUserDBEnabledPromise,
|
||||||
|
]);
|
||||||
useQueryCopilot.getState().setCopilotEnabled(copilotEnabled);
|
useQueryCopilot.getState().setCopilotEnabled(copilotEnabled);
|
||||||
useQueryCopilot.getState().setCopilotUserDBEnabled(copilotUserDBEnabled);
|
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 Explorer from "Explorer/Explorer";
|
||||||
import { QueryCopilotFeedbackModal } from "Explorer/QueryCopilot/Modal/QueryCopilotFeedbackModal";
|
import { QueryCopilotFeedbackModal } from "Explorer/QueryCopilot/Modal/QueryCopilotFeedbackModal";
|
||||||
import { useCopilotStore } from "Explorer/QueryCopilot/QueryCopilotContext";
|
import { useCopilotStore } from "Explorer/QueryCopilot/QueryCopilotContext";
|
||||||
|
@ -83,42 +83,6 @@ describe("Query Copilot Feedback Modal snapshot test", () => {
|
||||||
expect(wrapper).toMatchSnapshot();
|
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", () => {
|
it("should not render dont show again button", () => {
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<QueryCopilotFeedbackModal
|
<QueryCopilotFeedbackModal
|
||||||
|
@ -219,7 +183,6 @@ describe("Query Copilot Feedback Modal snapshot test", () => {
|
||||||
generatedQuery: "test query",
|
generatedQuery: "test query",
|
||||||
userPrompt: "test prompt",
|
userPrompt: "test prompt",
|
||||||
description: "",
|
description: "",
|
||||||
contact: getUserEmail(),
|
|
||||||
},
|
},
|
||||||
explorer: explorer,
|
explorer: explorer,
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import {
|
import {
|
||||||
Checkbox,
|
Checkbox,
|
||||||
ChoiceGroup,
|
|
||||||
DefaultButton,
|
DefaultButton,
|
||||||
IconButton,
|
IconButton,
|
||||||
Link,
|
Link,
|
||||||
|
@ -14,7 +13,6 @@ import Explorer from "Explorer/Explorer";
|
||||||
import { useCopilotStore } from "Explorer/QueryCopilot/QueryCopilotContext";
|
import { useCopilotStore } from "Explorer/QueryCopilot/QueryCopilotContext";
|
||||||
import { SubmitFeedback } from "Explorer/QueryCopilot/Shared/QueryCopilotClient";
|
import { SubmitFeedback } from "Explorer/QueryCopilot/Shared/QueryCopilotClient";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { getUserEmail } from "../../../Utils/UserUtils";
|
|
||||||
|
|
||||||
export const QueryCopilotFeedbackModal = ({
|
export const QueryCopilotFeedbackModal = ({
|
||||||
explorer,
|
explorer,
|
||||||
|
@ -35,16 +33,14 @@ export const QueryCopilotFeedbackModal = ({
|
||||||
closeFeedbackModal,
|
closeFeedbackModal,
|
||||||
setHideFeedbackModalForLikedQueries,
|
setHideFeedbackModalForLikedQueries,
|
||||||
} = useCopilotStore();
|
} = useCopilotStore();
|
||||||
const [isContactAllowed, setIsContactAllowed] = React.useState<boolean>(false);
|
|
||||||
const [description, setDescription] = React.useState<string>("");
|
const [description, setDescription] = React.useState<string>("");
|
||||||
const [doNotShowAgainChecked, setDoNotShowAgainChecked] = React.useState<boolean>(false);
|
const [doNotShowAgainChecked, setDoNotShowAgainChecked] = React.useState<boolean>(false);
|
||||||
const [contact, setContact] = React.useState<string>(getUserEmail());
|
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
closeFeedbackModal();
|
closeFeedbackModal();
|
||||||
setHideFeedbackModalForLikedQueries(doNotShowAgainChecked);
|
setHideFeedbackModalForLikedQueries(doNotShowAgainChecked);
|
||||||
SubmitFeedback({
|
SubmitFeedback({
|
||||||
params: { generatedQuery, likeQuery, description, userPrompt, contact },
|
params: { generatedQuery, likeQuery, description, userPrompt },
|
||||||
explorer,
|
explorer,
|
||||||
databaseId,
|
databaseId,
|
||||||
containerId,
|
containerId,
|
||||||
|
@ -77,30 +73,6 @@ export const QueryCopilotFeedbackModal = ({
|
||||||
defaultValue={generatedQuery}
|
defaultValue={generatedQuery}
|
||||||
readOnly
|
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 }}>
|
<Text style={{ fontSize: 12, marginBottom: 14 }}>
|
||||||
By pressing submit, your feedback will be used to improve Microsoft products and services. Please see the{" "}
|
By pressing submit, your feedback will be used to improve Microsoft products and services. Please see the{" "}
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
.modalContentPadding {
|
.modalContentPadding {
|
||||||
padding-top: 15px;
|
padding-top: 15px;
|
||||||
width: 513px;
|
width: 513px;
|
||||||
height: 638px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.exitPadding {
|
.exitPadding {
|
||||||
|
@ -39,7 +38,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.buttonPadding {
|
.buttonPadding {
|
||||||
padding: 15px 0px 0px 0px;
|
padding: 15px 0px 15px 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tryButton {
|
.tryButton {
|
||||||
|
|
|
@ -23,7 +23,7 @@ export const WelcomeModal = ({ visible }: { visible: boolean }): JSX.Element =>
|
||||||
isBlocking={false}
|
isBlocking={false}
|
||||||
styles={{
|
styles={{
|
||||||
main: {
|
main: {
|
||||||
maxHeight: 530,
|
maxHeight: 600,
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
overflow: "hidden",
|
overflow: "hidden",
|
||||||
},
|
},
|
||||||
|
@ -53,7 +53,7 @@ export const WelcomeModal = ({ visible }: { visible: boolean }): JSX.Element =>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack horizontalAlign="center">
|
<Stack horizontalAlign="center">
|
||||||
<Stack.Item align="center" style={{ textAlign: "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>
|
||||||
<Stack.Item align="center" className="text">
|
<Stack.Item align="center" className="text">
|
||||||
<Stack horizontal>
|
<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
|
<Text
|
||||||
style={
|
style={
|
||||||
Object {
|
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
|
<Text
|
||||||
style={
|
style={
|
||||||
Object {
|
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
|
<Text
|
||||||
style={
|
style={
|
||||||
Object {
|
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
|
<Text
|
||||||
style={
|
style={
|
||||||
Object {
|
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
|
<Text
|
||||||
style={
|
style={
|
||||||
Object {
|
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
|
<Text
|
||||||
style={
|
style={
|
||||||
Object {
|
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
|
<Text
|
||||||
style={
|
style={
|
||||||
Object {
|
Object {
|
||||||
|
|
|
@ -10,7 +10,7 @@ exports[`Query Copilot Welcome Modal snapshot test should render when isOpen is
|
||||||
Object {
|
Object {
|
||||||
"main": Object {
|
"main": Object {
|
||||||
"borderRadius": 10,
|
"borderRadius": 10,
|
||||||
"maxHeight": 530,
|
"maxHeight": 600,
|
||||||
"overflow": "hidden",
|
"overflow": "hidden",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ exports[`Query Copilot Welcome Modal snapshot test should render when isOpen is
|
||||||
<Text
|
<Text
|
||||||
className="title bold"
|
className="title bold"
|
||||||
>
|
>
|
||||||
Welcome to Copilot in Azure Cosmos DB
|
Welcome to Microsoft Copilot for Azure in Cosmos DB (preview)
|
||||||
</Text>
|
</Text>
|
||||||
</StackItem>
|
</StackItem>
|
||||||
<StackItem
|
<StackItem
|
||||||
|
|
|
@ -19,6 +19,7 @@ import {
|
||||||
TextField,
|
TextField,
|
||||||
} from "@fluentui/react";
|
} from "@fluentui/react";
|
||||||
import { useBoolean } from "@fluentui/react-hooks";
|
import { useBoolean } from "@fluentui/react-hooks";
|
||||||
|
import { HttpStatusCodes } from "Common/Constants";
|
||||||
import { handleError } from "Common/ErrorHandlingUtils";
|
import { handleError } from "Common/ErrorHandlingUtils";
|
||||||
import { createUri } from "Common/UrlUtility";
|
import { createUri } from "Common/UrlUtility";
|
||||||
import { WelcomeModal } from "Explorer/QueryCopilot/Modal/WelcomeModal";
|
import { WelcomeModal } from "Explorer/QueryCopilot/Modal/WelcomeModal";
|
||||||
|
@ -53,7 +54,15 @@ type QueryCopilotPromptProps = QueryCopilotProps & {
|
||||||
|
|
||||||
const promptStyles: IButtonStyles = {
|
const promptStyles: IButtonStyles = {
|
||||||
root: { border: 0, selectors: { ":hover": { outline: "1px dashed #605e5c" } } },
|
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> = ({
|
export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
|
||||||
|
@ -98,6 +107,7 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
|
||||||
setGeneratedQueryComments,
|
setGeneratedQueryComments,
|
||||||
setQueryResults,
|
setQueryResults,
|
||||||
setErrorMessage,
|
setErrorMessage,
|
||||||
|
errorMessage,
|
||||||
} = useCopilotStore();
|
} = useCopilotStore();
|
||||||
|
|
||||||
const sampleProps: SamplePromptsProps = {
|
const sampleProps: SamplePromptsProps = {
|
||||||
|
@ -230,6 +240,16 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
|
||||||
responseCode: response.status,
|
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 {
|
} else {
|
||||||
handleError(JSON.stringify(generateSQLQueryResponse), "copilotInternalServerError");
|
handleError(JSON.stringify(generateSQLQueryResponse), "copilotInternalServerError");
|
||||||
useTabs.getState().setIsQueryErrorThrown(true);
|
useTabs.getState().setIsQueryErrorThrown(true);
|
||||||
|
@ -361,7 +381,7 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
|
||||||
{isGeneratingQuery && <Spinner style={{ marginLeft: 8 }} />}
|
{isGeneratingQuery && <Spinner style={{ marginLeft: 8 }} />}
|
||||||
{showSamplePrompts && (
|
{showSamplePrompts && (
|
||||||
<Callout
|
<Callout
|
||||||
styles={{ root: { minWidth: 400 } }}
|
styles={{ root: { minWidth: 400, maxWidth: "70vw" } }}
|
||||||
target="#naturalLanguageInput"
|
target="#naturalLanguageInput"
|
||||||
isBeakVisible={false}
|
isBeakVisible={false}
|
||||||
onDismiss={() => setShowSamplePrompts(false)}
|
onDismiss={() => setShowSamplePrompts(false)}
|
||||||
|
@ -393,7 +413,7 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
|
||||||
setShowSamplePrompts(false);
|
setShowSamplePrompts(false);
|
||||||
inputEdited.current = true;
|
inputEdited.current = true;
|
||||||
}}
|
}}
|
||||||
onRenderIcon={() => <Image src={RecentIcon} />}
|
onRenderIcon={() => <Image src={RecentIcon} styles={{ root: { overflow: "unset" } }} />}
|
||||||
styles={promptStyles}
|
styles={promptStyles}
|
||||||
>
|
>
|
||||||
{history}
|
{history}
|
||||||
|
@ -469,7 +489,7 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
|
||||||
</Link>
|
</Link>
|
||||||
{showErrorMessageBar && (
|
{showErrorMessageBar && (
|
||||||
<MessageBar messageBarType={MessageBarType.error}>
|
<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>
|
</MessageBar>
|
||||||
)}
|
)}
|
||||||
{showInvalidQueryMessageBar && (
|
{showInvalidQueryMessageBar && (
|
||||||
|
|
|
@ -35,18 +35,38 @@ import { QueryCopilotState, useQueryCopilot } from "hooks/useQueryCopilot";
|
||||||
import { useTabs } from "hooks/useTabs";
|
import { useTabs } from "hooks/useTabs";
|
||||||
import * as StringUtility from "../../../Shared/StringUtility";
|
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> => {
|
export const isCopilotFeatureRegistered = async (subscriptionId: string): Promise<boolean> => {
|
||||||
const api_version = "2021-07-01";
|
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 authorizationHeader: AuthorizationTokenHeaderMetadata = getAuthorizationHeader();
|
||||||
const headers = { [authorizationHeader.header]: authorizationHeader.token };
|
const headers = { [authorizationHeader.header]: authorizationHeader.token };
|
||||||
|
|
||||||
let response;
|
let response;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
response = await window.fetch(url, {
|
response = await fetchWithTimeout(url, headers);
|
||||||
headers,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -67,9 +87,7 @@ export const getCopilotEnabled = async (): Promise<boolean> => {
|
||||||
let response;
|
let response;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
response = await window.fetch(url, {
|
response = await fetchWithTimeout(url, headers);
|
||||||
headers,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -443,7 +443,7 @@ export default class QueryTabComponent extends React.Component<IQueryTabComponen
|
||||||
onCommandClick: () => {
|
onCommandClick: () => {
|
||||||
this._toggleCopilot(!this.state.copilotActive);
|
this._toggleCopilot(!this.state.copilotActive);
|
||||||
},
|
},
|
||||||
commandButtonLabel: "Copilot",
|
commandButtonLabel: this.state.copilotActive ? "Disable Copilot" : "Enable Copilot",
|
||||||
ariaLabel: "Copilot",
|
ariaLabel: "Copilot",
|
||||||
hasPopup: false,
|
hasPopup: false,
|
||||||
};
|
};
|
||||||
|
|
|
@ -58,19 +58,21 @@ export function useKnockoutExplorer(platform: Platform): Explorer {
|
||||||
userContext.features.phoenixNotebooks = true;
|
userContext.features.phoenixNotebooks = true;
|
||||||
userContext.features.phoenixFeatures = true;
|
userContext.features.phoenixFeatures = true;
|
||||||
}
|
}
|
||||||
|
let explorer: Explorer;
|
||||||
if (platform === Platform.Hosted) {
|
if (platform === Platform.Hosted) {
|
||||||
const explorer = await configureHosted();
|
explorer = await configureHosted();
|
||||||
setExplorer(explorer);
|
|
||||||
} else if (platform === Platform.Emulator) {
|
} else if (platform === Platform.Emulator) {
|
||||||
const explorer = configureEmulator();
|
explorer = configureEmulator();
|
||||||
setExplorer(explorer);
|
|
||||||
} else if (platform === Platform.Portal) {
|
} else if (platform === Platform.Portal) {
|
||||||
const explorer = await configurePortal();
|
explorer = await configurePortal();
|
||||||
setExplorer(explorer);
|
|
||||||
} else if (platform === Platform.Fabric) {
|
} else if (platform === Platform.Fabric) {
|
||||||
const explorer = await configureFabric();
|
explorer = await configureFabric();
|
||||||
setExplorer(explorer);
|
|
||||||
}
|
}
|
||||||
|
if (explorer && userContext.features.enableCopilot) {
|
||||||
|
await updateContextForCopilot(explorer);
|
||||||
|
await updateContextForSampleData(explorer);
|
||||||
|
}
|
||||||
|
setExplorer(explorer);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
effect();
|
effect();
|
||||||
|
@ -79,9 +81,6 @@ export function useKnockoutExplorer(platform: Platform): Explorer {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (explorer) {
|
if (explorer) {
|
||||||
applyExplorerBindings(explorer);
|
applyExplorerBindings(explorer);
|
||||||
if (userContext.features.enableCopilot) {
|
|
||||||
updateContextForCopilot(explorer).then(() => updateContextForSampleData(explorer));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, [explorer]);
|
}, [explorer]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue