Prevent deletion if theme is in use (#20)

This commit is contained in:
Daniel J. Summers 2022-07-24 19:26:36 -04:00
parent d854178255
commit e103738d39

View File

@ -331,10 +331,17 @@ let saveTheme : HttpHandler = requireAccess Administrator >=> fun next ctx -> ta
// POST /admin/theme/{id}/delete
let deleteTheme themeId : HttpHandler = requireAccess Administrator >=> fun next ctx -> task {
let data = ctx.Data
if themeId = "admin" || themeId = "default" then
match themeId with
| "admin" | "default" ->
do! addMessage ctx { UserMessage.error with Message = $"You may not delete the {themeId} theme" }
return! listThemes next ctx
else
| it when WebLogCache.isThemeInUse (ThemeId it) ->
do! addMessage ctx
{ UserMessage.error with
Message = $"You may not delete the {themeId} theme, as it is currently in use"
}
return! listThemes next ctx
| _ ->
match! data.Theme.Delete (ThemeId themeId) with
| true ->
let zippedTheme = $"{themeId}-theme.zip"