mirror of
https://github.com/tale/headplane.git
synced 2026-08-27 15:37:04 +00:00
fix: address a bug that prevented remove split dns records
This commit is contained in:
@@ -35,7 +35,7 @@ export default function Nameservers({ nameservers, isDisabled }: Props) {
|
|||||||
key={key}
|
key={key}
|
||||||
isGlobal={key === 'global'}
|
isGlobal={key === 'global'}
|
||||||
isDisabled={isDisabled}
|
isDisabled={isDisabled}
|
||||||
nameservers={nameservers[key]}
|
nameservers={nameservers}
|
||||||
name={key}
|
name={key}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
@@ -59,6 +59,10 @@ interface ListProps {
|
|||||||
|
|
||||||
function NameserverList({ isGlobal, isDisabled, nameservers, name }: ListProps) {
|
function NameserverList({ isGlobal, isDisabled, nameservers, name }: ListProps) {
|
||||||
const submit = useSubmit()
|
const submit = useSubmit()
|
||||||
|
const list = isGlobal ? nameservers['global'] : nameservers[name]
|
||||||
|
if (list.length === 0) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="mb-8">
|
<div className="mb-8">
|
||||||
@@ -68,7 +72,7 @@ function NameserverList({ isGlobal, isDisabled, nameservers, name }: ListProps)
|
|||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
<TableList>
|
<TableList>
|
||||||
{nameservers.map((ns, index) => (
|
{list.length > 0 ? list.map((ns, index) => (
|
||||||
// eslint-disable-next-line react/no-array-index-key
|
// eslint-disable-next-line react/no-array-index-key
|
||||||
<TableList.Item key={index}>
|
<TableList.Item key={index}>
|
||||||
<p className="font-mono text-sm">{ns}</p>
|
<p className="font-mono text-sm">{ns}</p>
|
||||||
@@ -83,17 +87,18 @@ function NameserverList({ isGlobal, isDisabled, nameservers, name }: ListProps)
|
|||||||
onPress={() => {
|
onPress={() => {
|
||||||
if (isGlobal) {
|
if (isGlobal) {
|
||||||
submit({
|
submit({
|
||||||
'dns.nameservers.global': nameservers
|
'dns.nameservers.global': list
|
||||||
.filter((_, i) => i !== index),
|
.filter((_, i) => i !== index),
|
||||||
}, {
|
}, {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
encType: 'application/json',
|
encType: 'application/json',
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
const key = `dns.nameservers.split."${name}"`
|
|
||||||
const list = nameservers.filter((_, i) => i !== index)
|
|
||||||
submit({
|
submit({
|
||||||
[key]: list.length ? list : null,
|
'dns.nameservers.split': {
|
||||||
|
...nameservers,
|
||||||
|
[name]: list.filter((_, i) => i !== index),
|
||||||
|
}
|
||||||
}, {
|
}, {
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
encType: 'application/json',
|
encType: 'application/json',
|
||||||
@@ -104,7 +109,7 @@ function NameserverList({ isGlobal, isDisabled, nameservers, name }: ListProps)
|
|||||||
Remove
|
Remove
|
||||||
</Button>
|
</Button>
|
||||||
</TableList.Item>
|
</TableList.Item>
|
||||||
))}
|
)) : undefined}
|
||||||
</TableList>
|
</TableList>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user