[Query Copilot V2] Restructure code for V2 of copilot (#1577)

* Initial folder and code restructure

* Add snapshots

* Remove flag for local testing

* Remove unnecessary code

* Fix snapshot

* Update tests
This commit is contained in:
v-darkora
2023-08-16 10:10:21 +02:00
committed by GitHub
parent 96b88ac344
commit ceb66ed5b8
24 changed files with 963 additions and 253 deletions

View File

@@ -0,0 +1,10 @@
import { shallow } from "enzyme";
import React from "react";
import { WelcomeSidebarModal } from "./WelcomeSidebarModal";
describe("Footer snapshot test", () => {
it("should render ", () => {
const wrapper = shallow(<WelcomeSidebarModal />);
expect(wrapper).toMatchSnapshot();
});
});

View File

@@ -0,0 +1,127 @@
import { Image, Link, PrimaryButton, Stack, Text } from "@fluentui/react";
import { useQueryCopilot } from "hooks/useQueryCopilot";
import React from "react";
import Database from "../../../../../images/CopilotDatabase.svg";
import Flash from "../../../../../images/CopilotFlash.svg";
import CopilotSidebarWelcomeIllustration from "../../../../../images/CopilotSidebarWelcomeIllustration.svg";
import Thumb from "../../../../../images/CopilotThumb.svg";
export const WelcomeSidebarModal: React.FC = (): JSX.Element => {
const { setShowWelcomeSidebar } = useQueryCopilot();
const hideModal = () => {
setShowWelcomeSidebar(false);
window.localStorage.setItem("showWelcomeSidebar", "false");
};
React.useEffect(() => {
const showWelcomeSidebar = window.localStorage.getItem("showWelcomeSidebar");
setShowWelcomeSidebar(showWelcomeSidebar && showWelcomeSidebar === "false" ? false : true);
}, []);
return (
<Stack
style={{
width: "100%",
height: "100%",
overflow: "auto",
backgroundColor: "#FAFAFA",
}}
>
<div
style={{
margin: "20px 10px",
padding: "20px",
maxHeight: "100%",
boxSizing: "border-box",
borderRadius: "20px",
backgroundColor: "white",
}}
>
<Stack horizontalAlign="center" verticalAlign="center">
<Image src={CopilotSidebarWelcomeIllustration} />
</Stack>
<Stack>
<Stack.Item align="center" style={{ marginBottom: "10px" }}>
<Text className="title bold">Welcome to Copilot in CosmosDB</Text>
</Stack.Item>
<Stack.Item style={{ marginBottom: "15px" }}>
<Stack>
<Stack horizontal>
<Stack.Item align="start">
<Image src={Flash} />
</Stack.Item>
<Stack.Item align="center" style={{ marginLeft: "10px" }}>
<Text style={{ fontWeight: 600 }}>
Let copilot do the work for you
<br />
</Text>
</Stack.Item>
</Stack>
<Stack.Item style={{ textAlign: "start", marginLeft: "25px" }}>
<Text>
Ask Copilot to generate a query by describing the query in your words.
<br />
<Link href="http://aka.ms/cdb-copilot-learn-more">Learn more</Link>
</Text>
</Stack.Item>
</Stack>
</Stack.Item>
<Stack.Item style={{ marginBottom: "15px" }}>
<Stack>
<Stack horizontal>
<Stack.Item align="start">
<Image src={Thumb} />
</Stack.Item>
<Stack.Item align="center" style={{ marginLeft: "10px" }}>
<Text style={{ fontWeight: 600 }}>
Use your judgement
<br />
</Text>
</Stack.Item>
</Stack>
<Stack.Item style={{ textAlign: "start", marginLeft: "25px" }}>
<Text>
AI-generated content can have mistakes. Make sure its accurate and appropriate before using it.
<br />
<Link href="http://aka.ms/cdb-copilot-preview-terms">Read preview terms</Link>
</Text>
</Stack.Item>
</Stack>
</Stack.Item>
<Stack.Item style={{ marginBottom: "15px" }}>
<Stack>
<Stack horizontal>
<Stack.Item align="start">
<Image src={Database} />
</Stack.Item>
<Stack.Item align="center" style={{ marginLeft: "10px" }}>
<Text style={{ fontWeight: 600 }}>
Copilot currently works only a sample database
<br />
</Text>
</Stack.Item>
</Stack>
<Stack.Item style={{ textAlign: "start", marginLeft: "25px" }}>
<Text>
Copilot is setup on a sample database we have configured for you at no cost
<br />
<Link href="http://aka.ms/cdb-copilot-learn-more">Learn more</Link>
</Text>
</Stack.Item>
</Stack>
</Stack.Item>
</Stack>
<Stack>
<Stack.Item align="center">
<PrimaryButton style={{ width: "224px", height: "32px" }} onClick={hideModal}>
Get Started
</PrimaryButton>
</Stack.Item>
</Stack>
</div>
</Stack>
);
};

View File

@@ -0,0 +1,243 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Footer snapshot test should render 1`] = `
<Stack
style={
Object {
"backgroundColor": "#FAFAFA",
"height": "100%",
"overflow": "auto",
"width": "100%",
}
}
>
<div
style={
Object {
"backgroundColor": "white",
"borderRadius": "20px",
"boxSizing": "border-box",
"margin": "20px 10px",
"maxHeight": "100%",
"padding": "20px",
}
}
>
<Stack
horizontalAlign="center"
verticalAlign="center"
>
<Image
src=""
/>
</Stack>
<Stack>
<StackItem
align="center"
style={
Object {
"marginBottom": "10px",
}
}
>
<Text
className="title bold"
>
Welcome to Copilot in CosmosDB
</Text>
</StackItem>
<StackItem
style={
Object {
"marginBottom": "15px",
}
}
>
<Stack>
<Stack
horizontal={true}
>
<StackItem
align="start"
>
<Image
src=""
/>
</StackItem>
<StackItem
align="center"
style={
Object {
"marginLeft": "10px",
}
}
>
<Text
style={
Object {
"fontWeight": 600,
}
}
>
Let copilot do the work for you
<br />
</Text>
</StackItem>
</Stack>
<StackItem
style={
Object {
"marginLeft": "25px",
"textAlign": "start",
}
}
>
<Text>
Ask Copilot to generate a query by describing the query in your words.
<br />
<StyledLinkBase
href="http://aka.ms/cdb-copilot-learn-more"
>
Learn more
</StyledLinkBase>
</Text>
</StackItem>
</Stack>
</StackItem>
<StackItem
style={
Object {
"marginBottom": "15px",
}
}
>
<Stack>
<Stack
horizontal={true}
>
<StackItem
align="start"
>
<Image
src=""
/>
</StackItem>
<StackItem
align="center"
style={
Object {
"marginLeft": "10px",
}
}
>
<Text
style={
Object {
"fontWeight": 600,
}
}
>
Use your judgement
<br />
</Text>
</StackItem>
</Stack>
<StackItem
style={
Object {
"marginLeft": "25px",
"textAlign": "start",
}
}
>
<Text>
AI-generated content can have mistakes. Make sure its accurate and appropriate before using it.
<br />
<StyledLinkBase
href="http://aka.ms/cdb-copilot-preview-terms"
>
Read preview terms
</StyledLinkBase>
</Text>
</StackItem>
</Stack>
</StackItem>
<StackItem
style={
Object {
"marginBottom": "15px",
}
}
>
<Stack>
<Stack
horizontal={true}
>
<StackItem
align="start"
>
<Image
src=""
/>
</StackItem>
<StackItem
align="center"
style={
Object {
"marginLeft": "10px",
}
}
>
<Text
style={
Object {
"fontWeight": 600,
}
}
>
Copilot currently works only a sample database
<br />
</Text>
</StackItem>
</Stack>
<StackItem
style={
Object {
"marginLeft": "25px",
"textAlign": "start",
}
}
>
<Text>
Copilot is setup on a sample database we have configured for you at no cost
<br />
<StyledLinkBase
href="http://aka.ms/cdb-copilot-learn-more"
>
Learn more
</StyledLinkBase>
</Text>
</StackItem>
</Stack>
</StackItem>
</Stack>
<Stack>
<StackItem
align="center"
>
<CustomizedPrimaryButton
onClick={[Function]}
style={
Object {
"height": "32px",
"width": "224px",
}
}
>
Get Started
</CustomizedPrimaryButton>
</StackItem>
</Stack>
</div>
</Stack>
`;