mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-14 02:19:58 +08:00
🐛 fix(redis): 修复多节点连接编辑回填主节点
- 编辑 Redis Sentinel/Cluster 配置时优先保留已保存 host:port 作为主节点 - 合并 hosts 附加节点并去重,避免主节点被附加节点替换 - 补充连接弹窗 Redis 多节点回填回归断言
This commit is contained in:
@@ -53,6 +53,14 @@ describe('ConnectionModal Redis Sentinel configuration', () => {
|
||||
expect(source).toContain('form.setFieldValue("port", 26379)');
|
||||
expect(source).toContain('form.setFieldValue("port", 6379)');
|
||||
});
|
||||
|
||||
it('keeps the saved host as the primary Redis node when editing multi-node configs', () => {
|
||||
expect(source).toContain('const savedPrimaryAddress = isFileDbConfigType');
|
||||
expect(source).toContain('savedPrimaryAddress,');
|
||||
expect(source).toContain('...(Array.isArray(config.hosts) ? config.hosts : [])');
|
||||
expect(source).toContain('const redisHosts =');
|
||||
expect(source).toContain('configType === "redis" ? normalizedHosts.slice(1) : [];');
|
||||
});
|
||||
});
|
||||
|
||||
describe('ConnectionModal MongoDB configuration', () => {
|
||||
|
||||
@@ -2223,18 +2223,27 @@ const ConnectionModal: React.FC<{
|
||||
const defaultPort = getDefaultPortByType(configType);
|
||||
const isFileDbConfigType = isFileDatabaseType(configType);
|
||||
const jvmDefaultValues = buildDefaultJVMConnectionValues();
|
||||
const savedPrimaryAddress = isFileDbConfigType
|
||||
? ""
|
||||
: toAddress(
|
||||
config.host || "localhost",
|
||||
Number(config.port || defaultPort),
|
||||
defaultPort,
|
||||
);
|
||||
const normalizedHosts = isFileDbConfigType
|
||||
? []
|
||||
: normalizeAddressList(config.hosts, defaultPort);
|
||||
: normalizeAddressList(
|
||||
[
|
||||
savedPrimaryAddress,
|
||||
...(Array.isArray(config.hosts) ? config.hosts : []),
|
||||
],
|
||||
defaultPort,
|
||||
);
|
||||
const primaryAddress = isFileDbConfigType
|
||||
? null
|
||||
: parseHostPort(
|
||||
normalizedHosts[0] ||
|
||||
toAddress(
|
||||
config.host || "localhost",
|
||||
Number(config.port || defaultPort),
|
||||
defaultPort,
|
||||
),
|
||||
savedPrimaryAddress,
|
||||
defaultPort,
|
||||
);
|
||||
const primaryHost = isFileDbConfigType
|
||||
|
||||
Reference in New Issue
Block a user