diff --git a/frontend/src/components/Pages/FrontPage/MissionOverview/ScheduleMissionDialog/SelectMissionsToScheduleDialog.tsx b/frontend/src/components/Pages/FrontPage/MissionOverview/ScheduleMissionDialog/SelectMissionsToScheduleDialog.tsx index f679550e0..7d7f4c746 100644 --- a/frontend/src/components/Pages/FrontPage/MissionOverview/ScheduleMissionDialog/SelectMissionsToScheduleDialog.tsx +++ b/frontend/src/components/Pages/FrontPage/MissionOverview/ScheduleMissionDialog/SelectMissionsToScheduleDialog.tsx @@ -157,18 +157,27 @@ const SelectRobotComponent = memo( }) => { const { enabledRobots } = useRobotContext() const { TranslateText } = useLanguageContext() + const filteredRobots = enabledRobots.filter( + (r) => + (r.status === RobotStatus.Available || + r.status === RobotStatus.Busy || + r.status === RobotStatus.Recharging) && + r.isarConnected + ) + + const defaultRobotSelections = (): Robot[] => { + if (filteredRobots.length === 1) { + return [filteredRobots[0]] + } + return [] + } return ( (r ? r.name + ' (' + r.model.type + ')' : '')} - options={enabledRobots.filter( - (r) => - (r.status === RobotStatus.Available || - r.status === RobotStatus.Busy || - r.status === RobotStatus.Recharging) && - r.isarConnected - )} - disabled={!enabledRobots} + options={filteredRobots} + disabled={!filteredRobots} selectedOptions={[selectedRobot]} label={TranslateText('Select robot')} onOptionsChange={(changes) => setSelectedRobot(changes.selectedItems[0])} diff --git a/frontend/src/components/Pages/InspectionPage/ScheduleMissionDialogs.tsx b/frontend/src/components/Pages/InspectionPage/ScheduleMissionDialogs.tsx index 02ae3de0f..91bcad205 100644 --- a/frontend/src/components/Pages/InspectionPage/ScheduleMissionDialogs.tsx +++ b/frontend/src/components/Pages/InspectionPage/ScheduleMissionDialogs.tsx @@ -65,6 +65,14 @@ export const ScheduleMissionDialog = (props: IProps): JSX.Element => { r.status === RobotStatus.Recharging) && r.isarConnected ) + + const defaultRobotSelections = (): Robot[] => { + if (filteredRobots.length === 1) { + return [filteredRobots[0]] + } + return [] + } + const onSelectedRobot = (selectedRobot: Robot) => { if (filteredRobots) setSelectedRobot(selectedRobot) } @@ -151,6 +159,7 @@ export const ScheduleMissionDialog = (props: IProps): JSX.Element => { )} r.name + ' (' + r.model.type + ')'} options={filteredRobots}