mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 06:56:38 +00:00
Add feature flag for fixed output editor height or calculated height (#1606)
This commit is contained in:
parent
4e5358185f
commit
c1c12019da
@ -2,18 +2,31 @@ import { Stack, Text } from "@fluentui/react";
|
||||
import { EditorReact } from "Explorer/Controls/Editor/EditorReact";
|
||||
import { CopilotMessage } from "Explorer/QueryCopilot/Shared/QueryCopilotInterfaces";
|
||||
import { OutputBubbleButtons } from "Explorer/QueryCopilot/V2/Bubbles/Output/Buttons/OutputBubbleButtons";
|
||||
import { userContext } from "UserContext";
|
||||
import React, { useState } from "react";
|
||||
|
||||
export const OutputBubble = ({ copilotMessage }: { copilotMessage: CopilotMessage }): JSX.Element => {
|
||||
const [windowHeight, setWindowHeight] = useState<string>();
|
||||
const textHeightWithPadding = 16;
|
||||
|
||||
const calculateQueryWindowHeight = (): string => {
|
||||
const calculatedHeight = document.getElementById("outputBubble")?.clientHeight * (3 / 5);
|
||||
return `${calculatedHeight}px`;
|
||||
const outputWidth = document.getElementById("outputBubble")?.clientWidth;
|
||||
const responseLength = copilotMessage.sqlQuery.length;
|
||||
|
||||
if (outputWidth > responseLength) {
|
||||
return `${textHeightWithPadding * 3}px`;
|
||||
} else {
|
||||
const neededLines = Math.ceil(responseLength / outputWidth);
|
||||
return `${neededLines * textHeightWithPadding}px`;
|
||||
}
|
||||
};
|
||||
|
||||
React.useEffect(() => {
|
||||
setWindowHeight(calculateQueryWindowHeight());
|
||||
if (userContext.features.copilotChatFixedMonacoEditorHeight) {
|
||||
setWindowHeight(`${textHeightWithPadding * 5}px`);
|
||||
} else {
|
||||
setWindowHeight(calculateQueryWindowHeight());
|
||||
}
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
@ -40,6 +40,7 @@ export type Features = {
|
||||
readonly copilotVersion?: string;
|
||||
readonly disableCopilotPhoenixGateaway: boolean;
|
||||
readonly enableCopilotFullSchema: boolean;
|
||||
readonly copilotChatFixedMonacoEditorHeight: boolean;
|
||||
|
||||
// can be set via both flight and feature flag
|
||||
autoscaleDefault: boolean;
|
||||
@ -112,6 +113,7 @@ export function extractFeatures(given = new URLSearchParams(window.location.sear
|
||||
copilotVersion: get("copilotversion") ?? "v1.0",
|
||||
disableCopilotPhoenixGateaway: "true" === get("disablecopilotphoenixgateaway"),
|
||||
enableCopilotFullSchema: "true" === get("enablecopilotfullschema", "true"),
|
||||
copilotChatFixedMonacoEditorHeight: "true" === get("copilotchatfixedmonacoeditorheight"),
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user