[Query Copilot] Generate query on enter (#1558)
This commit is contained in:
parent
4ab93a5a32
commit
38d13cc74e
|
@ -297,6 +297,12 @@ export const QueryCopilotTab: React.FC<QueryCopilotTabProps> = ({
|
||||||
setShowCallout(false);
|
setShowCallout(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const startGenerateQueryProcess = () => {
|
||||||
|
updateHistories();
|
||||||
|
generateSQLQuery();
|
||||||
|
resetButtonState();
|
||||||
|
};
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
useCommandBar.getState().setContextButtons(getCommandbarButtons());
|
useCommandBar.getState().setContextButtons(getCommandbarButtons());
|
||||||
}, [query, selectedQuery]);
|
}, [query, selectedQuery]);
|
||||||
|
@ -325,6 +331,11 @@ export const QueryCopilotTab: React.FC<QueryCopilotTabProps> = ({
|
||||||
inputEdited.current = true;
|
inputEdited.current = true;
|
||||||
setShowSamplePrompts(true);
|
setShowSamplePrompts(true);
|
||||||
}}
|
}}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === "Enter") {
|
||||||
|
startGenerateQueryProcess();
|
||||||
|
}
|
||||||
|
}}
|
||||||
style={{ lineHeight: 30 }}
|
style={{ lineHeight: 30 }}
|
||||||
styles={{ root: { width: "95%" } }}
|
styles={{ root: { width: "95%" } }}
|
||||||
disabled={isGeneratingQuery}
|
disabled={isGeneratingQuery}
|
||||||
|
@ -357,11 +368,7 @@ export const QueryCopilotTab: React.FC<QueryCopilotTabProps> = ({
|
||||||
iconProps={{ iconName: "Send" }}
|
iconProps={{ iconName: "Send" }}
|
||||||
disabled={isGeneratingQuery || !userPrompt.trim()}
|
disabled={isGeneratingQuery || !userPrompt.trim()}
|
||||||
style={{ marginLeft: 8 }}
|
style={{ marginLeft: 8 }}
|
||||||
onClick={() => {
|
onClick={() => startGenerateQueryProcess()}
|
||||||
updateHistories();
|
|
||||||
generateSQLQuery();
|
|
||||||
resetButtonState();
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
{isGeneratingQuery && <Spinner style={{ marginLeft: 8 }} />}
|
{isGeneratingQuery && <Spinner style={{ marginLeft: 8 }} />}
|
||||||
{showSamplePrompts && (
|
{showSamplePrompts && (
|
||||||
|
|
|
@ -54,6 +54,7 @@ exports[`Query copilot tab snapshot test should render with initial input 1`] =
|
||||||
id="naturalLanguageInput"
|
id="naturalLanguageInput"
|
||||||
onChange={[Function]}
|
onChange={[Function]}
|
||||||
onClick={[Function]}
|
onClick={[Function]}
|
||||||
|
onKeyDown={[Function]}
|
||||||
style={
|
style={
|
||||||
Object {
|
Object {
|
||||||
"lineHeight": 30,
|
"lineHeight": 30,
|
||||||
|
|
Loading…
Reference in New Issue