Copy json results button (#1631)

* copy json button

* fixed formating issue

* moved icon to float right

* fixed formatting
This commit is contained in:
JustinKol 2023-10-03 15:01:05 -04:00 committed by GitHub
parent 90c1439d34
commit 12e8490350
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,6 +9,7 @@ import {
SelectionMode, SelectionMode,
Stack, Stack,
Text, Text,
IconButton,
TooltipHost, TooltipHost,
} from "@fluentui/react"; } from "@fluentui/react";
import { HttpHeaders, NormalizedEventKey } from "Common/Constants"; import { HttpHeaders, NormalizedEventKey } from "Common/Constants";
@ -24,6 +25,8 @@ import QueryEditorNext from "../../../../images/Query-Editor-Next.svg";
import RunQuery from "../../../../images/RunQuery.png"; import RunQuery from "../../../../images/RunQuery.png";
import InfoColor from "../../../../images/info_color.svg"; import InfoColor from "../../../../images/info_color.svg";
import { QueryResults } from "../../../Contracts/ViewModels"; import { QueryResults } from "../../../Contracts/ViewModels";
import copy from "clipboard-copy";
import CopilotCopy from "../../../../images/CopilotCopy.svg";
interface QueryResultProps { interface QueryResultProps {
isMongoDB: boolean; isMongoDB: boolean;
@ -352,6 +355,10 @@ export const QueryResultSection: React.FC<QueryResultProps> = ({
return items; return items;
}; };
const onClickCopyResults = (): void => {
copy(queryResultsString);
};
return ( return (
<Stack style={{ height: "100%" }}> <Stack style={{ height: "100%" }}>
{isMongoDB && queryEditorContent.length === 0 && ( {isMongoDB && queryEditorContent.length === 0 && (
@ -429,6 +436,17 @@ export const QueryResultSection: React.FC<QueryResultProps> = ({
</span> </span>
</> </>
)} )}
<IconButton
style={{
height: "100%",
verticalAlign: "middle",
float: "right",
}}
iconProps={{ imageProps: { src: CopilotCopy } }}
title="Copy to Clipboard"
ariaLabel="Copy"
onClick={onClickCopyResults}
/>
</div> </div>
{queryResults && queryResultsString?.length > 0 && !error && ( {queryResults && queryResultsString?.length > 0 && !error && (
<div <div