From f0ec5dbb67d865675221c3f667a043dd2eafdc80 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Fri, 13 Sep 2024 23:25:36 +0530 Subject: [PATCH 01/23] feat: updateListTextFieldLabel --- src/context/browserSteps.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/context/browserSteps.tsx b/src/context/browserSteps.tsx index 1c9dbf34..b3ed2b0a 100644 --- a/src/context/browserSteps.tsx +++ b/src/context/browserSteps.tsx @@ -42,6 +42,7 @@ interface BrowserStepsContextType { addScreenshotStep: (fullPage: boolean) => void; deleteBrowserStep: (id: number) => void; updateBrowserTextStepLabel: (id: number, newLabel: string) => void; + updateListTextFieldLabel: (listId: number, fieldKey: string, newLabel: string) => void; } const BrowserStepsContext = createContext(undefined); @@ -109,6 +110,7 @@ export const BrowserStepsProvider: React.FC<{ children: React.ReactNode }> = ({ addScreenshotStep, deleteBrowserStep, updateBrowserTextStepLabel, + updateListTextFieldLabel, }}> {children} From e4ed54a7c07d84de6b1404aa283e575a7b1667ba Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Fri, 13 Sep 2024 23:26:24 +0530 Subject: [PATCH 02/23] feat: implement updateListTextFieldLabel --- src/context/browserSteps.tsx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/context/browserSteps.tsx b/src/context/browserSteps.tsx index b3ed2b0a..badf5e5c 100644 --- a/src/context/browserSteps.tsx +++ b/src/context/browserSteps.tsx @@ -102,6 +102,26 @@ export const BrowserStepsProvider: React.FC<{ children: React.ReactNode }> = ({ ); }; + const updateListTextFieldLabel = (listId: number, fieldKey: string, newLabel: string) => { + setBrowserSteps(prevSteps => + prevSteps.map(step => { + if (step.type === 'list' && step.id === listId) { + return { + ...step, + fields: { + ...step.fields, + [fieldKey]: { + ...step.fields[fieldKey], + label: newLabel + } + } + }; + } + return step; + }) + ); + }; + return ( Date: Fri, 13 Sep 2024 23:27:03 +0530 Subject: [PATCH 03/23] chore: lint --- src/context/browserSteps.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/context/browserSteps.tsx b/src/context/browserSteps.tsx index badf5e5c..6421f393 100644 --- a/src/context/browserSteps.tsx +++ b/src/context/browserSteps.tsx @@ -102,7 +102,7 @@ export const BrowserStepsProvider: React.FC<{ children: React.ReactNode }> = ({ ); }; - const updateListTextFieldLabel = (listId: number, fieldKey: string, newLabel: string) => { + const updateListTextFieldLabel = (listId: number, fieldKey: string, newLabel: string) => { setBrowserSteps(prevSteps => prevSteps.map(step => { if (step.type === 'list' && step.id === listId) { From 35f835b6f1c74e6f954223ccd57a4be68f7c9ca0 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Fri, 13 Sep 2024 23:27:57 +0530 Subject: [PATCH 04/23] feat: get updateListTextFieldLabel from browser steps context --- src/components/organisms/RightSidePanel.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index d73d7ff2..44bad7a3 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -37,7 +37,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture const { lastAction, notify } = useGlobalInfoStore(); const { getText, startGetText, stopGetText, getScreenshot, startGetScreenshot, stopGetScreenshot, paginationMode, getList, startGetList, stopGetList, startPaginationMode, stopPaginationMode, paginationType, updatePaginationType, limitMode, limitType, customLimit, updateLimitType, updateCustomLimit, stopLimitMode, startLimitMode } = useActionContext(); - const { browserSteps, updateBrowserTextStepLabel, deleteBrowserStep, addScreenshotStep } = useBrowserSteps(); + const { browserSteps, updateBrowserTextStepLabel, deleteBrowserStep, addScreenshotStep, updateListTextFieldLabel } = useBrowserSteps(); const { socket } = useSocketStore(); const handleTextLabelChange = (id: number, label: string) => { From 4a49517b3aa3aa0793bcff7af12673ec696699c1 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Fri, 13 Sep 2024 23:32:42 +0530 Subject: [PATCH 05/23] feat: handle text label change --- src/components/organisms/RightSidePanel.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index 44bad7a3..daf11f3f 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -40,8 +40,14 @@ export const RightSidePanel: React.FC = ({ onFinishCapture const { browserSteps, updateBrowserTextStepLabel, deleteBrowserStep, addScreenshotStep, updateListTextFieldLabel } = useBrowserSteps(); const { socket } = useSocketStore(); - const handleTextLabelChange = (id: number, label: string) => { - setTextLabels(prevLabels => ({ ...prevLabels, [id]: label })); + const handleTextLabelChange = (id: number, label: string, listId?: number, fieldKey?: string) => { + if (listId !== undefined && fieldKey !== undefined) { + // This is a text field within a list step + updateListTextFieldLabel(listId, fieldKey, label); + } else { + // This is a standalone text step + setTextLabels(prevLabels => ({ ...prevLabels, [id]: label })); + } if (!label.trim()) { setErrors(prevErrors => ({ ...prevErrors, [id]: 'Label cannot be empty' })); } else { From 66e825ad56ded2ba4734dbce674adc89b23feacc Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Fri, 13 Sep 2024 23:34:02 +0530 Subject: [PATCH 06/23] feat: list step text label change --- src/components/organisms/RightSidePanel.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index daf11f3f..922b5875 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -375,7 +375,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture { }} + onChange={(e) => handleTextLabelChange(field.id, e.target.value, step.id, key)} fullWidth margin="normal" InputProps={{ From f74b9fefef62304a734e6cb1374542d452eb4625 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Fri, 13 Sep 2024 23:36:38 +0530 Subject: [PATCH 07/23] feat: local state for list text field confirmation --- 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 922b5875..d906d318 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -31,6 +31,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture const [textLabels, setTextLabels] = useState<{ [id: number]: string }>({}); const [errors, setErrors] = useState<{ [id: number]: string }>({}); const [confirmedTextSteps, setConfirmedTextSteps] = useState<{ [id: number]: boolean }>({}); + const [confirmedListTextFields, setConfirmedListTextFields] = useState<{ [listId: number]: { [fieldKey: string]: boolean } }>({}); const [showPaginationOptions, setShowPaginationOptions] = useState(false); const [showLimitOptions, setShowLimitOptions] = useState(false); const [captureStage, setCaptureStage] = useState<'initial' | 'pagination' | 'limit' | 'complete'>('initial'); From b9349a8f50802d2599c893e1a839a1e6c2e12149 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Fri, 13 Sep 2024 23:37:40 +0530 Subject: [PATCH 08/23] feat: handle list text field confirmation --- src/components/organisms/RightSidePanel.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index d906d318..b36159d0 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -78,6 +78,17 @@ export const RightSidePanel: React.FC = ({ onFinishCapture }); }; + const handleListTextFieldConfirm = (listId: number, fieldKey: string) => { + setConfirmedListTextFields(prev => ({ + ...prev, + [listId]: { + ...(prev[listId] || {}), + [fieldKey]: true + } + })); + }; + + const getTextSettingsObject = useCallback(() => { const settings: Record = {}; browserSteps.forEach(step => { From 37e54dc619968e45fa00743c13a8303cff36fa65 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Fri, 13 Sep 2024 23:38:58 +0530 Subject: [PATCH 09/23] feat: remove removeListTextField --- src/context/browserSteps.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/context/browserSteps.tsx b/src/context/browserSteps.tsx index 6421f393..8c9063e8 100644 --- a/src/context/browserSteps.tsx +++ b/src/context/browserSteps.tsx @@ -43,6 +43,7 @@ interface BrowserStepsContextType { deleteBrowserStep: (id: number) => void; updateBrowserTextStepLabel: (id: number, newLabel: string) => void; updateListTextFieldLabel: (listId: number, fieldKey: string, newLabel: string) => void; + removeListTextField: (listId: number, fieldKey: string) => void; } const BrowserStepsContext = createContext(undefined); @@ -131,6 +132,7 @@ export const BrowserStepsProvider: React.FC<{ children: React.ReactNode }> = ({ deleteBrowserStep, updateBrowserTextStepLabel, updateListTextFieldLabel, + removeListTextField, }}> {children} From 64d41896f7e3e219bf37df930349cbc0bf626222 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Fri, 13 Sep 2024 23:39:28 +0530 Subject: [PATCH 10/23] feat: handle removeListTextField --- src/context/browserSteps.tsx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/context/browserSteps.tsx b/src/context/browserSteps.tsx index 8c9063e8..81a78959 100644 --- a/src/context/browserSteps.tsx +++ b/src/context/browserSteps.tsx @@ -123,6 +123,21 @@ export const BrowserStepsProvider: React.FC<{ children: React.ReactNode }> = ({ ); }; + const removeListTextField = (listId: number, fieldKey: string) => { + setBrowserSteps(prevSteps => + prevSteps.map(step => { + if (step.type === 'list' && step.id === listId) { + const { [fieldKey]: _, ...remainingFields } = step.fields; + return { + ...step, + fields: remainingFields + }; + } + return step; + }) + ); + }; + return ( Date: Fri, 13 Sep 2024 23:40:11 +0530 Subject: [PATCH 11/23] feat: handle list text field discard --- src/components/organisms/RightSidePanel.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index b36159d0..19ce166f 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -88,6 +88,16 @@ export const RightSidePanel: React.FC = ({ onFinishCapture })); }; + const handleListTextFieldDiscard = (listId: number, fieldKey: string) => { + removeListTextField(listId, fieldKey); + setConfirmedListTextFields(prev => ({ + ...prev, + [listId]: { + ...(prev[listId] || {}), + [fieldKey]: false + } + })); +}; const getTextSettingsObject = useCallback(() => { const settings: Record = {}; From f37a4b53118f3d8e7bfc99805eb58e18329e0a95 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Fri, 13 Sep 2024 23:40:42 +0530 Subject: [PATCH 12/23] fix: import removeListTextField --- src/components/organisms/RightSidePanel.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index 19ce166f..dc0c3e47 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -38,7 +38,7 @@ export const RightSidePanel: React.FC = ({ onFinishCapture const { lastAction, notify } = useGlobalInfoStore(); const { getText, startGetText, stopGetText, getScreenshot, startGetScreenshot, stopGetScreenshot, paginationMode, getList, startGetList, stopGetList, startPaginationMode, stopPaginationMode, paginationType, updatePaginationType, limitMode, limitType, customLimit, updateLimitType, updateCustomLimit, stopLimitMode, startLimitMode } = useActionContext(); - const { browserSteps, updateBrowserTextStepLabel, deleteBrowserStep, addScreenshotStep, updateListTextFieldLabel } = useBrowserSteps(); + const { browserSteps, updateBrowserTextStepLabel, deleteBrowserStep, addScreenshotStep, updateListTextFieldLabel, removeListTextField } = useBrowserSteps(); const { socket } = useSocketStore(); const handleTextLabelChange = (id: number, label: string, listId?: number, fieldKey?: string) => { From 5cab3dfaca7ab1138caf8391a57faebec7307add Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Fri, 13 Sep 2024 23:55:22 +0530 Subject: [PATCH 13/23] chore: lint --- src/components/organisms/RightSidePanel.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index dc0c3e47..40082221 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -91,13 +91,13 @@ export const RightSidePanel: React.FC = ({ onFinishCapture const handleListTextFieldDiscard = (listId: number, fieldKey: string) => { removeListTextField(listId, fieldKey); setConfirmedListTextFields(prev => ({ - ...prev, - [listId]: { - ...(prev[listId] || {}), - [fieldKey]: false - } + ...prev, + [listId]: { + ...(prev[listId] || {}), + [fieldKey]: false + } })); -}; + }; const getTextSettingsObject = useCallback(() => { const settings: Record = {}; From fe279691a4e73575785a3f1432687d8c56748ca2 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Fri, 13 Sep 2024 23:58:00 +0530 Subject: [PATCH 14/23] feat: confirm & delete list fields --- src/components/organisms/RightSidePanel.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/components/organisms/RightSidePanel.tsx b/src/components/organisms/RightSidePanel.tsx index 40082221..be76b8c7 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -422,6 +422,23 @@ export const RightSidePanel: React.FC = ({ onFinishCapture ) }} /> + {!confirmedListTextFields[step.id]?.[key] && ( + + + + + )} ))} From 91624531b14107d48e70af4c5aff6255a73c976e Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Fri, 13 Sep 2024 23:58:09 +0530 Subject: [PATCH 15/23] 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 be76b8c7..4bc7ed45 100644 --- a/src/components/organisms/RightSidePanel.tsx +++ b/src/components/organisms/RightSidePanel.tsx @@ -424,15 +424,15 @@ export const RightSidePanel: React.FC = ({ onFinishCapture /> {!confirmedListTextFields[step.id]?.[key] && ( - -