luci-base: form.js: fix removing just created named GridSection
authorJo-Philipp Wich <jo@mein.io>
Fri, 22 Jul 2022 21:41:05 +0000 (23:41 +0200)
committerJo-Philipp Wich <jo@mein.io>
Fri, 22 Jul 2022 21:41:05 +0000 (23:41 +0200)
commit2771360108cb3e2011c7c9cb4921a9047ea70910
treeab5771a6fff2f078bac839d48eff0bd1273a44f9
parent94a1821c3b6ec01817e53a8a01a4cf0b7692ac42
luci-base: form.js: fix removing just created named GridSection

Since the `handleModalSave()` handler of the GridSection class invokes
`handleModalCancel()` after saving the data but before removing the
`addedSection` property, the `handleModalCancel` handler incorrectly
removed the uci section that has just been created.

This bug didn't affect anonymous GridSections because after saving the
id of the created section changes, causing the remove command to fail,
but for named ones with stable section IDs, the bug manifested.

Solve the issue by passing a flag to `handleModalCancel()` indicating
whether the method was called from a safe operation and use it do
decide whether to delete the new staged uci section or not.

Fixes: #5760
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/form.js