mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-07-15 01:13:02 +08:00
- host 和数据库下拉选项关闭原生 title,避免和自定义 Tooltip 重复显示 - 事务模式说明默认向上弹出,并保留边界自动避让 - 移除下拉打开时强制隐藏事务说明的状态控制 - 补充工具栏和事务设置回归断言
76 lines
2.4 KiB
TypeScript
76 lines
2.4 KiB
TypeScript
import React from 'react';
|
|
import { Select, Tooltip } from 'antd';
|
|
|
|
import { t as defaultTranslate } from '../i18n';
|
|
import { useOptionalI18n } from '../i18n/provider';
|
|
|
|
export type SqlEditorCommitMode = 'manual' | 'auto';
|
|
|
|
type SqlEditorAutoCommitDelayOption = {
|
|
value: number;
|
|
};
|
|
|
|
export const SQL_EDITOR_AUTO_COMMIT_DELAY_OPTIONS: SqlEditorAutoCommitDelayOption[] = [
|
|
{ value: 0 },
|
|
{ value: 3000 },
|
|
{ value: 5000 },
|
|
{ value: 10000 },
|
|
{ value: 30000 },
|
|
];
|
|
|
|
type QueryEditorTransactionSettingsProps = {
|
|
isV2Ui: boolean;
|
|
commitMode: SqlEditorCommitMode;
|
|
autoCommitDelayMs: number;
|
|
onCommitModeChange: (mode: SqlEditorCommitMode) => void;
|
|
onAutoCommitDelayMsChange: (delayMs: number) => void;
|
|
};
|
|
|
|
const QueryEditorTransactionSettings: React.FC<QueryEditorTransactionSettingsProps> = ({
|
|
isV2Ui,
|
|
commitMode,
|
|
autoCommitDelayMs,
|
|
onCommitModeChange,
|
|
onAutoCommitDelayMsChange,
|
|
}) => {
|
|
const i18n = useOptionalI18n();
|
|
const t = i18n?.t ?? defaultTranslate;
|
|
const autoCommitDelayOptions = SQL_EDITOR_AUTO_COMMIT_DELAY_OPTIONS.map((option) => ({
|
|
value: option.value,
|
|
label: option.value === 0
|
|
? t('query_editor.transaction.delay.immediate_commit')
|
|
: t('query_editor.transaction.delay.seconds_commit', { seconds: Math.round(option.value / 1000) }),
|
|
}));
|
|
|
|
return (
|
|
<>
|
|
<Tooltip
|
|
title={t('query_editor.transaction.mode.tooltip')}
|
|
placement="topLeft"
|
|
>
|
|
<Select
|
|
className={isV2Ui ? 'gn-v2-query-toolbar-select gn-v2-query-toolbar-transaction-mode-select' : undefined}
|
|
style={isV2Ui ? undefined : { width: 78 }}
|
|
value={commitMode}
|
|
onChange={(mode) => onCommitModeChange(mode === 'auto' ? 'auto' : 'manual')}
|
|
options={[
|
|
{ label: t('query_editor.transaction.mode.manual'), value: 'manual' },
|
|
{ label: t('query_editor.transaction.mode.auto'), value: 'auto' },
|
|
]}
|
|
/>
|
|
</Tooltip>
|
|
{commitMode === 'auto' && (
|
|
<Select
|
|
className={isV2Ui ? 'gn-v2-query-toolbar-select gn-v2-query-toolbar-transaction-delay-select' : undefined}
|
|
style={isV2Ui ? undefined : { width: 68 }}
|
|
value={autoCommitDelayMs}
|
|
onChange={(delayMs) => onAutoCommitDelayMsChange(Number(delayMs))}
|
|
options={autoCommitDelayOptions}
|
|
/>
|
|
)}
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default QueryEditorTransactionSettings;
|