mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-02-16 17:25:58 +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 { EditorReact } from "Explorer/Controls/Editor/EditorReact";
|
||||||
import { CopilotMessage } from "Explorer/QueryCopilot/Shared/QueryCopilotInterfaces";
|
import { CopilotMessage } from "Explorer/QueryCopilot/Shared/QueryCopilotInterfaces";
|
||||||
import { OutputBubbleButtons } from "Explorer/QueryCopilot/V2/Bubbles/Output/Buttons/OutputBubbleButtons";
|
import { OutputBubbleButtons } from "Explorer/QueryCopilot/V2/Bubbles/Output/Buttons/OutputBubbleButtons";
|
||||||
|
import { userContext } from "UserContext";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
|
|
||||||
export const OutputBubble = ({ copilotMessage }: { copilotMessage: CopilotMessage }): JSX.Element => {
|
export const OutputBubble = ({ copilotMessage }: { copilotMessage: CopilotMessage }): JSX.Element => {
|
||||||
const [windowHeight, setWindowHeight] = useState<string>();
|
const [windowHeight, setWindowHeight] = useState<string>();
|
||||||
|
const textHeightWithPadding = 16;
|
||||||
|
|
||||||
const calculateQueryWindowHeight = (): string => {
|
const calculateQueryWindowHeight = (): string => {
|
||||||
const calculatedHeight = document.getElementById("outputBubble")?.clientHeight * (3 / 5);
|
const outputWidth = document.getElementById("outputBubble")?.clientWidth;
|
||||||
return `${calculatedHeight}px`;
|
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(() => {
|
React.useEffect(() => {
|
||||||
setWindowHeight(calculateQueryWindowHeight());
|
if (userContext.features.copilotChatFixedMonacoEditorHeight) {
|
||||||
|
setWindowHeight(`${textHeightWithPadding * 5}px`);
|
||||||
|
} else {
|
||||||
|
setWindowHeight(calculateQueryWindowHeight());
|
||||||
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -40,6 +40,7 @@ export type Features = {
|
|||||||
readonly copilotVersion?: string;
|
readonly copilotVersion?: string;
|
||||||
readonly disableCopilotPhoenixGateaway: boolean;
|
readonly disableCopilotPhoenixGateaway: boolean;
|
||||||
readonly enableCopilotFullSchema: boolean;
|
readonly enableCopilotFullSchema: boolean;
|
||||||
|
readonly copilotChatFixedMonacoEditorHeight: boolean;
|
||||||
|
|
||||||
// can be set via both flight and feature flag
|
// can be set via both flight and feature flag
|
||||||
autoscaleDefault: boolean;
|
autoscaleDefault: boolean;
|
||||||
@ -112,6 +113,7 @@ export function extractFeatures(given = new URLSearchParams(window.location.sear
|
|||||||
copilotVersion: get("copilotversion") ?? "v1.0",
|
copilotVersion: get("copilotversion") ?? "v1.0",
|
||||||
disableCopilotPhoenixGateaway: "true" === get("disablecopilotphoenixgateaway"),
|
disableCopilotPhoenixGateaway: "true" === get("disablecopilotphoenixgateaway"),
|
||||||
enableCopilotFullSchema: "true" === get("enablecopilotfullschema", "true"),
|
enableCopilotFullSchema: "true" === get("enablecopilotfullschema", "true"),
|
||||||
|
copilotChatFixedMonacoEditorHeight: "true" === get("copilotchatfixedmonacoeditorheight"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user