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 {
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) {
return response.data;
} else {
throw new Error(`Couldn't edit stored recording ${robotId}`);
throw new Error(`Couldn't edit stored recording ${id}`);
}
} catch(error: any) {
console.log(error);

View File

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

View File

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