diff --git a/src/lib/components/theme/CommunityWorkshopView.svelte b/src/lib/components/theme/CommunityWorkshopView.svelte index 14e42ba..b741a05 100644 --- a/src/lib/components/theme/CommunityWorkshopView.svelte +++ b/src/lib/components/theme/CommunityWorkshopView.svelte @@ -157,6 +157,10 @@ let exportingReports = $state(false); let exportingEvents = $state(false); let quarantineId = $state(null); + let quarantineTarget = $state(null); + let quarantineAction = $state<'take_down' | 'lift'>('take_down'); + let quarantineReason = $state(''); + let quarantineError = $state(null); let tagEditorTarget = $state(null); let tagEditorTags = $state([]); @@ -1055,38 +1059,46 @@ } } - async function handleToggleQuarantine(theme: CommunityTheme) { + function handleToggleQuarantine(theme: CommunityTheme) { if (!canModerate || quarantineId) return; - const takingDown = !theme.isQuarantined; - const reason = takingDown - ? window.prompt( - `Take down "${theme.name}"?\n\nReason shown to the owner and stored in the audit log:`, - theme.quarantineReason || '' - ) - : window.prompt( - `Lift the takedown on "${theme.name}"?\n\nOptional note for the audit log:`, - '' - ); - if (reason === null) return; - if (takingDown && reason.trim().length < 3) { - sileo.error({ title: 'A takedown reason is required' }); + quarantineTarget = theme; + quarantineAction = theme.isQuarantined ? 'lift' : 'take_down'; + quarantineReason = ''; + quarantineError = null; + } + + function closeQuarantineDialog() { + if (quarantineId) return; + quarantineTarget = null; + quarantineReason = ''; + quarantineError = null; + } + + async function confirmQuarantine() { + const theme = quarantineTarget; + if (!theme || quarantineId) return; + + const takingDown = quarantineAction === 'take_down'; + const reason = quarantineReason.trim(); + if (takingDown && reason.length < 3) { + quarantineError = 'Please provide a reason of at least 3 characters.'; return; } quarantineId = theme.id; + quarantineError = null; try { - await setCommunityThemeQuarantine(theme.id, takingDown, reason.trim() || undefined); + await setCommunityThemeQuarantine(theme.id, takingDown, reason || undefined); sileo.success({ title: takingDown ? 'Theme taken down' : 'Takedown lifted', description: `"${theme.name}" was updated.`, }); + quarantineTarget = null; + quarantineReason = ''; await loadWorkshopThemes(); if (showModerationPanel) await loadModerationPanel(moderationPage); } catch (err) { - sileo.error({ - title: 'Could not update takedown', - description: err instanceof Error ? err.message : String(err), - }); + quarantineError = err instanceof Error ? err.message : String(err); } finally { quarantineId = null; } @@ -3152,6 +3164,109 @@ {/if} + {#if quarantineTarget} +
+ + +
+ {/if} + {#if reportTarget}