Skip to content

Commit 174ec16

Browse files
committed
feat: turn streaming on by default
1 parent dbab46b commit 174ec16

File tree

9 files changed

+133
-52
lines changed

9 files changed

+133
-52
lines changed

src/containers/Tenant/Query/QuerySettingsDialog/QuerySettingsDialog.scss

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,13 @@
2828
flex: 6;
2929
}
3030

31-
&__limit-rows,
32-
&__timeout {
33-
width: 33.3%;
31+
&__limit-rows {
32+
width: 50%;
3433
margin-right: var(--g-spacing-2);
3534
}
3635

37-
&__timeout-suffix {
38-
display: flex;
39-
align-items: center;
40-
41-
color: var(--g-color-text-secondary);
42-
}
43-
44-
&__documentation-link {
45-
display: flex;
46-
align-items: center;
47-
48-
margin-left: var(--g-spacing-4);
36+
&__postfix {
37+
margin-right: var(--g-spacing-2);
4938

5039
color: var(--g-color-text-secondary);
5140
}

src/containers/Tenant/Query/QuerySettingsDialog/QuerySettingsDialog.tsx

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22

3-
import {Dialog, Link as ExternalLink, Flex, TextInput, Tooltip} from '@gravity-ui/uikit';
3+
import {Button, Dialog, Flex, TextInput, Tooltip} from '@gravity-ui/uikit';
44
import {zodResolver} from '@hookform/resolvers/zod';
55
import {Controller, useForm} from 'react-hook-form';
66

@@ -18,9 +18,10 @@ import {
1818
useTypedDispatch,
1919
useTypedSelector,
2020
} from '../../../../utils/hooks';
21-
import {querySettingsValidationSchema} from '../../../../utils/query';
21+
import {DEFAULT_QUERY_SETTINGS, querySettingsValidationSchema} from '../../../../utils/query';
2222

2323
import {QuerySettingsSelect} from './QuerySettingsSelect';
24+
import {QuerySettingsTimeout} from './QuerySettingsTimeout';
2425
import {QUERY_SETTINGS_FIELD_SETTINGS} from './constants';
2526
import i18n from './i18n';
2627

@@ -104,35 +105,6 @@ function QuerySettingsForm({initialValues, onSubmit, onClose}: QuerySettingsForm
104105
/>
105106
</div>
106107
</Flex>
107-
<Flex direction="row" alignItems="flex-start" className={b('dialog-row')}>
108-
<label htmlFor="timeout" className={b('field-title')}>
109-
{QUERY_SETTINGS_FIELD_SETTINGS.timeout.title}
110-
</label>
111-
<div className={b('control-wrapper')}>
112-
<Controller
113-
name="timeout"
114-
control={control}
115-
render={({field}) => (
116-
<React.Fragment>
117-
<TextInput
118-
id="timeout"
119-
type="number"
120-
{...field}
121-
value={field.value?.toString()}
122-
className={b('timeout')}
123-
placeholder="60"
124-
validationState={errors.timeout ? 'invalid' : undefined}
125-
errorMessage={errors.timeout?.message}
126-
errorPlacement="inside"
127-
/>
128-
<span className={b('timeout-suffix')}>
129-
{i18n('form.timeout.seconds')}
130-
</span>
131-
</React.Fragment>
132-
)}
133-
/>
134-
</div>
135-
</Flex>
136108
{enableTracingLevel && (
137109
<Flex direction="row" alignItems="flex-start" className={b('dialog-row')}>
138110
<label htmlFor="tracingLevel" className={b('field-title')}>
@@ -225,11 +197,35 @@ function QuerySettingsForm({initialValues, onSubmit, onClose}: QuerySettingsForm
225197
validationState={errors.limitRows ? 'invalid' : undefined}
226198
errorMessage={errors.limitRows?.message}
227199
errorPlacement="inside"
200+
endContent={
201+
<span className={b('postfix')}>
202+
{i18n('form.limit.rows')}
203+
</span>
204+
}
228205
/>
229206
)}
230207
/>
231208
</div>
232209
</Flex>
210+
<Flex direction="row" alignItems="flex-start" className={b('dialog-row')}>
211+
<Controller
212+
name="timeout"
213+
control={control}
214+
render={({field}) => (
215+
<QuerySettingsTimeout
216+
id="timeout"
217+
value={field.value}
218+
onChange={field.onChange}
219+
isEnabled={Boolean(field.value)}
220+
onToggle={(enabled) =>
221+
field.onChange(enabled ? DEFAULT_QUERY_SETTINGS.timeout : '')
222+
}
223+
validationState={errors.timeout ? 'invalid' : undefined}
224+
errorMessage={errors.timeout?.message}
225+
/>
226+
)}
227+
/>
228+
</Flex>
233229
</Dialog.Body>
234230
<Dialog.Footer
235231
textButtonApply={i18n('button-done')}
@@ -240,13 +236,14 @@ function QuerySettingsForm({initialValues, onSubmit, onClose}: QuerySettingsForm
240236
}}
241237
renderButtons={(buttonApply, buttonCancel) => (
242238
<div className={b('buttons-container')}>
243-
<ExternalLink
239+
<Button
244240
href="https://ydb.tech/docs"
245241
target="_blank"
246-
className={b('documentation-link')}
242+
view="outlined"
243+
size="l"
247244
>
248245
{i18n('docs')}
249-
</ExternalLink>
246+
</Button>
250247
<div className={b('main-buttons')}>
251248
{buttonCancel}
252249
{buttonApply}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.ydb-query-settings-timeout {
2+
&__control-wrapper {
3+
display: flex;
4+
flex: 6;
5+
align-items: center;
6+
}
7+
8+
&__input {
9+
width: 50%;
10+
}
11+
12+
&__postfix {
13+
margin-right: var(--g-spacing-2);
14+
color: var(--g-color-text-secondary);
15+
}
16+
17+
&__title {
18+
flex: 4;
19+
20+
margin-right: var(--g-spacing-3);
21+
22+
font-weight: 500;
23+
align-items: center;
24+
height: var(--g-text-header-2-line-height);
25+
white-space: nowrap;
26+
}
27+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import React from 'react';
2+
3+
import {Switch, TextInput} from '@gravity-ui/uikit';
4+
5+
import {cn} from '../../../../utils/cn';
6+
7+
import {QUERY_SETTINGS_FIELD_SETTINGS} from './constants';
8+
import i18n from './i18n';
9+
10+
import './QuerySettingsTimeout.scss';
11+
12+
const b = cn('ydb-query-settings-timeout');
13+
14+
interface QuerySettingsTimeoutProps {
15+
id?: string;
16+
value: number | undefined;
17+
onChange: (value: number | undefined) => void;
18+
isEnabled: boolean;
19+
onToggle: (enabled: boolean) => void;
20+
validationState?: 'invalid';
21+
errorMessage?: string;
22+
}
23+
24+
export function QuerySettingsTimeout({
25+
id,
26+
value,
27+
onChange,
28+
isEnabled,
29+
onToggle,
30+
validationState,
31+
errorMessage,
32+
}: QuerySettingsTimeoutProps) {
33+
const handleValueChange = React.useCallback(
34+
(event: React.ChangeEvent<HTMLInputElement>) => {
35+
const newValue = event.target.value ? Number(event.target.value) : undefined;
36+
onChange(newValue);
37+
},
38+
[onChange],
39+
);
40+
41+
return (
42+
<React.Fragment>
43+
<Switch checked={isEnabled} onUpdate={onToggle} className={b('title')}>
44+
{QUERY_SETTINGS_FIELD_SETTINGS.timeout.title}
45+
</Switch>
46+
{isEnabled ? (
47+
<div className={b('control-wrapper')}>
48+
<TextInput
49+
id={id}
50+
type="number"
51+
value={value?.toString() || ''}
52+
onChange={handleValueChange}
53+
className={b('input')}
54+
placeholder="60"
55+
validationState={validationState}
56+
errorMessage={errorMessage}
57+
errorPlacement="inside"
58+
endContent={
59+
<span className={b('postfix')}>{i18n('form.timeout.seconds')}</span>
60+
}
61+
/>
62+
</div>
63+
) : null}
64+
</React.Fragment>
65+
);
66+
}

src/containers/Tenant/Query/QuerySettingsDialog/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"tooltip_plan-to-svg-statistics": "Statistics option is set to \"Full\" due to the enabled \"Execution plan\" experiment.\n To disable it, go to the \"Experiments\" section in the user settings.",
1111
"button-cancel": "Cancel",
1212
"form.timeout.seconds": "sec",
13+
"form.limit.rows": "rows",
1314
"form.validation.timeout": "Must be positive",
1415
"form.validation.limitRows": "Must be between 1 and 100000",
1516
"description.default": " (default)",

src/containers/Tenant/Query/QuerySettingsDialog/i18n/ru.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"button-done": "Готово",
1111
"button-cancel": "Отменить",
1212
"form.timeout.seconds": "сек",
13+
"form.limit.rows": "строк",
1314
"form.validation.timeout": "Таймаут должен быть положительным",
1415
"form.validation.limitRows": "Лимит строк должен быть между 1 и 100000",
1516
"description.default": " (default)",

src/services/settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const DEFAULT_USER_SETTINGS = {
4646
[USE_CLUSTER_BALANCER_AS_BACKEND_KEY]: true,
4747
[ENABLE_AUTOCOMPLETE]: true,
4848
[ENABLE_CODE_ASSISTANT]: true,
49-
[ENABLE_QUERY_STREAMING]: false,
49+
[ENABLE_QUERY_STREAMING]: true,
5050
[AUTOCOMPLETE_ON_ENTER]: true,
5151
[IS_HOTKEYS_HELP_HIDDEN_KEY]: false,
5252
[AUTO_REFRESH_INTERVAL]: 0,

src/store/reducers/capabilities/hooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export const useClusterDashboardAvailable = () => {
7171
};
7272

7373
export const useStreamingAvailable = () => {
74-
return useGetFeatureVersion('/viewer/query') >= 7;
74+
return useGetFeatureVersion('/viewer/query') >= 8;
7575
};
7676

7777
const useGetSecuritySetting = (feature: SecuritySetting) => {

src/utils/query.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ export const querySettingsRestoreSchema = z
329329
.object({
330330
timeout: z.preprocess(
331331
(val) => (val === '' ? undefined : val),
332-
z.coerce.number().positive().optional().catch(DEFAULT_QUERY_SETTINGS.timeout),
332+
z.coerce.number().positive().optional(),
333333
),
334334
limitRows: z.preprocess(
335335
(val) => (val === '' ? undefined : val),

0 commit comments

Comments
 (0)