Merge pull request #63 from amhsirak/develop

fix: edit existing robot
This commit is contained in:
Karishma Shukla
2024-10-10 04:31:34 +05:30
committed by GitHub
3 changed files with 9 additions and 8 deletions

View File

@@ -60,13 +60,13 @@ export const deleteRunFromStorage = async (id: string): Promise<boolean> => {
} }
}; };
export const editRecordingFromStorage = async (browserId: string, robotId: string): Promise<WorkflowFile | null> => { export const editRecordingFromStorage = async (browserId: string, id: string): Promise<WorkflowFile | null> => {
try { try {
const response = await axios.put(`http://localhost:8080/workflow/${browserId}/${robotId}`); const response = await axios.put(`http://localhost:8080/workflow/${browserId}/${id}`);
if (response.status === 200) { if (response.status === 200) {
return response.data; return response.data;
} else { } else {
throw new Error(`Couldn't edit stored recording ${robotId}`); throw new Error(`Couldn't edit stored recording ${id}`);
} }
} catch(error: any) { } catch(error: any) {
console.log(error); console.log(error);

View File

@@ -42,7 +42,7 @@ export const MainPage = ({ handleEditRecording }: MainPageProps) => {
let aborted = false; let aborted = false;
const { notify, setRerenderRuns } = useGlobalInfoStore(); const { notify, setRerenderRuns, setRecordingId } = useGlobalInfoStore();
const abortRunHandler = (runId: string) => { const abortRunHandler = (runId: string) => {
aborted = true; aborted = true;
@@ -58,6 +58,7 @@ export const MainPage = ({ handleEditRecording }: MainPageProps) => {
const setRecordingInfo = (id: string, name: string) => { const setRecordingInfo = (id: string, name: string) => {
setRunningRecordingId(id); setRunningRecordingId(id);
setRecordingId(id);
setRunningRecordingName(name); setRunningRecordingName(name);
} }

View File

@@ -39,7 +39,7 @@ export const RecordingPage = ({ recordingName }: RecordingPageProps) => {
const { setId, socket } = useSocketStore(); const { setId, socket } = useSocketStore();
const { setWidth } = useBrowserDimensionsStore(); const { setWidth } = useBrowserDimensionsStore();
const { browserId, setBrowserId } = useGlobalInfoStore(); const { browserId, setBrowserId, recordingId } = useGlobalInfoStore();
const handleShowOutputData = useCallback(() => { const handleShowOutputData = useCallback(() => {
setShowOutputData(true); setShowOutputData(true);
@@ -93,15 +93,15 @@ export const RecordingPage = ({ recordingName }: RecordingPageProps) => {
}, [socket]); }, [socket]);
const handleLoaded = useCallback(() => { const handleLoaded = useCallback(() => {
if (recordingName && browserId) { if (recordingName && browserId && recordingId) {
editRecordingFromStorage(browserId, recordingName).then(() => setIsLoaded(true)); editRecordingFromStorage(browserId, recordingId).then(() => setIsLoaded(true));
} else { } else {
if (browserId === 'new-recording') { if (browserId === 'new-recording') {
socket?.emit('new-recording'); socket?.emit('new-recording');
} }
setIsLoaded(true); setIsLoaded(true);
} }
}, [socket, browserId, recordingName, isLoaded]) }, [socket, browserId, recordingName, recordingId, isLoaded])
useEffect(() => { useEffect(() => {
socket?.on('loaded', handleLoaded); socket?.on('loaded', handleLoaded);