Merge pull request #602 from getmaxun/single-discard
feat: discard only current active action
This commit is contained in:
@@ -85,7 +85,7 @@ export const BrowserWindow = () => {
|
|||||||
const [paginationSelector, setPaginationSelector] = useState<string>('');
|
const [paginationSelector, setPaginationSelector] = useState<string>('');
|
||||||
|
|
||||||
const { socket } = useSocketStore();
|
const { socket } = useSocketStore();
|
||||||
const { notify } = useGlobalInfoStore();
|
const { notify, currentTextActionId, currentListActionId } = useGlobalInfoStore();
|
||||||
const { getText, getList, paginationMode, paginationType, limitMode, captureStage } = useActionContext();
|
const { getText, getList, paginationMode, paginationType, limitMode, captureStage } = useActionContext();
|
||||||
const { addTextStep, addListStep, updateListStepData } = useBrowserSteps();
|
const { addTextStep, addListStep, updateListStepData } = useBrowserSteps();
|
||||||
|
|
||||||
@@ -326,8 +326,8 @@ export const BrowserWindow = () => {
|
|||||||
selector: highlighterData.selector,
|
selector: highlighterData.selector,
|
||||||
tag: highlighterData.elementInfo?.tagName,
|
tag: highlighterData.elementInfo?.tagName,
|
||||||
shadow: highlighterData.elementInfo?.isShadowRoot,
|
shadow: highlighterData.elementInfo?.isShadowRoot,
|
||||||
attribute
|
attribute,
|
||||||
});
|
}, currentTextActionId || `text-${crypto.randomUUID()}`);
|
||||||
} else {
|
} else {
|
||||||
// Show the modal if there are multiple options
|
// Show the modal if there are multiple options
|
||||||
setAttributeOptions(options);
|
setAttributeOptions(options);
|
||||||
@@ -344,7 +344,7 @@ export const BrowserWindow = () => {
|
|||||||
if (paginationType !== '' && paginationType !== 'scrollDown' && paginationType !== 'scrollUp' && paginationType !== 'none') {
|
if (paginationType !== '' && paginationType !== 'scrollDown' && paginationType !== 'scrollUp' && paginationType !== 'none') {
|
||||||
setPaginationSelector(highlighterData.selector);
|
setPaginationSelector(highlighterData.selector);
|
||||||
notify(`info`, t('browser_window.attribute_modal.notifications.pagination_select_success'));
|
notify(`info`, t('browser_window.attribute_modal.notifications.pagination_select_success'));
|
||||||
addListStep(listSelector!, fields, currentListId || 0, { type: paginationType, selector: highlighterData.selector });
|
addListStep(listSelector!, fields, currentListId || 0, currentListActionId || `list-${crypto.randomUUID()}`, { type: paginationType, selector: highlighterData.selector });
|
||||||
socket?.emit('setPaginationMode', { pagination: false });
|
socket?.emit('setPaginationMode', { pagination: false });
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -412,6 +412,7 @@ export const BrowserWindow = () => {
|
|||||||
listSelector,
|
listSelector,
|
||||||
updatedFields,
|
updatedFields,
|
||||||
currentListId,
|
currentListId,
|
||||||
|
currentListActionId || `list-${crypto.randomUUID()}`,
|
||||||
{ type: '', selector: paginationSelector }
|
{ type: '', selector: paginationSelector }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -449,7 +450,7 @@ export const BrowserWindow = () => {
|
|||||||
tag: selectedElement.info?.tagName,
|
tag: selectedElement.info?.tagName,
|
||||||
shadow: selectedElement.info?.isShadowRoot,
|
shadow: selectedElement.info?.isShadowRoot,
|
||||||
attribute: attribute
|
attribute: attribute
|
||||||
});
|
}, currentTextActionId || `text-${crypto.randomUUID()}`);
|
||||||
}
|
}
|
||||||
if (getList === true && listSelector && currentListId) {
|
if (getList === true && listSelector && currentListId) {
|
||||||
const newField: TextStep = {
|
const newField: TextStep = {
|
||||||
@@ -484,6 +485,7 @@ export const BrowserWindow = () => {
|
|||||||
listSelector,
|
listSelector,
|
||||||
updatedFields,
|
updatedFields,
|
||||||
currentListId,
|
currentListId,
|
||||||
|
currentListActionId || `list-${crypto.randomUUID()}`,
|
||||||
{ type: '', selector: paginationSelector }
|
{ type: '', selector: paginationSelector }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
const [isCaptureListConfirmed, setIsCaptureListConfirmed] = useState(false);
|
const [isCaptureListConfirmed, setIsCaptureListConfirmed] = useState(false);
|
||||||
const { panelHeight } = useBrowserDimensionsStore();
|
const { panelHeight } = useBrowserDimensionsStore();
|
||||||
|
|
||||||
const { lastAction, notify, currentWorkflowActionsState, setCurrentWorkflowActionsState, resetInterpretationLog } = useGlobalInfoStore();
|
const { lastAction, notify, currentWorkflowActionsState, setCurrentWorkflowActionsState, resetInterpretationLog, currentListActionId, setCurrentListActionId, currentTextActionId, setCurrentTextActionId, currentScreenshotActionId, setCurrentScreenshotActionId } = useGlobalInfoStore();
|
||||||
const {
|
const {
|
||||||
getText, startGetText, stopGetText,
|
getText, startGetText, stopGetText,
|
||||||
getList, startGetList, stopGetList,
|
getList, startGetList, stopGetList,
|
||||||
@@ -69,7 +69,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
startAction, finishAction
|
startAction, finishAction
|
||||||
} = useActionContext();
|
} = useActionContext();
|
||||||
|
|
||||||
const { browserSteps, updateBrowserTextStepLabel, deleteBrowserStep, addScreenshotStep, updateListTextFieldLabel, removeListTextField, updateListStepLimit } = useBrowserSteps();
|
const { browserSteps, updateBrowserTextStepLabel, deleteBrowserStep, addScreenshotStep, updateListTextFieldLabel, removeListTextField, updateListStepLimit, deleteStepsByActionId } = useBrowserSteps();
|
||||||
const { id, socket } = useSocketStore();
|
const { id, socket } = useSocketStore();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
@@ -139,15 +139,21 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
|
|
||||||
const handleStartGetText = () => {
|
const handleStartGetText = () => {
|
||||||
setIsCaptureTextConfirmed(false);
|
setIsCaptureTextConfirmed(false);
|
||||||
|
const newActionId = `text-${crypto.randomUUID()}`;
|
||||||
|
setCurrentTextActionId(newActionId);
|
||||||
startGetText();
|
startGetText();
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleStartGetList = () => {
|
const handleStartGetList = () => {
|
||||||
setIsCaptureListConfirmed(false);
|
setIsCaptureListConfirmed(false);
|
||||||
|
const newActionId = `list-${crypto.randomUUID()}`;
|
||||||
|
setCurrentListActionId(newActionId);
|
||||||
startGetList();
|
startGetList();
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleStartGetScreenshot = () => {
|
const handleStartGetScreenshot = () => {
|
||||||
|
const newActionId = `screenshot-${crypto.randomUUID()}`;
|
||||||
|
setCurrentScreenshotActionId(newActionId);
|
||||||
startGetScreenshot();
|
startGetScreenshot();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -277,6 +283,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
socket?.emit('action', { action: 'scrapeSchema', settings });
|
socket?.emit('action', { action: 'scrapeSchema', settings });
|
||||||
}
|
}
|
||||||
setIsCaptureTextConfirmed(true);
|
setIsCaptureTextConfirmed(true);
|
||||||
|
setCurrentTextActionId('');
|
||||||
resetInterpretationLog();
|
resetInterpretationLog();
|
||||||
finishAction('text');
|
finishAction('text');
|
||||||
onFinishCapture();
|
onFinishCapture();
|
||||||
@@ -337,6 +344,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
notify('error', t('right_panel.errors.unable_create_settings'));
|
notify('error', t('right_panel.errors.unable_create_settings'));
|
||||||
}
|
}
|
||||||
handleStopGetList();
|
handleStopGetList();
|
||||||
|
setCurrentListActionId('');
|
||||||
resetInterpretationLog();
|
resetInterpretationLog();
|
||||||
finishAction('list');
|
finishAction('list');
|
||||||
onFinishCapture();
|
onFinishCapture();
|
||||||
@@ -434,35 +442,73 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
|
|
||||||
const discardGetText = useCallback(() => {
|
const discardGetText = useCallback(() => {
|
||||||
stopGetText();
|
stopGetText();
|
||||||
browserSteps.forEach(step => {
|
|
||||||
if (step.type === 'text') {
|
if (currentTextActionId) {
|
||||||
deleteBrowserStep(step.id);
|
const stepsToDelete = browserSteps
|
||||||
}
|
.filter(step => step.type === 'text' && step.actionId === currentTextActionId)
|
||||||
});
|
.map(step => step.id);
|
||||||
setTextLabels({});
|
|
||||||
setErrors({});
|
deleteStepsByActionId(currentTextActionId);
|
||||||
setConfirmedTextSteps({});
|
|
||||||
|
setTextLabels(prevLabels => {
|
||||||
|
const newLabels = { ...prevLabels };
|
||||||
|
stepsToDelete.forEach(id => {
|
||||||
|
delete newLabels[id];
|
||||||
|
});
|
||||||
|
return newLabels;
|
||||||
|
});
|
||||||
|
|
||||||
|
setErrors(prevErrors => {
|
||||||
|
const newErrors = { ...prevErrors };
|
||||||
|
stepsToDelete.forEach(id => {
|
||||||
|
delete newErrors[id];
|
||||||
|
});
|
||||||
|
return newErrors;
|
||||||
|
});
|
||||||
|
|
||||||
|
setConfirmedTextSteps(prev => {
|
||||||
|
const newConfirmed = { ...prev };
|
||||||
|
stepsToDelete.forEach(id => {
|
||||||
|
delete newConfirmed[id];
|
||||||
|
});
|
||||||
|
return newConfirmed;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setCurrentTextActionId('');
|
||||||
setIsCaptureTextConfirmed(false);
|
setIsCaptureTextConfirmed(false);
|
||||||
notify('error', t('right_panel.errors.capture_text_discarded'));
|
notify('error', t('right_panel.errors.capture_text_discarded'));
|
||||||
}, [browserSteps, stopGetText, deleteBrowserStep, notify, t]);
|
}, [currentTextActionId, browserSteps, stopGetText, deleteStepsByActionId, notify, t]);
|
||||||
|
|
||||||
const discardGetList = useCallback(() => {
|
const discardGetList = useCallback(() => {
|
||||||
stopGetList();
|
stopGetList();
|
||||||
browserSteps.forEach(step => {
|
|
||||||
if (step.type === 'list') {
|
if (currentListActionId) {
|
||||||
deleteBrowserStep(step.id);
|
const listStepsToDelete = browserSteps
|
||||||
}
|
.filter(step => step.type === 'list' && step.actionId === currentListActionId)
|
||||||
});
|
.map(step => step.id);
|
||||||
|
|
||||||
|
deleteStepsByActionId(currentListActionId);
|
||||||
|
|
||||||
|
setConfirmedListTextFields(prev => {
|
||||||
|
const newConfirmed = { ...prev };
|
||||||
|
listStepsToDelete.forEach(id => {
|
||||||
|
delete newConfirmed[id];
|
||||||
|
});
|
||||||
|
return newConfirmed;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
resetListState();
|
resetListState();
|
||||||
stopPaginationMode();
|
stopPaginationMode();
|
||||||
stopLimitMode();
|
stopLimitMode();
|
||||||
setShowPaginationOptions(false);
|
setShowPaginationOptions(false);
|
||||||
setShowLimitOptions(false);
|
setShowLimitOptions(false);
|
||||||
setCaptureStage('initial');
|
setCaptureStage('initial');
|
||||||
setConfirmedListTextFields({});
|
setCurrentListActionId('');
|
||||||
setIsCaptureListConfirmed(false);
|
setIsCaptureListConfirmed(false);
|
||||||
notify('error', t('right_panel.errors.capture_list_discarded'));
|
notify('error', t('right_panel.errors.capture_list_discarded'));
|
||||||
}, [browserSteps, stopGetList, deleteBrowserStep, resetListState, setShowPaginationOptions, setShowLimitOptions, setCaptureStage, notify, t]);
|
}, [currentListActionId, browserSteps, stopGetList, deleteStepsByActionId, resetListState, setShowPaginationOptions, setShowLimitOptions, setCaptureStage, notify, t]);
|
||||||
|
|
||||||
const captureScreenshot = (fullPage: boolean) => {
|
const captureScreenshot = (fullPage: boolean) => {
|
||||||
const screenshotSettings: ScreenshotSettings = {
|
const screenshotSettings: ScreenshotSettings = {
|
||||||
@@ -474,7 +520,7 @@ export const RightSidePanel: React.FC<RightSidePanelProps> = ({ onFinishCapture
|
|||||||
scale: 'device',
|
scale: 'device',
|
||||||
};
|
};
|
||||||
socket?.emit('action', { action: 'screenshot', settings: screenshotSettings });
|
socket?.emit('action', { action: 'screenshot', settings: screenshotSettings });
|
||||||
addScreenshotStep(fullPage);
|
addScreenshotStep(fullPage, currentScreenshotActionId);
|
||||||
stopGetScreenshot();
|
stopGetScreenshot();
|
||||||
resetInterpretationLog();
|
resetInterpretationLog();
|
||||||
finishAction('screenshot');
|
finishAction('screenshot');
|
||||||
|
|||||||
@@ -6,12 +6,14 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ListStep {
|
export interface ListStep {
|
||||||
@@ -24,6 +26,7 @@ export interface ListStep {
|
|||||||
selector: string;
|
selector: string;
|
||||||
};
|
};
|
||||||
limit?: number;
|
limit?: number;
|
||||||
|
actionId?: string; // Add actionId to track which action created this step
|
||||||
}
|
}
|
||||||
|
|
||||||
export type BrowserStep = TextStep | ScreenshotStep | ListStep;
|
export type BrowserStep = TextStep | ScreenshotStep | ListStep;
|
||||||
@@ -38,15 +41,16 @@ export interface SelectorObject {
|
|||||||
|
|
||||||
interface BrowserStepsContextType {
|
interface BrowserStepsContextType {
|
||||||
browserSteps: BrowserStep[];
|
browserSteps: BrowserStep[];
|
||||||
addTextStep: (label: string, data: string, selectorObj: SelectorObject) => void;
|
addTextStep: (label: string, data: string, selectorObj: SelectorObject, actionId: string) => void;
|
||||||
addListStep: (listSelector: string, fields: { [key: string]: TextStep }, listId: number, pagination?: { type: string; selector: string }, limit?: number) => void
|
addListStep: (listSelector: string, fields: { [key: string]: TextStep }, listId: number, actionId: string, pagination?: { type: string; selector: string }, limit?: number) => void
|
||||||
addScreenshotStep: (fullPage: boolean) => void;
|
addScreenshotStep: (fullPage: boolean, actionId: string) => void;
|
||||||
deleteBrowserStep: (id: number) => void;
|
deleteBrowserStep: (id: number) => void;
|
||||||
updateBrowserTextStepLabel: (id: number, newLabel: string) => void;
|
updateBrowserTextStepLabel: (id: number, newLabel: string) => void;
|
||||||
updateListTextFieldLabel: (listId: number, fieldKey: string, newLabel: string) => void;
|
updateListTextFieldLabel: (listId: number, fieldKey: string, newLabel: string) => void;
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
const BrowserStepsContext = createContext<BrowserStepsContextType | undefined>(undefined);
|
const BrowserStepsContext = createContext<BrowserStepsContextType | undefined>(undefined);
|
||||||
@@ -55,14 +59,14 @@ export const BrowserStepsProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||||||
const [browserSteps, setBrowserSteps] = useState<BrowserStep[]>([]);
|
const [browserSteps, setBrowserSteps] = useState<BrowserStep[]>([]);
|
||||||
const [discardedFields, setDiscardedFields] = useState<Set<string>>(new Set());
|
const [discardedFields, setDiscardedFields] = useState<Set<string>>(new Set());
|
||||||
|
|
||||||
const addTextStep = (label: string, data: string, selectorObj: SelectorObject) => {
|
const addTextStep = (label: string, data: string, selectorObj: SelectorObject, actionId: string) => {
|
||||||
setBrowserSteps(prevSteps => [
|
setBrowserSteps(prevSteps => [
|
||||||
...prevSteps,
|
...prevSteps,
|
||||||
{ id: Date.now(), type: 'text', label, data, selectorObj }
|
{ id: Date.now(), type: 'text', label, data, selectorObj, actionId }
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
const addListStep = (listSelector: string, newFields: { [key: string]: TextStep }, listId: number, pagination?: { type: string; selector: string }, limit?: number) => {
|
const addListStep = (listSelector: string, newFields: { [key: string]: TextStep }, listId: number, actionId: string, pagination?: { type: string; selector: string }, limit?: number) => {
|
||||||
setBrowserSteps(prevSteps => {
|
setBrowserSteps(prevSteps => {
|
||||||
const existingListStepIndex = prevSteps.findIndex(step => step.type === 'list' && step.id === listId);
|
const existingListStepIndex = prevSteps.findIndex(step => step.type === 'list' && step.id === listId);
|
||||||
|
|
||||||
@@ -77,10 +81,14 @@ export const BrowserStepsProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||||||
if (existingListStep.fields[key]) {
|
if (existingListStep.fields[key]) {
|
||||||
acc[key] = {
|
acc[key] = {
|
||||||
...field,
|
...field,
|
||||||
label: existingListStep.fields[key].label
|
label: existingListStep.fields[key].label,
|
||||||
|
actionId
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
acc[key] = field;
|
acc[key] = {
|
||||||
|
...field,
|
||||||
|
actionId
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
@@ -90,22 +98,31 @@ export const BrowserStepsProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||||||
...existingListStep,
|
...existingListStep,
|
||||||
fields: mergedFields,
|
fields: mergedFields,
|
||||||
pagination: pagination || existingListStep.pagination,
|
pagination: pagination || existingListStep.pagination,
|
||||||
limit: limit
|
limit: limit,
|
||||||
|
actionId
|
||||||
};
|
};
|
||||||
return updatedSteps;
|
return updatedSteps;
|
||||||
} else {
|
} else {
|
||||||
|
const fieldsWithActionId = Object.entries(newFields).reduce((acc, [key, field]) => {
|
||||||
|
acc[key] = {
|
||||||
|
...field,
|
||||||
|
actionId
|
||||||
|
};
|
||||||
|
return acc;
|
||||||
|
}, {} as { [key: string]: TextStep });
|
||||||
|
|
||||||
return [
|
return [
|
||||||
...prevSteps,
|
...prevSteps,
|
||||||
{ id: listId, type: 'list', listSelector, fields: newFields, pagination, limit }
|
{ id: listId, type: 'list', listSelector, fields: fieldsWithActionId, pagination, limit, actionId }
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const addScreenshotStep = (fullPage: boolean) => {
|
const addScreenshotStep = (fullPage: boolean, actionId: string) => {
|
||||||
setBrowserSteps(prevSteps => [
|
setBrowserSteps(prevSteps => [
|
||||||
...prevSteps,
|
...prevSteps,
|
||||||
{ id: Date.now(), type: 'screenshot', fullPage }
|
{ id: Date.now(), type: 'screenshot', fullPage, actionId }
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -113,6 +130,10 @@ export const BrowserStepsProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||||||
setBrowserSteps(prevSteps => prevSteps.filter(step => step.id !== id));
|
setBrowserSteps(prevSteps => prevSteps.filter(step => step.id !== id));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const deleteStepsByActionId = (actionId: string) => {
|
||||||
|
setBrowserSteps(prevSteps => prevSteps.filter(step => step.actionId !== actionId));
|
||||||
|
};
|
||||||
|
|
||||||
const updateBrowserTextStepLabel = (id: number, newLabel: string) => {
|
const updateBrowserTextStepLabel = (id: number, newLabel: string) => {
|
||||||
setBrowserSteps(prevSteps =>
|
setBrowserSteps(prevSteps =>
|
||||||
prevSteps.map(step =>
|
prevSteps.map(step =>
|
||||||
@@ -199,6 +220,7 @@ export const BrowserStepsProvider: React.FC<{ children: React.ReactNode }> = ({
|
|||||||
updateListStepLimit,
|
updateListStepLimit,
|
||||||
updateListStepData,
|
updateListStepData,
|
||||||
removeListTextField,
|
removeListTextField,
|
||||||
|
deleteStepsByActionId, // Export the new function
|
||||||
}}>
|
}}>
|
||||||
{children}
|
{children}
|
||||||
</BrowserStepsContext.Provider>
|
</BrowserStepsContext.Provider>
|
||||||
@@ -211,4 +233,4 @@ export const useBrowserSteps = () => {
|
|||||||
throw new Error('useBrowserSteps must be used within a BrowserStepsProvider');
|
throw new Error('useBrowserSteps must be used within a BrowserStepsProvider');
|
||||||
}
|
}
|
||||||
return context;
|
return context;
|
||||||
};
|
};
|
||||||
@@ -80,6 +80,12 @@ interface GlobalInfo {
|
|||||||
}) => void;
|
}) => void;
|
||||||
shouldResetInterpretationLog: boolean;
|
shouldResetInterpretationLog: boolean;
|
||||||
resetInterpretationLog: () => void;
|
resetInterpretationLog: () => void;
|
||||||
|
currentTextActionId: string;
|
||||||
|
setCurrentTextActionId: (actionId: string) => void;
|
||||||
|
currentListActionId: string;
|
||||||
|
setCurrentListActionId: (actionId: string) => void;
|
||||||
|
currentScreenshotActionId: string;
|
||||||
|
setCurrentScreenshotActionId: (actionId: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GlobalInfoStore implements Partial<GlobalInfo> {
|
class GlobalInfoStore implements Partial<GlobalInfo> {
|
||||||
@@ -106,6 +112,9 @@ class GlobalInfoStore implements Partial<GlobalInfo> {
|
|||||||
hasScrapeSchemaAction: false,
|
hasScrapeSchemaAction: false,
|
||||||
};
|
};
|
||||||
shouldResetInterpretationLog = false;
|
shouldResetInterpretationLog = false;
|
||||||
|
currentTextActionId = '';
|
||||||
|
currentListActionId = '';
|
||||||
|
currentScreenshotActionId = '';
|
||||||
};
|
};
|
||||||
|
|
||||||
const globalInfoStore = new GlobalInfoStore();
|
const globalInfoStore = new GlobalInfoStore();
|
||||||
@@ -129,6 +138,9 @@ export const GlobalInfoProvider = ({ children }: { children: JSX.Element }) => {
|
|||||||
const [recordingUrl, setRecordingUrl] = useState<string>(globalInfoStore.recordingUrl);
|
const [recordingUrl, setRecordingUrl] = useState<string>(globalInfoStore.recordingUrl);
|
||||||
const [currentWorkflowActionsState, setCurrentWorkflowActionsState] = useState(globalInfoStore.currentWorkflowActionsState);
|
const [currentWorkflowActionsState, setCurrentWorkflowActionsState] = useState(globalInfoStore.currentWorkflowActionsState);
|
||||||
const [shouldResetInterpretationLog, setShouldResetInterpretationLog] = useState<boolean>(globalInfoStore.shouldResetInterpretationLog);
|
const [shouldResetInterpretationLog, setShouldResetInterpretationLog] = useState<boolean>(globalInfoStore.shouldResetInterpretationLog);
|
||||||
|
const [currentTextActionId, setCurrentTextActionId] = useState<string>('');
|
||||||
|
const [currentListActionId, setCurrentListActionId] = useState<string>('');
|
||||||
|
const [currentScreenshotActionId, setCurrentScreenshotActionId] = useState<string>('');
|
||||||
|
|
||||||
const notify = (severity: 'error' | 'warning' | 'info' | 'success', message: string) => {
|
const notify = (severity: 'error' | 'warning' | 'info' | 'success', message: string) => {
|
||||||
setNotification({ severity, message, isOpen: true });
|
setNotification({ severity, message, isOpen: true });
|
||||||
@@ -187,6 +199,12 @@ export const GlobalInfoProvider = ({ children }: { children: JSX.Element }) => {
|
|||||||
setCurrentWorkflowActionsState,
|
setCurrentWorkflowActionsState,
|
||||||
shouldResetInterpretationLog,
|
shouldResetInterpretationLog,
|
||||||
resetInterpretationLog,
|
resetInterpretationLog,
|
||||||
|
currentTextActionId,
|
||||||
|
setCurrentTextActionId,
|
||||||
|
currentListActionId,
|
||||||
|
setCurrentListActionId,
|
||||||
|
currentScreenshotActionId,
|
||||||
|
setCurrentScreenshotActionId,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
Reference in New Issue
Block a user