feat: add duplicate tab name check
This commit is contained in:
@@ -61,7 +61,7 @@ export const InterpretationLog: React.FC<InterpretationLogProps> = ({ isOpen, se
|
||||
const { captureStage, getText } = useActionContext();
|
||||
|
||||
const { browserWidth, outputPreviewHeight, outputPreviewWidth } = useBrowserDimensionsStore();
|
||||
const { currentWorkflowActionsState, shouldResetInterpretationLog, currentTextGroupName, setCurrentTextGroupName } = useGlobalInfoStore();
|
||||
const { currentWorkflowActionsState, shouldResetInterpretationLog, currentTextGroupName, setCurrentTextGroupName, notify } = useGlobalInfoStore();
|
||||
|
||||
const [showPreviewData, setShowPreviewData] = useState<boolean>(false);
|
||||
const userClosedDrawer = useRef<boolean>(false);
|
||||
@@ -154,6 +154,28 @@ export const InterpretationLog: React.FC<InterpretationLogProps> = ({ isOpen, se
|
||||
}
|
||||
};
|
||||
|
||||
const checkForDuplicateName = (stepId: number, type: 'list' | 'text' | 'screenshot', newName: string): boolean => {
|
||||
const trimmedName = newName.trim();
|
||||
|
||||
if (type === 'list') {
|
||||
const listSteps = browserSteps.filter(step => step.type === 'list' && step.id !== stepId);
|
||||
const duplicate = listSteps.find(step => step.name === trimmedName);
|
||||
if (duplicate) {
|
||||
notify('error', `A list with the name "${trimmedName}" already exists. Please choose a different name.`);
|
||||
return true;
|
||||
}
|
||||
} else if (type === 'screenshot') {
|
||||
const screenshotSteps = browserSteps.filter(step => step.type === 'screenshot' && step.id !== stepId);
|
||||
const duplicate = screenshotSteps.find(step => step.name === trimmedName);
|
||||
if (duplicate) {
|
||||
notify('error', `A screenshot with the name "${trimmedName}" already exists. Please choose a different name.`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
const startEdit = (stepId: number, type: 'list' | 'text' | 'screenshot', currentValue: string) => {
|
||||
setEditing({ stepId, type, value: currentValue });
|
||||
};
|
||||
@@ -168,6 +190,10 @@ export const InterpretationLog: React.FC<InterpretationLogProps> = ({ isOpen, se
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkForDuplicateName(stepId, type, finalValue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type === 'list') {
|
||||
updateListStepName(stepId, finalValue);
|
||||
} else if (type === 'text') {
|
||||
|
||||
Reference in New Issue
Block a user