Skip to content

Commit a17d849

Browse files
authored
Merge pull request #730 from getmaxun/schedule-ui
fix: schedule modal ui update
2 parents 3b16446 + 9c895c6 commit a17d849

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

src/components/robot/Recordings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { useTranslation } from "react-i18next";
1414
interface RecordingsProps {
1515
handleEditRecording: (id: string, fileName: string) => void;
1616
handleRunRecording: (settings: RunSettings) => void;
17-
handleScheduleRecording: (settings: ScheduleSettings) => void;
17+
handleScheduleRecording: (settings: ScheduleSettings) => Promise<boolean>;
1818
setRecordingInfo: (id: string, name: string) => void;
1919
}
2020

src/components/robot/ScheduleSettings.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { getSchedule, deleteSchedule } from '../../api/storage';
1010

1111
interface ScheduleSettingsProps {
1212
isOpen: boolean;
13-
handleStart: (settings: ScheduleSettings) => void;
13+
handleStart: (settings: ScheduleSettings) => Promise<boolean>;
1414
handleClose: () => void;
1515
initialSettings?: ScheduleSettings | null;
1616
}
@@ -272,7 +272,12 @@ export const ScheduleSettingsModal = ({ isOpen, handleStart, handleClose, initia
272272
</Dropdown>
273273
</Box>
274274
<Box mt={2} display="flex" justifyContent="flex-end">
275-
<Button onClick={() => handleStart(settings)} variant="contained" color="primary">
275+
<Button onClick={async () => {
276+
const success = await handleStart(settings);
277+
if (success) {
278+
await getRobotSchedule();
279+
}
280+
}} variant="contained" color="primary">
276281
{t('schedule_settings.buttons.save_schedule')}
277282
</Button>
278283
<Button

src/pages/MainPage.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,14 @@ export const MainPage = ({ handleEditRecording, initialContent }: MainPageProps)
235235
}
236236
}, [runningRecordingName, sockets, ids, debugMessageHandler, user?.id, t, notify, setRerenderRuns, setQueuedRuns, navigate, setContent, setIds]);
237237

238-
const handleScheduleRecording = (settings: ScheduleSettings) => {
239-
scheduleStoredRecording(runningRecordingId, settings)
240-
.then(({ message, runId }: ScheduleRunResponse) => {
241-
if (message === 'success') {
242-
notify('success', t('main_page.notifications.schedule_success', { name: runningRecordingName }));
243-
} else {
244-
notify('error', t('main_page.notifications.schedule_failed', { name: runningRecordingName }));
245-
}
246-
});
238+
const handleScheduleRecording = async (settings: ScheduleSettings) => {
239+
const { message, runId }: ScheduleRunResponse = await scheduleStoredRecording(runningRecordingId, settings);
240+
if (message === 'success') {
241+
notify('success', t('main_page.notifications.schedule_success', { name: runningRecordingName }));
242+
} else {
243+
notify('error', t('main_page.notifications.schedule_failed', { name: runningRecordingName }));
244+
}
245+
return message === 'success';
247246
}
248247

249248
const DisplayContent = () => {

0 commit comments

Comments
 (0)