Require confirmation and block deleting library actions still referenced by node groups.

This commit is contained in:
2026-07-20 21:00:24 +02:00
parent d188ca41b8
commit be255341e5
5 changed files with 217 additions and 0 deletions
+11
View File
@@ -49,6 +49,7 @@ var (
errActionIDRequired = errors.New("action id is required")
errActionWidgetTypeNeeded = errors.New("widget_type is required when show_widget is true")
errActionWidgetTypeBad = errors.New("widget_type must be memory, disk, or raw")
errActionInUse = errors.New("action is used by node action groups; remove or clone to customize first")
)
func actionsGetHandler(configDir string) http.HandlerFunc {
@@ -221,6 +222,16 @@ func actionsDeleteHandler(configDir string) http.HandlerFunc {
return
}
groups, err := settings.LoadNodeActionGroupsOrEmpty(configDir)
if err != nil {
writeJSON(writer, http.StatusInternalServerError, apiErrorResponse{Error: err.Error()})
return
}
if settings.LibraryActionInUse(groups, actionID) {
writeJSON(writer, http.StatusConflict, apiErrorResponse{Error: errActionInUse.Error()})
return
}
store.Actions = append(store.Actions[:index], store.Actions[index+1:]...)
if err := settings.SaveActions(configDir, store); err != nil {
writeJSON(writer, http.StatusInternalServerError, apiErrorResponse{Error: err.Error()})