Merge pull request #212 from getmaxun/better-notifs

feat: better notifications
This commit is contained in:
Karishma Shukla
2024-11-30 10:20:00 +05:30
committed by GitHub
6 changed files with 15 additions and 15 deletions

View File

@@ -105,9 +105,9 @@ export const InterpretationButtons = ({ enableStepping }: InterpretationButtonsP
const finished = await interpretCurrentRecording(); const finished = await interpretCurrentRecording();
setInfo({ ...info, running: false }); setInfo({ ...info, running: false });
if (finished) { if (finished) {
notify('info', 'Interpretation finished'); notify('info', 'Run finished');
} else { } else {
notify('error', 'Interpretation failed to start'); notify('error', 'Run failed to start');
} }
} }
}; };

View File

@@ -253,14 +253,14 @@ export const RecordingsTable = ({ handleEditRecording, handleRunRecording, handl
checkRunsForRecording(row.id).then((result: boolean) => { checkRunsForRecording(row.id).then((result: boolean) => {
if (result) { if (result) {
notify('warning', 'Cannot delete recording as it has active runs'); notify('warning', 'Cannot delete robot as it has associated runs');
} }
}) })
deleteRecordingFromStorage(row.id).then((result: boolean) => { deleteRecordingFromStorage(row.id).then((result: boolean) => {
if (result) { if (result) {
setRows([]); setRows([]);
notify('success', 'Recording deleted successfully'); notify('success', 'Robot deleted successfully');
fetchRecordings(); fetchRecordings();
} }
}) })

View File

@@ -46,7 +46,7 @@ export const SaveRecording = ({ fileName }: SaveRecordingProps) => {
}; };
const exitRecording = useCallback(async () => { const exitRecording = useCallback(async () => {
notify('success', 'Recording saved successfully'); notify('success', 'Robot saved successfully');
if (browserId) { if (browserId) {
await stopRecording(browserId); await stopRecording(browserId);
} }

View File

@@ -88,7 +88,7 @@ const ApiKeyManager = () => {
navigator.clipboard.writeText(apiKey); navigator.clipboard.writeText(apiKey);
setCopySuccess(true); setCopySuccess(true);
setTimeout(() => setCopySuccess(false), 2000); setTimeout(() => setCopySuccess(false), 2000);
notify('info', 'Copied to clipboard'); notify('info', 'Copied API Key successfully');
} }
}; };

View File

@@ -49,10 +49,10 @@ export const MainPage = ({ handleEditRecording }: MainPageProps) => {
aborted = true; aborted = true;
notifyAboutAbort(runId).then(async (response) => { notifyAboutAbort(runId).then(async (response) => {
if (response) { if (response) {
notify('success', `Interpretation of ${runningRecordingName} aborted successfully`); notify('success', `Interpretation of robot ${runningRecordingName} aborted successfully`);
await stopRecording(ids.browserId); await stopRecording(ids.browserId);
} else { } else {
notify('error', `Failed to abort the interpretation ${runningRecordingName} recording`); notify('error', `Failed to abort the interpretation of ${runningRecordingName} robot`);
} }
}) })
} }
@@ -67,9 +67,9 @@ export const MainPage = ({ handleEditRecording }: MainPageProps) => {
interpretStoredRecording(runId).then(async (interpretation: boolean) => { interpretStoredRecording(runId).then(async (interpretation: boolean) => {
if (!aborted) { if (!aborted) {
if (interpretation) { if (interpretation) {
notify('success', `Interpretation of ${runningRecordingName} succeeded`); notify('success', `Interpretation of robot ${runningRecordingName} succeeded`);
} else { } else {
notify('success', `Failed to interpret ${runningRecordingName} recording`); notify('success', `Failed to interpret ${runningRecordingName} robot`);
// destroy the created browser // destroy the created browser
await stopRecording(browserId); await stopRecording(browserId);
} }
@@ -98,9 +98,9 @@ export const MainPage = ({ handleEditRecording }: MainPageProps) => {
socket.on('debugMessage', debugMessageHandler); socket.on('debugMessage', debugMessageHandler);
setContent('runs'); setContent('runs');
if (browserId) { if (browserId) {
notify('info', `Running recording: ${runningRecordingName}`); notify('info', `Running robot: ${runningRecordingName}`);
} else { } else {
notify('error', `Failed to run recording: ${runningRecordingName}`); notify('error', `Failed to run robot: ${runningRecordingName}`);
} }
}) })
return (socket: Socket, browserId: string, runId: string) => { return (socket: Socket, browserId: string, runId: string) => {
@@ -113,9 +113,9 @@ export const MainPage = ({ handleEditRecording }: MainPageProps) => {
scheduleStoredRecording(runningRecordingId, settings) scheduleStoredRecording(runningRecordingId, settings)
.then(({ message, runId }: ScheduleRunResponse) => { .then(({ message, runId }: ScheduleRunResponse) => {
if (message === 'success') { if (message === 'success') {
notify('success', `Recording ${runningRecordingName} scheduled successfully`); notify('success', `Robot ${runningRecordingName} scheduled successfully`);
} else { } else {
notify('error', `Failed to schedule recording ${runningRecordingName}`); notify('error', `Failed to schedule robot ${runningRecordingName}`);
} }
}); });
} }

View File

@@ -44,7 +44,7 @@ const Register = () => {
window.localStorage.setItem("user", JSON.stringify(data)); window.localStorage.setItem("user", JSON.stringify(data));
navigate("/"); navigate("/");
} catch (error:any) { } catch (error:any) {
notify("error", error.response.data || "Registration Failed. Please try again."); notify("error", `Registration Failed. Please try again. ${error.response.data}`);
setLoading(false); setLoading(false);
} }
}; };