From a8f2e31c4eda90184ec1df7c34a220aa5c22e05d Mon Sep 17 00:00:00 2001 From: Mantvydas Deltuva Date: Mon, 26 Aug 2024 22:26:57 +0300 Subject: [PATCH] MDE/back-end-optimization fixes on the front-end --- app/front-end/package.json | 2 - .../components/consoleView/consoleView.tsx | 5 +- .../editorView/editorColumnMenu.tsx | 16 +++ .../components/editorView/editorToolbar.tsx | 14 +- .../components/editorView/editorView.tsx | 125 ++++++++++-------- .../editor/components/editorView/index.ts | 1 + .../src/features/editor/types/fileData.ts | 13 ++ .../src/features/editor/types/index.ts | 1 + app/front-end/src/types/constants/events.ts | 4 + app/front-end/src/types/index.ts | 1 + 10 files changed, 115 insertions(+), 67 deletions(-) create mode 100644 app/front-end/src/features/editor/components/editorView/editorColumnMenu.tsx create mode 100644 app/front-end/src/features/editor/types/fileData.ts create mode 100644 app/front-end/src/types/constants/events.ts diff --git a/app/front-end/package.json b/app/front-end/package.json index 53a821e..3876996 100644 --- a/app/front-end/package.json +++ b/app/front-end/package.json @@ -18,7 +18,6 @@ "@mui/x-tree-view": "^7.12.1", "@react-spring/web": "^9.7.4", "axios": "^1.7.4", - "papaparse": "^5.4.1", "react": "^18.3.1", "react-dom": "^18.3.1", "react-router-dom": "^6.26.0", @@ -27,7 +26,6 @@ "devDependencies": { "@mui/x-data-grid-generator": "^7.12.1", "@types/node": "^22.2.0", - "@types/papaparse": "^5.3.14", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", "@typescript-eslint/eslint-plugin": "^7.15.0", diff --git a/app/front-end/src/features/editor/components/consoleView/consoleView.tsx b/app/front-end/src/features/editor/components/consoleView/consoleView.tsx index 1893343..c008e41 100644 --- a/app/front-end/src/features/editor/components/consoleView/consoleView.tsx +++ b/app/front-end/src/features/editor/components/consoleView/consoleView.tsx @@ -1,6 +1,7 @@ import { ConsoleGroup, ConsoleGroupItem } from '@/features/editor/components/consoleView'; import { ConsoleFeedback } from '@/features/editor/types'; import { socket } from '@/lib'; +import { Events } from '@/types'; import { useEffect, useRef, useState } from 'react'; /** @@ -29,10 +30,10 @@ export const ConsoleView: React.FC = () => { setConsoleFeedback((prev) => [...prev, data]); }; - socket.on('console_feedback', handleConsoleFeedback); + socket.on(Events.CONSOLE_FEEDBACK_EVENT, handleConsoleFeedback); return () => { - socket.off('console_feedback'); + socket.off(Events.CONSOLE_FEEDBACK_EVENT); }; }, []); diff --git a/app/front-end/src/features/editor/components/editorView/editorColumnMenu.tsx b/app/front-end/src/features/editor/components/editorView/editorColumnMenu.tsx new file mode 100644 index 0000000..95868c4 --- /dev/null +++ b/app/front-end/src/features/editor/components/editorView/editorColumnMenu.tsx @@ -0,0 +1,16 @@ +import { styled } from '@mui/material/styles'; +import { GridColumnMenuContainer, GridColumnMenuHideItem, GridColumnMenuProps } from '@mui/x-data-grid'; + +const StyledGridColumnMenuContainer = styled(GridColumnMenuContainer)(({ theme }) => ({ + backgroundColor: theme.palette.secondary.main, +})); + +interface GridColumnMenuContainerProps extends GridColumnMenuProps {} + +export const EditorColumnMenu: React.FC = ({ hideMenu, colDef, ...other }) => { + return ( + + + + ); +}; diff --git a/app/front-end/src/features/editor/components/editorView/editorToolbar.tsx b/app/front-end/src/features/editor/components/editorView/editorToolbar.tsx index 61c17d1..3235f30 100644 --- a/app/front-end/src/features/editor/components/editorView/editorToolbar.tsx +++ b/app/front-end/src/features/editor/components/editorView/editorToolbar.tsx @@ -1,12 +1,11 @@ import { socket } from '@/lib'; +import { Events } from '@/types'; import { Done as DoneIcon, Error as ErrorIcon } from '@mui/icons-material'; import { Box, Button, CircularProgress, useTheme } from '@mui/material'; import { GridToolbarColumnsButton, GridToolbarContainer, GridToolbarDensitySelector, - GridToolbarExport, - GridToolbarFilterButton, GridToolbarProps, ToolbarPropsOverrides, } from '@mui/x-data-grid'; @@ -55,22 +54,23 @@ export const EditorToolbar: React.FC = ({ disabled, handleSa const Theme = useTheme(); useEffect(() => { - socket.on('workspace_file_update_status', (data) => { + const handleWorkspaceFileSaveFeedback = (data: { status: 'success' | 'error' }) => { setIsSaving(false); setSaveStatus(data.status === 'success'); - }); + }; + socket.on(Events.WORKSPACE_FILE_SAVE_FEEDBACK_EVENT, handleWorkspaceFileSaveFeedback); return () => { - socket.off('workspace_file_update_status'); + socket.off(Events.WORKSPACE_FILE_SAVE_FEEDBACK_EVENT); }; }); return ( - + {/* */} - + {/* */}