Skip to content

Commit

Permalink
Prevent deletion if theme is in use (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljsummers committed Jul 24, 2022
1 parent d854178 commit e103738
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/MyWebLog/Handlers/Admin.fs
Expand Up @@ -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"
Expand Down

0 comments on commit e103738

Please sign in to comment.