Update ACP UI copy, accents, and defaults
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { Button, ButtonGroup, Col, Container, Form, Modal, Row, Tab, Tabs } from 'react-bootstrap'
|
||||
import DataTable, { createTheme } from 'react-data-table-component'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
@@ -218,6 +218,7 @@ export default function Acp({ isAdmin }) {
|
||||
)
|
||||
}
|
||||
const [collapsed, setCollapsed] = useState(() => new Set())
|
||||
const hasInitializedCollapse = useRef(false)
|
||||
const [showModal, setShowModal] = useState(false)
|
||||
const [form, setForm] = useState({
|
||||
name: '',
|
||||
@@ -245,6 +246,16 @@ export default function Acp({ isAdmin }) {
|
||||
}
|
||||
}, [isAdmin])
|
||||
|
||||
useEffect(() => {
|
||||
if (!hasInitializedCollapse.current && forums.length > 0) {
|
||||
const ids = forums
|
||||
.filter((forum) => forum.type === 'category')
|
||||
.map((forum) => String(forum.id))
|
||||
setCollapsed(new Set(ids))
|
||||
hasInitializedCollapse.current = true
|
||||
}
|
||||
}, [forums])
|
||||
|
||||
const refreshUsers = async () => {
|
||||
setUsersLoading(true)
|
||||
setUsersError('')
|
||||
@@ -602,7 +613,7 @@ export default function Acp({ isAdmin }) {
|
||||
<div className="bb-muted">{node.description || t('forum.no_description')}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="d-flex align-items-center gap-2">
|
||||
<div className="d-flex align-items-center gap-3">
|
||||
<span
|
||||
className="bb-drag-handle text-muted"
|
||||
style={{ cursor: 'grab', display: 'inline-flex' }}
|
||||
@@ -651,11 +662,11 @@ export default function Acp({ isAdmin }) {
|
||||
<div className="d-flex align-items-center justify-content-between mb-3 gap-3 flex-wrap">
|
||||
<div className="d-flex align-items-center gap-2">
|
||||
<h5 className="mb-0">{t('acp.forums_tree')}</h5>
|
||||
<Button size="sm" variant="outline-dark" onClick={handleExpandAll}>
|
||||
<Button size="sm" variant="outline-dark" className="bb-acp-action" onClick={handleExpandAll}>
|
||||
<i className="bi bi-arrows-expand me-1" aria-hidden="true" />
|
||||
{t('acp.expand_all')}
|
||||
</Button>
|
||||
<Button size="sm" variant="outline-dark" onClick={handleCollapseAll}>
|
||||
<Button size="sm" variant="outline-dark" className="bb-acp-action" onClick={handleCollapseAll}>
|
||||
<i className="bi bi-arrows-collapse me-1" aria-hidden="true" />
|
||||
{t('acp.collapse_all')}
|
||||
</Button>
|
||||
@@ -663,7 +674,8 @@ export default function Acp({ isAdmin }) {
|
||||
<div className="d-flex gap-2">
|
||||
<Button
|
||||
size="sm"
|
||||
variant={createType === 'category' ? 'dark' : 'outline-dark'}
|
||||
variant="outline-dark"
|
||||
className={`bb-acp-action ${createType === 'category' ? 'bb-acp-action--active' : ''}`}
|
||||
onClick={() => handleStartCreate('category')}
|
||||
>
|
||||
<i className="bi bi-folder2 me-1" aria-hidden="true" />
|
||||
@@ -671,7 +683,8 @@ export default function Acp({ isAdmin }) {
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant={createType === 'forum' ? 'dark' : 'outline-dark'}
|
||||
variant="outline-dark"
|
||||
className={`bb-acp-action ${createType === 'forum' ? 'bb-acp-action--active' : ''}`}
|
||||
onClick={() => handleStartCreate('forum')}
|
||||
>
|
||||
<i className="bi bi-chat-left-text me-1" aria-hidden="true" />
|
||||
@@ -720,11 +733,29 @@ export default function Acp({ isAdmin }) {
|
||||
<Modal show={showModal} onHide={handleReset} centered size="lg">
|
||||
<Modal.Header closeButton closeVariant="white">
|
||||
<Modal.Title>
|
||||
{selectedId ? t('acp.forums_edit_title') : t('acp.forums_create_title')}
|
||||
{selectedId
|
||||
? form.type === 'category'
|
||||
? t('acp.forums_edit_category_title')
|
||||
: t('acp.forums_edit_forum_title')
|
||||
: createType === 'category'
|
||||
? t('acp.forums_create_category_title')
|
||||
: createType === 'forum'
|
||||
? t('acp.forums_create_forum_title')
|
||||
: t('acp.forums_create_title')}
|
||||
</Modal.Title>
|
||||
</Modal.Header>
|
||||
<Modal.Body>
|
||||
<p className="bb-muted">{t('acp.forums_form_hint')}</p>
|
||||
<p className="bb-muted">
|
||||
{selectedId
|
||||
? form.type === 'category'
|
||||
? t('acp.forums_edit_category_hint')
|
||||
: t('acp.forums_edit_forum_hint')
|
||||
: createType === 'category'
|
||||
? t('acp.forums_create_category_hint')
|
||||
: createType === 'forum'
|
||||
? t('acp.forums_create_forum_hint')
|
||||
: t('acp.forums_form_hint')}
|
||||
</p>
|
||||
<Form onSubmit={handleSubmit}>
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t('form.title')}</Form.Label>
|
||||
@@ -744,16 +775,18 @@ export default function Acp({ isAdmin }) {
|
||||
onChange={(event) => setForm({ ...form, description: event.target.value })}
|
||||
/>
|
||||
</Form.Group>
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t('acp.forums_type')}</Form.Label>
|
||||
<Form.Select
|
||||
value={form.type}
|
||||
onChange={(event) => setForm({ ...form, type: event.target.value })}
|
||||
>
|
||||
<option value="category">{t('forum.type_category')}</option>
|
||||
<option value="forum">{t('forum.type_forum')}</option>
|
||||
</Form.Select>
|
||||
</Form.Group>
|
||||
{selectedId && (
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t('acp.forums_type')}</Form.Label>
|
||||
<Form.Select
|
||||
value={form.type}
|
||||
onChange={(event) => setForm({ ...form, type: event.target.value })}
|
||||
>
|
||||
<option value="category">{t('forum.type_category')}</option>
|
||||
<option value="forum">{t('forum.type_forum')}</option>
|
||||
</Form.Select>
|
||||
</Form.Group>
|
||||
)}
|
||||
<Form.Group className="mb-3">
|
||||
<Form.Label>{t('acp.forums_parent')}</Form.Label>
|
||||
<Form.Select
|
||||
|
||||
Reference in New Issue
Block a user