PUT /panels/ carries a version and refuses a stale one with 409
The Panels dialog re-reads the list on 409. A panels.json without a version reads as 0.
This commit is contained in:
@@ -107,9 +107,17 @@ export function PanelsDialog() {
|
||||
const host = config?.frontend_host ?? ""
|
||||
|
||||
const write = (next: PanelsConfig) =>
|
||||
save.mutate(next, {
|
||||
onError: (error) => handleError.call(showErrorToast, error as ApiError),
|
||||
})
|
||||
save.mutate(
|
||||
{ ...next, version: config?.version },
|
||||
{
|
||||
onError: (error) =>
|
||||
(error as ApiError).status === 409
|
||||
? showErrorToast(
|
||||
"Someone else changed the panels first. Their version is shown now, so make the change again.",
|
||||
)
|
||||
: handleError.call(showErrorToast, error as ApiError),
|
||||
},
|
||||
)
|
||||
|
||||
const replace = (id: string, panel: PanelDef) =>
|
||||
write({ panels: panels.map((p) => (p.id === id ? panel : p)) })
|
||||
|
||||
Reference in New Issue
Block a user