From 7c4e2183299c418ed40282a4a22c3a159d5231f0 Mon Sep 17 00:00:00 2001 From: Sayali Joshi Date: Thu, 16 Jan 2025 17:59:38 +0530 Subject: [PATCH 1/3] Resolved Icons issue on Logger panel --- ui/src/components/LogScreen/MigrationLogViewer.tsx | 2 +- ui/src/components/LogScreen/index.tsx | 2 +- ui/src/components/TestMigration/index.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/src/components/LogScreen/MigrationLogViewer.tsx b/ui/src/components/LogScreen/MigrationLogViewer.tsx index 2b90c7d62..5cfe82e47 100644 --- a/ui/src/components/LogScreen/MigrationLogViewer.tsx +++ b/ui/src/components/LogScreen/MigrationLogViewer.tsx @@ -273,7 +273,7 @@ const MigrationLogViewer = ({ serverPath }: LogsType) => { } - {!newMigrationData?.migration_execution?.migrationCompleted && ( + {!newMigrationData?.migration_execution?.migrationCompleted && !logs?.every((log) => log.message === "Migration logs will appear here once the process begins.") && (
diff --git a/ui/src/components/LogScreen/index.tsx b/ui/src/components/LogScreen/index.tsx index 215ec3cab..8d4171dcb 100644 --- a/ui/src/components/LogScreen/index.tsx +++ b/ui/src/components/LogScreen/index.tsx @@ -238,7 +238,7 @@ const TestMigrationLogViewer = ({ serverPath, sendDataToParent,projectId }: Logs
{/* Action buttons for scrolling and zooming */} - {!migratedTestStack?.isMigrated && !logs?.some((log) => log.message === "Migration logs will appear here once the process begins.") && ( + {!migratedTestStack?.isMigrated && !logs?.every((log) => log.message === "Migration logs will appear here once the process begins.") && (
diff --git a/ui/src/components/TestMigration/index.tsx b/ui/src/components/TestMigration/index.tsx index 6b800ccc1..80a1ffcd5 100644 --- a/ui/src/components/TestMigration/index.tsx +++ b/ui/src/components/TestMigration/index.tsx @@ -75,7 +75,7 @@ const TestMigration = () => { ? !newMigrationData?.testStacks?.some( (stack) => stack?.stackUid === newMigrationData?.test_migration?.stack_api_key && - stack.isMigrated + stack?.isMigrated ) || newMigrationData?.test_migration?.isMigrationStarted : newMigrationData?.migration_execution?.migrationCompleted || newMigrationData?.migration_execution?.migrationStarted || false; From 02bd405680a1c01cc68f8d8cdfe8392c641d4b3d Mon Sep 17 00:00:00 2001 From: AishDani Date: Thu, 16 Jan 2025 22:24:40 +0530 Subject: [PATCH 2/3] refactor:displaying test migration completed message in terminal on UI --- ui/src/components/LogScreen/index.tsx | 50 +++++++++++++++++++++------ 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/ui/src/components/LogScreen/index.tsx b/ui/src/components/LogScreen/index.tsx index 8d4171dcb..b3659bf04 100644 --- a/ui/src/components/LogScreen/index.tsx +++ b/ui/src/components/LogScreen/index.tsx @@ -9,7 +9,7 @@ import { RootState } from '../../store'; import { updateNewMigrationData } from '../../store/slice/migrationDataSlice'; // Interface -import { INewMigration } from '../../context/app/app.interface'; +import { INewMigration, TestStacks } from '../../context/app/app.interface'; // CSS import './index.scss'; @@ -44,9 +44,19 @@ const TestMigrationLogViewer = ({ serverPath, sendDataToParent,projectId }: Logs const newMigrationData = useSelector((state: RootState) => state?.migration?.newMigrationData); + const [migratedStack, setmigratedSatck] = useState( + (newMigrationData?.testStacks ?? [])?.find((test) => test?.stackUid === newMigrationData?.test_migration?.stack_api_key)); + const [isLogsLoading, setisLogsLoading] = useState(false) // Redux dispatcher const dispatch = useDispatch(); + + + useEffect(()=>{ + const migratedTestStack = newMigrationData?.testStacks?.find((test) => test?.stackUid === newMigrationData?.test_migration?.stack_api_key); + setmigratedSatck(migratedTestStack); + },[newMigrationData?.test_migration]); + // Set up WebSocket connection useEffect(() => { const socket = io(serverPath || '',{ @@ -63,6 +73,7 @@ const TestMigrationLogViewer = ({ serverPath, sendDataToParent,projectId }: Logs * @param {string} newLogs - The new logs received from the server. */ socket.on('logUpdate', (newLogs: string) => { + setisLogsLoading(true); const parsedLogsArray: LogEntry[] = []; const logArray = newLogs?.split('\n') @@ -145,19 +156,19 @@ const TestMigrationLogViewer = ({ serverPath, sendDataToParent,projectId }: Logs const logsContainerRef = useRef(null); - const migratedTestStack = newMigrationData?.testStacks?.find((test) => test?.stackUid === newMigrationData?.test_migration?.stack_api_key) useEffect(() => { if (logsContainerRef.current) { logsContainerRef.current.scrollTop = logsContainerRef.current.scrollHeight; } - logs?.forEach((log) => { + logs?.forEach((log: LogEntry) => { try { //const logObject = JSON.parse(log); const message = log?.message; if (message === "Test Migration Process Completed") { + setisLogsLoading(false); // Save test migration state to local storage saveStateToLocalStorage(`testmigration_${projectId}`, { @@ -174,11 +185,21 @@ const TestMigrationLogViewer = ({ serverPath, sendDataToParent,projectId }: Logs type: 'success' }); sendDataToParent?.(false); - + const stacks = newMigrationData?.testStacks?.length > 0 ? + newMigrationData?.testStacks?.map((stack)=> + stack?.stackUid === newMigrationData?.test_migration?.stack_api_key + ? { + ...stack, + stackName: newMigrationData?.test_migration?.stack_name, + isMigrated: true + } + : stack + ) : [{stackUid: newMigrationData?.test_migration?.stack_api_key, stackName: newMigrationData?.test_migration?.stack_name, isMigrated: true}] + // Update testStacks data in Redux const newMigrationObj: INewMigration = { ...newMigrationData, - testStacks: [...newMigrationData?.testStacks ?? [], {stackUid: newMigrationData?.test_migration?.stack_api_key, stackName: newMigrationData?.test_migration?.stack_name, isMigrated: true}], + testStacks: stacks, test_migration:{ ...newMigrationData?.test_migration, isMigrationComplete:true, @@ -194,14 +215,22 @@ const TestMigrationLogViewer = ({ serverPath, sendDataToParent,projectId }: Logs }); }, [logs]); + useEffect(()=>{ + if(! isLogsLoading && !migratedStack?.isMigrated){ + setLogs([{ message: "Migration logs will appear here once the process begins.", level: ''}]); + } + + },[isLogsLoading, migratedStack?.isMigrated]); + + return (
{/* Logs container */}
- {migratedTestStack?.isMigrated + {migratedStack?.isMigrated ?
-
Test Migration is completed for stack {migratedTestStack?.stackName}
-
+
Test Migration is completed for stack {migratedStack?.stackName}
+
:
{message === "Migration logs will appear here once the process begins." ?
-
{message}
: +
{message}
+
:
{index}
@@ -238,7 +268,7 @@ const TestMigrationLogViewer = ({ serverPath, sendDataToParent,projectId }: Logs
{/* Action buttons for scrolling and zooming */} - {!migratedTestStack?.isMigrated && !logs?.every((log) => log.message === "Migration logs will appear here once the process begins.") && ( + {!migratedStack?.isMigrated && !logs?.some((log) => log.message === "Migration logs will appear here once the process begins.") && (
From 87c40e472be7066c5cafe97235f5811ef7872c97 Mon Sep 17 00:00:00 2001 From: AishDani Date: Thu, 16 Jan 2025 22:29:59 +0530 Subject: [PATCH 3/3] refactor:reverted code of icon issue --- ui/src/components/LogScreen/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/components/LogScreen/index.tsx b/ui/src/components/LogScreen/index.tsx index b3659bf04..800fb5277 100644 --- a/ui/src/components/LogScreen/index.tsx +++ b/ui/src/components/LogScreen/index.tsx @@ -268,7 +268,7 @@ const TestMigrationLogViewer = ({ serverPath, sendDataToParent,projectId }: Logs
{/* Action buttons for scrolling and zooming */} - {!migratedStack?.isMigrated && !logs?.some((log) => log.message === "Migration logs will appear here once the process begins.") && ( + {!migratedStack?.isMigrated && !logs?.every((log) => log.message === "Migration logs will appear here once the process begins.") && (