From d1b84718071e52a589999c9ad4785e1cc28477ab Mon Sep 17 00:00:00 2001 From: Maria Betania Cedeno Tepedino Date: Tue, 30 Jul 2024 10:20:17 +0200 Subject: [PATCH] Filtering robots in ScheduleMissionDialogs.tsx --- .../SelectMissionsToScheduleDialog.tsx | 6 +++++- .../InspectionPage/ScheduleMissionDialogs.tsx | 14 ++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/Pages/FrontPage/MissionOverview/ScheduleMissionDialog/SelectMissionsToScheduleDialog.tsx b/frontend/src/components/Pages/FrontPage/MissionOverview/ScheduleMissionDialog/SelectMissionsToScheduleDialog.tsx index 8addad6df..2f3c6bb68 100644 --- a/frontend/src/components/Pages/FrontPage/MissionOverview/ScheduleMissionDialog/SelectMissionsToScheduleDialog.tsx +++ b/frontend/src/components/Pages/FrontPage/MissionOverview/ScheduleMissionDialog/SelectMissionsToScheduleDialog.tsx @@ -153,7 +153,11 @@ const SelectRobotComponent = memo( (r ? r.name + ' (' + r.model.type + ')' : '')} options={enabledRobots.filter( - (r) => (r.status === RobotStatus.Available || r.status === RobotStatus.Busy) && r.isarConnected + (r) => + (r.status === RobotStatus.Available || + r.status === RobotStatus.Busy || + r.status === RobotStatus.Recharging) && + r.isarConnected )} disabled={!enabledRobots} selectedOptions={[selectedRobot]} diff --git a/frontend/src/components/Pages/InspectionPage/ScheduleMissionDialogs.tsx b/frontend/src/components/Pages/InspectionPage/ScheduleMissionDialogs.tsx index 096b369e3..b3862069f 100644 --- a/frontend/src/components/Pages/InspectionPage/ScheduleMissionDialogs.tsx +++ b/frontend/src/components/Pages/InspectionPage/ScheduleMissionDialogs.tsx @@ -2,7 +2,7 @@ import { Autocomplete, Dialog, Typography, Icon } from '@equinor/eds-core-react' import styled from 'styled-components' import { useLanguageContext } from 'components/Contexts/LanguageContext' import { useState } from 'react' -import { Robot } from 'models/Robot' +import { Robot, RobotStatus } from 'models/Robot' import { CondensedMissionDefinition } from 'models/MissionDefinition' import { BackendAPICaller } from 'api/ApiCaller' import { Icons } from 'utils/icons' @@ -58,9 +58,15 @@ export const ScheduleMissionDialog = (props: IProps): JSX.Element => { const [isLocalizationVerificationDialogOpen, setIsLocalizationVerificationDialog] = useState(false) const [selectedRobot, setSelectedRobot] = useState() const [missionsToSchedule, setMissionsToSchedule] = useState() - + const filteredRobots = enabledRobots.filter( + (r) => + (r.status === RobotStatus.Available || + r.status === RobotStatus.Busy || + r.status === RobotStatus.Recharging) && + r.isarConnected + ) const onSelectedRobot = (selectedRobot: Robot) => { - if (enabledRobots) setSelectedRobot(selectedRobot) + if (filteredRobots) setSelectedRobot(selectedRobot) } const onScheduleButtonPress = (missions: CondensedMissionDefinition[]) => () => { @@ -138,7 +144,7 @@ export const ScheduleMissionDialog = (props: IProps): JSX.Element => { r.name + ' (' + r.model.type + ')'} - options={enabledRobots} + options={filteredRobots} label={TranslateText('Select robot')} onOptionsChange={(changes) => onSelectedRobot(changes.selectedItems[0])} autoWidth={true}