mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-21 05:53:46 +08:00
- 修复自定义连接编辑时已保存 DSN 无法留空沿用的问题 - 重置 AI 供应商编辑态与清空密钥开关,避免关闭后状态残留 - 对齐浏览器 mock 复制连接的 config.id 语义并补充回归测试
28 lines
766 B
TypeScript
28 lines
766 B
TypeScript
export interface CustomConnectionDsnState {
|
|
dsnInput: unknown;
|
|
hasStoredSecret?: boolean;
|
|
clearStoredSecret?: boolean;
|
|
}
|
|
|
|
export const getCustomConnectionDsnValidationMessage = ({
|
|
dsnInput,
|
|
hasStoredSecret,
|
|
clearStoredSecret,
|
|
}: CustomConnectionDsnState): string | null => {
|
|
const dsnText = String(dsnInput ?? '').trim();
|
|
if (dsnText !== '') {
|
|
return null;
|
|
}
|
|
if (hasStoredSecret && !clearStoredSecret) {
|
|
return null;
|
|
}
|
|
if (hasStoredSecret && clearStoredSecret) {
|
|
return '请输入新的连接字符串,或取消清除已保存 DSN';
|
|
}
|
|
return '请输入连接字符串';
|
|
};
|
|
|
|
export const shouldAllowBlankCustomDsn = (state: CustomConnectionDsnState): boolean => (
|
|
getCustomConnectionDsnValidationMessage(state) === null
|
|
);
|