-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathTimeoutLabel.tsx
47 lines (39 loc) · 1.44 KB
/
TimeoutLabel.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import {HelpMark, Switch} from '@gravity-ui/uikit';
import {cn} from '../../../../utils/cn';
import {ENABLE_QUERY_STREAMING} from '../../../../utils/constants';
import {useSetting} from '../../../../utils/hooks';
import {QUERY_SETTINGS_FIELD_SETTINGS} from './constants';
import i18n from './i18n';
import './TimeoutLabel.scss';
const b = cn('ydb-timeout-label');
interface TimeoutLabelProps {
isDisabled?: boolean;
isChecked: boolean;
onToggle: (enabled: boolean) => void;
}
export function TimeoutLabel({isDisabled, isChecked, onToggle}: TimeoutLabelProps) {
const [isQueryStreamingEnabled] = useSetting<boolean>(ENABLE_QUERY_STREAMING);
if (isQueryStreamingEnabled) {
return (
<div className={b('switch-title')}>
<Switch
disabled={isDisabled}
checked={isChecked}
onUpdate={onToggle}
className={b('switch')}
content={QUERY_SETTINGS_FIELD_SETTINGS.timeout.title}
/>
{isDisabled && (
<HelpMark className={b('question-icon')} placement="bottom-start">
{i18n('form.timeout.disabled')}
</HelpMark>
)}
</div>
);
}
return (
<label htmlFor="timeout" className={b('label-title')}>
{QUERY_SETTINGS_FIELD_SETTINGS.timeout.title}
</label>
);
}