feat: support removing config values via null

This commit is contained in:
Aarnav Tale 2024-08-24 10:33:30 -04:00
parent 9aedd9baad
commit ea2ffdf0c1
No known key found for this signature in database
2 changed files with 7 additions and 2 deletions

View File

@ -91,9 +91,9 @@ function NameserverList({ isGlobal, isDisabled, nameservers, name }: ListProps)
})
} else {
const key = `dns.nameservers.split."${name}"`
const list = nameservers.filter((_, i) => i !== index)
submit({
[key]: nameservers
.filter((_, i) => i !== index),
[key]: list.length ? list : null,
}, {
method: 'PATCH',
encType: 'application/json',

View File

@ -308,6 +308,11 @@ export async function patchConfig(partial: Record<string, unknown>) {
// Push the remaining element
path.push(temp.replaceAll('"', ''))
if (value === null) {
configYaml.deleteIn(path)
continue
}
configYaml.setIn(path, value)
}