fix(firewall): fehlende onError-Handler + i18n in Rules + NATRules
- 6 Mutations (create/update/del je Rules + NATRules) bekommen onError-Handler - Deutsche Placeholder-Texte → t() überführt - Action-Labels (accept/drop/reject) und Kind-Labels (any/object/group/cidr) in t() überführt statt hardkodiert anzeigen - CIDR-Label-Hardkodierung in Rules-Formular behoben - en/de: fw.rule.actions.*, fw.rule.kinds.*, fw.rule.namePlaceholder, fw.nat.namePlaceholder ergänzt Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -69,6 +69,7 @@ export default function NATRulesTab() {
|
||||
message.success(t('common.save')); setCreating(false); form.resetFields()
|
||||
void qc.invalidateQueries({ queryKey: ['fw', 'nat'] })
|
||||
},
|
||||
onError: (e: Error) => message.error(e.message),
|
||||
})
|
||||
const update = useMutation({
|
||||
mutationFn: async ({ id, v }: { id: number; v: FormValues }) => { await apiClient.put(`/firewall/nat-rules/${id}`, v) },
|
||||
@@ -76,10 +77,12 @@ export default function NATRulesTab() {
|
||||
message.success(t('common.save')); setEditing(null); form.resetFields()
|
||||
void qc.invalidateQueries({ queryKey: ['fw', 'nat'] })
|
||||
},
|
||||
onError: (e: Error) => message.error(e.message),
|
||||
})
|
||||
const del = useMutation({
|
||||
mutationFn: async (id: number) => { await apiClient.delete(`/firewall/nat-rules/${id}`) },
|
||||
onSuccess: () => { void qc.invalidateQueries({ queryKey: ['fw', 'nat'] }) },
|
||||
onError: (e: Error) => message.error(e.message),
|
||||
})
|
||||
const quickToggle = useMutation({
|
||||
mutationFn: async ({ id, row, checked }: { id: number; row: NATRule; checked: boolean }) => {
|
||||
@@ -190,7 +193,7 @@ export default function NATRulesTab() {
|
||||
onFinish={(v) => { if (editing) update.mutate({ id: editing.id, v }); else create.mutate(v) }}
|
||||
>
|
||||
<Form.Item label={t('fw.nat.name')} name="name">
|
||||
<Input placeholder="Forward HTTP zu Web-Backend" />
|
||||
<Input placeholder={t('fw.nat.namePlaceholder')} />
|
||||
</Form.Item>
|
||||
<Space size="middle">
|
||||
<Form.Item label={t('fw.nat.priority')} name="priority" rules={[{ required: true }]}>
|
||||
|
||||
@@ -158,6 +158,7 @@ export default function RulesTab() {
|
||||
message.success(t('common.save')); setCreating(false); form.resetFields()
|
||||
void qc.invalidateQueries({ queryKey: ['fw', 'rules'] })
|
||||
},
|
||||
onError: (e: Error) => message.error(e.message),
|
||||
})
|
||||
const update = useMutation({
|
||||
mutationFn: async ({ id, v }: { id: number; v: FormValues }) => { await apiClient.put(`/firewall/rules/${id}`, buildPayload(v)) },
|
||||
@@ -165,10 +166,12 @@ export default function RulesTab() {
|
||||
message.success(t('common.save')); setEditing(null); form.resetFields()
|
||||
void qc.invalidateQueries({ queryKey: ['fw', 'rules'] })
|
||||
},
|
||||
onError: (e: Error) => message.error(e.message),
|
||||
})
|
||||
const del = useMutation({
|
||||
mutationFn: async (id: number) => { await apiClient.delete(`/firewall/rules/${id}`) },
|
||||
onSuccess: () => { void qc.invalidateQueries({ queryKey: ['fw', 'rules'] }) },
|
||||
onError: (e: Error) => message.error(e.message),
|
||||
})
|
||||
const quickToggle = useMutation({
|
||||
mutationFn: async ({ id, row, checked }: { id: number; row: FwRule; checked: boolean }) => {
|
||||
@@ -295,7 +298,7 @@ export default function RulesTab() {
|
||||
onFinish={(v) => { if (editing) update.mutate({ id: editing.id, v }); else create.mutate(v) }}
|
||||
>
|
||||
<Form.Item label={t('fw.rule.name')} name="name">
|
||||
<Input placeholder="SSH von Office" />
|
||||
<Input placeholder={t('fw.rule.namePlaceholder')} />
|
||||
</Form.Item>
|
||||
|
||||
<Space size="middle" className="flex-wrap">
|
||||
@@ -303,7 +306,7 @@ export default function RulesTab() {
|
||||
<InputNumber min={0} max={9999} />
|
||||
</Form.Item>
|
||||
<Form.Item label={t('fw.rule.action')} name="action" rules={[{ required: true }]}>
|
||||
<Select style={{ width: 140 }} options={(['accept','drop','reject'] as const).map(a => ({ value: a, label: a }))} />
|
||||
<Select style={{ width: 140 }} options={(['accept','drop','reject'] as const).map(a => ({ value: a, label: t(`fw.rule.actions.${a}`) }))} />
|
||||
</Form.Item>
|
||||
<Form.Item label={t('fw.rule.enabled')} name="enabled" valuePropName="checked">
|
||||
<Switch />
|
||||
@@ -319,7 +322,7 @@ export default function RulesTab() {
|
||||
<Select style={{ width: 140 }} options={zoneOptions.map(z => ({ value: z, label: z }))} />
|
||||
</Form.Item>
|
||||
<Form.Item label={t(`fw.rule.${side}Kind`)} name={`${side}_kind`} rules={[{ required: true }]}>
|
||||
<Select style={{ width: 120 }} options={(['any','object','group','cidr'] as const).map(k => ({ value: k, label: k }))} />
|
||||
<Select style={{ width: 120 }} options={(['any','object','group','cidr'] as const).map(k => ({ value: k, label: t(`fw.rule.kinds.${k}`) }))} />
|
||||
</Form.Item>
|
||||
<Form.Item noStyle shouldUpdate={(p, c) => p[`${side}_kind`] !== c[`${side}_kind`]}>
|
||||
{({ getFieldValue }) => {
|
||||
@@ -337,7 +340,7 @@ export default function RulesTab() {
|
||||
</Form.Item>
|
||||
}
|
||||
if (k === 'cidr') {
|
||||
return <Form.Item label="CIDR" name={`${side}_cidr`} rules={[{ required: true }]}>
|
||||
return <Form.Item label={t('fw.rule.kinds.cidr')} name={`${side}_cidr`} rules={[{ required: true }]}>
|
||||
<Input placeholder="10.0.0.0/24" style={{ width: 200 }} />
|
||||
</Form.Item>
|
||||
}
|
||||
@@ -349,7 +352,7 @@ export default function RulesTab() {
|
||||
|
||||
<Space size="middle" className="flex-wrap">
|
||||
<Form.Item label={t('fw.rule.serviceKind')} name="service_kind" rules={[{ required: true }]}>
|
||||
<Select style={{ width: 120 }} options={(['any','object','group'] as const).map(k => ({ value: k, label: k }))} />
|
||||
<Select style={{ width: 120 }} options={(['any','object','group'] as const).map(k => ({ value: k, label: t(`fw.rule.kinds.${k}`) }))} />
|
||||
</Form.Item>
|
||||
<Form.Item noStyle shouldUpdate={(p, c) => p.service_kind !== c.service_kind}>
|
||||
{({ getFieldValue }) => {
|
||||
|
||||
Reference in New Issue
Block a user