♻️ refactor: restructure TaskLogsTable into modular component architecture
Refactor the monolithic TaskLogsTable component (802 lines) into a modular, maintainable architecture following the established pattern from LogsTable and MjLogsTable refactors. ## What Changed ### 🏗️ Architecture - Split large single file into focused, single-responsibility components - Introduced custom hook `useTaskLogsData` for centralized state management - Created dedicated column definitions file for better organization - Implemented modal components for user interactions ### 📁 New Structure ``` web/src/components/table/task-logs/ ├── index.jsx # Main page component orchestrator ├── TaskLogsTable.jsx # Pure table rendering component ├── TaskLogsActions.jsx # Actions area (task records + compact mode) ├── TaskLogsFilters.jsx # Search form component ├── TaskLogsColumnDefs.js # Column definitions and renderers └── modals/ ├── ColumnSelectorModal.jsx # Column visibility settings └── ContentModal.jsx # Content viewer for JSON data web/src/hooks/task-logs/ └── useTaskLogsData.js # Custom hook for state & logic ``` ### 🎯 Key Improvements - **Maintainability**: Clear separation of concerns, easier to understand - **Reusability**: Modular components can be reused independently - **Performance**: Optimized with `useMemo` for column rendering - **Testing**: Single-responsibility components easier to test - **Developer Experience**: Better code organization and readability ### 🎨 Task-Specific Features Preserved - All task type rendering with icons (MUSIC, LYRICS, video generation) - Platform-specific rendering (Suno, Kling, Jimeng) with distinct colors - Progress indicators for task completion status - Video preview links for successful video generation tasks - Admin-only columns for channel information - Status rendering with appropriate colors and icons ### 🔧 Technical Details - Centralized all business logic in `useTaskLogsData` custom hook - Extracted comprehensive column definitions with Lucide React icons - Split complex UI into focused components (table, actions, filters, modals) - Maintained responsive design patterns for mobile compatibility - Preserved admin permission handling for restricted features - Optimized spacing and layout (reduced gap from 4 to 2 for better density) ### 🎮 Platform Support - **Suno**: Music and lyrics generation with music icons - **Kling**: Video generation with video icons - **Jimeng**: Video generation with distinct purple styling ### 🐛 Fixes - Improved component prop passing patterns - Enhanced type safety through better state management - Optimized rendering performance with proper memoization - Streamlined export pattern using `export { default }` ## Breaking Changes None - all existing imports and functionality preserved.
This commit is contained in:
33
web/src/components/table/task-logs/index.jsx
Normal file
33
web/src/components/table/task-logs/index.jsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import React from 'react';
|
||||
import { Layout } from '@douyinfe/semi-ui';
|
||||
import CardPro from '../../common/ui/CardPro.js';
|
||||
import TaskLogsTable from './TaskLogsTable.jsx';
|
||||
import TaskLogsActions from './TaskLogsActions.jsx';
|
||||
import TaskLogsFilters from './TaskLogsFilters.jsx';
|
||||
import ColumnSelectorModal from './modals/ColumnSelectorModal.jsx';
|
||||
import ContentModal from './modals/ContentModal.jsx';
|
||||
import { useTaskLogsData } from '../../../hooks/task-logs/useTaskLogsData.js';
|
||||
|
||||
const TaskLogsPage = () => {
|
||||
const taskLogsData = useTaskLogsData();
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* Modals */}
|
||||
<ColumnSelectorModal {...taskLogsData} />
|
||||
<ContentModal {...taskLogsData} />
|
||||
|
||||
<Layout>
|
||||
<CardPro
|
||||
type="type2"
|
||||
statsArea={<TaskLogsActions {...taskLogsData} />}
|
||||
searchArea={<TaskLogsFilters {...taskLogsData} />}
|
||||
>
|
||||
<TaskLogsTable {...taskLogsData} />
|
||||
</CardPro>
|
||||
</Layout>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default TaskLogsPage;
|
||||
Reference in New Issue
Block a user