Files
NightSpire/web-next/components/TopicModBar.tsx
T
Inna fa7897c195 Prefijos del tema nw- y uw- -> ns- (carpetas, ficheros, clases y rutas)
Renombrado completo de los prefijos heredados: 19 carpetas, 11 ficheros y 318
referencias en 35 ficheros de código, más las clases y las rutas url() de dentro
del CSS del tema. Se usa git mv para conservar el historial.

También fuera del código, que un sed no ve:
- BD: votesite.image_url (4 filas) apuntaba a /nw-themes/...
- Ficheros con la marca vieja en el NOMBRE: novawow-maintenance.webp ->
  nightspire-maintenance.webp (lo usa la página de mantenimiento) y
  store_novawow_response.js.

⚠ Alias en Caddy /nw-themes/* -> /ns-themes/*: los correos ENVIADOS antes del
rebranding llevan esas rutas escritas y están en las bandejas de los usuarios.
Sin el alias, sus imágenes se romperían. Verificado que las rutas viejas siguen
sirviendo 200.

Nota: ns-js/ y ns-js-handlers/ son CÓDIGO MUERTO (manejadores jQuery del portal
Django, que ya se borró). Se midió en el navegador: la web no pide ni un solo JS
del tema. Se renombran igualmente por consistencia, pero son candidatos a
borrarse.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-15 15:50:43 +00:00

96 lines
2.9 KiB
TypeScript

'use client'
import { useState } from 'react'
import { useTranslations } from 'next-intl'
import { useRouter } from '@/i18n/navigation'
export function TopicModBar({
topicId,
locked,
sticky,
deleted = false,
moveForums = [],
}: {
topicId: number
locked: boolean
sticky: boolean
deleted?: boolean
moveForums?: { id: number; name: string }[]
}) {
const t = useTranslations('Forum')
const router = useRouter()
const [busy, setBusy] = useState(false)
async function act(action: string, extra?: Record<string, unknown>, confirmMsg?: string) {
if (busy) return
if (confirmMsg && !confirm(confirmMsg)) return
setBusy(true)
try {
const res = await fetch('/api/forum/moderate', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
credentials: 'same-origin',
body: JSON.stringify({ topicId, action, ...extra }),
})
const data: { success?: boolean; forumId?: number } = await res.json()
if (data.success && action === 'delete' && data.forumId) {
router.push(`/forum/${data.forumId}`)
} else if (data.success && action === 'move') {
router.push(`/forum/${extra?.forumId}`)
} else {
router.refresh()
}
} finally {
setBusy(false)
}
}
if (deleted) {
return (
<div className="info-box-light separate">
<span className="red-info2">{t('deletedMark')}</span>{' '}
<button type="button" onClick={() => act('restore')} disabled={busy} className="ns-tool-btn green-info">
{t('restoreTopic')}
</button>
</div>
)
}
return (
<div className="info-box-light separate">
<span className="yellow-info">{t('moderation')}:</span>{' '}
<button type="button" onClick={() => act(locked ? 'unlock' : 'lock')} disabled={busy} className="ns-tool-btn">
{locked ? t('unlock') : t('lock')}
</button>{' '}
<button type="button" onClick={() => act(sticky ? 'unsticky' : 'sticky')} disabled={busy} className="ns-tool-btn">
{sticky ? t('unpin') : t('pin')}
</button>{' '}
{moveForums.length > 0 && (
<select
defaultValue=""
disabled={busy}
onChange={(e) => {
const forumId = Number(e.target.value)
e.target.value = ''
if (forumId) act('move', { forumId })
}}
style={{ width: 'auto' }}
aria-label={t('moveTopic')}
>
<option value="" disabled>
{t('moveTopic')}
</option>
{moveForums.map((f) => (
<option key={f.id} value={f.id}>
{f.name}
</option>
))}
</select>
)}{' '}
<button type="button" onClick={() => act('delete', undefined, t('confirmDeleteTopic'))} disabled={busy} className="ns-tool-btn red-info2">
{t('deleteTopic')}
</button>
</div>
)
}