Merge pull request #879 from getmaxun/unique-tab

feat: prevent duplicate action name
This commit is contained in:
Karishma Shukla
2025-11-12 21:55:57 +05:30
committed by GitHub

View File

@@ -61,7 +61,7 @@ export const InterpretationLog: React.FC<InterpretationLogProps> = ({ isOpen, se
const { captureStage, getText } = useActionContext(); const { captureStage, getText } = useActionContext();
const { browserWidth, outputPreviewHeight, outputPreviewWidth } = useBrowserDimensionsStore(); 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 [showPreviewData, setShowPreviewData] = useState<boolean>(false);
const userClosedDrawer = useRef<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) => { const startEdit = (stepId: number, type: 'list' | 'text' | 'screenshot', currentValue: string) => {
setEditing({ stepId, type, value: currentValue }); setEditing({ stepId, type, value: currentValue });
}; };
@@ -168,6 +190,10 @@ export const InterpretationLog: React.FC<InterpretationLogProps> = ({ isOpen, se
return; return;
} }
if (checkForDuplicateName(stepId, type, finalValue)) {
return;
}
if (type === 'list') { if (type === 'list') {
updateListStepName(stepId, finalValue); updateListStepName(stepId, finalValue);
} else if (type === 'text') { } else if (type === 'text') {