mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-28 00:24:19 +00:00
fix(inbound): preserve custom share strategy on edit (#5225)
This commit is contained in:
@@ -381,7 +381,8 @@ export default function InboundFormModal({
|
||||
// protocol reset drops a nodeId that no longer applies.
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
if (!nodeShareOptionAvailable && shareAddrStrategy === 'node') {
|
||||
const current = form.getFieldValue('shareAddrStrategy') as InboundFormValues['shareAddrStrategy'] | undefined;
|
||||
if (!nodeShareOptionAvailable && (current ?? 'node') === 'node') {
|
||||
form.setFieldValue('shareAddrStrategy', 'listen');
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { screen } from '@testing-library/react';
|
||||
|
||||
import InboundFormModal from '@/pages/inbounds/form/InboundFormModal';
|
||||
import { DBInbound } from '@/models/dbinbound';
|
||||
import {
|
||||
renderWithProviders,
|
||||
fieldLabels,
|
||||
@@ -38,4 +40,39 @@ describe('InboundFormModal', () => {
|
||||
expect(fieldLabels()).toMatchSnapshot(proto);
|
||||
}
|
||||
});
|
||||
|
||||
it('preserves custom share address strategy when editing a local inbound', async () => {
|
||||
renderWithProviders(
|
||||
<InboundFormModal
|
||||
open
|
||||
mode="edit"
|
||||
dbInbound={new DBInbound({
|
||||
id: 1,
|
||||
port: 12345,
|
||||
listen: '',
|
||||
protocol: 'shadowsocks',
|
||||
remark: 'edge',
|
||||
enable: true,
|
||||
settings: {
|
||||
method: '2022-blake3-aes-128-gcm',
|
||||
password: 'server-password',
|
||||
network: 'tcp,udp',
|
||||
clients: [],
|
||||
},
|
||||
streamSettings: { network: 'tcp', security: 'none', tcpSettings: {} },
|
||||
sniffing: { enabled: false },
|
||||
nodeId: null,
|
||||
shareAddrStrategy: 'custom',
|
||||
shareAddr: 'edge.example.test',
|
||||
})}
|
||||
dbInbounds={[]}
|
||||
availableNodes={[]}
|
||||
onClose={() => {}}
|
||||
onSaved={() => {}}
|
||||
/>,
|
||||
);
|
||||
|
||||
const shareAddrInput = await screen.findByDisplayValue('edge.example.test');
|
||||
expect((shareAddrInput as HTMLInputElement).value).toBe('edge.example.test');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user