Refactor the monolithic MjLogsTable component (971 lines) into a modular, maintainable architecture following the same pattern as LogsTable refactor. ## What Changed ### 🏗️ Architecture - Split large single file into focused, single-responsibility components - Introduced custom hook `useMjLogsData` for centralized state management - Created dedicated column definitions file for better organization - Implemented specialized modal components for Midjourney-specific features ### 📁 New Structure ``` web/src/components/table/mj-logs/ ├── index.jsx # Main page component orchestrator ├── MjLogsTable.jsx # Pure table rendering component ├── MjLogsActions.jsx # Actions area (banner + compact mode) ├── MjLogsFilters.jsx # Search form component ├── MjLogsColumnDefs.js # Column definitions and renderers └── modals/ ├── ColumnSelectorModal.jsx # Column visibility settings └── ContentModal.jsx # Content viewer (text + image preview) web/src/hooks/mj-logs/ └── useMjLogsData.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 ### 🎨 Midjourney-Specific Features Preserved - All task type rendering with icons (IMAGINE, UPSCALE, VARIATION, etc.) - Status rendering with appropriate colors and icons - Image preview functionality for generated artwork - Progress indicators for task completion - Admin-only columns for channel and submission results - Banner notification system for callback settings ### 🔧 Technical Details - Centralized all business logic in `useMjLogsData` 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 ### 🐛 Fixes - Improved component prop passing patterns - Enhanced type safety through better state management - Optimized rendering performance with proper memoization ## Breaking Changes None - all existing imports and functionality preserved.
33 lines
950 B
JavaScript
33 lines
950 B
JavaScript
import React from 'react';
|
|
import { Layout } from '@douyinfe/semi-ui';
|
|
import CardPro from '../../common/ui/CardPro.js';
|
|
import MjLogsTable from './MjLogsTable.jsx';
|
|
import MjLogsActions from './MjLogsActions.jsx';
|
|
import MjLogsFilters from './MjLogsFilters.jsx';
|
|
import ColumnSelectorModal from './modals/ColumnSelectorModal.jsx';
|
|
import ContentModal from './modals/ContentModal.jsx';
|
|
import { useMjLogsData } from '../../../hooks/mj-logs/useMjLogsData.js';
|
|
|
|
const MjLogsPage = () => {
|
|
const mjLogsData = useMjLogsData();
|
|
|
|
return (
|
|
<>
|
|
{/* Modals */}
|
|
<ColumnSelectorModal {...mjLogsData} />
|
|
<ContentModal {...mjLogsData} />
|
|
|
|
<Layout>
|
|
<CardPro
|
|
type="type2"
|
|
statsArea={<MjLogsActions {...mjLogsData} />}
|
|
searchArea={<MjLogsFilters {...mjLogsData} />}
|
|
>
|
|
<MjLogsTable {...mjLogsData} />
|
|
</CardPro>
|
|
</Layout>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default MjLogsPage;
|