From 845047ddc85fbc793481e2ed51fc0083c41a3f55 Mon Sep 17 00:00:00 2001 From: Mantvydas Deltuva Date: Tue, 10 Sep 2024 19:16:27 +0300 Subject: [PATCH] MDE/PKFE-46 implemented socket emit in [FE] --- .../fileTreeItem/fileTreeItemContextMenu.tsx | 9 +++++---- app/front-end/src/types/constants/events.ts | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/front-end/src/features/editor/components/fileTreeView/fileTreeItem/fileTreeItemContextMenu.tsx b/app/front-end/src/features/editor/components/fileTreeView/fileTreeItem/fileTreeItemContextMenu.tsx index 2b7518c..5595cb1 100644 --- a/app/front-end/src/features/editor/components/fileTreeView/fileTreeItem/fileTreeItemContextMenu.tsx +++ b/app/front-end/src/features/editor/components/fileTreeView/fileTreeItem/fileTreeItemContextMenu.tsx @@ -5,8 +5,9 @@ import { } from '@/features/editor/components/fileTreeView/fileTreeItem'; import { useWorkspaceContext } from '@/features/editor/hooks'; import { FileTreeItemContextMenuActions, FileTreeViewItemProps, FileTypes } from '@/features/editor/types'; -import { axios } from '@/lib'; -import { Endpoints } from '@/types'; +import { axios, socket } from '@/lib'; +import { Endpoints, Events } from '@/types'; +import { getSID, getUUID } from '@/utils'; import { Divider, Menu, MenuItem } from '@mui/material'; import { useCallback, useState } from 'react'; @@ -174,9 +175,9 @@ export const FileTreeItemContextMenu: React.FC = ( link.click(); window.URL.revokeObjectURL(url); - // TODO: Implement socket console event for successful file export - console.log('Exported:', fileName); + socket.emit(Events.WORKSPACE_EXPORT_FEEDBACK_EVENT, { uuid: getUUID(), sid: getSID(), status: 'success' }); } catch (error) { + socket.emit(Events.WORKSPACE_EXPORT_FEEDBACK_EVENT, { uuid: getUUID(), sid: getSID(), status: 'failure' }); console.error('Error exporting file:', error); } }, [item]); diff --git a/app/front-end/src/types/constants/events.ts b/app/front-end/src/types/constants/events.ts index 33b7072..d4460e0 100644 --- a/app/front-end/src/types/constants/events.ts +++ b/app/front-end/src/types/constants/events.ts @@ -9,11 +9,13 @@ * - `CONSOLE_FEEDBACK_EVENT`: The event name for console feedback messages. * - `WORKSPACE_FILE_SAVE_FEEDBACK_EVENT`: The event name for feedback related to saving files in the workspace. * - `WORKSPACE_UPDATE_FEEDBACK_EVENT`: The event name for feedback related to updates in the workspace. + * - `WORKSPACE_EXPORT_FEEDBACK_EVENT`: The event name for feedback related to exporting the workspace. * * @constant {Object} Events - The object containing event names. * @property {string} CONSOLE_FEEDBACK_EVENT - The event name for receiving console feedback messages. * @property {string} WORKSPACE_FILE_SAVE_FEEDBACK_EVENT - The event name for receiving feedback on file save operations within the workspace. * @property {string} WORKSPACE_UPDATE_FEEDBACK_EVENT - The event name for receiving feedback on workspace updates. + * @property {string} WORKSPACE_EXPORT_FEEDBACK_EVENT - The event name for receiving feedback on exporting the workspace. * * @example * // Example usage of the Events object @@ -26,4 +28,5 @@ export const Events = { CONSOLE_FEEDBACK_EVENT: 'console_feedback', WORKSPACE_FILE_SAVE_FEEDBACK_EVENT: 'workspace_file_save_feedback', WORKSPACE_UPDATE_FEEDBACK_EVENT: 'workspace_update_feedback', + WORKSPACE_EXPORT_FEEDBACK_EVENT: 'workspace_export_feedback', };