Skip to content

Commit c49c843

Browse files
committed
fix: add flag
1 parent dbdce22 commit c49c843

File tree

6 files changed

+21
-4
lines changed

6 files changed

+21
-4
lines changed

package-lock.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/containers/Tenant/Query/QueryEditor/QueryEditor.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {cn} from '../../../../utils/cn';
2727
import {
2828
DEFAULT_IS_QUERY_RESULT_COLLAPSED,
2929
DEFAULT_SIZE_RESULT_PANE_KEY,
30+
ENABLE_QUERY_STREAMING,
3031
LAST_USED_QUERY_ACTION_KEY,
3132
} from '../../../../utils/constants';
3233
import {
@@ -90,7 +91,8 @@ export default function QueryEditor(props: QueryEditorProps) {
9091
LAST_USED_QUERY_ACTION_KEY,
9192
);
9293
const [lastExecutedQueryText, setLastExecutedQueryText] = React.useState<string>('');
93-
const isStreamingSupported = useStreamingAvailable();
94+
const [isQueryStreamingEnabled] = useSetting(ENABLE_QUERY_STREAMING);
95+
const isStreamingEnabled = useStreamingAvailable() && isQueryStreamingEnabled;
9496

9597
const [sendQuery] = queryApi.useUseSendQueryMutation();
9698
const [streamQuery] = queryApi.useUseStreamQueryMutation();
@@ -130,7 +132,7 @@ export default function QueryEditor(props: QueryEditorProps) {
130132
}
131133
const queryId = uuidv4();
132134

133-
if (isStreamingSupported) {
135+
if (isStreamingEnabled) {
134136
runningQueryRef.current = streamQuery({
135137
actionType: 'execute',
136138
query: text,
@@ -190,12 +192,12 @@ export default function QueryEditor(props: QueryEditorProps) {
190192
});
191193

192194
const handleCancelRunningQuery = React.useCallback(() => {
193-
if (isStreamingSupported && runningQueryRef.current) {
195+
if (isStreamingEnabled && runningQueryRef.current) {
194196
runningQueryRef.current.abort();
195197
} else if (result?.queryId) {
196198
sendCancelQuery({queryId: result?.queryId, database: tenantName});
197199
}
198-
}, [isStreamingSupported, result?.queryId, sendCancelQuery, tenantName]);
200+
}, [isStreamingEnabled, result?.queryId, sendCancelQuery, tenantName]);
199201

200202
const onCollapseResultHandler = () => {
201203
dispatchResultVisibilityState(PaneVisibilityActionTypes.triggerCollapse);

src/containers/UserSettings/i18n/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
"settings.editor.codeAssistant.title": "Code Assistant",
1818
"settings.editor.codeAssistant.description": "Use Code Assistant for autocomplete.",
1919

20+
"settings.editor.queryStreaming.title": "Query Streaming",
21+
"settings.editor.queryStreaming.description": "Use streaming api for query results.",
22+
2023
"settings.editor.autocomplete-on-enter.title": "Accept suggestion on Enter",
2124
"settings.editor.autocomplete-on-enter.description": "Controls whether suggestions should be accepted on Enter, in addition to Tab. Helps to avoid ambiguity between inserting new lines or accepting suggestions.",
2225

src/containers/UserSettings/settings.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ENABLE_AUTOCOMPLETE,
99
ENABLE_CODE_ASSISTANT,
1010
ENABLE_NETWORK_TABLE_KEY,
11+
ENABLE_QUERY_STREAMING,
1112
INVERTED_DISKS_KEY,
1213
LANGUAGE_KEY,
1314
SHOW_DOMAIN_DATABASE_KEY,
@@ -127,6 +128,12 @@ export const enableCodeAssistantSetting: SettingProps = {
127128
description: i18n('settings.editor.codeAssistant.description'),
128129
};
129130

131+
export const enableQueryStreamingSetting: SettingProps = {
132+
settingKey: ENABLE_QUERY_STREAMING,
133+
title: i18n('settings.editor.queryStreaming.title'),
134+
description: i18n('settings.editor.queryStreaming.description'),
135+
};
136+
130137
export const autocompleteOnEnterSetting: SettingProps = {
131138
settingKey: AUTOCOMPLETE_ON_ENTER,
132139
title: i18n('settings.editor.autocomplete-on-enter.title'),

src/services/settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ENABLE_AUTOCOMPLETE,
99
ENABLE_CODE_ASSISTANT,
1010
ENABLE_NETWORK_TABLE_KEY,
11+
ENABLE_QUERY_STREAMING,
1112
INVERTED_DISKS_KEY,
1213
IS_HOTKEYS_HELP_HIDDEN_KEY,
1314
LANGUAGE_KEY,
@@ -44,6 +45,7 @@ export const DEFAULT_USER_SETTINGS = {
4445
[USE_CLUSTER_BALANCER_AS_BACKEND_KEY]: true,
4546
[ENABLE_AUTOCOMPLETE]: true,
4647
[ENABLE_CODE_ASSISTANT]: true,
48+
[ENABLE_QUERY_STREAMING]: false,
4749
[AUTOCOMPLETE_ON_ENTER]: true,
4850
[IS_HOTKEYS_HELP_HIDDEN_KEY]: false,
4951
[AUTO_REFRESH_INTERVAL]: 0,

src/utils/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ export const ENABLE_AUTOCOMPLETE = 'enableAutocomplete';
119119

120120
export const ENABLE_CODE_ASSISTANT = 'enableCodeAssistant';
121121

122+
export const ENABLE_QUERY_STREAMING = 'enableQueryStreaming';
123+
122124
export const AUTOCOMPLETE_ON_ENTER = 'autocompleteOnEnter';
123125

124126
export const IS_HOTKEYS_HELP_HIDDEN_KEY = 'isHotKeysHelpHidden';

0 commit comments

Comments
 (0)