From db6c30b6a7b80b992d722bf49d4643769948f260 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 14 Sep 2024 07:49:53 +0530 Subject: [PATCH 01/13] chore: lint --- src/context/browserSteps.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/context/browserSteps.tsx b/src/context/browserSteps.tsx index c2cab814..4af37df0 100644 --- a/src/context/browserSteps.tsx +++ b/src/context/browserSteps.tsx @@ -91,6 +91,7 @@ export const BrowserStepsProvider: React.FC<{ children: React.ReactNode }> = ({ } }); }; + const addScreenshotStep = (fullPage: boolean) => { setBrowserSteps(prevSteps => [ ...prevSteps, From 393ad8cb9df962a3568bde59f82ff7de0f812f31 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 14 Sep 2024 08:05:33 +0530 Subject: [PATCH 02/13] fix: use id as key instead of label for newField --- src/components/organisms/BrowserWindow.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/organisms/BrowserWindow.tsx b/src/components/organisms/BrowserWindow.tsx index 929eb06f..c92fdc25 100644 --- a/src/components/organisms/BrowserWindow.tsx +++ b/src/components/organisms/BrowserWindow.tsx @@ -216,7 +216,7 @@ export const BrowserWindow = () => { const newField: TextStep = { id: Date.now(), type: 'text', - label: ``, + label: `Label ${Object.keys(fields).length + 1}`, data: data, selectorObj: { selector: highlighterData.selector, @@ -228,14 +228,14 @@ export const BrowserWindow = () => { setFields(prevFields => { const updatedFields = { ...prevFields, - [newField.label]: newField + [newField.id]: newField }; console.log(updatedFields) return updatedFields; }); if (listSelector) { - addListStep(listSelector, { ...fields, [newField.label]: newField }, currentListId, { type: '', selector: paginationSelector }); + addListStep(listSelector, { ...fields, [newField.id]: newField }, currentListId, { type: '', selector: paginationSelector }); } } else { @@ -276,7 +276,7 @@ export const BrowserWindow = () => { const newField: TextStep = { id: Date.now(), type: 'text', - label: ``, + label: `Label ${Object.keys(fields).length + 1}`, data: data, selectorObj: { selector: selectedElement.selector, @@ -288,7 +288,7 @@ export const BrowserWindow = () => { setFields(prevFields => { const updatedFields = { ...prevFields, - [newField.label]: newField + [newField.id]: newField }; console.log(updatedFields) @@ -296,7 +296,7 @@ export const BrowserWindow = () => { }); if (listSelector) { - addListStep(listSelector, { ...fields, [newField.label]: newField }, currentListId, { type: '', selector: paginationSelector }); + addListStep(listSelector, { ...fields, [newField.id]: newField }, currentListId, { type: '', selector: paginationSelector }); } } From 2348795f084d80ed1e834a5d8babb46d378ba10f Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 14 Sep 2024 08:06:22 +0530 Subject: [PATCH 03/13] fix: foramt --- src/components/organisms/BrowserWindow.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/components/organisms/BrowserWindow.tsx b/src/components/organisms/BrowserWindow.tsx index c92fdc25..f14c7024 100644 --- a/src/components/organisms/BrowserWindow.tsx +++ b/src/components/organisms/BrowserWindow.tsx @@ -290,15 +290,12 @@ export const BrowserWindow = () => { ...prevFields, [newField.id]: newField }; - console.log(updatedFields) - return updatedFields; }); if (listSelector) { addListStep(listSelector, { ...fields, [newField.id]: newField }, currentListId, { type: '', selector: paginationSelector }); } - } } } From dca070fb4f263896c05fadff805a61809b10dc09 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 14 Sep 2024 08:14:45 +0530 Subject: [PATCH 04/13] feat: prevent list text label edit if field confirmed --- src/components/organisms/RightSidePanel.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index 36986203..e1c4d26f 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -41,6 +41,10 @@ export const RightSidePanel: React.FC = ({ onFinishCapture const handleTextLabelChange = (id: number, label: string, listId?: number, fieldKey?: string) => { if (listId !== undefined && fieldKey !== undefined) { + // Prevent editing if the field is confirmed + if (confirmedListTextFields[listId]?.[fieldKey]) { + return; + } // This is a text field within a list step updateListTextFieldLabel(listId, fieldKey, label); } else { From e9f7e6b41b431aec95780770d412d5056a7ce8e5 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 14 Sep 2024 08:16:36 +0530 Subject: [PATCH 05/13] feat: set to read-only if field confirmed --- src/components/organisms/RightSidePanel.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index e1c4d26f..88a2bb18 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -409,6 +409,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture fullWidth margin="normal" InputProps={{ + readOnly: confirmedListTextFields[field.id]?.[key], startAdornment: ( From 29f78086d986c39bdcec1c1c85dc7d934ae25dca Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 14 Sep 2024 08:17:00 +0530 Subject: [PATCH 06/13] chore: lint --- src/components/organisms/RightSidePanel.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index 88a2bb18..5b9d6b5c 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -42,9 +42,9 @@ export const RightSidePanel: React.FC = ({ onFinishCapture const handleTextLabelChange = (id: number, label: string, listId?: number, fieldKey?: string) => { if (listId !== undefined && fieldKey !== undefined) { // Prevent editing if the field is confirmed - if (confirmedListTextFields[listId]?.[fieldKey]) { - return; - } + if (confirmedListTextFields[listId]?.[fieldKey]) { + return; + } // This is a text field within a list step updateListTextFieldLabel(listId, fieldKey, label); } else { @@ -166,7 +166,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture return settings; }, [browserSteps, paginationType, limitType, customLimit]); - + const resetListState = useCallback(() => { setShowPaginationOptions(false); From 7b9f47756044029805c56c4252008755b7284d68 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 14 Sep 2024 08:24:39 +0530 Subject: [PATCH 07/13] chore: remove clickNext & clickLoadMore check --- src/components/organisms/RightSidePanel.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index 5b9d6b5c..0672dcd3 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -242,8 +242,6 @@ export const RightSidePanel: React.FC = ({ onFinishCapture const handlePaginationSettingSelect = (option: PaginationType) => { updatePaginationType(option); - if (['clickNext', 'clickLoadMore'].includes(option)) { - } }; const captureScreenshot = (fullPage: boolean) => { From 31d47f56fcdf73eb354495035907ab37dd03bb9d Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 14 Sep 2024 08:32:56 +0530 Subject: [PATCH 08/13] feat: handle stop get text --- src/components/organisms/RightSidePanel.tsx | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index 0672dcd3..4ee59d7e 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -244,6 +244,28 @@ export const RightSidePanel: React.FC = ({ onFinishCapture updatePaginationType(option); }; + const handleStopGetText = useCallback(() => { + stopGetText(); + + // Delete all text steps from browserSteps + browserSteps.forEach(step => { + if (step.type === 'text') { + deleteBrowserStep(step.id); + } + }); + + // Clear all related UI state + setTextLabels({}); + setErrors({}); + setConfirmedTextSteps({}); + + // Optionally notify user of deletion + notify('info', 'All text capture steps discarded'); + }, [browserSteps, stopGetText, deleteBrowserStep]); + + + + const captureScreenshot = (fullPage: boolean) => { const screenshotSettings: ScreenshotSettings = { fullPage, From 8311dad032eab42ecf2149a7627c0ba0aa383633 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 14 Sep 2024 08:33:23 +0530 Subject: [PATCH 09/13] feat: handle stop get list --- src/components/organisms/RightSidePanel.tsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index 4ee59d7e..8f7f2f3e 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -246,24 +246,27 @@ export const RightSidePanel: React.FC = ({ onFinishCapture const handleStopGetText = useCallback(() => { stopGetText(); - - // Delete all text steps from browserSteps browserSteps.forEach(step => { if (step.type === 'text') { deleteBrowserStep(step.id); } }); - - // Clear all related UI state setTextLabels({}); setErrors({}); setConfirmedTextSteps({}); - - // Optionally notify user of deletion notify('info', 'All text capture steps discarded'); }, [browserSteps, stopGetText, deleteBrowserStep]); - + const handleStopGetList = useCallback(() => { + stopGetList(); + browserSteps.forEach(step => { + if (step.type === 'list') { + deleteBrowserStep(step.id); + } + }); + resetListState(); + notify('info', 'All list capture steps discarded'); + }, [browserSteps, stopGetList, deleteBrowserStep, resetListState]); const captureScreenshot = (fullPage: boolean) => { From 25579a2ce56ab8ecc15d04fa43bca2cb0bb3ad18 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 14 Sep 2024 08:34:31 +0530 Subject: [PATCH 10/13] refactor: better names --- src/components/organisms/RightSidePanel.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index 8f7f2f3e..09c6a1c9 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -244,7 +244,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture updatePaginationType(option); }; - const handleStopGetText = useCallback(() => { + const discardGetText = useCallback(() => { stopGetText(); browserSteps.forEach(step => { if (step.type === 'text') { @@ -257,7 +257,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture notify('info', 'All text capture steps discarded'); }, [browserSteps, stopGetText, deleteBrowserStep]); - const handleStopGetList = useCallback(() => { + const discardGetList = useCallback(() => { stopGetList(); browserSteps.forEach(step => { if (step.type === 'list') { From 3d3083c946d29cf83ef11d99e08f09cabfb54db9 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 14 Sep 2024 08:35:41 +0530 Subject: [PATCH 11/13] feat: use discard list & text --- src/components/organisms/RightSidePanel.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index 09c6a1c9..be14f9af 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -299,7 +299,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture captureStage === 'pagination' ? 'Confirm Pagination' : captureStage === 'limit' ? 'Confirm Limit' : 'Finish Capture'} - + )} @@ -354,7 +354,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture <> - + } From 8acc306a58c837acf1299c114f485bf592415ca6 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 14 Sep 2024 08:38:07 +0530 Subject: [PATCH 12/13] feat: notify --- src/components/organisms/RightSidePanel.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index be14f9af..02f5ef3a 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -254,7 +254,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture setTextLabels({}); setErrors({}); setConfirmedTextSteps({}); - notify('info', 'All text capture steps discarded'); + notify('info', 'Capture Text steps discarded'); }, [browserSteps, stopGetText, deleteBrowserStep]); const discardGetList = useCallback(() => { @@ -265,7 +265,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture } }); resetListState(); - notify('info', 'All list capture steps discarded'); + notify('info', 'Capture List steps discarded'); }, [browserSteps, stopGetList, deleteBrowserStep, resetListState]); From 9a0c9f05b2b833cb4c8a4200129eeb5aed8d8dc5 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Sat, 14 Sep 2024 08:38:32 +0530 Subject: [PATCH 13/13] chore: lint --- src/components/organisms/RightSidePanel.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index 02f5ef3a..0cf0cb90 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -256,7 +256,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture setConfirmedTextSteps({}); notify('info', 'Capture Text steps discarded'); }, [browserSteps, stopGetText, deleteBrowserStep]); - + const discardGetList = useCallback(() => { stopGetList(); browserSteps.forEach(step => { @@ -267,7 +267,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture resetListState(); notify('info', 'Capture List steps discarded'); }, [browserSteps, stopGetList, deleteBrowserStep, resetListState]); - + const captureScreenshot = (fullPage: boolean) => { const screenshotSettings: ScreenshotSettings = {