♻️ refactor: modularize TokensTable component into maintainable architecture
- Split monolithic 922-line TokensTable.js into modular components: * useTokensData.js: Custom hook for centralized state and logic management * TokensColumnDefs.js: Column definitions and rendering functions * TokensTable.jsx: Pure table component for rendering * TokensActions.jsx: Actions area (add, copy, delete tokens) * TokensFilters.jsx: Search form component with keyword and token filters * TokensDescription.jsx: Description area with compact mode toggle * index.jsx: Main orchestrator component - Features preserved: * Token status management with switch controls * Quota progress bars and visual indicators * Model limitations display with vendor avatars * IP restrictions handling and display * Chat integrations with dropdown menu * Batch operations (copy, delete) with confirmations * Key visibility toggle and copy functionality * Compact mode for responsive layouts * Search and filtering capabilities * Pagination and loading states - Improvements: * Better separation of concerns * Enhanced reusability and testability * Simplified maintenance and debugging * Consistent modular architecture pattern * Performance optimizations with useMemo * Backward compatibility maintained This refactoring follows the same successful pattern used for LogsTable, MjLogsTable, and TaskLogsTable, significantly improving code maintainability while preserving all existing functionality.
This commit is contained in:
@@ -14,7 +14,7 @@ import { useTableCompactMode } from '../common/useTableCompactMode';
|
||||
|
||||
export const useTaskLogsData = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
|
||||
// Define column keys for selection
|
||||
const COLUMN_KEYS = {
|
||||
SUBMIT_TIME: 'submit_time',
|
||||
@@ -36,10 +36,10 @@ export const useTaskLogsData = () => {
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [logCount, setLogCount] = useState(0);
|
||||
const [pageSize, setPageSize] = useState(ITEMS_PER_PAGE);
|
||||
|
||||
|
||||
// User and admin
|
||||
const isAdminUser = isAdmin();
|
||||
|
||||
|
||||
// Modal state
|
||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||
const [modalContent, setModalContent] = useState('');
|
||||
@@ -48,7 +48,7 @@ export const useTaskLogsData = () => {
|
||||
const [formApi, setFormApi] = useState(null);
|
||||
let now = new Date();
|
||||
let zeroNow = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
||||
|
||||
|
||||
const formInitValues = {
|
||||
channel_id: '',
|
||||
task_id: '',
|
||||
@@ -239,7 +239,7 @@ export const useTaskLogsData = () => {
|
||||
logCount,
|
||||
pageSize,
|
||||
isAdminUser,
|
||||
|
||||
|
||||
// Modal state
|
||||
isModalOpen,
|
||||
setIsModalOpen,
|
||||
|
||||
Reference in New Issue
Block a user