feat: add update screenshot step data
This commit is contained in:
@@ -6,14 +6,15 @@ export interface TextStep {
|
|||||||
label: string;
|
label: string;
|
||||||
data: string;
|
data: string;
|
||||||
selectorObj: SelectorObject;
|
selectorObj: SelectorObject;
|
||||||
actionId?: string; // Add actionId to track which action created this step
|
actionId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ScreenshotStep {
|
interface ScreenshotStep {
|
||||||
id: number;
|
id: number;
|
||||||
type: 'screenshot';
|
type: 'screenshot';
|
||||||
fullPage: boolean;
|
fullPage: boolean;
|
||||||
actionId?: string; // Add actionId to track which action created this step
|
actionId?: string;
|
||||||
|
screenshotData?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ListStep {
|
export interface ListStep {
|
||||||
@@ -26,7 +27,7 @@ export interface ListStep {
|
|||||||
selector: string;
|
selector: string;
|
||||||
};
|
};
|
||||||
limit?: number;
|
limit?: number;
|
||||||
actionId?: string; // Add actionId to track which action created this step
|
actionId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type BrowserStep = TextStep | ScreenshotStep | ListStep;
|
export type BrowserStep = TextStep | ScreenshotStep | ListStep;
|
||||||
@@ -50,7 +51,8 @@ interface BrowserStepsContextType {
|
|||||||
updateListStepLimit: (listId: number, limit: number) => void;
|
updateListStepLimit: (listId: number, limit: number) => void;
|
||||||
updateListStepData: (listId: number, extractedData: any[]) => void;
|
updateListStepData: (listId: number, extractedData: any[]) => void;
|
||||||
removeListTextField: (listId: number, fieldKey: string) => void;
|
removeListTextField: (listId: number, fieldKey: string) => void;
|
||||||
deleteStepsByActionId: (actionId: string) => void; // New function to delete steps by actionId
|
deleteStepsByActionId: (actionId: string) => void;
|
||||||
|
updateScreenshotStepData: (id: number, screenshotData: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const BrowserStepsContext = createContext<BrowserStepsContextType | undefined>(undefined);
|
const BrowserStepsContext = createContext<BrowserStepsContextType | undefined>(undefined);
|
||||||
@@ -179,6 +181,20 @@ export const BrowserStepsProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updateScreenshotStepData = (id: number, screenshotData: string) => {
|
||||||
|
setBrowserSteps(prevSteps => {
|
||||||
|
return prevSteps.map(step => {
|
||||||
|
if (step.type === 'screenshot' && step.id === id) {
|
||||||
|
return {
|
||||||
|
...step,
|
||||||
|
screenshotData: screenshotData
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return step;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const updateListStepLimit = (listId: number, limit: number) => {
|
const updateListStepLimit = (listId: number, limit: number) => {
|
||||||
setBrowserSteps(prevSteps =>
|
setBrowserSteps(prevSteps =>
|
||||||
prevSteps.map(step => {
|
prevSteps.map(step => {
|
||||||
@@ -220,7 +236,8 @@ export const BrowserStepsProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||||||
updateListStepLimit,
|
updateListStepLimit,
|
||||||
updateListStepData,
|
updateListStepData,
|
||||||
removeListTextField,
|
removeListTextField,
|
||||||
deleteStepsByActionId, // Export the new function
|
deleteStepsByActionId,
|
||||||
|
updateScreenshotStepData,
|
||||||
}}>
|
}}>
|
||||||
{children}
|
{children}
|
||||||
</BrowserStepsContext.Provider>
|
</BrowserStepsContext.Provider>
|
||||||
|
|||||||
Reference in New Issue
Block a user